Module Flambda2_simplify.Flow_acc
Dataflow analysis.
This module aims mainly at tracking uses of variables (other things may be added later on), with the aim of:
- removing unused parameters of *recursive* continuations;
- moving allocations out of the hot path of recursive continuations (e.g. the allocation of a float that was unboxed by the simplifier).
type t = Flambda2_simplify.Flow_types.Acc.tType alias for convenience.
val print : Stdlib.Format.formatter -> Flambda2_simplify.Flow_acc.t -> unitPrinting
val normalize_acc :
specialization_map:
Flambda2_identifiers.Continuation.t
Flambda2_identifiers.Apply_cont_rewrite_id.Map.t
Flambda2_identifiers.Continuation.Map.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tNormalize an accumulator before begin processed. Does two things:
- "Consume" the extra args of an accumulator in order to add them to the regular args and parameters in the continuation info of each continuation
- Rewrite the callsites of specialized continuations
A name for the incorrec tdummy toplevel cont used to initialize the acc.
val empty : unit -> Flambda2_simplify.Flow_acc.tEmpty uses
val init_toplevel :
dummy_toplevel_cont:Flambda2_identifiers.Continuation.t ->
Flambda2_bound_identifiers.Bound_parameters.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tInitialize the analysis so that the stack consists of a single toplevel continuation.
val enter_continuation :
Flambda2_identifiers.Continuation.t ->
recursive:bool ->
is_exn_handler:bool ->
Flambda2_bound_identifiers.Bound_parameters.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tAdd a new continuation on the stack. Used when entering a continuation handler.
val exit_continuation :
Flambda2_identifiers.Continuation.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tPop the current top of the stack. Used when exiting the current continuation handler.
val record_defined_var :
Flambda2_identifiers.Variable.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tThat variable is defined in the current handler
val record_var_binding :
Flambda2_identifiers.Variable.t ->
Flambda2_nominal.Name_occurrences.t ->
generate_phantom_lets:bool ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tAdd a variable binding from the current handler.
val record_let_binding :
rewrite_id:Flambda2_identifiers.Named_rewrite_id.t ->
generate_phantom_lets:bool ->
let_bound:Flambda2_bound_identifiers.Bound_pattern.t ->
simplified_defining_expr:Flambda2_simplify.Simplified_named.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tRecord a let-binding
val record_symbol_projection :
Flambda2_identifiers.Variable.t ->
Flambda2_nominal.Name_occurrences.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tAdd a variable binding to the symbol. Projections might get recorded multiple times.
val record_symbol_binding :
Flambda2_identifiers.Symbol.t ->
Flambda2_nominal.Name_occurrences.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tAdd a symbol binding from the current handler.
val record_code_id_binding :
Flambda2_identifiers.Code_id.t ->
Flambda2_nominal.Name_occurrences.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tAdd a code id binding from the current handler.
val record_value_slot :
Flambda2_identifiers.Name.t ->
Flambda2_identifiers.Value_slot.t ->
Flambda2_nominal.Name_occurrences.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tAdd a value slot from the current handler.
val add_used_in_current_handler :
Flambda2_nominal.Name_occurrences.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tAdd name occurrences used in the body of the current continuation's handler, *excluding* uses in apply_cont expressions, which are tracked separately.
val add_apply_conts :
result_cont:
(Flambda2_identifiers.Apply_cont_rewrite_id.t
* Flambda2_identifiers.Continuation.t)
option ->
exn_cont:
(Flambda2_identifiers.Apply_cont_rewrite_id.t
* Flambda2_terms.Exn_continuation.t) ->
result_arity:[ `Unarized ] Flambda2_kinds.Flambda_arity.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tAdd the given continuation as being used as the return continuation for a function call.
val add_apply_cont_args :
rewrite_id:Flambda2_identifiers.Apply_cont_rewrite_id.t ->
Flambda2_identifiers.Continuation.t ->
Flambda2_term_basics.Simple.t list ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tAdd, for the current continuation handler, uses for an apply cont of the given continuation with given arguments occurrences.
val add_extra_params_and_args :
Flambda2_identifiers.Continuation.t ->
Flambda2_simplify.Continuation_extra_params_and_args.t ->
Flambda2_simplify.Flow_acc.t ->
Flambda2_simplify.Flow_acc.tAdd extra params and args to a continuation.