Lean Compiler Normal Form (LCNF) #
It is based on the A-normal form, and the approach described in the paper Compiling without continuations.
This type is used to index the fundamental LCNF IR data structures. Depending on its value different constructors are available for the different semantic phases of LCNF.
Notably in order to save memory we never index the IR types over Purity. Instead the type is
parametrized by the phase and the individual constructors might carry a proof (that will be erased)
that they are only allowed in a certain phase.
- pure : Purity
The code we are acting on is still pure, things like reordering up to value dependencies are acceptable.
- impure : Purity
The code we are acting on is to be considered generally impure, doing reorderings is potentially no longer legal.
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Compiler.LCNF.tacticPurity_tac = Lean.ParserDescr.node `Lean.Compiler.LCNF.tacticPurity_tac 1024 (Lean.ParserDescr.nonReservedSymbol "purity_tac" false)
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
- Lean.Compiler.LCNF.instBEqParam.beq x✝¹ x✝ = false
Instances For
Equations
- p.toExpr = Lean.Expr.fvar p.fvarId
Instances For
Equations
Equations
- Lean.Compiler.LCNF.instBEqLitValue.beq (Lean.Compiler.LCNF.LitValue.nat a) (Lean.Compiler.LCNF.LitValue.nat b) = (a == b)
- Lean.Compiler.LCNF.instBEqLitValue.beq (Lean.Compiler.LCNF.LitValue.str a) (Lean.Compiler.LCNF.LitValue.str b) = (a == b)
- Lean.Compiler.LCNF.instBEqLitValue.beq (Lean.Compiler.LCNF.LitValue.uint8 a) (Lean.Compiler.LCNF.LitValue.uint8 b) = (a == b)
- Lean.Compiler.LCNF.instBEqLitValue.beq (Lean.Compiler.LCNF.LitValue.uint16 a) (Lean.Compiler.LCNF.LitValue.uint16 b) = (a == b)
- Lean.Compiler.LCNF.instBEqLitValue.beq (Lean.Compiler.LCNF.LitValue.uint32 a) (Lean.Compiler.LCNF.LitValue.uint32 b) = (a == b)
- Lean.Compiler.LCNF.instBEqLitValue.beq (Lean.Compiler.LCNF.LitValue.uint64 a) (Lean.Compiler.LCNF.LitValue.uint64 b) = (a == b)
- Lean.Compiler.LCNF.instBEqLitValue.beq (Lean.Compiler.LCNF.LitValue.usize a) (Lean.Compiler.LCNF.LitValue.usize b) = (a == b)
- Lean.Compiler.LCNF.instBEqLitValue.beq x✝¹ x✝ = false
Instances For
Equations
Equations
- Lean.Compiler.LCNF.instHashableLitValue.hash (Lean.Compiler.LCNF.LitValue.nat a) = mixHash 0 (hash a)
- Lean.Compiler.LCNF.instHashableLitValue.hash (Lean.Compiler.LCNF.LitValue.str a) = mixHash 1 (hash a)
- Lean.Compiler.LCNF.instHashableLitValue.hash (Lean.Compiler.LCNF.LitValue.uint8 a) = mixHash 2 (hash a)
- Lean.Compiler.LCNF.instHashableLitValue.hash (Lean.Compiler.LCNF.LitValue.uint16 a) = mixHash 3 (hash a)
- Lean.Compiler.LCNF.instHashableLitValue.hash (Lean.Compiler.LCNF.LitValue.uint32 a) = mixHash 4 (hash a)
- Lean.Compiler.LCNF.instHashableLitValue.hash (Lean.Compiler.LCNF.LitValue.uint64 a) = mixHash 5 (hash a)
- Lean.Compiler.LCNF.instHashableLitValue.hash (Lean.Compiler.LCNF.LitValue.usize a) = mixHash 6 (hash a)
Instances For
Equations
- (Lean.Compiler.LCNF.LitValue.nat a).toExpr = Lean.Expr.lit (Lean.Literal.natVal a)
- (Lean.Compiler.LCNF.LitValue.str a).toExpr = Lean.Expr.lit (Lean.Literal.strVal a)
- (Lean.Compiler.LCNF.LitValue.uint8 a).toExpr = (Lean.Expr.const `UInt8.ofNat []).app (Lean.Expr.lit (Lean.Literal.natVal a.toNat))
- (Lean.Compiler.LCNF.LitValue.uint16 a).toExpr = (Lean.Expr.const `UInt16.ofNat []).app (Lean.Expr.lit (Lean.Literal.natVal a.toNat))
- (Lean.Compiler.LCNF.LitValue.uint32 a).toExpr = (Lean.Expr.const `UInt32.ofNat []).app (Lean.Expr.lit (Lean.Literal.natVal a.toNat))
- (Lean.Compiler.LCNF.LitValue.uint64 a).toExpr = (Lean.Expr.const `UInt64.ofNat []).app (Lean.Expr.lit (Lean.Literal.natVal a.toNat))
- (Lean.Compiler.LCNF.LitValue.usize a).toExpr = (Lean.Expr.const `USize.ofNat []).app (Lean.Expr.lit (Lean.Literal.natVal a.toNat))
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Lean.Compiler.LCNF.LitValue.impureTypeScalarNumLit (Lean.Expr.const `UInt8 []) n = Lean.Compiler.LCNF.LitValue.uint8 n.toUInt8
- Lean.Compiler.LCNF.LitValue.impureTypeScalarNumLit (Lean.Expr.const `UInt16 []) n = Lean.Compiler.LCNF.LitValue.uint16 n.toUInt16
- Lean.Compiler.LCNF.LitValue.impureTypeScalarNumLit (Lean.Expr.const `UInt32 []) n = Lean.Compiler.LCNF.LitValue.uint32 n.toUInt32
- Lean.Compiler.LCNF.LitValue.impureTypeScalarNumLit (Lean.Expr.const `UInt64 []) n = Lean.Compiler.LCNF.LitValue.uint64 n.toUInt64
- Lean.Compiler.LCNF.LitValue.impureTypeScalarNumLit (Lean.Expr.const `USize []) n = Lean.Compiler.LCNF.LitValue.usize n.toUInt64
Instances For
Instances For
Equations
Equations
- Lean.Compiler.LCNF.instBEqArg.beq Lean.Compiler.LCNF.Arg.erased Lean.Compiler.LCNF.Arg.erased = true
- Lean.Compiler.LCNF.instBEqArg.beq (Lean.Compiler.LCNF.Arg.fvar a) (Lean.Compiler.LCNF.Arg.fvar b) = (a == b)
- Lean.Compiler.LCNF.instBEqArg.beq (Lean.Compiler.LCNF.Arg.type a a_1) (Lean.Compiler.LCNF.Arg.type b b_1) = (a == b)
- Lean.Compiler.LCNF.instBEqArg.beq x✝¹ x✝ = false
Instances For
Equations
Equations
Instances For
Equations
Equations
Instances For
Equations
Instances For
Constructor information.
nameis the Name of the Constructor in Lean.cidxis the Constructor index (aka tag).sizeis the number of arguments of typeobject/tobject.usizeis the number of arguments of typeusize.ssizeis the number of bytes used to store scalar values.
Recall that a Constructor object contains a header, then a sequence of
pointers to other Lean objects, a sequence of USize (i.e., size_t)
scalar values, and a sequence of other scalar values.
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
- Lean.Compiler.LCNF.instBEqCtorInfo.beq x✝¹ x✝ = false
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
- lit
{pu : Purity}
(value : LitValue)
: LetValue pu
A literal value.
- erased
{pu : Purity}
: LetValue pu
An erased value that is irrelevant for computation.
- proj
{pu : Purity}
(typeName : Name)
(idx : Nat)
(struct : FVarId)
(h : pu = Purity.pure := by purity_tac)
: LetValue pu
A projection from a pure LCNF value.
- const
{pu : Purity}
(declName : Name)
(us : List Level)
(args : Array (Arg pu))
(h : pu = Purity.pure := by purity_tac)
: LetValue pu
A pure application of a constant.
- fvar
{pu : Purity}
(fvarId : FVarId)
(args : Array (Arg pu))
: LetValue pu
An application of a free variable
- ctor
{pu : Purity}
(i : CtorInfo)
(args : Array (Arg pu))
(h : pu = Purity.impure := by purity_tac)
: LetValue pu
Allocating a constructor.
- oproj
{pu : Purity}
(i : Nat)
(var : FVarId)
(h : pu = Purity.impure := by purity_tac)
: LetValue pu
Projecting objects out of a value.
- uproj
{pu : Purity}
(i : Nat)
(var : FVarId)
(h : pu = Purity.impure := by purity_tac)
: LetValue pu
Projecting USize scalars out of a value.
- sproj
{pu : Purity}
(n offset : Nat)
(var : FVarId)
(h : pu = Purity.impure := by purity_tac)
: LetValue pu
Projecting non-USize scalars out of a value
- fap
{pu : Purity}
(fn : Name)
(args : Array (Arg pu))
(h : pu = Purity.impure := by purity_tac)
: LetValue pu
Full, impure, application of a function.
- pap
{pu : Purity}
(fn : Name)
(args : Array (Arg pu))
(h : pu = Purity.impure := by purity_tac)
: LetValue pu
Partial application of a function.
- reset
{pu : Purity}
(n : Nat)
(var : FVarId)
(h : pu = Purity.impure := by purity_tac)
: LetValue pu
The reset instruction from Counting Immutable Beans.
nis the amount of object fields stored in the constructor invar. - reuse
{pu : Purity}
(var : FVarId)
(i : CtorInfo)
(updateHeader : Bool)
(args : Array (Arg pu))
(h : pu = Purity.impure := by purity_tac)
: LetValue pu
reuse x in ctor_i ysinstruction in the paper.updateHeaderis set if the tag in the new ctor differs from the one in the old ctor and thus needs to be updated. - box
{pu : Purity}
(ty : Expr)
(fvarId : FVarId)
(h : pu = Purity.impure := by purity_tac)
: LetValue pu
Given a scalar type
tyand a valuefvarId : ty, this operation returns a value of typetobject. For small scalar values the result is a tagged pointer, and no memory allocation is performed. - unbox
{pu : Purity}
(fvarId : FVarId)
(h : pu = Purity.impure := by purity_tac)
: LetValue pu
Given
fvarId : [t]object, obtain the underlying scalar value.
Instances For
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.lit a) = mixHash 0 (hash a)
- Lean.Compiler.LCNF.instHashableLetValue.hash Lean.Compiler.LCNF.LetValue.erased = 1
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.proj a a_1 a_2 a_3) = mixHash (mixHash (mixHash (mixHash 2 (hash a)) (hash a_1)) (hash a_2)) (hash a_3)
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.const a a_1 a_2 a_3) = mixHash (mixHash (mixHash (mixHash 3 (hash a)) (hash a_1)) (hash a_2)) (hash a_3)
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.fvar a a_1) = mixHash (mixHash 4 (hash a)) (hash a_1)
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.ctor a a_1 a_2) = mixHash (mixHash (mixHash 5 (hash a)) (hash a_1)) (hash a_2)
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.oproj a a_1 a_2) = mixHash (mixHash (mixHash 6 (hash a)) (hash a_1)) (hash a_2)
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.uproj a a_1 a_2) = mixHash (mixHash (mixHash 7 (hash a)) (hash a_1)) (hash a_2)
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.sproj a a_1 a_2 a_3) = mixHash (mixHash (mixHash (mixHash 8 (hash a)) (hash a_1)) (hash a_2)) (hash a_3)
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.fap a a_1 a_2) = mixHash (mixHash (mixHash 9 (hash a)) (hash a_1)) (hash a_2)
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.pap a a_1 a_2) = mixHash (mixHash (mixHash 10 (hash a)) (hash a_1)) (hash a_2)
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.reset a a_1 a_2) = mixHash (mixHash (mixHash 11 (hash a)) (hash a_1)) (hash a_2)
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.box a a_1 a_2) = mixHash (mixHash (mixHash 13 (hash a)) (hash a_1)) (hash a_2)
- Lean.Compiler.LCNF.instHashableLetValue.hash (Lean.Compiler.LCNF.LetValue.unbox a a_1) = mixHash (mixHash 14 (hash a)) (hash a_1)
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
- (Lean.Compiler.LCNF.LetValue.lit v).toExpr = v.toExpr
- Lean.Compiler.LCNF.LetValue.erased.toExpr = Lean.Compiler.LCNF.erasedExpr
- (Lean.Compiler.LCNF.LetValue.proj n i s h).toExpr = Lean.Expr.proj n i (Lean.Expr.fvar s)
- (Lean.Compiler.LCNF.LetValue.const n us as h).toExpr = Lean.mkAppN (Lean.Expr.const n us) (Array.map Lean.Compiler.LCNF.Arg.toExpr as)
- (Lean.Compiler.LCNF.LetValue.fvar fvarId as).toExpr = Lean.mkAppN (Lean.Expr.fvar fvarId) (Array.map Lean.Compiler.LCNF.Arg.toExpr as)
- (Lean.Compiler.LCNF.LetValue.ctor i as h).toExpr = Lean.mkAppN (Lean.Expr.const i.name []) (Array.map Lean.Compiler.LCNF.Arg.toExpr as)
- (Lean.Compiler.LCNF.LetValue.fap fn as h).toExpr = Lean.mkAppN (Lean.Expr.const fn []) (Array.map Lean.Compiler.LCNF.Arg.toExpr as)
- (Lean.Compiler.LCNF.LetValue.pap fn as h).toExpr = Lean.mkAppN (Lean.Expr.const fn []) (Array.map Lean.Compiler.LCNF.Arg.toExpr as)
- (Lean.Compiler.LCNF.LetValue.oproj i var h).toExpr = Lean.mkApp2 (Lean.Expr.const `oproj []) (Lean.toExpr i) (Lean.Expr.fvar var)
- (Lean.Compiler.LCNF.LetValue.uproj i var h).toExpr = Lean.mkApp2 (Lean.Expr.const `uproj []) (Lean.toExpr i) (Lean.Expr.fvar var)
- (Lean.Compiler.LCNF.LetValue.sproj i offset var h).toExpr = Lean.mkApp3 (Lean.Expr.const `sproj []) (Lean.toExpr i) (Lean.toExpr offset) (Lean.Expr.fvar var)
- (Lean.Compiler.LCNF.LetValue.reset n var h).toExpr = Lean.mkApp2 (Lean.Expr.const `reset []) (Lean.toExpr n) (Lean.Expr.fvar var)
- (Lean.Compiler.LCNF.LetValue.box ty var h).toExpr = Lean.mkApp2 (Lean.Expr.const `box []) ty (Lean.Expr.fvar var)
- (Lean.Compiler.LCNF.LetValue.unbox var h).toExpr = Lean.mkApp (Lean.Expr.const `unbox []) (Lean.Expr.fvar var)
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
- Lean.Compiler.LCNF.instBEqLetDecl.beq x✝¹ x✝ = false
Instances For
Equations
Equations
Instances For
Equations
Equations
Instances For
- let {pu : Purity} (decl : LetDecl pu) (k : Code pu) : Code pu
- fun {pu : Purity} (decl : FunDecl pu) (k : Code pu) (h : pu = Purity.pure := by purity_tac) : Code pu
- jp {pu : Purity} (decl : FunDecl pu) (k : Code pu) : Code pu
- jmp {pu : Purity} (fvarId : FVarId) (args : Array (Arg pu)) : Code pu
- cases {pu : Purity} (cases : Cases pu) : Code pu
- return {pu : Purity} (fvarId : FVarId) : Code pu
- unreach {pu : Purity} (type : Expr) : Code pu
- uset {pu : Purity} (var : FVarId) (i : Nat) (y : FVarId) (k : Code pu) (h : pu = Purity.impure := by purity_tac) : Code pu
- sset {pu : Purity} (var : FVarId) (i offset : Nat) (y : FVarId) (ty : Expr) (k : Code pu) (h : pu = Purity.impure := by purity_tac) : Code pu
Instances For
Equations
- (Lean.Compiler.LCNF.FunDecl.mk fvarId binderName params type value).fvarId = fvarId
Instances For
Equations
- (Lean.Compiler.LCNF.FunDecl.mk fvarId binderName params type value).binderName = binderName
Instances For
Equations
- (Lean.Compiler.LCNF.FunDecl.mk fvarId binderName params type value).params = params
Instances For
Equations
- (Lean.Compiler.LCNF.FunDecl.mk fvarId binderName params type value).type = type
Instances For
Equations
- (Lean.Compiler.LCNF.FunDecl.mk fvarId binderName params type value).value = value
Instances For
Equations
- (Lean.Compiler.LCNF.FunDecl.mk fvarId binderName params type value).updateBinderName x✝ = Lean.Compiler.LCNF.FunDecl.mk fvarId x✝ params type value
Instances For
Equations
- (Lean.Compiler.LCNF.Cases.mk typeName resultType discr alts).typeName = typeName
Instances For
Equations
- (Lean.Compiler.LCNF.Cases.mk typeName resultType discr alts).resultType = resultType
Instances For
Equations
- (Lean.Compiler.LCNF.Cases.mk typeName resultType discr alts).discr = discr
Instances For
Equations
- (Lean.Compiler.LCNF.Cases.mk typeName resultType discr alts).alts = alts
Instances For
Equations
- (Lean.Compiler.LCNF.Cases.mk typeName resultType discr alts).updateAlts x✝ = Lean.Compiler.LCNF.Cases.mk typeName resultType discr x✝
Instances For
Instances For
Equations
Equations
Instances For
Equations
Return the constructor names that have an explicit (non-default) alternative.
Equations
- One or more equations did not get rendered due to their size.
Instances For
- let {pu : Purity} (decl : LetDecl pu) : CodeDecl pu
- fun {pu : Purity} (decl : FunDecl pu) (h : pu = Purity.pure := by purity_tac) : CodeDecl pu
- jp {pu : Purity} (decl : FunDecl pu) : CodeDecl pu
- uset {pu : Purity} (var : FVarId) (i : Nat) (y : FVarId) (h : pu = Purity.impure := by purity_tac) : CodeDecl pu
- sset {pu : Purity} (var : FVarId) (i offset : Nat) (y : FVarId) (ty : Expr) (h : pu = Purity.impure := by purity_tac) : CodeDecl pu
Instances For
Equations
Instances For
Equations
- (Lean.Compiler.LCNF.CodeDecl.let decl).fvarId = decl.fvarId
- (Lean.Compiler.LCNF.CodeDecl.fun decl h).fvarId = decl.fvarId
- (Lean.Compiler.LCNF.CodeDecl.jp decl).fvarId = decl.fvarId
- (Lean.Compiler.LCNF.CodeDecl.uset var i y h).fvarId = var
- (Lean.Compiler.LCNF.CodeDecl.sset var i offset y ty h).fvarId = var
Instances For
Equations
- (Lean.Compiler.LCNF.Code.let decl k).toCodeDecl! = Lean.Compiler.LCNF.CodeDecl.let decl
- (Lean.Compiler.LCNF.Code.fun decl k h).toCodeDecl! = Lean.Compiler.LCNF.CodeDecl.fun decl h
- (Lean.Compiler.LCNF.Code.jp decl k).toCodeDecl! = Lean.Compiler.LCNF.CodeDecl.jp decl
- (Lean.Compiler.LCNF.Code.uset var i y k h).toCodeDecl! = Lean.Compiler.LCNF.CodeDecl.uset var i y h
- (Lean.Compiler.LCNF.Code.sset var i offset ty y k h).toCodeDecl! = Lean.Compiler.LCNF.CodeDecl.sset var i offset ty y h
- x✝.toCodeDecl! = panicWithPosWithDecl "Lean.Compiler.LCNF.Basic" "Lean.Compiler.LCNF.Code.toCodeDecl!" 455 7 "unreachable code has been reached"
Instances For
Equations
- Lean.Compiler.LCNF.attachCodeDecls decls code = Lean.Compiler.LCNF.attachCodeDecls.go✝ decls decls.size code
Instances For
Equations
Equations
Equations
- (Lean.Compiler.LCNF.Alt.default k).getCode = k
- (Lean.Compiler.LCNF.Alt.alt ctorName params k h).getCode = k
- (Lean.Compiler.LCNF.Alt.ctorAlt info k h).getCode = k
Instances For
Equations
- (Lean.Compiler.LCNF.Alt.default code).getParams = #[]
- (Lean.Compiler.LCNF.Alt.alt ctorName ps code h).getParams = ps
Instances For
Equations
- (Lean.Compiler.LCNF.Alt.default k).forCodeM f = f k
- (Lean.Compiler.LCNF.Alt.alt ctorName params k h).forCodeM f = f k
- (Lean.Compiler.LCNF.Alt.ctorAlt info k h).forCodeM f = f k
Instances For
Low-level update LetDecl function. It does not update the local context.
Consider using LetDecl.update : LetDecl → Expr → Expr → CompilerM LetDecl if you want the local context
to be updated.
Low-level update FunDecl function. It does not update the local context.
Consider using FunDecl.update : LetDecl → Expr → Array Param → Code → CompilerM FunDecl if you want the local context
to be updated.
Equations
- (Lean.Compiler.LCNF.Code.let decl k).isDecl = true
- (Lean.Compiler.LCNF.Code.fun decl k h).isDecl = true
- (Lean.Compiler.LCNF.Code.jp decl k).isDecl = true
- x✝.isDecl = false
Instances For
Equations
- (Lean.Compiler.LCNF.Code.return fvarId).isReturnOf x✝ = (fvarId == x✝)
- x✝¹.isReturnOf x✝ = false
Instances For
Equations
Instances For
Return true iff c.size ≤ n
Equations
- c.sizeLe n = match (Lean.Compiler.LCNF.Code.sizeLe.go✝ n c).run 0 with | EStateM.Result.ok a a_1 => true | EStateM.Result.error a a_1 => false
Instances For
Equations
- code.instantiateValueLevelParams levelParams us = Lean.Compiler.LCNF.Code.instantiateValueLevelParams.instCode✝ levelParams us code
Instances For
Equations
Instances For
Equations
Equations
Equations
- Lean.Compiler.LCNF.instBEqDeclValue.beq (Lean.Compiler.LCNF.DeclValue.code a) (Lean.Compiler.LCNF.DeclValue.code b) = (a == b)
- Lean.Compiler.LCNF.instBEqDeclValue.beq (Lean.Compiler.LCNF.DeclValue.extern a) (Lean.Compiler.LCNF.DeclValue.extern b) = (a == b)
- Lean.Compiler.LCNF.instBEqDeclValue.beq x✝¹ x✝ = false
Instances For
Equations
- (Lean.Compiler.LCNF.DeclValue.code c).size = c.size
- (Lean.Compiler.LCNF.DeclValue.extern externAttrData).size = 0
Instances For
Equations
Instances For
Equations
- Lean.Compiler.LCNF.DeclValue.mapCodeM f (Lean.Compiler.LCNF.DeclValue.code c) = do let __do_lift ← f c pure (Lean.Compiler.LCNF.DeclValue.code __do_lift)
- Lean.Compiler.LCNF.DeclValue.mapCodeM f (Lean.Compiler.LCNF.DeclValue.extern externAttrData) = pure (Lean.Compiler.LCNF.DeclValue.extern externAttrData)
Instances For
Equations
- (Lean.Compiler.LCNF.DeclValue.code c).isCodeAndM f = f c
- (Lean.Compiler.LCNF.DeclValue.extern externAttrData).isCodeAndM f = pure false
Instances For
The signature of a declaration being processed by the Lean to Lean compiler passes.
- name : Name
The name of the declaration from the
Environmentit came from Universe level parameter names.
- type : Expr
The type of the declaration. Note that this is an erased LCNF type instead of the fully dependent one that might have been the original type of the declaration in the
Environment. Furthermore, once in the impure staged of LCNF this type is only the return type. Parameters.
- safe : Bool
We set this flag to false during LCNF conversion if the Lean function associated with this function was tagged as partial or unsafe. This information affects how static analyzers treat function applications of this kind. See
DefinitionSafety.partialandunsafefunctions may not be terminating, but Lean functions terminate, and some static analyzers exploit this fact. So, we use the following semantics. Suppose we have a (large) natural numberC. We consider a nondeterministic model for computation of Lean expressions as follows: Each call to a partial/unsafe function uses up one "recursion token". Prior to consumingCrecursion tokens all partial functions must be called as normal. Once the model has used upCrecursion tokens, a subsequent call to a partial function has the following nondeterministic options: it can either call the function again, or return any value of the target type (even a noncomputable one). Larger values ofCyield less nondeterminism in the model, but even the intersection of all choices ofCyields nondeterminism wheredef loop : A := loopreturns any value of typeA. The compiler fixes a choice forC. This is a fixed constant greater than 2^2^64, which is allowed to be compiler and architecture dependent, and promises that it will produce an execution consistent with every possible nondeterministic outcome of theC-model. In the event that different nondeterministic executions disagree, the compiler is required to exhaust resources or output a looping computation.
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
- Lean.Compiler.LCNF.instBEqSignature.beq x✝¹ x✝ = false
Instances For
Declaration being processed by the Lean to Lean compiler passes.
- value : DeclValue pu
The body of the declaration, usually changes as it progresses through compiler passes.
- recursive : Bool
We set this flag to true during LCNF conversion. When we receive a block of functions to be compiled, we set this flag to
trueif there is an application to the function in the block containing it. This is an approximation, but it should be good enough because in the frontend, we invoke the compiler with blocks of strongly connected components only. We use this information to control inlining. - inlineAttr? : Option InlineAttributeKind
We store the inline attribute at LCNF declarations to make sure we can set them for auxiliary declarations created during compilation.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
- Lean.Compiler.LCNF.instBEqDecl.beq x✝¹ x✝ = false
Instances For
Equations
Equations
- decl.inlineAttr = match decl.inlineAttr? with | some Lean.Compiler.InlineAttributeKind.inline => true | x => false
Instances For
Equations
- decl.noinlineAttr = match decl.inlineAttr? with | some Lean.Compiler.InlineAttributeKind.noinline => true | x => false
Instances For
Equations
- decl.inlineIfReduceAttr = match decl.inlineAttr? with | some Lean.Compiler.InlineAttributeKind.inlineIfReduce => true | x => false
Instances For
Equations
- decl.alwaysInlineAttr = match decl.inlineAttr? with | some Lean.Compiler.InlineAttributeKind.alwaysInline => true | x => false
Instances For
Return true if the given declaration has been annotated with [inline], [inline_if_reduce], [macro_inline], or [always_inline]
Equations
- decl.inlineable = match decl.inlineAttr? with | some Lean.Compiler.InlineAttributeKind.noinline => false | some val => true | none => false
Instances For
Return some i if decl is of the form
def f (a_0 ... a_i ...) :=
...
cases a_i
| ...
| ...
That is, f is a sequence of declarations followed by a cases on the parameter i.
We use this function to decide whether we should inline a declaration tagged with
[inline_if_reduce] or not.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- decl.instantiateTypeLevelParams us = decl.type.instantiateLevelParamsNoCache decl.levelParams us
Instances For
Equations
- decl.instantiateParamsLevelParams us = decl.params.mapMono fun (param : Lean.Compiler.LCNF.Param pu) => param.updateCore (param.type.instantiateLevelParamsNoCache decl.levelParams us)
Instances For
Return true if the arrow type contains an instance implicit argument.
Equations
- One or more equations did not get rendered due to their size.
- Lean.Compiler.LCNF.hasLocalInst type = pure false
Instances For
Equations
Instances For
Equations
- (Lean.Compiler.LCNF.CodeDecl.let decl).collectUsed s = Lean.Compiler.LCNF.collectLetValue✝ decl.value (Lean.Compiler.LCNF.collectType✝ decl.type s)
- (Lean.Compiler.LCNF.CodeDecl.jp decl).collectUsed s = decl.collectUsed s
- (Lean.Compiler.LCNF.CodeDecl.fun decl h).collectUsed s = decl.collectUsed s
- (Lean.Compiler.LCNF.CodeDecl.sset var i offset y ty h).collectUsed s = Lean.Compiler.LCNF.collectType✝ ty ((Std.HashSet.insert s var).insert y)
- (Lean.Compiler.LCNF.CodeDecl.uset var i y h).collectUsed s = (Std.HashSet.insert s var).insert y
Instances For
Traverse the given block of potentially mutually recursive functions
and mark a declaration f as recursive if there is an application
f ... in the block.
This is an overapproximation, and relies on the fact that our frontend
computes strongly connected components.
See comment at recursive field.
Equations
- One or more equations did not get rendered due to their size.