Helper functions for backend code generators #
Return true iff b
is of the form let x := g ys; ret x
Equations
- Lean.IR.isTailCallTo g b = match b with | Lean.IR.FnBody.vdecl x ty (Lean.IR.Expr.fap f ys) (Lean.IR.FnBody.ret (Lean.IR.Arg.var y)) => x == y && f == g | x => false
Instances For
Equations
- Lean.IR.usesModuleFrom env modulePrefix = env.allImportedModuleNames.toList.any fun (modName : Lake.Name) => modulePrefix.isPrefixOf modName
Instances For
@[reducible, inline]
Instances For
@[inline]
Equations
- Lean.IR.CollectUsedDecls.collect f = modify fun (s : Lean.NameSet) => s.insert f
Instances For
Equations
- Lean.IR.CollectUsedDecls.collectInitDecl fn = do let env ← read match Lean.getInitFnNameFor? env fn with | some initFn => Lean.IR.CollectUsedDecls.collect initFn | x => pure ()
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Lean.IR.collectUsedDecls
(env : Lean.Environment)
(decl : Lean.IR.Decl)
(used : optParam Lean.NameSet ∅)
:
Equations
- Lean.IR.collectUsedDecls env decl used = StateT.run' (Lean.IR.CollectUsedDecls.collectDecl decl env) used
Instances For
@[reducible, inline]
Instances For
@[reducible, inline]
Instances For
@[reducible, inline]
Equations
Instances For
@[inline]
Equations
- Lean.IR.CollectMaps.collectVar x✝ t x = match x with | (vs, js) => (Lean.HashMap.insert vs x✝ t, js)
Instances For
Equations
- Lean.IR.CollectMaps.collectParams ps s = Array.foldl (fun (s : Lean.IR.VarTypeMap × Lean.IR.JPParamsMap) (p : Lean.IR.Param) => Lean.IR.CollectMaps.collectVar p.x p.ty s) s ps
Instances For
@[inline]
Equations
- Lean.IR.CollectMaps.collectJP j xs x = match x with | (vs, js) => (vs, Lean.HashMap.insert js j xs)
Instances For
collectFnBody
assumes the variables in
Equations
- Lean.IR.CollectMaps.collectDecl x = match x with | Lean.IR.Decl.fdecl f xs type b info => Lean.IR.CollectMaps.collectParams xs ∘ Lean.IR.CollectMaps.collectFnBody b | x => id
Instances For
Return a pair (v, j)
, where v
is a mapping from variable/parameter to type,
and j
is a mapping from join point to parameters.
This function assumes d
has normalized indexes (see normids.lean
).