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

full_name: Lean.IR.Borrow.OwnedSet.Key
code: abbrev Key 
goal: Type

full_name: Lean.IR.Borrow.OwnedSet.beq
code: def beq : Key → Key → Bool
  
goal: Lean.IR.Borrow.OwnedSet.Key → Lean.IR.Borrow.OwnedSet.Key → Bool

full_name: Lean.IR.Borrow.OwnedSet.instBEqKey
code: instance : BEq Key 
goal: BEq Lean.IR.Borrow.OwnedSet.Key

full_name: Lean.IR.Borrow.OwnedSet.getHash
code: def getHash : Key → UInt64
  
goal: Lean.IR.Borrow.OwnedSet.Key → UInt64

full_name: Lean.IR.Borrow.OwnedSet.instHashableKey
code: instance : Hashable Key 
goal: Hashable Lean.IR.Borrow.OwnedSet.Key

full_name: Lean.IR.Borrow.OwnedSet
code: abbrev OwnedSet 
goal: Type

full_name: Lean.IR.Borrow.OwnedSet.insert
code: def OwnedSet.insert (s : OwnedSet) (k : OwnedSet.Key) : OwnedSet 
goal: Lean.IR.Borrow.OwnedSet

full_name: Lean.IR.Borrow.OwnedSet.contains
code: def OwnedSet.contains (s : OwnedSet) (k : OwnedSet.Key) : Bool   
goal: Bool

full_name: Lean.IR.Borrow.ParamMap.instBEqKey
code: inductive Key where
  | decl (name : FunId)
  | jp   (name : FunId) (jpid : JoinPointId)
  deriving BEq
goal: BEq Lean.IR.Borrow.ParamMap.Key

full_name: Lean.IR.Borrow.ParamMap.Key
code: inductive Key where
  | decl (name : FunId)
  | jp   (name : FunId) (jpid : JoinPointId)
  deriving BEq
goal: Type

full_name: Lean.IR.Borrow.ParamMap.Key.jp
code: inductive Key where
  | decl (name : FunId)
  | jp   (name : FunId) (jpid : JoinPointId)
  deriving BEq
goal: Lean.IR.Borrow.ParamMap.Key

full_name: Lean.IR.Borrow.ParamMap.Key.decl
code: inductive Key where
  | decl (name : FunId)
  | jp   (name : FunId) (jpid : JoinPointId)
  deriving BEq
goal: Lean.IR.Borrow.ParamMap.Key

full_name: Lean.IR.Borrow.ParamMap.getHash
code: def getHash : Key → UInt64
  
goal: Lean.IR.Borrow.ParamMap.Key → UInt64

full_name: Lean.IR.Borrow.ParamMap.instHashableKey
code: instance : Hashable Key 
goal: Hashable Lean.IR.Borrow.ParamMap.Key

full_name: Lean.IR.Borrow.ParamMap
code: abbrev ParamMap 
goal: Type

full_name: Lean.IR.Borrow.ParamMap.fmt
code: def ParamMap.fmt (map : ParamMap) : Format 
goal: Lean.Format

full_name: Lean.IR.Borrow.instToFormatParamMap
code: instance : ToFormat ParamMap 
goal: Lean.ToFormat Lean.IR.Borrow.ParamMap

full_name: Lean.IR.Borrow.instToStringParamMap
code: instance : ToString ParamMap 
goal: ToString Lean.IR.Borrow.ParamMap

full_name: Lean.IR.Borrow.InitParamMap.initBorrow
code: /-- Mark parameters that take a reference as borrow -/
def initBorrow (ps : Array Param) : Array Param 
goal: Array Lean.IR.Param

full_name: Lean.IR.Borrow.InitParamMap.initBorrowIfNotExported
code: /-- We do perform borrow inference for constants marked as `export`.
   Reason: we current write wrappers in C++ for using exported functions.
   These wrappers use smart pointers such as `object_ref`.
   When writing a new wrapper we need to know whether an argument is a borrow
   inference or not.
   We can revise this decision when we implement code for generating
   the wrappers automatically. -/
def initBorrowIfNotExported (exported : Bool) (ps : Array Param) : Array Param 
goal: Array Lean.IR.Param

full_name: Lean.IR.Borrow.InitParamMap.visitFnBody
code: partial def visitFnBody (fnid : FunId) : FnBody → StateM ParamMap Unit
  
goal: Lean.IR.FnBody → StateM Lean.IR.Borrow.ParamMap Unit

full_name: Lean.IR.Borrow.InitParamMap.visitDecls
code: def visitDecls (env : Environment) (decls : Array Decl) : StateM ParamMap Unit 
goal: StateM Lean.IR.Borrow.ParamMap Unit

full_name: Lean.IR.Borrow.mkInitParamMap
code: def mkInitParamMap (env : Environment) (decls : Array Decl) : ParamMap 
goal: Lean.IR.Borrow.ParamMap

full_name: Lean.IR.Borrow.ApplyParamMap.visitFnBody
code: partial def visitFnBody (fn : FunId) (paramMap : ParamMap) : FnBody → FnBody
  
goal: Lean.IR.FnBody → Lean.IR.FnBody

full_name: Lean.IR.Borrow.ApplyParamMap.visitDecls
code: def visitDecls (decls : Array Decl) (paramMap : ParamMap) : Array Decl 
goal: Array Lean.IR.Decl

full_name: Lean.IR.Borrow.applyParamMap
code: def applyParamMap (decls : Array Decl) (map : ParamMap) : Array Decl 
goal: Array Lean.IR.Decl

full_name: Lean.IR.Borrow.BorrowInfCtx.currFn
code: structure BorrowInfCtx where
  env      : Environment
  decls    : Array Decl  -- block of mutually recursive functions
  currFn   : FunId    := default -- Function being analyzed.
  paramSet : IndexSet := {}
goal: Lean.IR.FunId

full_name: Lean.IR.Borrow.BorrowInfCtx.env
code: structure BorrowInfCtx where
  env      : Environment
  decls    : Array Decl  -- block of mutually recursive functions
  currFn   : FunId    := default -- Function being analyzed.
  paramSet : IndexSet := {}
goal: Lean.Environment

full_name: Lean.IR.Borrow.BorrowInfCtx.paramSet
code: structure BorrowInfCtx where
  env      : Environment
  decls    : Array Decl  -- block of mutually recursive functions
  currFn   : FunId    := default -- Function being analyzed.
  paramSet : IndexSet := {}
goal: Lean.IR.IndexSet

full_name: Lean.IR.Borrow.BorrowInfCtx
code: structure BorrowInfCtx where
  env      : Environment
  decls    : Array Decl  -- block of mutually recursive functions
  currFn   : FunId    := default -- Function being analyzed.
  paramSet : IndexSet := {}
goal: Type

full_name: Lean.IR.Borrow.BorrowInfCtx.decls
code: structure BorrowInfCtx where
  env      : Environment
  decls    : Array Decl  -- block of mutually recursive functions
  currFn   : FunId    := default -- Function being analyzed.
  paramSet : IndexSet := {}
goal: Array Lean.IR.Decl

full_name: Lean.IR.Borrow.BorrowInfState.owned
code: structure BorrowInfState where
  /-- Set of variables that must be `owned`. -/
  owned    : OwnedSet := {}
  modified : Bool     := false
  paramMap : ParamMap
goal: Lean.IR.Borrow.OwnedSet

full_name: Lean.IR.Borrow.BorrowInfState.paramMap
code: structure BorrowInfState where
  /-- Set of variables that must be `owned`. -/
  owned    : OwnedSet := {}
  modified : Bool     := false
  paramMap : ParamMap
goal: Lean.IR.Borrow.ParamMap

full_name: Lean.IR.Borrow.BorrowInfState.modified
code: structure BorrowInfState where
  /-- Set of variables that must be `owned`. -/
  owned    : OwnedSet := {}
  modified : Bool     := false
  paramMap : ParamMap
goal: Bool

full_name: Lean.IR.Borrow.BorrowInfState
code: structure BorrowInfState where
  /-- Set of variables that must be `owned`. -/
  owned    : OwnedSet := {}
  modified : Bool     := false
  paramMap : ParamMap
goal: Type

full_name: Lean.IR.Borrow.M
code: abbrev M 
goal: Type

full_name: Lean.IR.Borrow.getCurrFn
code: def getCurrFn : M FunId 
goal: Lean.IR.Borrow.M Lean.IR.FunId

full_name: Lean.IR.Borrow.markModified
code: def markModified : M Unit 
goal: Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.ownVar
code: def ownVar (x : VarId) : M Unit 
goal: Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.ownArg
code: def ownArg (x : Arg) : M Unit 
goal: Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.ownArgs
code: def ownArgs (xs : Array Arg) : M Unit 
goal: Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.isOwned
code: def isOwned (x : VarId) : M Bool 
goal: Lean.IR.Borrow.M Bool

full_name: Lean.IR.Borrow.updateParamMap
code: /-- Updates `map[k]` using the current set of `owned` variables. -/
def updateParamMap (k : ParamMap.Key) : M Unit 
goal: Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.getParamInfo
code: def getParamInfo (k : ParamMap.Key) : M (Array Param) 
goal: Lean.IR.Borrow.M (Array Lean.IR.Param)

full_name: Lean.IR.Borrow.ownArgsUsingParams
code: /-- For each ps[i], if ps[i] is owned, then mark xs[i] as owned. -/
def ownArgsUsingParams (xs : Array Arg) (ps : Array Param) : M Unit 
goal: Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.ownParamsUsingArgs
code: /-- For each xs[i], if xs[i] is owned, then mark ps[i] as owned.
   We use this action to preserve tail calls. That is, if we have
   a tail call `f xs`, if the i-th parameter is borrowed, but `xs[i]` is owned
   we would have to insert a `dec xs[i]` after `f xs` and consequently
   "break" the tail call. -/
def ownParamsUsingArgs (xs : Array Arg) (ps : Array Param) : M Unit 
goal: Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.ownArgsIfParam
code: /-- Mark `xs[i]` as owned if it is one of the parameters `ps`.
   We use this action to mark function parameters that are being "packed" inside constructors.
   This is a heuristic, and is not related with the effectiveness of the reset/reuse optimization.
   It is useful for code such as
   ```
   def f (x y : obj) :=
   let z := ctor_1 x y;
   ret z
   ```
-/
def ownArgsIfParam (xs : Array Arg) : M Unit 
goal: Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.collectExpr
code: def collectExpr (z : VarId) : Expr → M Unit
  
goal: Lean.IR.Expr → Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.preserveTailCall
code: def preserveTailCall (x : VarId) (v : Expr) (b : FnBody) : M Unit 
goal: Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.updateParamSet
code: def updateParamSet (ctx : BorrowInfCtx) (ps : Array Param) : BorrowInfCtx 
goal: Lean.IR.Borrow.BorrowInfCtx

full_name: Lean.IR.Borrow.collectFnBody
code: partial def collectFnBody : FnBody → M Unit
  
goal: Lean.IR.FnBody → Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.collectDecl
code: partial def collectDecl : Decl → M Unit
  
goal: Lean.IR.Decl → Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.whileModifing
code: /-- Keep executing `x` until it reaches a fixpoint -/
partial def whileModifing (x : M Unit) : M Unit 
goal: Lean.IR.Borrow.M Unit

full_name: Lean.IR.Borrow.collectDecls
code: def collectDecls : M ParamMap 
goal: Lean.IR.Borrow.M Lean.IR.Borrow.ParamMap

full_name: Lean.IR.Borrow.infer
code: def infer (env : Environment) (decls : Array Decl) : ParamMap 
goal: Lean.IR.Borrow.ParamMap

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