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 (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)
- Lean.IR.isTailCallTo g b = 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.
- Lean.IR.CollectUsedDecls.collectDecl (Lean.IR.Decl.extern f xs type ext) = SeqRight.seqRight (Lean.IR.CollectUsedDecls.collectInitDecl f) fun (x : Unit) => get
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 (vs, js) = (Std.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 (vs, js) = (vs, Std.HashMap.insert js j xs)
Instances For
collectFnBody
assumes the variables in
Equations
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
).