Sarek_codegen.Sarek_ir_ptx_kernelPTX kernel emitter: parameter/local declaration, register-block output, PTX file header, and top-level generate entry points.
val emit_params :
Stdlib.Buffer.t ->
Sarek_ir_ptx_types.reg_alloc ->
Sarek_ir_ptx_types.env ->
soa_params:string list ->
Sarek_ir_types.decl list ->
stringemit_params buf alloc env ~soa_params params emits ld.param instructions for each kernel parameter into buf, binds each parameter register into env, and records array element types in alloc.arr_elt_types. Returns the formatted .param declaration block string for embedding in the .entry header. Parameters named in ~soa_params are lowered as Structure-of-Arrays (N per-leaf base pointers + one shared length, leaves recorded in alloc.arr_soa); they must be flat-record custom vectors.
val soa_leaves_of_param :
string ->
Sarek_ir_types.elttype ->
(string * Sarek_ir_types.elttype) listScalar leaves of a flat-record custom-vector type selected for SoA: (field, scalar type) in declaration order. Rejects nested-record / variant / array / unit fields with Ptx_codegen_error.
val emit_locals :
Stdlib.Buffer.t ->
Stdlib.Buffer.t ->
Stdlib.Buffer.t ->
Sarek_ir_ptx_types.reg_alloc ->
Sarek_ir_ptx_types.env ->
Sarek_ir_types.decl list ->
unitemit_locals buf shared_buf module_buf alloc env locals emits register allocations and optional initialisation moves for each DLocal declaration (DLocal of array type is rejected fail-closed: it carries no size and cannot allocate storage). Statically-sized DShared declarations emit a .shared directive to shared_buf; a dynamic DShared (size None) emits a module-scope .extern .shared incomplete-array directive to module_buf (one per kernel; the region's byte size is supplied at launch via ~shared_mem). Both bind the base address with a mov.u32 in buf. DParam entries are skipped.
val emit_reg_decls : Stdlib.Buffer.t -> Sarek_ir_ptx_types.reg_alloc -> unitemit_reg_decls buf alloc emits .reg declarations based on the allocator high-water marks. Must be called after all emit_* calls.
make_ptx_header ?sm_target ?ptx_version () returns the PTX file header string (.version, .target, .address_size). Defaults: sm_target = "sm_86", ptx_version = "8.0".
val generate :
?sm_target:string ->
?soa_params:string list ->
Sarek_ir_types.kernel ->
stringgenerate ?sm_target ?soa_params k translates kernel k to a complete PTX string. Uses three-phase generation: body → register-count → header concatenation.
val generate_with_types :
types:_ ->
?soa_params:string list ->
Sarek_ir_types.kernel ->
stringgenerate_with_types ~types ?soa_params k is generate ?soa_params k. Record and variant type definitions are not representable as PTX struct types; the ~types argument is accepted for interface compatibility with other backends and is ignored.