LLVM: llvm::sandboxir::Context Class Reference (original) (raw)

#include "[llvm/SandboxIR/Context.h](SandboxIR%5F2Context%5F8h%5Fsource.html)"

Public Member Functions
LLVM_ABI Context (LLVMContext &LLVMCtx)
LLVM_ABI ~Context ()
LLVM_ABI void clear ()
Clears function-level state.
Tracker & getTracker ()
void save ()
Convenience function for getTracker().save()
void revert ()
Convenience function for getTracker().revert()
void accept ()
Convenience function for getTracker().accept()
LLVM_ABI sandboxir::Value * getValue (llvm::Value *V) const
const sandboxir::Value * getValue (const llvm::Value *V) const
LLVM_ABI Module * getModule (llvm::Module *LLVMM) const
LLVM_ABI Module * getOrCreateModule (llvm::Module *LLVMM)
Type * getType (llvm::Type *LLVMTy)
LLVM_ABI Function * createFunction (llvm::Function *F)
Create a sandboxir::Function for an existing LLVM IR F, including all blocks and instructions.
LLVM_ABI Module * createModule (llvm::Module *LLVMM)
Create a sandboxir::Module corresponding to LLVMM.
size_t getNumValues () const
\Returns the number of values registered with Context.
LLVM_ABI CallbackID registerEraseInstrCallback (EraseInstrCallback CB)
Register a callback that gets called when a SandboxIR instruction is about to be removed from its parent.
LLVM_ABI void unregisterEraseInstrCallback (CallbackID ID)
LLVM_ABI CallbackID registerCreateInstrCallback (CreateInstrCallback CB)
Register a callback that gets called right after a SandboxIR instruction is created.
LLVM_ABI void unregisterCreateInstrCallback (CallbackID ID)
LLVM_ABI CallbackID registerMoveInstrCallback (MoveInstrCallback CB)
Register a callback that gets called when a SandboxIR instruction is about to be moved.
LLVM_ABI void unregisterMoveInstrCallback (CallbackID ID)
LLVM_ABI CallbackID registerSetUseCallback (SetUseCallback CB)
Register a callback that gets called when a Use gets set.
LLVM_ABI void unregisterSetUseCallback (CallbackID ID)
Protected Member Functions
LLVM_ABI std::unique_ptr< Value > detachLLVMValue (llvm::Value *V)
Remove V from the maps and returns the unique_ptr.
LLVM_ABI std::unique_ptr< Value > detach (Value *V)
Remove SBV from all SandboxIR maps and stop owning it.
LLVM_ABI Value * registerValue (std::unique_ptr< Value > &&VPtr)
Take ownership of VPtr and store it in LLVMValueToValueMap.
LLVM_ABI Value * getOrCreateValueInternal (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.
LLVM_ABI Argument * getOrCreateArgument (llvm::Argument *LLVMArg)
Get or create a sandboxir::Argument for an existing LLVM IR LLVMArg.
Value * getOrCreateValue (llvm::Value *LLVMV)
Get or create a sandboxir::Value for an existing LLVM IR LLVMV.
LLVM_ABI Constant * getOrCreateConstant (llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
LLVM_ABI void runEraseInstrCallbacks (Instruction *I)
LLVM_ABI void runCreateInstrCallbacks (Instruction *I)
LLVM_ABI void runMoveInstrCallbacks (Instruction *I, const BBIterator &Where)
LLVM_ABI void runSetUseCallbacks (const Use &U, Value *NewSrc)
LLVM_ABI BasicBlock * createBasicBlock (llvm::BasicBlock *BB)
Create a sandboxir::BasicBlock for an existing LLVM IR BB.
auto & getLLVMIRBuilder ()
LLVM_ABI VAArgInst * createVAArgInst (llvm::VAArgInst *SI)
LLVM_ABI FreezeInst * createFreezeInst (llvm::FreezeInst *SI)
LLVM_ABI FenceInst * createFenceInst (llvm::FenceInst *SI)
LLVM_ABI SelectInst * createSelectInst (llvm::SelectInst *SI)
LLVM_ABI InsertElementInst * createInsertElementInst (llvm::InsertElementInst *IEI)
LLVM_ABI ExtractElementInst * createExtractElementInst (llvm::ExtractElementInst *EEI)
LLVM_ABI ShuffleVectorInst * createShuffleVectorInst (llvm::ShuffleVectorInst *SVI)
LLVM_ABI ExtractValueInst * createExtractValueInst (llvm::ExtractValueInst *IVI)
LLVM_ABI InsertValueInst * createInsertValueInst (llvm::InsertValueInst *IVI)
LLVM_ABI BranchInst * createBranchInst (llvm::BranchInst *I)
LLVM_ABI LoadInst * createLoadInst (llvm::LoadInst *LI)
LLVM_ABI StoreInst * createStoreInst (llvm::StoreInst *SI)
LLVM_ABI ReturnInst * createReturnInst (llvm::ReturnInst *I)
LLVM_ABI CallInst * createCallInst (llvm::CallInst *I)
LLVM_ABI InvokeInst * createInvokeInst (llvm::InvokeInst *I)
LLVM_ABI CallBrInst * createCallBrInst (llvm::CallBrInst *I)
LLVM_ABI LandingPadInst * createLandingPadInst (llvm::LandingPadInst *I)
LLVM_ABI CatchPadInst * createCatchPadInst (llvm::CatchPadInst *I)
LLVM_ABI CleanupPadInst * createCleanupPadInst (llvm::CleanupPadInst *I)
LLVM_ABI CatchReturnInst * createCatchReturnInst (llvm::CatchReturnInst *I)
LLVM_ABI CleanupReturnInst * createCleanupReturnInst (llvm::CleanupReturnInst *I)
LLVM_ABI GetElementPtrInst * createGetElementPtrInst (llvm::GetElementPtrInst *I)
LLVM_ABI CatchSwitchInst * createCatchSwitchInst (llvm::CatchSwitchInst *I)
LLVM_ABI ResumeInst * createResumeInst (llvm::ResumeInst *I)
LLVM_ABI SwitchInst * createSwitchInst (llvm::SwitchInst *I)
LLVM_ABI UnaryOperator * createUnaryOperator (llvm::UnaryOperator *I)
LLVM_ABI BinaryOperator * createBinaryOperator (llvm::BinaryOperator *I)
LLVM_ABI AtomicRMWInst * createAtomicRMWInst (llvm::AtomicRMWInst *I)
LLVM_ABI AtomicCmpXchgInst * createAtomicCmpXchgInst (llvm::AtomicCmpXchgInst *I)
LLVM_ABI AllocaInst * createAllocaInst (llvm::AllocaInst *I)
LLVM_ABI CastInst * createCastInst (llvm::CastInst *I)
LLVM_ABI PHINode * createPHINode (llvm::PHINode *I)
LLVM_ABI UnreachableInst * createUnreachableInst (llvm::UnreachableInst *UI)
LLVM_ABI CmpInst * createCmpInst (llvm::CmpInst *I)
LLVM_ABI ICmpInst * createICmpInst (llvm::ICmpInst *I)
LLVM_ABI FCmpInst * createFCmpInst (llvm::FCmpInst *I)
Protected Attributes
LLVMContext & LLVMCtx
Tracker IRTracker
DenseMap< llvm::Value *, std::unique_ptr< Value > > LLVMValueToValueMap
Maps LLVM Value to the corresponding sandboxir::Value.
DenseMap< llvm::Module *, std::unique_ptr< Module > > LLVMModuleToModuleMap
Maps an LLVM Module to the corresponding sandboxir::Module.
DenseMap< llvm::Type *, std::unique_ptr< Type, TypeDeleter > > LLVMTypeToTypeMap
Maps LLVM Type to the corresonding sandboxir::Type.
MapVector< CallbackID, EraseInstrCallback > EraseInstrCallbacks
Callbacks called when an IR instruction is about to get erased.
MapVector< CallbackID, CreateInstrCallback > CreateInstrCallbacks
Callbacks called when an IR instruction is about to get created.
MapVector< CallbackID, MoveInstrCallback > MoveInstrCallbacks
Callbacks called when an IR instruction is about to get moved.
MapVector< CallbackID, SetUseCallback > SetUseCallbacks
Callbacks called when a Use gets its source set.
CallbackID::ValTy NextCallbackID = 1
A counter used for assigning callback IDs during registration.
IRBuilder< ConstantFolder > LLVMIRBuilder
friend VAArgInst
friend FreezeInst
friend FenceInst
friend SelectInst
friend InsertElementInst
friend ExtractElementInst
friend ShuffleVectorInst
friend ExtractValueInst
friend InsertValueInst
friend BranchInst
friend LoadInst
friend StoreInst
friend ReturnInst
friend CallInst
friend InvokeInst
friend CallBrInst
friend LandingPadInst
friend CatchPadInst
friend CleanupPadInst
friend CatchReturnInst
friend CleanupReturnInst
friend GetElementPtrInst
friend CatchSwitchInst
friend ResumeInst
friend SwitchInst
friend UnaryOperator
friend BinaryOperator
friend AtomicRMWInst
friend AtomicCmpXchgInst
friend AllocaInst
friend CastInst
friend PHINode
friend UnreachableInst
friend CmpInst
friend ICmpInst
friend FCmpInst
Friends
class Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a signed Int and unsigned UInt variant in order to map directly to C++ types.
class PointerType
class IntegerType
class StructType
class Region
class IRSnapshotChecker
class Instruction
Iterator for Instructions in a `BasicBlock.
class EraseFromParent
class ConstantDataSequential
class Utils
class User
class Value
class BasicBlock
Various leaf nodes.

Definition at line 33 of file Context.h.

CreateInstrCallback

EraseInstrCallback

MoveInstrCallback

Initial value:

std::function<void(Instruction *, const BBIterator &)>

friend class Instruction

Iterator for Instructions in a `BasicBlock.

Definition at line 41 of file Context.h.

SetUseCallback

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

~Context()

llvm::sandboxir::Context::~Context ( ) default

accept()

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

clear()

void llvm::sandboxir::Context::clear ( )

createAllocaInst()

createAtomicCmpXchgInst()

createAtomicRMWInst()

createBasicBlock()

createBinaryOperator()

createBranchInst()

createCallBrInst()

createCallInst()

createCastInst()

createCatchPadInst()

createCatchReturnInst()

createCatchSwitchInst()

createCleanupPadInst()

createCleanupReturnInst()

createCmpInst()

createExtractElementInst()

createExtractValueInst()

createFCmpInst()

createFenceInst()

createFreezeInst()

createFunction()

createGetElementPtrInst()

createICmpInst()

createInsertElementInst()

createInsertValueInst()

createInvokeInst()

createLandingPadInst()

createLoadInst()

createModule()

createPHINode()

createResumeInst()

createReturnInst()

createSelectInst()

createShuffleVectorInst()

createStoreInst()

createSwitchInst()

createUnaryOperator()

createUnreachableInst()

createVAArgInst()

detach()

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

detachLLVMValue()

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

getLLVMIRBuilder()

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

getModule()

getNumValues()

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

getOrCreateArgument()

getOrCreateConstant()

getOrCreateModule()

getOrCreateValue()

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

getOrCreateValueInternal()

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

Definition at line 56 of file Context.cpp.

References AllocaInst, assert(), AtomicCmpXchgInst, AtomicRMWInst, BinaryOperator, BranchInst, CallBrInst, CallInst, llvm::cast(), CastInst, CatchPadInst, CatchReturnInst, CatchSwitchInst, CleanupPadInst, CleanupReturnInst, llvm::dyn_cast(), ExtractElementInst, ExtractValueInst, FCmpInst, FenceInst, FreezeInst, GetElementPtrInst, getOrCreateValueInternal(), getValue(), ICmpInst, InsertElementInst, InsertValueInst, InvokeInst, llvm::isa(), LandingPadInst, llvm_unreachable, LLVMAlloca, LLVMAtomicCmpXchg, LLVMAtomicRMW, LLVMBr, LLVMCall, LLVMCallBr, LLVMFCmp, LLVMFence, LLVMFreeze, LLVMICmp, LLVMInvoke, LLVMRet, LLVMUnreachable, LLVMVAArg, LLVMValueToValueMap, LoadInst, PHINode, ResumeInst, ReturnInst, SelectInst, llvm::seq(), ShuffleVectorInst, StoreInst, SwitchInst, UnaryOperator, UnreachableInst, VAArgInst, and Value.

Referenced by getOrCreateConstant(), getOrCreateValue(), and getOrCreateValueInternal().

getTracker()

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

getType()

Type * llvm::sandboxir::Context::getType ( llvm::Type * LLVMTy) inline

getValue() [1/2]

getValue() [2/2]

registerCreateInstrCallback()

registerEraseInstrCallback()

registerMoveInstrCallback()

registerSetUseCallback()

registerValue()

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

Take ownership of VPtr and store it in LLVMValueToValueMap.

Definition at line 35 of file Context.cpp.

References assert(), llvm::dyn_cast(), llvm::sandboxir::Tracker::emplaceIfTracking(), getTracker(), I, LLVMValueToValueMap, runCreateInstrCallbacks(), and Value.

Referenced by createAllocaInst(), createAtomicCmpXchgInst(), createAtomicRMWInst(), createBasicBlock(), createBinaryOperator(), createBranchInst(), createCallBrInst(), createCallInst(), createCastInst(), createCatchPadInst(), createCatchReturnInst(), createCatchSwitchInst(), createCleanupPadInst(), createCleanupReturnInst(), createExtractElementInst(), createExtractValueInst(), createFCmpInst(), createFenceInst(), createFreezeInst(), createFunction(), createGetElementPtrInst(), createICmpInst(), createInsertElementInst(), createInsertValueInst(), createInvokeInst(), createLandingPadInst(), createLoadInst(), createPHINode(), createResumeInst(), createReturnInst(), createSelectInst(), createShuffleVectorInst(), createStoreInst(), createSwitchInst(), createUnaryOperator(), createUnreachableInst(), and createVAArgInst().

revert()

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

runCreateInstrCallbacks()

void llvm::sandboxir::Context::runCreateInstrCallbacks ( Instruction * I) protected

runEraseInstrCallbacks()

void llvm::sandboxir::Context::runEraseInstrCallbacks ( Instruction * I) protected

runMoveInstrCallbacks()

void llvm::sandboxir::Context::runMoveInstrCallbacks ( Instruction * I, const BBIterator & Where ) protected

runSetUseCallbacks()

void llvm::sandboxir::Context::runSetUseCallbacks ( const Use & U, Value * NewSrc ) protected

save()

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

unregisterCreateInstrCallback()

void llvm::sandboxir::Context::unregisterCreateInstrCallback ( CallbackID ID )

unregisterEraseInstrCallback()

void llvm::sandboxir::Context::unregisterEraseInstrCallback ( CallbackID ID )

unregisterMoveInstrCallback()

void llvm::sandboxir::Context::unregisterMoveInstrCallback ( CallbackID ID )

unregisterSetUseCallback()

void llvm::sandboxir::Context::unregisterSetUseCallback ( CallbackID ID )

BasicBlock

ConstantDataSequential

EraseFromParent

Instruction

Iterator for Instructions in a `BasicBlock.

/ \Returns an sandboxir::Instruction & when derereferenced. class BBIterator { public: using difference_type = std::ptrdiff_t; using value_type = Instruction; using pointer = value_type *; using reference = value_type &; using iterator_category = std::bidirectional_iterator_tag;

private: llvm::BasicBlock *BB; llvm::BasicBlock::iterator It; Context *Ctx; LLVM_ABI pointer getInstr(llvm::BasicBlock::iterator It) const;

public: BBIterator() : BB(nullptr), Ctx(nullptr) {} BBIterator(llvm::BasicBlock BB, llvm::BasicBlock::iterator It, Context *Ctx) : BB(BB), It(It), Ctx(Ctx) {} reference operator() const { return *getInstr(It); } LLVM_ABI BBIterator &operator++(); BBIterator operator++(int) { auto Copy = *this; ++*this; return Copy; } LLVM_ABI BBIterator &operator--(); BBIterator operator--(int) { auto Copy = *this; –*this; return Copy; } bool operator==(const BBIterator &Other) const { assert(Ctx == Other.Ctx && "BBIterators in different context!"); return It == Other.It; } bool operator!=(const BBIterator &Other) const { return !(*this == Other); } / \Returns the SBInstruction that corresponds to this iterator, or null if / the instruction is not found in the IR-to-SandboxIR tables. pointer get() const { return getInstr(It); } / \Returns the parent BB. LLVM_ABI BasicBlock *getNodeParent() const; };

/ Contains a list of sandboxir::Instruction's. class BasicBlock : public Value { / Builds a graph that contains all values in BB in their original form / i.e., no vectorization is taking place here. LLVM_ABI void buildBasicBlockFromLLVMIR(llvm::BasicBlock *LLVMBB); friend class Context; // For buildBasicBlockFromIR

Definition at line 120 of file Context.h.

References Instruction, LLVM_ABI, and Value.

Referenced by Instruction, runCreateInstrCallbacks(), runEraseInstrCallbacks(), runMoveInstrCallbacks(), and Utils.

IntegerType

IRSnapshotChecker

PointerType

Region

StructType

Type

User

Utils

Value

AllocaInst

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

AtomicCmpXchgInst

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

AtomicRMWInst

friend llvm::sandboxir::Context::AtomicRMWInst protected

BinaryOperator

friend llvm::sandboxir::Context::BinaryOperator protected

BranchInst

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

CallBrInst

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

CallInst

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

CastInst

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

CatchPadInst

friend llvm::sandboxir::Context::CatchPadInst protected

CatchReturnInst

friend llvm::sandboxir::Context::CatchReturnInst protected

CatchSwitchInst

friend llvm::sandboxir::Context::CatchSwitchInst protected

CleanupPadInst

friend llvm::sandboxir::Context::CleanupPadInst protected

CleanupReturnInst

friend llvm::sandboxir::Context::CleanupReturnInst protected

CmpInst

friend llvm::sandboxir::Context::CmpInst protected

CreateInstrCallbacks

EraseInstrCallbacks

ExtractElementInst

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

ExtractValueInst

friend llvm::sandboxir::Context::ExtractValueInst protected

FCmpInst

friend llvm::sandboxir::Context::FCmpInst protected

FenceInst

friend llvm::sandboxir::Context::FenceInst protected

FreezeInst

friend llvm::sandboxir::Context::FreezeInst protected

GetElementPtrInst

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

ICmpInst

friend llvm::sandboxir::Context::ICmpInst protected

InsertElementInst

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

InsertValueInst

friend llvm::sandboxir::Context::InsertValueInst protected

InvokeInst

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

IRTracker

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

LandingPadInst

friend llvm::sandboxir::Context::LandingPadInst protected

LLVMCtx

LLVMIRBuilder

LLVMModuleToModuleMap

LLVMTypeToTypeMap

LLVMValueToValueMap

LoadInst

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

MoveInstrCallbacks

NextCallbackID

PHINode

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

ResumeInst

friend llvm::sandboxir::Context::ResumeInst protected

ReturnInst

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

SelectInst

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

SetUseCallbacks

ShuffleVectorInst

friend llvm::sandboxir::Context::ShuffleVectorInst protected

StoreInst

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

SwitchInst

friend llvm::sandboxir::Context::SwitchInst protected

UnaryOperator

friend llvm::sandboxir::Context::UnaryOperator protected

UnreachableInst

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

VAArgInst

friend llvm::sandboxir::Context::VAArgInst protected

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