jon.recoil.org

Module Flambda2_to_cmm.To_cmm_result

Result structure used during Flambda to Cmm translation.

type t

An accumulator for the Cmm phrases and GC roots that result from translating statically-allocated blocks and function bodies.

Values of type t contain both older, "archived" data and "current" data which is still being worked on. The archive_data function transfers current data into the archived part, clearing the current data area for subsequent use.

val create : module_symbol:Flambda2_identifiers.Symbol.t -> reachable_names:Flambda2_nominal.Name_occurrences.t -> t

Create a result structure.

reachable_names specifies which names are reachable from outside the compilation unit (same terminology as used in Flambda_cmx).

Translate an existing Symbol.t to a Cmm symbol.

val symbol_of_code_id : t -> Flambda2_identifiers.Code_id.t -> currently_in_inlined_body:bool -> Cmm.symbol

Produce the Cmm function symbol for a piece of code.

val raw_symbol : t -> global:Cmm.is_global -> string -> t * Cmm.symbol

Create a Cmm symbol, not arising from a Symbol.t.

val archive_data : t -> t

Archive the current data into the list of already-translated data.

val add_archive_data_items : t -> Cmm.data_item list -> t

Add already-translated Cmm data items into the archived part of the result structure.

val update_data : t -> (Cmm.data_item list -> Cmm.data_item list) -> t

Update the current data part of the result structure.

val set_data : t -> Cmm.data_item list -> t

Set the current data to the given list. Raises a fatal error if the current data is not empty, to avoid inadvertently losing data.

val add_gc_roots : t -> Flambda2_identifiers.Symbol.t list -> t

Register one or more symbols as required GC roots.

val add_function : t -> Cmm.fundecl -> t

Register a function that has been translated to Cmm.

val check_for_module_symbol : t -> Flambda2_identifiers.Symbol.t -> t

Record the given symbol as having been defined. This is used to keep track of whether the module block symbol for the current unit has been defined.

val add_invalid_message_symbol : t -> Flambda2_identifiers.Symbol.t -> message:string -> t

Caching of symbols associated with Invalid messages.

val invalid_message_symbol : t -> message:string -> Flambda2_identifiers.Symbol.t option
type result = private {
  1. data_items : Cmm.phrase list;
  2. gc_roots : Cmm.symbol list;
  3. functions : Cmm.phrase list;
}
val to_cmm : t -> result

Archive the current data and then return the translated data present in the given result structure.