Sarek_ir_ppxtype elttype = | TInt32| TInt64| TFloat16Mirrors Sarek_ir_types.elttype.TFloat16: IEEE binary16 storage, f32 compute. No matching CFloat16 constant — f16 has no literal.
| TFloat32| TFloat64| TBool| TUnit| TRecord of string * (string * elttype) list| TVariant of string * (string * elttype list) list| TArray of elttype * memspace| TVec of elttypeElement types
Variables with type info
type expr = | EConst of const| EVar of var| EBinop of binop * expr * expr| EUnop of unop * expr| EArrayRead of string * expr| EArrayReadExpr of expr * expr| ERecordField of expr * string| EIntrinsic of string list * string * expr list| ECast of elttype * expr| ETuple of expr list| EApp of expr * expr list| ERecord of string * (string * expr) list| EVariant of string * string * expr list| EArrayLen of string| EArrayCreate of elttype * expr * memspaceelem type, size, memspace
*)| EIf of expr * expr * expr| EMatch of expr * (pattern * expr) listExpressions (pure, no side effects)
type stmt = | SAssign of lvalue * expr| SSeq of stmt list| SIf of expr * stmt * stmt option| SWhile of expr * stmt| SFor of var * expr * expr * for_dir * stmt| SMatch of expr * (pattern * stmt) list| SReturn of expr| SBarrier| SWarpBarrier| SExpr of expr| SEmpty| SLet of var * expr * stmt| SLetMut of var * expr * stmt| SPragma of string list * stmt| SMemFence| SBlock of stmtScoped block for C variable isolation
*)| SNative of {gpu : Ppxlib.expression;fun dev -> "cuda/opencl code"
*)ocaml : Ppxlib.expression;OCaml fallback for interpreter/native
*)}Inline native GPU code with OCaml fallback
*)Statements (imperative, side effects)
Declarations
Helper function (device function called from kernel)
type kernel = {kern_name : string;kern_params : decl list;kern_locals : decl list;kern_body : stmt;kern_types : (string * (string * elttype) list) list;Record type definitions: (type_name, (field_name, field_type); ...)
kern_variants : (string * (string * elttype list) list) list;Variant type definitions: (type_name, (constructor_name, payload_types); ...)
kern_funcs : helper_func list;Helper functions defined in kernel scope
*)kern_native_fn : unit option;Placeholder for native function - actual function added during quoting
*)}Kernel representation
val default_kernel : kernelBase for a record update, mirroring Sarek_ir_types.default_kernel.
This module's kernel and Sarek_ir_types.kernel are two structurally parallel records bridged by Sarek_ir_conv.conv_kernel: this one is what lowering PRODUCES, the other is what the backends CONSUME. A field added to one almost always has to be added to the other and threaded through the converter, so both get the same escape hatch — otherwise migrating one type and not the other just moves the problem.