LLVM 19.0.0git
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
llvm::sandboxir::Context Class Reference

#include "llvm/SandboxIR/SandboxIR.h"

Public Member Functions

 Context (LLVMContext &LLVMCtx)
 
TrackergetTracker ()
 
void save ()
 Convenience function for getTracker().save()
 
void revert ()
 Convenience function for getTracker().revert()
 
void accept ()
 Convenience function for getTracker().accept()
 
sandboxir::ValuegetValue (llvm::Value *V) const
 
const sandboxir::ValuegetValue (const llvm::Value *V) const
 
FunctioncreateFunction (llvm::Function *F)
 Create a sandboxir::Function for an existing LLVM IR F, including all blocks and instructions.
 
size_t getNumValues () const
 \Returns the number of values registered with Context.
 

Protected Member Functions

std::unique_ptr< ValuedetachLLVMValue (llvm::Value *V)
 Remove V from the maps and returns the unique_ptr.
 
std::unique_ptr< Valuedetach (Value *V)
 Remove SBV from all SandboxIR maps and stop owning it.
 
ValueregisterValue (std::unique_ptr< Value > &&VPtr)
 Take ownership of VPtr and store it in LLVMValueToValueMap.
 
ValuegetOrCreateValueInternal (llvm::Value *V, llvm::User *U=nullptr)
 This is the actual function that creates sandboxir values for V, and among others handles all instruction types.
 
ArgumentgetOrCreateArgument (llvm::Argument *LLVMArg)
 Get or create a sandboxir::Argument for an existing LLVM IR LLVMArg.
 
ValuegetOrCreateValue (llvm::Value *LLVMV)
 Get or create a sandboxir::Value for an existing LLVM IR LLVMV.
 
BasicBlockcreateBasicBlock (llvm::BasicBlock *BB)
 Create a sandboxir::BasicBlock for an existing LLVM IR BB.
 
auto & getLLVMIRBuilder ()
 
LoadInstcreateLoadInst (llvm::LoadInst *LI)
 

Protected Attributes

LLVMContextLLVMCtx
 
Tracker IRTracker
 
DenseMap< llvm::Value *, std::unique_ptr< sandboxir::Value > > LLVMValueToValueMap
 Maps LLVM Value to the corresponding sandboxir::Value.
 
IRBuilder< ConstantFolderLLVMIRBuilder
 
friend LoadInst
 

Friends

class EraseFromParent
 
class BasicBlock
 Various leaf nodes.
 
void Instruction::eraseFromParent ()
 

Detailed Description

Definition at line 690 of file SandboxIR.h.

Constructor & Destructor Documentation

◆ Context()

llvm::sandboxir::Context::Context ( LLVMContext LLVMCtx)
inline

Definition at line 739 of file SandboxIR.h.

Member Function Documentation

◆ accept()

void llvm::sandboxir::Context::accept ( )
inline

Convenience function for getTracker().accept()

Definition at line 749 of file SandboxIR.h.

References llvm::sandboxir::Tracker::accept(), and IRTracker.

◆ createBasicBlock()

BasicBlock * Context::createBasicBlock ( llvm::BasicBlock BB)
protected

Create a sandboxir::BasicBlock for an existing LLVM IR BB.

This will also create all contents of the block.

Definition at line 631 of file SandboxIR.cpp.

References assert(), BasicBlock, getValue(), and registerValue().

Referenced by createFunction().

◆ createFunction()

Function * Context::createFunction ( llvm::Function F)

Create a sandboxir::Function for an existing LLVM IR F, including all blocks and instructions.

This is the main API function for creating Sandbox IR.

Definition at line 652 of file SandboxIR.cpp.

References assert(), createBasicBlock(), F, getOrCreateArgument(), getValue(), and registerValue().

◆ createLoadInst()

LoadInst * Context::createLoadInst ( llvm::LoadInst LI)
protected

Definition at line 640 of file SandboxIR.cpp.

References LoadInst, and registerValue().

Referenced by llvm::sandboxir::LoadInst::create().

◆ detach()

std::unique_ptr< Value > Context::detach ( Value V)
protected

Remove SBV from all SandboxIR maps and stop owning it.

This effectively detaches V from the underlying IR.

Definition at line 573 of file SandboxIR.cpp.

References assert(), and detachLLVMValue().

Referenced by llvm::sandboxir::Instruction::eraseFromParent().

◆ detachLLVMValue()

std::unique_ptr< Value > Context::detachLLVMValue ( llvm::Value V)
protected

Remove V from the maps and returns the unique_ptr.

Definition at line 562 of file SandboxIR.cpp.

References LLVMValueToValueMap.

Referenced by detach().

◆ getLLVMIRBuilder()

auto & llvm::sandboxir::Context::getLLVMIRBuilder ( )
inlineprotected

Definition at line 733 of file SandboxIR.h.

References LLVMIRBuilder.

Referenced by llvm::sandboxir::LoadInst::create().

◆ getNumValues()

size_t llvm::sandboxir::Context::getNumValues ( ) const
inline

\Returns the number of values registered with Context.

Definition at line 761 of file SandboxIR.h.

References LLVMValueToValueMap.

Referenced by llvm::sandboxir::Value::Value().

◆ getOrCreateArgument()

Argument * llvm::sandboxir::Context::getOrCreateArgument ( llvm::Argument LLVMArg)
inlineprotected

Get or create a sandboxir::Argument for an existing LLVM IR LLVMArg.

Definition at line 713 of file SandboxIR.h.

References LLVMValueToValueMap.

Referenced by createFunction().

◆ getOrCreateValue()

Value * llvm::sandboxir::Context::getOrCreateValue ( llvm::Value LLVMV)
inlineprotected

Get or create a sandboxir::Value for an existing LLVM IR LLVMV.

Definition at line 723 of file SandboxIR.h.

References getOrCreateValueInternal().

◆ getOrCreateValueInternal()

Value * Context::getOrCreateValueInternal ( llvm::Value V,
llvm::User U = nullptr 
)
protected

This is the actual function that creates sandboxir values for V, and among others handles all instruction types.

Definition at line 590 of file SandboxIR.cpp.

References assert(), llvm::CallingConv::C, getOpcode(), getOrCreateValueInternal(), getValue(), LLVMValueToValueMap, and LoadInst.

Referenced by getOrCreateValue(), and getOrCreateValueInternal().

◆ getTracker()

Tracker & llvm::sandboxir::Context::getTracker ( )
inline

◆ getValue() [1/2]

const sandboxir::Value * llvm::sandboxir::Context::getValue ( const llvm::Value V) const
inline

Definition at line 752 of file SandboxIR.h.

References getValue().

◆ getValue() [2/2]

Value * Context::getValue ( llvm::Value V) const

◆ registerValue()

Value * Context::registerValue ( std::unique_ptr< Value > &&  VPtr)
protected

Take ownership of VPtr and store it in LLVMValueToValueMap.

Definition at line 580 of file SandboxIR.cpp.

References assert(), and LLVMValueToValueMap.

Referenced by createBasicBlock(), createFunction(), createLoadInst(), and llvm::sandboxir::EraseFromParent::revert().

◆ revert()

void llvm::sandboxir::Context::revert ( )
inline

Convenience function for getTracker().revert()

Definition at line 747 of file SandboxIR.h.

References IRTracker, and llvm::sandboxir::Tracker::revert().

◆ save()

void llvm::sandboxir::Context::save ( )
inline

Convenience function for getTracker().save()

Definition at line 745 of file SandboxIR.h.

References IRTracker, and llvm::sandboxir::Tracker::save().

Friends And Related Function Documentation

◆ BasicBlock

friend class BasicBlock
friend

Various leaf nodes.

Definition at line 730 of file SandboxIR.h.

Referenced by createBasicBlock().

◆ EraseFromParent

friend class EraseFromParent
friend

Definition at line 708 of file SandboxIR.h.

◆ Instruction::eraseFromParent

Member Data Documentation

◆ IRTracker

Tracker llvm::sandboxir::Context::IRTracker
protected

Definition at line 693 of file SandboxIR.h.

Referenced by accept(), getTracker(), revert(), and save().

◆ LLVMCtx

LLVMContext& llvm::sandboxir::Context::LLVMCtx
protected

Definition at line 692 of file SandboxIR.h.

◆ LLVMIRBuilder

IRBuilder<ConstantFolder> llvm::sandboxir::Context::LLVMIRBuilder
protected

Definition at line 732 of file SandboxIR.h.

Referenced by getLLVMIRBuilder().

◆ LLVMValueToValueMap

DenseMap<llvm::Value *, std::unique_ptr<sandboxir::Value> > llvm::sandboxir::Context::LLVMValueToValueMap
protected

Maps LLVM Value to the corresponding sandboxir::Value.

Owns all SandboxIR objects.

Definition at line 698 of file SandboxIR.h.

Referenced by detachLLVMValue(), getNumValues(), getOrCreateArgument(), getOrCreateValueInternal(), getValue(), and registerValue().

◆ LoadInst

friend llvm::sandboxir::Context::LoadInst
protected

Definition at line 736 of file SandboxIR.h.

Referenced by createLoadInst(), and getOrCreateValueInternal().


The documentation for this class was generated from the following files: