Module Mlang.DecoupledExpr
type offset
=
|
GetValueConst of int
|
GetValueExpr of string
|
GetValueVar of Com.Var.t
|
PassPointer
|
None
Low-level M computation
Local variables
val locals_from_m : unit -> local_var * local_var
Return a couple of local variable from a MIR one, for defineness and valuation in this order.
val new_local : unit -> local_var
Create a fresh local variable
Expression constructors
val dtrue : constr
True value
val dfalse : constr
False value
val lit : float -> constr
Float literal
val m_var : Com.Var.t -> offset -> dflag -> constr
Value from TGV.
m_var v off df
represents an access to the TGV variablev
withdf
to read defineness or valuation.off
is the access type for M array, and should beNone
most of the time. For array access, seeaccess
.
val let_local : local_var -> constr -> constr -> constr
Local let-binding.
let_local v defining_expr body_expr
is akin to OCamllet v = defining_expr in body_expr
val div : constr -> constr -> constr
Float division. Care to guard for division by zero as it is not intrisectly guarranteed
val comp : string -> constr -> constr -> constr
Comparison operation. The operator is given as C-style string literal
val dinstr : string -> constr
Direct instruction
val dlow_level : string -> constr
Direct instruction, not pushed
Decoupled expressions
type expression_composition
=
{
set_vars : (dflag * string * constr) list;
def_test : constr;
value_comp : constr;
}
Representation of an M computation in construction.
def_test
for the defineness flag, andvalue_comp
for the actual valuation.
val build_transitive_composition : ?safe_def:bool -> expression_composition -> expression_composition
Refine an expression composition to enfore M invariants. Mainly the fact that undefined value are valuated to zero.
value_comp
of the argument is expected to be defined assuming the expression is defined.safe_def
, which defaults tofalse
, can be set when the definedvalue_comp
computation will evaluate to zero ifdef_test
do, allowing the guard to be optimized away.
val is_always_true : t -> bool
Tells if the expression
t
reprensents a value statically different to zero
val build_expression : expression_composition -> local_decls * (dflag * string * t) list * t * t
Crush Expression constructors values into closed expressions
t
val format_local_declarations : Stdlib.Format.formatter -> local_decls -> unit
val format_assign : Dgfip_options.flags -> string -> Stdlib.Format.formatter -> t -> unit
val format_set_vars : Dgfip_options.flags -> Stdlib.Format.formatter -> (dflag * string * t) list -> unit