Module Sarek_registry

type type_info = {
  1. ti_name : string;
  2. ti_device : Spoc_framework.Device_type.t -> string;
  3. ti_size : int;
}

Information about a primitive/intrinsic type (float32, int64, etc.)

type field_info = {
  1. field_name : string;
  2. field_type : string;
  3. field_mutable : bool;
}

Information about a record field

type record_info = {
  1. ri_name : string;
  2. ri_fields : field_info list;
  3. ri_size : int;
}

Information about a record type (user-defined via @@sarek.type)

type constructor_info = {
  1. ctor_name : string;
  2. ctor_arg_type : string option;
}

Information about a variant constructor

type variant_info = {
  1. vi_name : string;
  2. vi_constructors : constructor_info list;
}

Information about a variant type

type fun_info = {
  1. fi_name : string;
  2. fi_arity : int;
  3. fi_device : Spoc_framework.Device_type.t -> string;
  4. fi_arg_types : string list;
  5. fi_ret_type : string;
}

Information about an intrinsic function

val type_registry : (string, type_info) Stdlib.Hashtbl.t

Type registry - maps type names to their info (primitives)

val record_registry : (string, record_info) Stdlib.Hashtbl.t

Record registry - maps type names to their info (user-defined records)

val variant_registry : (string, variant_info) Stdlib.Hashtbl.t

Variant registry - maps type names to their info (user-defined variants)

val fun_registry : (string list * string, fun_info) Stdlib.Hashtbl.t

Function registry - maps (module_path, name) to their info

val register_type : string -> device:(Spoc_framework.Device_type.t -> string) -> size:int -> unit

Register a primitive type

val register_record : string -> fields:field_info list -> size:int -> unit

Register a record type (called by PPX-generated code for @@sarek.type)

val register_variant : string -> constructors:constructor_info list -> unit

Register a variant type (called by PPX-generated code for @@sarek.type)

val register_fun : ?module_path:string list -> string -> arity:int -> device:(Spoc_framework.Device_type.t -> string) -> arg_types:string list -> ret_type:string -> unit

Register an intrinsic function

val find_type : string -> type_info option

Find a primitive type by name

val find_record : string -> record_info option

Find a record type by name

val find_variant : string -> variant_info option

Find a variant type by name

val find_fun : ?module_path:string list -> string -> fun_info option

Find a function by name, optionally in a module

val is_type : string -> bool

Check if a name is a registered primitive type

val is_record : string -> bool

Check if a name is a registered record type

val is_variant : string -> bool

Check if a name is a registered variant type

val is_fun : ?module_path:string list -> string -> bool

Check if a name is a registered function

val type_device_code : string -> Spoc_framework.Device_type.t -> string

Get device code for a type

val fun_device_code : ?module_path:string list -> string -> Spoc_framework.Device_type.t -> string

Get device code for a function

val fun_device_template : ?module_path:string list -> string -> string option

Get device code template for a function, using a minimal device. This is for V2 IR codegens that don't have SPOC device objects.

val find_record_by_short_name : string -> record_info option

Find a record by short name (last component after '.'). This handles cases where the registry uses qualified names like "Module.typename" but the custom_type uses just "typename".

val record_fields : string -> field_info list

Get record field info - tries exact match first, then short name

val variant_constructors : string -> constructor_info list

Get variant constructors

val cuda_or_opencl : Spoc_framework.Device_type.t -> 'a -> 'a -> 'a