jon.recoil.org

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 Ocaml_typing.Jkind_types.Sort.Const.t
  3. | Unboxed_float of Ocaml_typing.Primitive.boxed_float
  4. | Unboxed_vector of Ocaml_typing.Primitive.boxed_vector
  5. | Unboxed_or_untagged_integer of Ocaml_typing.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 : Ocaml_typing.Primitive.effects;
  6. prim_coeffects : Ocaml_typing.Primitive.coeffects;
  7. prim_native_name : string;
  8. prim_native_repr_args : (Ocaml_typing.Primitive.mode * 'repr) list;
  9. prim_native_repr_res : Ocaml_typing.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:Ocaml_typing.Primitive.effects -> coeffects:Ocaml_typing.Primitive.coeffects -> native_name:string -> native_repr_args:(Ocaml_typing.Primitive.mode * 'repr) list -> native_repr_res:(Ocaml_typing.Primitive.mode * 'repr) -> is_layout_poly:bool -> 'repr Ocaml_typing.Primitive.description_gen
val native_name : 'a Ocaml_typing.Primitive.description_gen -> string
val byte_name : 'a Ocaml_typing.Primitive.description_gen -> string
val native_name_is_external : Ocaml_typing.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:Ocaml_parsing.Location.t -> Ocaml_typing.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 : Ocaml_typing.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