jon.recoil.org

Module Complex_shape

module RS = Runtime_shape
module Layout = Jkind_types.Sort.Const

Complex shape types.

Complex shapes represent type layouts that may include unboxed products and void types, in addition to "simple" runtime shapes that fit in a single register. The term "complex" follows Flambda 2's naming convention (see Flambda_arity.Component_for_creation in middle_end/flambda2/kinds), where "complex" arities can contain unboxed products, as opposed to "singleton" arities that describe single-register values.

A complex shape can be:

Complex shapes are used during DWARF type generation to accurately describe OxCaml types with unboxed layouts before they are flattened into sequences of runtime shapes.

type t = private {
  1. desc : desc;
  2. layout : Layout.t;
  3. hash : int;
}
and desc = private
  1. | Runtime of RS.t
  2. | Void
  3. | Unboxed_product of {
    1. kind : unboxed_product_kind;
    2. components : t list;
    }
and unboxed_product_kind = private
  1. | Unboxed_record of string list
  2. | Unboxed_tuple
val runtime : RS.t -> t
val unboxed_tuple : t list -> t
val record_unboxed : (string * t) list -> t
val void : t
val to_layout : t -> Layout.t
val print : Format.formatter -> t -> unit
val equal : t -> t -> bool
val hash : t -> int
val runtime_shape : t -> RS.t option

Extract the runtime shape from a complex shape, if it is a simple runtime shape. Returns None for Void and Unboxed_product variants.

val flatten_complex_shape : t -> RS.t RS.Or_void.t list

Flatten a complex shape into a list of runtime shapes and voids. Can be used to simulate the effect of unarization on function arguments.

module Shape_cache : sig ... end

Cache for memoizing type_shape_to_complex_shape results.

val type_shape_to_complex_shape : cache:Shape_cache.t -> Type_shape.Evaluated_shape.t -> Layout.t -> t

Convert an evaluated type shape and layout to a complex shape for DWARF type generation.