jon.recoil.org

Module 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 Primitive.boxed_float
  4. | Unboxed_vector of Primitive.boxed_vector
  5. | Unboxed_or_untagged_integer of Primitive.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 : Primitive.effects;
  6. prim_coeffects : Primitive.coeffects;
  7. prim_native_name : string;
  8. prim_native_repr_args : (Primitive.mode * 'repr) list;
  9. prim_native_repr_res : Primitive.mode * 'repr;
  10. prim_is_layout_poly : bool;
}
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:Primitive.effects -> coeffects:Primitive.coeffects -> native_name:string -> native_repr_args:(Primitive.mode * 'repr) list -> native_repr_res:(Primitive.mode * 'repr) -> is_layout_poly:bool -> 'repr Primitive.description_gen
val parse_declaration : Parsetree.value_description -> native_repr_args:(Primitive.mode * Primitive.native_repr) list -> native_repr_res:(Primitive.mode * Primitive.native_repr) -> is_layout_poly:bool -> Primitive.description
val native_name : 'a Primitive.description_gen -> string
val byte_name : 'a Primitive.description_gen -> string
val equal_unboxed_or_untagged_integer : Primitive.unboxed_or_untagged_integer -> Primitive.unboxed_or_untagged_integer -> bool
val equal_unboxed_float : Primitive.unboxed_float -> Primitive.unboxed_float -> bool
val equal_unboxed_vector : Primitive.unboxed_vector -> Primitive.unboxed_vector -> bool
val compare_unboxed_float : Primitive.unboxed_float -> Primitive.unboxed_float -> int
val compare_unboxed_vector : Primitive.unboxed_vector -> Primitive.unboxed_vector -> int
val equal_boxed_integer : Primitive.boxed_integer -> Primitive.boxed_integer -> bool
val equal_boxed_float : Primitive.boxed_float -> Primitive.boxed_float -> bool
val equal_boxed_vector : Primitive.boxed_vector -> Primitive.boxed_vector -> bool
val compare_boxed_float : Primitive.boxed_float -> Primitive.boxed_float -> int
val compare_boxed_vector : Primitive.boxed_vector -> Primitive.boxed_vector -> int
val equal_native_repr : Primitive.native_repr -> Primitive.native_repr -> bool
val equal_effects : Primitive.effects -> Primitive.effects -> bool
val equal_coeffects : Primitive.coeffects -> Primitive.coeffects -> bool
val native_name_is_external : Primitive.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:Location.t -> Primitive.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 : Primitive.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 Location.t * Primitive.error