Module Analysis_and_optimization.Mir_utils

val var_declarations : ('a, 'b) Middle.Stmt.t -> Core.string Core.Set.Poly.t
type bound_values = {
  1. lower : [ `None | `Nonlit | `Lit of Core.float ];
  2. upper : [ `None | `Nonlit | `Lit of Core.float ];
}
val chop_dist_name : Core.string -> Core.string Core.Option.t
val top_var_declarations : Middle.Stmt.Located.t -> Core.string Core.Set.Poly.t
val data_set : ?exclude_transformed:Core.bool -> ?exclude_ints:Core.bool -> Middle.Program.Typed.t -> Core.string Core.Set.Poly.t
val parameter_names_set : ?include_transformed:Core.bool -> Middle.Program.Typed.t -> Core.string Core.Set.Poly.t
val fold_expr : take_expr:('c -> Middle.Expr.Typed.t -> 'c) -> init:'c -> Middle.Expr.Typed.t -> 'c
val fold_stmts : take_expr:('c -> Middle.Expr.Typed.t -> 'c) -> take_stmt:('c -> Middle.Stmt.Located.t -> 'c) -> init:'c -> Middle.Stmt.Located.t Core.List.t -> 'c
val fwd_traverse_statement : ('e, 'a) Middle.Stmt.Pattern.t -> init:'f -> f:('f -> 'a -> 'f * 'c) -> 'f * ('e, 'c) Middle.Stmt.Pattern.t

A traversal that simultaneously accumulates a state (type 'f) and replaces the substatement values from ('a to 'c). Traversal is done in-order but ignores branching, e.g., and if's then block is followed by the else block rather than branching.

val vexpr_of_expr_exn : Middle.Expr.Typed.t -> Dataflow_types.vexpr

Take a LHS expression from a general expression, throwing an exception if it can't be a LHS expression.

The set of variables in an expression, including inside an index. For use in RHS sets, not LHS assignment sets, except in a target term.

The set of variables in an index. For use in RHS sets, not LHS assignment sets, except in a target term

val expr_var_names_set : Middle.Expr.Typed.t -> Core.string Core.Set.Poly.t

Return the names of the variables in an expression.

The set of variables that can affect the value or behavior of the expression, i.e. rhs. Using Set.Poly instead of ExprSet so that 'e can be polymorphic, it usually doesn't matter if there's duplication.

val union_map : 'a Core.Set.Poly.t -> f:('a -> 'b Core.Set.Poly.t) -> 'b Core.Set.Poly.t

This is a helper function equivalent to List.concat_map but for Sets

The set of variables in an expression, including inside an index. For use in RHS sets, not LHS assignment sets, except in a target term.

val expr_assigned_var : Middle.Expr.Typed.t -> Dataflow_types.vexpr

The variable being assigned to when the expression is the LHS

The list of terms in expression separated by a +

Substitute variables in an expression according to the provided Map.

Substitute variables occurring at the top level in statements according to the provided Map.

Substitute variables occurring anywhere in a statement according to the provided Map.

Substitute subexpressions occurring anywhere in a statement according to the provided Map.

val expr_subst_expr : Middle.Expr.Typed.t Core.Map.M(Middle.Expr.Typed).t -> Middle.Expr.Typed.t -> Middle.Expr.Typed.t

Substitute subexpressions in an expression according to the provided Map, trying to match on larger subexpressions before smaller ones.

val expr_subst_stmt_base : Middle.Expr.Typed.t Core.Map.M(Middle.Expr.Typed).t -> (Middle.Expr.Typed.t, 'a) Middle.Stmt.Pattern.t -> (Middle.Expr.Typed.t, 'a) Middle.Stmt.Pattern.t

Substitute subexpressions occurring at the top level in statements according to the provided Map.

val expr_depth : Middle.Expr.Typed.t -> Core.int

Calculate how deeply nested an expression is.

Recompute all AD-levels in the metadata of an expression from the bottom up, making the variables in the first argument autodiffable

val cleanup_empty_stmts : ('e, 's) Middle.Stmt.t Core.list -> ('e, 's) Middle.Stmt.t Core.list