LLVM 20.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.
 
ConstantgetOrCreateConstant (llvm::Constant *LLVMC)
 Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
 
BasicBlockcreateBasicBlock (llvm::BasicBlock *BB)
 Create a sandboxir::BasicBlock for an existing LLVM IR BB.
 
auto & getLLVMIRBuilder ()
 
SelectInstcreateSelectInst (llvm::SelectInst *SI)
 
InsertElementInstcreateInsertElementInst (llvm::InsertElementInst *IEI)
 
ExtractElementInstcreateExtractElementInst (llvm::ExtractElementInst *EEI)
 
BranchInstcreateBranchInst (llvm::BranchInst *I)
 
LoadInstcreateLoadInst (llvm::LoadInst *LI)
 
StoreInstcreateStoreInst (llvm::StoreInst *SI)
 
ReturnInstcreateReturnInst (llvm::ReturnInst *I)
 
CallInstcreateCallInst (llvm::CallInst *I)
 
InvokeInstcreateInvokeInst (llvm::InvokeInst *I)
 
CallBrInstcreateCallBrInst (llvm::CallBrInst *I)
 
GetElementPtrInstcreateGetElementPtrInst (llvm::GetElementPtrInst *I)
 
AtomicCmpXchgInstcreateAtomicCmpXchgInst (llvm::AtomicCmpXchgInst *I)
 
AllocaInstcreateAllocaInst (llvm::AllocaInst *I)
 
CastInstcreateCastInst (llvm::CastInst *I)
 
PHINodecreatePHINode (llvm::PHINode *I)
 
UnreachableInstcreateUnreachableInst (llvm::UnreachableInst *UI)
 

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 SelectInst
 
friend InsertElementInst
 
friend ExtractElementInst
 
friend BranchInst
 
friend LoadInst
 
friend StoreInst
 
friend ReturnInst
 
friend CallInst
 
friend InvokeInst
 
friend CallBrInst
 
friend GetElementPtrInst
 
friend AtomicCmpXchgInst
 
friend AllocaInst
 
friend CastInst
 
friend PHINode
 
friend UnreachableInst
 

Friends

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

Detailed Description

Definition at line 1715 of file SandboxIR.h.

Constructor & Destructor Documentation

◆ Context()

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

Definition at line 1799 of file SandboxIR.h.

Member Function Documentation

◆ accept()

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

Convenience function for getTracker().accept()

Definition at line 1809 of file SandboxIR.h.

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

◆ createAllocaInst()

AllocaInst * Context::createAllocaInst ( llvm::AllocaInst I)
protected

Definition at line 1663 of file SandboxIR.cpp.

References AllocaInst, I, and registerValue().

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

◆ createAtomicCmpXchgInst()

AtomicCmpXchgInst * Context::createAtomicCmpXchgInst ( llvm::AtomicCmpXchgInst I)
protected

Definition at line 1658 of file SandboxIR.cpp.

References AtomicCmpXchgInst, I, and registerValue().

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

◆ 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 1582 of file SandboxIR.cpp.

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

Referenced by createFunction().

◆ createBranchInst()

BranchInst * Context::createBranchInst ( llvm::BranchInst I)
protected

Definition at line 1610 of file SandboxIR.cpp.

References BranchInst, and registerValue().

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

◆ createCallBrInst()

CallBrInst * Context::createCallBrInst ( llvm::CallBrInst I)
protected

Definition at line 1640 of file SandboxIR.cpp.

References CallBrInst, I, and registerValue().

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

◆ createCallInst()

CallInst * Context::createCallInst ( llvm::CallInst I)
protected

Definition at line 1630 of file SandboxIR.cpp.

References CallInst, I, and registerValue().

◆ createCastInst()

CastInst * Context::createCastInst ( llvm::CastInst I)
protected

Definition at line 1667 of file SandboxIR.cpp.

References CastInst, I, and registerValue().

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

◆ createExtractElementInst()

ExtractElementInst * Context::createExtractElementInst ( llvm::ExtractElementInst EEI)
protected

Definition at line 1597 of file SandboxIR.cpp.

References ExtractElementInst, and registerValue().

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

◆ 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 1683 of file SandboxIR.cpp.

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

◆ createGetElementPtrInst()

GetElementPtrInst * Context::createGetElementPtrInst ( llvm::GetElementPtrInst I)
protected

Definition at line 1652 of file SandboxIR.cpp.

References GetElementPtrInst, I, and registerValue().

◆ createInsertElementInst()

InsertElementInst * Context::createInsertElementInst ( llvm::InsertElementInst IEI)
protected

Definition at line 1604 of file SandboxIR.cpp.

References InsertElementInst, and registerValue().

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

◆ createInvokeInst()

InvokeInst * Context::createInvokeInst ( llvm::InvokeInst I)
protected

Definition at line 1635 of file SandboxIR.cpp.

References I, InvokeInst, and registerValue().

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

◆ createLoadInst()

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

Definition at line 1615 of file SandboxIR.cpp.

References LoadInst, and registerValue().

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

◆ createPHINode()

PHINode * Context::createPHINode ( llvm::PHINode I)
protected

Definition at line 1671 of file SandboxIR.cpp.

References I, PHINode, and registerValue().

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

◆ createReturnInst()

ReturnInst * Context::createReturnInst ( llvm::ReturnInst I)
protected

Definition at line 1625 of file SandboxIR.cpp.

References I, registerValue(), and ReturnInst.

◆ createSelectInst()

SelectInst * Context::createSelectInst ( llvm::SelectInst SI)
protected

Definition at line 1591 of file SandboxIR.cpp.

References registerValue(), and SelectInst.

◆ createStoreInst()

StoreInst * Context::createStoreInst ( llvm::StoreInst SI)
protected

Definition at line 1620 of file SandboxIR.cpp.

References registerValue(), and StoreInst.

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

◆ createUnreachableInst()

UnreachableInst * Context::createUnreachableInst ( llvm::UnreachableInst UI)
protected

Definition at line 1645 of file SandboxIR.cpp.

References registerValue(), and UnreachableInst.

Referenced by llvm::sandboxir::UnreachableInst::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 1421 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 1410 of file SandboxIR.cpp.

References LLVMValueToValueMap.

Referenced by detach().

◆ getLLVMIRBuilder()

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

◆ getNumValues()

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

\Returns the number of values registered with Context.

Definition at line 1821 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 1738 of file SandboxIR.h.

References LLVMValueToValueMap.

Referenced by createFunction().

◆ getOrCreateConstant()

Constant * llvm::sandboxir::Context::getOrCreateConstant ( llvm::Constant LLVMC)
inlineprotected

◆ 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 1748 of file SandboxIR.h.

References getOrCreateValueInternal().

◆ getOrCreateValueInternal()

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

◆ 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 1812 of file SandboxIR.h.

References getValue().

◆ getValue() [2/2]

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

Definition at line 1676 of file SandboxIR.cpp.

References LLVMValueToValueMap.

Referenced by llvm::sandboxir::BasicBlock::begin(), createBasicBlock(), createFunction(), llvm::sandboxir::Use::dumpOS(), llvm::sandboxir::BasicBlock::dumpOS(), llvm::sandboxir::Function::dumpOS(), llvm::sandboxir::Use::get(), llvm::sandboxir::Function::getArg(), llvm::sandboxir::AllocaInst::getArraySize(), llvm::sandboxir::CallBase::getCalledFunction(), llvm::sandboxir::CallBase::getCalledOperand(), llvm::sandboxir::CallBase::getCalledOperandUse(), llvm::sandboxir::CallBase::getCaller(), llvm::sandboxir::AtomicCmpXchgInst::getCompareOperand(), llvm::sandboxir::BranchInst::getCondition(), llvm::sandboxir::CallBrInst::getDefaultDest(), llvm::sandboxir::PHINode::getIncomingBlock(), llvm::sandboxir::PHINode::getIncomingValue(), llvm::sandboxir::PHINode::getIncomingValueForBlock(), llvm::sandboxir::CallBrInst::getIndirectDest(), llvm::sandboxir::CallBrInst::getIndirectDestLabel(), llvm::sandboxir::CallBrInst::getIndirectDestLabelUse(), llvm::sandboxir::CallBrInst::getIndirectDests(), llvm::sandboxir::InvokeInst::getLandingPadInst(), llvm::sandboxir::AtomicCmpXchgInst::getNewValOperand(), llvm::sandboxir::Instruction::getNextNode(), llvm::sandboxir::InvokeInst::getNormalDest(), getOrCreateValueInternal(), llvm::sandboxir::BasicBlock::getParent(), llvm::sandboxir::Instruction::getParent(), llvm::sandboxir::AtomicCmpXchgInst::getPointerOperand(), llvm::sandboxir::LoadInst::getPointerOperand(), llvm::sandboxir::StoreInst::getPointerOperand(), llvm::sandboxir::GetElementPtrInst::getPointerOperand(), llvm::sandboxir::ReturnInst::getReturnValue(), llvm::sandboxir::CallBrInst::getSuccessor(), llvm::sandboxir::BranchInst::getSuccessor(), llvm::sandboxir::InvokeInst::getSuccessor(), llvm::sandboxir::BasicBlock::getTerminator(), llvm::sandboxir::InvokeInst::getUnwindDest(), getValue(), llvm::sandboxir::StoreInst::getValueOperand(), llvm::sandboxir::PHINode::hasConstantValue(), llvm::sandboxir::BBIterator::operator++(), llvm::sandboxir::PHINode::removeIncomingValue(), llvm::sandboxir::Value::replaceUsesWithIf(), llvm::sandboxir::Value::use_begin(), llvm::sandboxir::Value::user_begin(), and llvm::sandboxir::User::verifyUserOfLLVMUse().

◆ registerValue()

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

◆ revert()

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

Convenience function for getTracker().revert()

Definition at line 1807 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 1805 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 1760 of file SandboxIR.h.

Referenced by createBasicBlock().

◆ Constant

friend class Constant
friend

Definition at line 1755 of file SandboxIR.h.

Referenced by getOrCreateValueInternal().

◆ EraseFromParent

friend class EraseFromParent
friend

Definition at line 1733 of file SandboxIR.h.

◆ Instruction::eraseFromParent

Member Data Documentation

◆ AllocaInst

friend llvm::sandboxir::Context::AllocaInst
protected

Definition at line 1790 of file SandboxIR.h.

Referenced by createAllocaInst(), and getOrCreateValueInternal().

◆ AtomicCmpXchgInst

friend llvm::sandboxir::Context::AtomicCmpXchgInst
protected

Definition at line 1788 of file SandboxIR.h.

Referenced by createAtomicCmpXchgInst(), and getOrCreateValueInternal().

◆ BranchInst

friend llvm::sandboxir::Context::BranchInst
protected

Definition at line 1772 of file SandboxIR.h.

Referenced by createBranchInst(), and getOrCreateValueInternal().

◆ CallBrInst

friend llvm::sandboxir::Context::CallBrInst
protected

Definition at line 1784 of file SandboxIR.h.

Referenced by createCallBrInst(), and getOrCreateValueInternal().

◆ CallInst

friend llvm::sandboxir::Context::CallInst
protected

Definition at line 1780 of file SandboxIR.h.

Referenced by createCallInst(), and getOrCreateValueInternal().

◆ CastInst

friend llvm::sandboxir::Context::CastInst
protected

Definition at line 1792 of file SandboxIR.h.

Referenced by createCastInst(), and getOrCreateValueInternal().

◆ ExtractElementInst

friend llvm::sandboxir::Context::ExtractElementInst
protected

Definition at line 1770 of file SandboxIR.h.

Referenced by createExtractElementInst(), and getOrCreateValueInternal().

◆ GetElementPtrInst

friend llvm::sandboxir::Context::GetElementPtrInst
protected

Definition at line 1786 of file SandboxIR.h.

Referenced by createGetElementPtrInst(), and getOrCreateValueInternal().

◆ InsertElementInst

friend llvm::sandboxir::Context::InsertElementInst
protected

Definition at line 1768 of file SandboxIR.h.

Referenced by createInsertElementInst(), and getOrCreateValueInternal().

◆ InvokeInst

friend llvm::sandboxir::Context::InvokeInst
protected

Definition at line 1782 of file SandboxIR.h.

Referenced by createInvokeInst(), and getOrCreateValueInternal().

◆ IRTracker

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

Definition at line 1718 of file SandboxIR.h.

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

◆ LLVMCtx

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

Definition at line 1717 of file SandboxIR.h.

◆ LLVMIRBuilder

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

Definition at line 1762 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 1723 of file SandboxIR.h.

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

◆ LoadInst

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

Definition at line 1774 of file SandboxIR.h.

Referenced by createLoadInst(), and getOrCreateValueInternal().

◆ PHINode

friend llvm::sandboxir::Context::PHINode
protected

Definition at line 1794 of file SandboxIR.h.

Referenced by createPHINode(), and getOrCreateValueInternal().

◆ ReturnInst

friend llvm::sandboxir::Context::ReturnInst
protected

Definition at line 1778 of file SandboxIR.h.

Referenced by createReturnInst(), and getOrCreateValueInternal().

◆ SelectInst

friend llvm::sandboxir::Context::SelectInst
protected

Definition at line 1766 of file SandboxIR.h.

Referenced by createSelectInst(), and getOrCreateValueInternal().

◆ StoreInst

friend llvm::sandboxir::Context::StoreInst
protected

Definition at line 1776 of file SandboxIR.h.

Referenced by createStoreInst(), and getOrCreateValueInternal().

◆ UnreachableInst

friend llvm::sandboxir::Context::UnreachableInst
protected

Definition at line 1796 of file SandboxIR.h.

Referenced by createUnreachableInst(), and getOrCreateValueInternal().


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