jon.recoil.org

Module Ocaml_typing.PrimitiveSource

Sourcetype 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.

    *)
Sourcetype unboxed_float =
  1. | Unboxed_float64
  2. | Unboxed_float32
Sourcetype unboxed_vector =
  1. | Unboxed_vec128
  2. | Unboxed_vec256
  3. | Unboxed_vec512
Sourcetype boxed_integer =
  1. | Boxed_int64
  2. | Boxed_nativeint
  3. | Boxed_int32
Sourcetype boxed_float =
  1. | Boxed_float64
  2. | Boxed_float32
Sourcetype boxed_vector =
  1. | Boxed_vec128
  2. | Boxed_vec256
  3. | Boxed_vec512
Sourcetype 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
  6. | Unpacked_product of Jkind_types.Sort.Const.t

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

Sourcetype effects =
  1. | No_effects
  2. | Only_generative_effects
  3. | Arbitrary_effects
Sourcetype coeffects =
  1. | No_coeffects
  2. | Has_coeffects
Sourcetype mode =
  1. | Prim_local
  2. | Prim_global
  3. | Prim_poly
Sourcetype '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;
}
Sourceval 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.

Sourceval 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
Sourceval 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
Sourceval native_name : 'a description_gen -> string
Sourceval byte_name : 'a description_gen -> string
Sourceval unboxed_float : boxed_float -> unboxed_float
Sourceval unboxed_or_untagged_integer : boxed_integer -> unboxed_or_untagged_integer
Sourceval unboxed_vector : boxed_vector -> unboxed_vector
Sourceval equal_unboxed_or_untagged_integer : unboxed_or_untagged_integer -> unboxed_or_untagged_integer -> bool
Sourceval equal_unboxed_float : unboxed_float -> unboxed_float -> bool
Sourceval equal_unboxed_vector : unboxed_vector -> unboxed_vector -> bool
Sourceval compare_unboxed_float : unboxed_float -> unboxed_float -> int
Sourceval compare_unboxed_vector : unboxed_vector -> unboxed_vector -> int
Sourceval equal_boxed_integer : boxed_integer -> boxed_integer -> bool
Sourceval equal_boxed_float : boxed_float -> boxed_float -> bool
Sourceval equal_boxed_vector : boxed_vector -> boxed_vector -> bool
Sourceval compare_boxed_float : boxed_float -> boxed_float -> int
Sourceval compare_boxed_vector : boxed_vector -> boxed_vector -> int
Sourceval equal_native_repr : native_repr -> native_repr -> bool
Sourceval equal_effects : effects -> effects -> bool
Sourceval equal_coeffects : coeffects -> coeffects -> bool
Sourceval 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.

Sourceval 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.

Sourceval 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).

Sourcetype wrong_repr_error =
  1. | Product_arg
  2. | Expected_value_prim
  3. | Product_return
  4. | Unpacked_product_return
  5. | Repr_mismatch
Sourcetype 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 {
    1. prim_name : string;
    2. errors : wrong_repr_error list;
    }