Sarek_ppx_lib.Sarek_lower_irmodule Ir = Sarek_ir_ppxval elttype_of_typ : Sarek_types.typ -> Ir.elttypeConvert Sarek_types.typ to Sarek_ir_ppx.elttype
val memspace_of_memspace : Sarek_types.memspace -> Ir.memspaceConvert Sarek_types.memspace to Sarek_ir_ppx.memspace
val c_type_of_typ : Sarek_types.typ -> stringGet C type string for a typ
val record_constructor_strings :
string ->
(string * Sarek_types.typ) list ->
string listGenerate C struct definition and builder for record types
val variant_constructor_strings :
string ->
(string * Sarek_types.typ option) list ->
string listGenerate C struct definitions and builders for variant types
type state = {mutable next_var_id : int;fun_map : (string, Sarek_typed_ast.tparam list * Sarek_typed_ast.texpr)
Stdlib.Hashtbl.t;lowering_stack : (string, unit) Stdlib.Hashtbl.t;lowered_funs : (string, Ir.helper_func) Stdlib.Hashtbl.t;Lowered helper functions: name -> helper_func
*)mutable lowered_funs_order : string list;Order in which functions were lowered (for dependency ordering)
*)types : (string, (string * Ir.elttype) list) Stdlib.Hashtbl.t;Collected record types: type_name -> (field_name, field_type); ...
variants : (string, (string * Ir.elttype list) list) Stdlib.Hashtbl.t;Collected variant types: type_name -> (constructor_name, payload_types); ...
}Lowering state
val create_state :
(string, Sarek_typed_ast.tparam list * Sarek_typed_ast.texpr)
Stdlib.Hashtbl.t ->
stateval fresh_id : state -> intval ir_binop : Sarek_ast.binop -> Sarek_types.typ -> Ir.binopConvert Sarek_ast.binop to Sarek_ir_ppx.binop
val ir_unop : Sarek_ast.unop -> Ir.unopConvert Sarek_ast.unop to Sarek_ir_ppx.unop
val lower_memspace : Sarek_types.memspace -> Ir.memspaceConvert memspace
val make_var : string -> int -> Sarek_types.typ -> bool -> Ir.varCreate a var from typed var info
val lower_decl : mutable_:bool -> int -> string -> Sarek_types.typ -> Ir.declLower a declaration
Transform a statement to ensure it returns a value. This adds SReturn to leaf statements without re-traversing the original AST.
val lower_expr : state -> Sarek_typed_ast.texpr -> Ir.exprConvert a typed expression to IR expression
val lower_stmt : state -> Sarek_typed_ast.texpr -> Ir.stmtConvert a typed expression to IR statement
val lower_lvalue : state -> Sarek_typed_ast.texpr -> string -> Ir.lvalueval lower_pattern : Sarek_typed_ast.tpattern -> Ir.patternval extract_pattern_vars : Sarek_typed_ast.tpattern -> string listval lower_param : Sarek_typed_ast.tparam -> Ir.declConvert a kernel parameter to IR declaration
val lower_kernel : Sarek_typed_ast.tkernel -> Ir.kernel * string listLower a complete kernel
val lower_return_value : Sarek_typed_ast.tkernel -> Ir.decl optionGet the return value declaration for a kernel