Mapping from variable to projections
Instances For
Equations
Instances For
Equations
- Lean.IR.ExpandResetReuse.CollectProjMap.collectVDecl x (Lean.IR.Expr.proj i x_1) m = Std.HashMap.insert m x (Lean.IR.Expr.proj i x_1)
- Lean.IR.ExpandResetReuse.CollectProjMap.collectVDecl x (Lean.IR.Expr.sproj n offset x_1) m = Std.HashMap.insert m x (Lean.IR.Expr.sproj n offset x_1)
- Lean.IR.ExpandResetReuse.CollectProjMap.collectVDecl x (Lean.IR.Expr.uproj i x_1) m = Std.HashMap.insert m x (Lean.IR.Expr.uproj i x_1)
- Lean.IR.ExpandResetReuse.CollectProjMap.collectVDecl x v m = m
Instances For
Create a mapping from variables to projections. This function assumes variable ids have been normalized
Equations
Instances For
- projMap : Lean.IR.ExpandResetReuse.ProjMap
Instances For
Return true iff x
is consumed in all branches of the current block.
Here consumption means the block contains a dec x
or reuse x ...
.
Equations
Instances For
Auxiliary function for eraseProjIncFor
Try to erase inc
instructions on projections of y
occurring in the tail of bs
.
Return the updated bs
and a bit mask specifying which inc
s have been removed.
Equations
- Lean.IR.ExpandResetReuse.eraseProjIncFor n y bs = Lean.IR.ExpandResetReuse.eraseProjIncForAux y bs (mkArray n none) #[]
Instances For
Replace reuse x ctor ...
with ctor ...
, and remove dec x
replace
x := reset y; b
with
inc z_1; ...; inc z_i; dec y; b'
where z_i
's are the variables in mask
,
and b'
is b
where we removed dec x
and replaced reuse x ctor_i ...
with ctor_i ...
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
- Lean.IR.ExpandResetReuse.mkFresh = modifyGet fun (n : Lean.IR.Index) => ({ idx := n }, n + 1)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.IR.ExpandResetReuse.setFields y zs b = zs.size.fold (fun (i : Nat) (x : i < zs.size) (b : Lean.IR.FnBody) => Lean.IR.FnBody.set y i zs[i] b) b
Instances For
Given set x[i] := y
, return true iff y := proj[i] x
Equations
- Lean.IR.ExpandResetReuse.isSelfSet ctx x i (Lean.IR.Arg.var y_2) = match ctx.projMap[y_2]? with | some (Lean.IR.Expr.proj j w) => j == i && w == x | x => false
- Lean.IR.ExpandResetReuse.isSelfSet ctx x i y = false
Instances For
Given uset x[i] := y
, return true iff y := uproj[i] x
Equations
- Lean.IR.ExpandResetReuse.isSelfUSet ctx x i y = match ctx.projMap[y]? with | some (Lean.IR.Expr.uproj j w) => j == i && w == x | x => false
Instances For
Given sset x[n, i] := y
, return true iff y := sproj[n, i] x
Equations
- Lean.IR.ExpandResetReuse.isSelfSSet ctx x n i y = match ctx.projMap[y]? with | some (Lean.IR.Expr.sproj m j w) => n == m && j == i && w == x | x => false
Instances For
Remove unnecessary set/uset/sset
operations
replace
x := reset y; b
with
let f_i_1 := proj[i_1] y;
...
let f_i_k := proj[i_k] y;
b'
where i_j
s are the field indexes
that the code did not touch immediately before the reset.
That is mask[j] == none
.
b'
is b
where y
dec x
is replaced with del y
,
and z := reuse x ctor_i ws; F
is replaced with
set x i ws[i]
operations, and we replace z
with x
in F
Equations
- Lean.IR.ExpandResetReuse.mkFastPath x y mask b = do let ctx ← read let b : Lean.IR.FnBody := Lean.IR.ExpandResetReuse.reuseToSet ctx x y b Lean.IR.ExpandResetReuse.releaseUnreadFields y mask b
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Lean.IR.ExpandResetReuse.main d = d
Instances For
(Try to) expand reset
and reuse
instructions.
Equations
- d.expandResetReuse = (Lean.IR.ExpandResetReuse.main d).normalizeIds