File: .lake/packages/lean4/src/lean/Lean/Compiler/IR/RC.lean

full_name: Lean.IR.ExplicitRC.instInhabitedVarInfo
code: structure VarInfo where
  ref        : Bool := true  -- true if the variable may be a reference (aka pointer) at runtime
  persistent : Bool := false -- true if the variable is statically known to be marked a Persistent at runtime
  consume    : Bool := false -- true if the variable RC must be "consumed"
  deriving Inhabited
goal: Inhabited Lean.IR.ExplicitRC.VarInfo

full_name: Lean.IR.ExplicitRC.VarInfo.ref
code: structure VarInfo where
  ref        : Bool := true  -- true if the variable may be a reference (aka pointer) at runtime
  persistent : Bool := false -- true if the variable is statically known to be marked a Persistent at runtime
  consume    : Bool := false -- true if the variable RC must be "consumed"
  deriving Inhabited
goal: Bool

full_name: Lean.IR.ExplicitRC.VarInfo.persistent
code: structure VarInfo where
  ref        : Bool := true  -- true if the variable may be a reference (aka pointer) at runtime
  persistent : Bool := false -- true if the variable is statically known to be marked a Persistent at runtime
  consume    : Bool := false -- true if the variable RC must be "consumed"
  deriving Inhabited
goal: Bool

full_name: Lean.IR.ExplicitRC.VarInfo.consume
code: structure VarInfo where
  ref        : Bool := true  -- true if the variable may be a reference (aka pointer) at runtime
  persistent : Bool := false -- true if the variable is statically known to be marked a Persistent at runtime
  consume    : Bool := false -- true if the variable RC must be "consumed"
  deriving Inhabited
goal: Bool

full_name: Lean.IR.ExplicitRC.VarInfo
code: structure VarInfo where
  ref        : Bool := true  -- true if the variable may be a reference (aka pointer) at runtime
  persistent : Bool := false -- true if the variable is statically known to be marked a Persistent at runtime
  consume    : Bool := false -- true if the variable RC must be "consumed"
  deriving Inhabited
goal: Type

full_name: Lean.IR.ExplicitRC.VarMap
code: abbrev VarMap 
goal: Type

full_name: Lean.IR.ExplicitRC.Context.jpLiveVarMap
code: structure Context where
  env            : Environment
  decls          : Array Decl
  varMap         : VarMap := {}
  jpLiveVarMap   : JPLiveVarMap := {} -- map: join point => live variables
  localCtx       : LocalContext := {}
goal: Lean.IR.JPLiveVarMap

full_name: Lean.IR.ExplicitRC.Context.env
code: structure Context where
  env            : Environment
  decls          : Array Decl
  varMap         : VarMap := {}
  jpLiveVarMap   : JPLiveVarMap := {} -- map: join point => live variables
  localCtx       : LocalContext := {}
goal: Lean.Environment

full_name: Lean.IR.ExplicitRC.Context.decls
code: structure Context where
  env            : Environment
  decls          : Array Decl
  varMap         : VarMap := {}
  jpLiveVarMap   : JPLiveVarMap := {} -- map: join point => live variables
  localCtx       : LocalContext := {}
goal: Array Lean.IR.Decl

full_name: Lean.IR.ExplicitRC.Context
code: structure Context where
  env            : Environment
  decls          : Array Decl
  varMap         : VarMap := {}
  jpLiveVarMap   : JPLiveVarMap := {} -- map: join point => live variables
  localCtx       : LocalContext := {}
goal: Type

full_name: Lean.IR.ExplicitRC.Context.varMap
code: structure Context where
  env            : Environment
  decls          : Array Decl
  varMap         : VarMap := {}
  jpLiveVarMap   : JPLiveVarMap := {} -- map: join point => live variables
  localCtx       : LocalContext := {}
goal: Lean.IR.ExplicitRC.VarMap

full_name: Lean.IR.ExplicitRC.Context.localCtx
code: structure Context where
  env            : Environment
  decls          : Array Decl
  varMap         : VarMap := {}
  jpLiveVarMap   : JPLiveVarMap := {} -- map: join point => live variables
  localCtx       : LocalContext := {}
goal: Lean.IR.LocalContext

full_name: Lean.IR.ExplicitRC.getDecl
code: def getDecl (ctx : Context) (fid : FunId) : Decl 
goal: Lean.IR.Decl

full_name: Lean.IR.ExplicitRC.getVarInfo
code: def getVarInfo (ctx : Context) (x : VarId) : VarInfo 
goal: Lean.IR.ExplicitRC.VarInfo

full_name: Lean.IR.ExplicitRC.getJPParams
code: def getJPParams (ctx : Context) (j : JoinPointId) : Array Param 
goal: Array Lean.IR.Param

full_name: Lean.IR.ExplicitRC.getJPLiveVars
code: def getJPLiveVars (ctx : Context) (j : JoinPointId) : LiveVarSet 
goal: Lean.IR.LiveVarSet

full_name: Lean.IR.ExplicitRC.mustConsume
code: def mustConsume (ctx : Context) (x : VarId) : Bool 
goal: Bool

full_name: Lean.IR.ExplicitRC.addInc
code: @[inline] def addInc (ctx : Context) (x : VarId) (b : FnBody) (n := 1) : FnBody 
goal: Lean.IR.FnBody

full_name: Lean.IR.ExplicitRC.addDec
code: @[inline] def addDec (ctx : Context) (x : VarId) (b : FnBody) : FnBody 
goal: Lean.IR.FnBody

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.updateRefUsingCtorInfo
code: private def updateRefUsingCtorInfo (ctx : Context) (x : VarId) (c : CtorInfo) : Context 
goal: Lean.IR.ExplicitRC.Context

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.addDecForAlt
code: private def addDecForAlt (ctx : Context) (caseLiveVars altLiveVars : LiveVarSet) (b : FnBody) : FnBody 
goal: Lean.IR.FnBody

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.isFirstOcc
code: /-- `isFirstOcc xs x i = true` if `xs[i]` is the first occurrence of `xs[i]` in `xs` -/
private def isFirstOcc (xs : Array Arg) (i : Nat) : Bool 
goal: Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.isBorrowParamAux
code: /-- Return true if `x` also occurs in `ys` in a position that is not consumed.
   That is, it is also passed as a borrow reference. -/
private def isBorrowParamAux (x : VarId) (ys : Array Arg) (consumeParamPred : Nat → Bool) : Bool 
goal: Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.isBorrowParam
code: private def isBorrowParam (x : VarId) (ys : Array Arg) (ps : Array Param) : Bool 
goal: Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.getNumConsumptions
code: /--
Return `n`, the number of times `x` is consumed.
- `ys` is a sequence of instruction parameters where we search for `x`.
- `consumeParamPred i = true` if parameter `i` is consumed.
-/
private def getNumConsumptions (x : VarId) (ys : Array Arg) (consumeParamPred : Nat → Bool) : Nat 
goal: Nat

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.addIncBeforeAux
code: private def addIncBeforeAux (ctx : Context) (xs : Array Arg) (consumeParamPred : Nat → Bool) (b : FnBody) (liveVarsAfter : LiveVarSet) : FnBody 
goal: Lean.IR.FnBody

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.addIncBefore
code: private def addIncBefore (ctx : Context) (xs : Array Arg) (ps : Array Param) (b : FnBody) (liveVarsAfter : LiveVarSet) : FnBody 
goal: Lean.IR.FnBody

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.addDecAfterFullApp
code: /-- See `addIncBeforeAux`/`addIncBefore` for the procedure that inserts `inc` operations before an application.  -/
private def addDecAfterFullApp (ctx : Context) (xs : Array Arg) (ps : Array Param) (b : FnBody) (bLiveVars : LiveVarSet) : FnBody 
goal: Lean.IR.FnBody

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.addIncBeforeConsumeAll
code: private def addIncBeforeConsumeAll (ctx : Context) (xs : Array Arg) (b : FnBody) (liveVarsAfter : LiveVarSet) : FnBody 
goal: Lean.IR.FnBody

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.addDecForDeadParams
code: /-- Add `dec` instructions for parameters that are references, are not alive in `b`, and are not borrow.
   That is, we must make sure these parameters are consumed. -/
private def addDecForDeadParams (ctx : Context) (ps : Array Param) (b : FnBody) (bLiveVars : LiveVarSet) : FnBody 
goal: Lean.IR.FnBody

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.isPersistent
code: private def isPersistent : Expr → Bool
  
goal: Lean.IR.Expr → Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.consumeExpr
code: /-- We do not need to consume the projection of a variable that is not consumed -/
private def consumeExpr (m : VarMap) : Expr → Bool
  
goal: Lean.IR.Expr → Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.isScalarBoxedInTaggedPtr
code: /-- Return true iff `v` at runtime is a scalar value stored in a tagged pointer.
   We do not need RC operations for this kind of value. -/
private def isScalarBoxedInTaggedPtr (v : Expr) : Bool 
goal: Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.updateVarInfo
code: private def updateVarInfo (ctx : Context) (x : VarId) (t : IRType) (v : Expr) : Context 
goal: Lean.IR.ExplicitRC.Context

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.addDecIfNeeded
code: private def addDecIfNeeded (ctx : Context) (x : VarId) (b : FnBody) (bLiveVars : LiveVarSet) : FnBody 
goal: Lean.IR.FnBody

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.IR.RC.0.Lean.IR.ExplicitRC.processVDecl
code: private def processVDecl (ctx : Context) (z : VarId) (t : IRType) (v : Expr) (b : FnBody) (bLiveVars : LiveVarSet) : FnBody × LiveVarSet 
goal: Lean.IR.FnBody × Lean.IR.LiveVarSet

full_name: Lean.IR.ExplicitRC.updateVarInfoWithParams
code: def updateVarInfoWithParams (ctx : Context) (ps : Array Param) : Context 
goal: Lean.IR.ExplicitRC.Context

full_name: Lean.IR.ExplicitRC.visitFnBody
code: partial def visitFnBody : FnBody → Context → (FnBody × LiveVarSet)
  
goal: Lean.IR.FnBody → Lean.IR.ExplicitRC.Context → Lean.IR.FnBody × Lean.IR.LiveVarSet

full_name: Lean.IR.ExplicitRC.visitDecl
code: partial def visitDecl (env : Environment) (decls : Array Decl) (d : Decl) : Decl 
goal: Lean.IR.Decl

full_name: Lean.IR.explicitRC
code: def explicitRC (decls : Array Decl) : CompilerM (Array Decl) 
goal: Lean.IR.CompilerM (Array Lean.IR.Decl)