jon.recoil.org

Module Flambda2_to_cmm.To_cmm_effects

type effects_and_coeffects_classification =
  1. | Pure
    (*

    Pure expressions can be commuted with *everything*, including effectful expressions such as function calls.

    *)
  2. | Effect
    (*

    Effectful expressions only commute with pure expressions.

    For the purpose of To_cmm, generative effects, i.e. allocations, are considered to have effects. This is because the mutable state of the GC that allocations affect can be observed by coeffects performed by function calls (in particular those coming from the Gc module).

    *)
  3. | Coeffect_only
    (*

    Coeffects without any effect. These expression can commute with other coeffectful expressions (and pure expressions), but cannot commute with an effectful expression.

    *)
  4. | Generative_immutable
    (*

    Only immutable generative effects. These are technically effects (since functions in the `Gc` module can read counters related to allocations), but we are interested in moving allocation (e.g. for unboxing of numbers in classic mode).

    *)

Classification of expressions based on their effects and coeffects.

Return the classification of an expression with the given effects and coeffects.

type let_binding_classification = private
  1. | Drop_defining_expr
    (*

    The defining expression may be deleted.

    *)
  2. | Regular
    (*

    Proceed as normal, do not inline the defining expression.

    *)
  3. | May_inline_once
    (*

    The defining expression is guaranteed to be used once, and may be inlined at the use site.

    *)
  4. | Must_inline_once
    (*

    The defining expression is guaranteed to be used once, and must inlined at the use site.

    *)
  5. | Must_inline_and_duplicate
    (*

    The defining expression must be inlined at all use sites, and it is used multiple times (or inside a loop).

    *)

Classification of Let-expressions, identifying what may be done with the defining expression.

type continuation_handler_classification = private
  1. | Regular
  2. | May_inline

Classification of continuations, indicating what may be done with the handler expression.

Effects and coeffects of C calls

val transl_c_call_effects : Flambda2_terms.Effects.t -> Cmm.effects
val transl_c_call_coeffects : Flambda2_terms.Coeffects.t -> Cmm.coeffects