Name of the declaration being simplified. We currently use this information because we are generating phase1 declarations on demand, and it may trigger non-termination when trying to access the phase1 declaration.
declName : Lean.Name- config : Lean.Compiler.LCNF.Simp.Config
Stack of global declarations being recursively inlined.
Mapping from declaration names to number of occurrences at
inlineStack
inlineStackOccs : Lean.PHashMap Lean.Name Nat
Instances For
Free variable substitution. We use it to implement inlining and removing redundant variables
let _x.i := _x.j
subst : Lean.Compiler.LCNF.FVarSubstTrack used local declarations to be able to eliminate dead variables.
Mapping containing free variables ids that need to be renamed (i.e., the
binderName
). We use this map to preserve user provide names.binderRenaming : Lean.Compiler.LCNF.RenamingMapping used to decide whether a local function declaration must be inlined or not.
funDeclInfoMap : Lean.Compiler.LCNF.Simp.FunDeclInfoMaptrue
if some simplification was performed in the current simplification pass.simplified : BoolNumber of visited
let-declarations
and terminal values. This is a performance counter, and currently has no impact on code generation.visited : NatNumber of definitions inlined. This is a performance counter.
inline : NatNumber of local functions inlined. This is a performance counter.
inlineLocal : Nat
Instances For
Equations
- Lean.Compiler.LCNF.Simp.instMonadSimpM = let i := inferInstanceAs (Monad Lean.Compiler.LCNF.Simp.SimpM); Monad.mk
Equations
- Lean.Compiler.LCNF.Simp.instMonadFVarSubstSimpMFalse = { getSubst := do let __do_lift ← get pure __do_lift.subst }
Equations
- One or more equations did not get rendered due to their size.
Set the simplified
flag to true
.
Equations
- One or more equations did not get rendered due to their size.
Increment visited
performance counter.
Equations
- One or more equations did not get rendered due to their size.
Increment inline
performance counter. It is the number of inlined global declarations.
Equations
- One or more equations did not get rendered due to their size.
Increment inlineLocal
performance counter. It is the number of inlined local function and join point declarations.
Equations
- One or more equations did not get rendered due to their size.
Mark the local function declaration or join point with the given id as a "must inline".
Equations
- One or more equations did not get rendered due to their size.
Add a new occurrence of local function fvarId
.
Equations
- One or more equations did not get rendered due to their size.
Add a new occurrence of local function fvarId
in argument position .
Equations
- One or more equations did not get rendered due to their size.
Traverse code
and update function occurrence map.
This map is used to decide whether we inline local functions or not.
If mustInline := true
, then all local function declarations occurring in
code
are tagged as .mustInline
.
Recall that we use .mustInline
for local function declarations occurring in type class instances.
Equations
- One or more equations did not get rendered due to their size.
Execute x
with an updated inlineStack
. If value
is of the form const ...
, add const
to the stack.
Otherwise, do not change the inlineStack
.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Similar to the default Lean.withIncRecDepth
, but include the inlineStack
in the error messsage.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Execute x
with fvarId
set as mustInline
.
After execution the original setting is restored.
Equations
- One or more equations did not get rendered due to their size.
Return true if the given local function declaration or join point id is marked as
once
or mustInline
. We use this information to decide whether to inline them.
Equations
- One or more equations did not get rendered due to their size.
Return true
if the given code is considered "small".
Equations
- Lean.Compiler.LCNF.Simp.isSmall code = do let __do_lift ← liftM Lean.Compiler.LCNF.getConfig pure (Lean.Compiler.LCNF.Code.sizeLe code __do_lift.smallThreshold)
Return true
if the given local function declaration should be inlined.
Equations
- One or more equations did not get rendered due to their size.
LCNF "Beta-reduce". The equivalent of (fun params => code) args
.
If mustInline
is true, the local function declarations in the resulting code are marked as .mustInline
.
See comment at updateFunDeclInfo
.
Equations
- One or more equations did not get rendered due to their size.
Erase the given let-declaration from the local context,
and set the simplified
flag to true.
Equations
Erase the given local function declaration from the local context,
and set the simplified
flag to true.
Equations
Similar to LCNF.addFVarSubst
. That is, add the entry
fvarId ↦ fvarId'
to the free variable substitution.
If fvarId
has a non-internal binder name n
, but fvarId'
does not,
this method also adds the entry fvarId' ↦ n
to the binderRenaming
map.
The goal is to preserve user provided names.
Equations
- One or more equations did not get rendered due to their size.