jon.recoil.org

Module Flambda2_simplify.Expr_builder

Functions for rebuilding expressions that are used during simplification. Unlike the basic creation functions in Expr these functions do things such as keeping track of free names and avoiding generation of unused bindings. They also elide construction of the terms themselves if required, e.g. during speculative inlining.

Some expressions are rebuilt directly using the functions in Rebuilt_expr rather than using this module.

type binding_to_place =
  1. | Keep_binding of {
    1. let_bound : Flambda2_bound_identifiers.Bound_pattern.t;
    2. simplified_defining_expr : Flambda2_simplify.Simplified_named.t;
    3. original_defining_expr : Flambda2_terms.Flambda.Import.Named.t option;
    }
  2. | Delete_binding of {
    1. original_defining_expr : Flambda2_terms.Flambda.Import.Named.t option;
    }

Create Let binding(s) around a given body. (The type of this function prevents it from being used to create "let symbol" bindings; use the other functions in this module instead.) Bindings will be elided if they are unused.

The name_occurrences in the provided uacc must contain exactly the free names of the body.

Create the "let symbol" binding(s) around a given body necessary to define the given lifted constant.

Value slots are removed if they are not used according to the given uacc. (Such uacc must have seen all uses in the whole compilation unit.)

The name_occurrences in the provided uacc must contain exactly the free names of the body.

Place lifted constants arising from a let-expr (coming from both the defining_expr and the body).

Create a Switch expression, save that zero-arm switches are converted to Invalid, and one-arm switches to Apply_cont.

Handling of the rewriting of continuation use sites.

type rewrite_switch_arm_result = private
  1. | Invalid of {
    1. message : string;
    }
  2. | Apply_cont of Flambda2_terms.Flambda.Import.Apply_cont.t
  3. | New_wrapper of Flambda2_simplify.Expr_builder.new_let_cont