Module Ocaml_typing.Primitive

type unboxed_or_untagged_integer =
  1. | Unboxed_int64
  2. | Unboxed_nativeint
  3. | Unboxed_int32
  4. | Untagged_int16
  5. | Untagged_int8
  6. | Untagged_int
    (*

    Untagged_int is used for int# and when you write int[@untagged] on external declarations.

    *)
type unboxed_float =
  1. | Unboxed_float64
  2. | Unboxed_float32
type unboxed_vector =
  1. | Unboxed_vec128
  2. | Unboxed_vec256
  3. | Unboxed_vec512
type boxed_integer =
  1. | Boxed_int64
  2. | Boxed_nativeint
  3. | Boxed_int32
type boxed_float =
  1. | Boxed_float64
  2. | Boxed_float32
type boxed_vector =
  1. | Boxed_vec128
  2. | Boxed_vec256
  3. | Boxed_vec512
type native_repr =
  1. | Repr_poly
  2. | Same_as_ocaml_repr of Jkind_types.Sort.Const.t
  3. | Unboxed_float of boxed_float
  4. | Unboxed_vector of boxed_vector
  5. | Unboxed_or_untagged_integer of unboxed_or_untagged_integer

Representation of arguments/result for the native code version of a primitive.

Untagged integers (such as int[@untagged]) are represented as Unboxed_integer Untagged_int

type effects =
  1. | No_effects
  2. | Only_generative_effects
  3. | Arbitrary_effects
type coeffects =
  1. | No_coeffects
  2. | Has_coeffects
type mode =
  1. | Prim_local
  2. | Prim_global
  3. | Prim_poly
type 'repr description_gen = private {
  1. prim_name : string;
  2. prim_arity : int;
  3. prim_alloc : bool;
  4. prim_c_builtin : bool;
  5. prim_effects : effects;
  6. prim_coeffects : coeffects;
  7. prim_native_name : string;
  8. prim_native_repr_args : (mode * 'repr) list;
  9. prim_native_repr_res : mode * 'repr;
  10. prim_is_layout_poly : bool;
}
type description = native_repr description_gen
val make_prim_repr_args : int -> 'a -> 'a list

make_prim_repr_args n x is the same as List.init n (fun _ -> x). Keeping this function here to be close to upstream. It's intended for use with make.

val make : name:string -> alloc:bool -> c_builtin:bool -> effects:effects -> coeffects:coeffects -> native_name:string -> native_repr_args:(mode * 'repr) list -> native_repr_res:(mode * 'repr) -> is_layout_poly:bool -> 'repr description_gen
val parse_declaration : Ocaml_parsing.Parsetree.value_description -> native_repr_args:(mode * native_repr) list -> native_repr_res:(mode * native_repr) -> is_layout_poly:bool -> description
val native_name : 'a description_gen -> string
val byte_name : 'a description_gen -> string
val unboxed_float : boxed_float -> unboxed_float
val unboxed_or_untagged_integer : boxed_integer -> unboxed_or_untagged_integer
val unboxed_vector : boxed_vector -> unboxed_vector
val equal_unboxed_or_untagged_integer : unboxed_or_untagged_integer -> unboxed_or_untagged_integer -> bool
val equal_unboxed_float : unboxed_float -> unboxed_float -> bool
val equal_unboxed_vector : unboxed_vector -> unboxed_vector -> bool
val compare_unboxed_float : unboxed_float -> unboxed_float -> int
val compare_unboxed_vector : unboxed_vector -> unboxed_vector -> int
val equal_boxed_integer : boxed_integer -> boxed_integer -> bool
val equal_boxed_float : boxed_float -> boxed_float -> bool
val equal_boxed_vector : boxed_vector -> boxed_vector -> bool
val compare_boxed_float : boxed_float -> boxed_float -> int
val compare_boxed_vector : boxed_vector -> boxed_vector -> int
val equal_native_repr : native_repr -> native_repr -> bool
val equal_effects : effects -> effects -> bool
val equal_coeffects : coeffects -> coeffects -> bool
val native_name_is_external : description -> bool

native_name_is_externa returns true iff the native_name for the given primitive identifies that the primitive is not implemented in the compiler itself.

val prim_has_valid_reprs : loc:Ocaml_parsing.Location.t -> description -> unit

Check if a primitive has the correct native representations for its argument/return types. This check is done based on the primitive name and only imposes constraints on built-in primitives. Raises if the check fails.

val prim_can_contain_layout_any : description -> bool

Check if a primitive can have layout any anywhere within its type declaration. Returns false for built-in primitives that inspect the layout of type parameters (%array_length for example).

type error =
  1. | Old_style_float_with_native_repr_attribute
  2. | Old_style_float_with_non_value
  3. | Old_style_noalloc_with_noalloc_attribute
  4. | No_native_primitive_with_repr_attribute
  5. | No_native_primitive_with_non_value
  6. | Inconsistent_attributes_for_effects
  7. | Inconsistent_noalloc_attributes_for_effects
  8. | Invalid_representation_polymorphic_attribute
  9. | Invalid_native_repr_for_primitive of string
exception Error of Ocaml_parsing.Location.t * error