Mlang.DecoupledExpr
type offset =
| GetValueConst of int |
| GetValueExpr of string |
| GetValueVar of Bir.variable |
| PassPointer |
| None |
val generate_variable :
Dgfip_varid.var_id_map ->
offset ->
?def_flag:bool ->
?trace_flag:bool ->
Bir.variable ->
string
This module distinguish defineness and valuation computations of M expressions so they can be expressed independantly and more thoroughtly optimized. Definition of such expression follows as such:
expression_composition
)build_expression
)val locals_from_m : Mir.LocalVariable.t -> 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
These are the smart constructors used to build expressions. In effect, they represent the language in which computations are defined.
They are used as traditional nestable sum-type constructors. An example:
0.5 * (x + y)
would turn into
mult (lit 0.5) (plus (local_var x) (local_var y))
where x
and y
are previously defined local_var
s
val dtrue : constr
True value
val dfalse : constr
False value
val lit : float -> constr
Float literal
val m_var : Bir.variable -> offset -> dflag -> constr
Value from TGV. m_var v off df
represents an access to the TGV variable v
with df
to read defineness or valuation. off
is the access type for M array, and should be None
most of the time. For array access, see access
.
Local let-binding. let_local v defining_expr body_expr
is akin to OCaml let v = defining_expr in body_expr
Float division. Care to guard for division by zero as it is not intrisectly guarranteed
Comparison operation. The operator is given as C-style string literal
val dinstr : string -> constr
Direct instruction
val access : Bir.variable -> dflag -> constr -> constr
Arbitrary access to M TGV variable. Either defineness of valuation
Functionnal if-the-else construction. ite cond_expr then_expr else_expr
is akin to if cond_expr then then_expr else else_expr
While constr
is the expression language for decoupled values, the following represents complete and optimized expressions for M computations
Representation of an M computation in construction. def_test
for the defineness flag, and value_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 to false
, can be set when the defined value_comp
computation will evaluate to zero if def_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 * t * t
val format_local_declarations : Stdlib.Format.formatter -> local_decls -> unit
val format_assign :
Dgfip_options.flags ->
Dgfip_varid.var_id_map ->
string ->
Stdlib.Format.formatter ->
t ->
unit