Each parameter is associated with a SpecParamInfo. This information is used by LCNF/Specialize.lean.
- fixedInst : SpecParamInfo
A parameter that is an type class instance (or an arrow that produces a type class instance), and is fixed in recursive declarations. By default, Lean always specializes this kind of argument.
- fixedHO : SpecParamInfo
- fixedNeutral : SpecParamInfo
- user : SpecParamInfo
An argument that has been specified in the
@[specialize]attribute. Lean specializes it even if it is not fixed in recursive declarations. Non-termination can happen, and Lean interrupts it with an error message based on the stack depth. - other : SpecParamInfo
Parameter is not going to be specialized.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Compiler.LCNF.SpecParamInfo.fixedInst.causesSpecialization = true
- Lean.Compiler.LCNF.SpecParamInfo.fixedHO.causesSpecialization = true
- Lean.Compiler.LCNF.SpecParamInfo.user.causesSpecialization = true
- Lean.Compiler.LCNF.SpecParamInfo.fixedNeutral.causesSpecialization = false
- Lean.Compiler.LCNF.SpecParamInfo.other.causesSpecialization = false
Instances For
Equations
- One or more equations did not get rendered due to their size.
- declName : Name
The name of the declaration.
- paramsInfo : Array SpecParamInfo
Information about which parameters of the declaration qualify for specialization.
- alreadySpecialized : Bool
True if
declNamewas already specialized before. This is relevant because we specialize declarations that have already been specialized less aggressively than declarations that have not.
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Compiler.LCNF.instInhabitedSpecState.default = { specInfo := default }
Instances For
Extension for storing SpecParamInfo for declarations being compiled.
Remark: we only store information for declarations that will be specialized.
Note: fixedNeutral must have forward dependencies.
The code specializer consider a fixedNeutral parameter during code specialization
only if it contains forward dependencies that are tagged as .user, .fixedHO, or .fixedInst.
The motivation is to minimize the number of code specializations that have little or no impact on
performance. For example, let's consider the function.
def liftMacroM
{α : Type} {m : Type → Type}
[Monad m] [MonadMacroAdapter m] [MonadEnv m] [MonadRecDepth m] [MonadError m]
[MonadResolveName m] [MonadTrace m] [MonadOptions m] [AddMessageContext m] [MonadLiftT IO m] (x : MacroM α) : m α := do
The parameter α does not occur in any local instance, and x is marked as .other since the function
is not tagged as [specialize]. There is little value in considering α during code specialization,
but if we do many copies of this function will be generated.
Recall users may still force the code specializer to take α into account by using [specialize α] (α has .user info),
or [specialize x] (α has .fixedNeutral since x is a forward dependency tagged as .user),
or [specialize] (α has .fixedNeutral since x is a forward dependency tagged as .fixedHO).
Compute specialization information for decls. We assume that decls contains a full SCC of
computationally relevant declarations. Furthermore this function takes:
autoSpecializewhich determines whether we apply "automated" specialization to a decl, that is whether we automatically specialize for all fixedHO parameters. It receives both the name and the array of arguments mentioned in@[specialize]if any.alreadySpecializedwhich is a mask that says whether a decl is already a specialized declaration itself.
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.
Instances For
Equations
- Lean.Compiler.LCNF.getSpecEntry? declName = do let __do_lift ← Lean.getEnv pure (Lean.Compiler.LCNF.getSpecEntryCore? __do_lift declName)
Instances For
Equations
- Lean.Compiler.LCNF.isSpecCandidate declName = do let __do_lift ← Lean.getEnv pure (Lean.Compiler.LCNF.getSpecEntryCore? __do_lift declName).isSome