LLVM 22.0.0git
llvm::sandboxir::Context Class Reference

#include "llvm/SandboxIR/Context.h"

Classes

class  CallbackID
 An ID for a registered callback. More...
struct  TypeDeleter
 Type has a protected destructor to prohibit the user from managing the lifetime of the Type objects. More...

Public Types

using EraseInstrCallback = std::function<void(Instruction *)>
using CreateInstrCallback = std::function<void(Instruction *)>
using MoveInstrCallback
using SetUseCallback = std::function<void(const Use &, Value *)>

Public Member Functions

LLVM_ABI Context (LLVMContext &LLVMCtx)
LLVM_ABI ~Context ()
LLVM_ABI void clear ()
 Clears function-level state.
TrackergetTracker ()
void save ()
 Convenience function for getTracker().save()
void revert ()
 Convenience function for getTracker().revert()
void accept ()
 Convenience function for getTracker().accept()
LLVM_ABI sandboxir::ValuegetValue (llvm::Value *V) const
const sandboxir::ValuegetValue (const llvm::Value *V) const
LLVM_ABI ModulegetModule (llvm::Module *LLVMM) const
LLVM_ABI ModulegetOrCreateModule (llvm::Module *LLVMM)
TypegetType (llvm::Type *LLVMTy)
LLVM_ABI FunctioncreateFunction (llvm::Function *F)
 Create a sandboxir::Function for an existing LLVM IR F, including all blocks and instructions.
LLVM_ABI ModulecreateModule (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< ValuedetachLLVMValue (llvm::Value *V)
 Remove V from the maps and returns the unique_ptr.
LLVM_ABI std::unique_ptr< Valuedetach (Value *V)
 Remove SBV from all SandboxIR maps and stop owning it.
LLVM_ABI ValueregisterValue (std::unique_ptr< Value > &&VPtr)
 Take ownership of VPtr and store it in LLVMValueToValueMap.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI ConstantgetOrCreateConstant (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 BasicBlockcreateBasicBlock (llvm::BasicBlock *BB)
 Create a sandboxir::BasicBlock for an existing LLVM IR BB.
auto & getLLVMIRBuilder ()
LLVM_ABI VAArgInstcreateVAArgInst (llvm::VAArgInst *SI)
LLVM_ABI FreezeInstcreateFreezeInst (llvm::FreezeInst *SI)
LLVM_ABI FenceInstcreateFenceInst (llvm::FenceInst *SI)
LLVM_ABI SelectInstcreateSelectInst (llvm::SelectInst *SI)
LLVM_ABI InsertElementInstcreateInsertElementInst (llvm::InsertElementInst *IEI)
LLVM_ABI ExtractElementInstcreateExtractElementInst (llvm::ExtractElementInst *EEI)
LLVM_ABI ShuffleVectorInstcreateShuffleVectorInst (llvm::ShuffleVectorInst *SVI)
LLVM_ABI ExtractValueInstcreateExtractValueInst (llvm::ExtractValueInst *IVI)
LLVM_ABI InsertValueInstcreateInsertValueInst (llvm::InsertValueInst *IVI)
LLVM_ABI BranchInstcreateBranchInst (llvm::BranchInst *I)
LLVM_ABI LoadInstcreateLoadInst (llvm::LoadInst *LI)
LLVM_ABI StoreInstcreateStoreInst (llvm::StoreInst *SI)
LLVM_ABI ReturnInstcreateReturnInst (llvm::ReturnInst *I)
LLVM_ABI CallInstcreateCallInst (llvm::CallInst *I)
LLVM_ABI InvokeInstcreateInvokeInst (llvm::InvokeInst *I)
LLVM_ABI CallBrInstcreateCallBrInst (llvm::CallBrInst *I)
LLVM_ABI LandingPadInstcreateLandingPadInst (llvm::LandingPadInst *I)
LLVM_ABI CatchPadInstcreateCatchPadInst (llvm::CatchPadInst *I)
LLVM_ABI CleanupPadInstcreateCleanupPadInst (llvm::CleanupPadInst *I)
LLVM_ABI CatchReturnInstcreateCatchReturnInst (llvm::CatchReturnInst *I)
LLVM_ABI CleanupReturnInstcreateCleanupReturnInst (llvm::CleanupReturnInst *I)
LLVM_ABI GetElementPtrInstcreateGetElementPtrInst (llvm::GetElementPtrInst *I)
LLVM_ABI CatchSwitchInstcreateCatchSwitchInst (llvm::CatchSwitchInst *I)
LLVM_ABI ResumeInstcreateResumeInst (llvm::ResumeInst *I)
LLVM_ABI SwitchInstcreateSwitchInst (llvm::SwitchInst *I)
LLVM_ABI UnaryOperatorcreateUnaryOperator (llvm::UnaryOperator *I)
LLVM_ABI BinaryOperatorcreateBinaryOperator (llvm::BinaryOperator *I)
LLVM_ABI AtomicRMWInstcreateAtomicRMWInst (llvm::AtomicRMWInst *I)
LLVM_ABI AtomicCmpXchgInstcreateAtomicCmpXchgInst (llvm::AtomicCmpXchgInst *I)
LLVM_ABI AllocaInstcreateAllocaInst (llvm::AllocaInst *I)
LLVM_ABI CastInstcreateCastInst (llvm::CastInst *I)
LLVM_ABI PHINodecreatePHINode (llvm::PHINode *I)
LLVM_ABI UnreachableInstcreateUnreachableInst (llvm::UnreachableInst *UI)
LLVM_ABI CmpInstcreateCmpInst (llvm::CmpInst *I)
LLVM_ABI ICmpInstcreateICmpInst (llvm::ICmpInst *I)
LLVM_ABI FCmpInstcreateFCmpInst (llvm::FCmpInst *I)

Protected Attributes

LLVMContextLLVMCtx
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, EraseInstrCallbackEraseInstrCallbacks
 Callbacks called when an IR instruction is about to get erased.
MapVector< CallbackID, CreateInstrCallbackCreateInstrCallbacks
 Callbacks called when an IR instruction is about to get created.
MapVector< CallbackID, MoveInstrCallbackMoveInstrCallbacks
 Callbacks called when an IR instruction is about to get moved.
MapVector< CallbackID, SetUseCallbackSetUseCallbacks
 Callbacks called when a Use gets its source set.
CallbackID::ValTy NextCallbackID = 1
 A counter used for assigning callback IDs during registration.
IRBuilder< ConstantFolderLLVMIRBuilder
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.

Detailed Description

Definition at line 33 of file Context.h.

Member Typedef Documentation

◆ CreateInstrCallback

Definition at line 38 of file Context.h.

◆ EraseInstrCallback

Definition at line 36 of file Context.h.

◆ MoveInstrCallback

Initial value:
std::function<void(Instruction *, const BBIterator &)>
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition Context.h:120

Definition at line 41 of file Context.h.

◆ SetUseCallback

using llvm::sandboxir::Context::SetUseCallback = std::function<void(const Use &, Value *)>

Definition at line 44 of file Context.h.

Constructor & Destructor Documentation

◆ Context()

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

Definition at line 636 of file Context.cpp.

References IRTracker, LLVMCtx, and LLVMIRBuilder.

◆ ~Context()

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

Definition at line 640 of file Context.cpp.

Member Function Documentation

◆ accept()

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

Convenience function for getTracker().accept()

Definition at line 251 of file Context.h.

References IRTracker.

◆ clear()

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

Clears function-level state.

Definition at line 642 of file Context.cpp.

References LLVMValueToValueMap.

◆ createAllocaInst()

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

Definition at line 609 of file Context.cpp.

References AllocaInst, llvm::cast(), I, and registerValue().

◆ createAtomicCmpXchgInst()

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

Definition at line 604 of file Context.cpp.

References AtomicCmpXchgInst, llvm::cast(), I, and registerValue().

◆ createAtomicRMWInst()

AtomicRMWInst * llvm::sandboxir::Context::createAtomicRMWInst ( llvm::AtomicRMWInst * I)
protected

Definition at line 599 of file Context.cpp.

References AtomicRMWInst, llvm::cast(), I, and registerValue().

◆ createBasicBlock()

BasicBlock * llvm::sandboxir::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 449 of file Context.cpp.

References assert(), BasicBlock, llvm::cast(), getValue(), and registerValue().

Referenced by createFunction().

◆ createBinaryOperator()

BinaryOperator * llvm::sandboxir::Context::createBinaryOperator ( llvm::BinaryOperator * I)
protected

Definition at line 595 of file Context.cpp.

References BinaryOperator, llvm::cast(), I, and registerValue().

◆ createBranchInst()

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

Definition at line 511 of file Context.cpp.

References BranchInst, llvm::cast(), and registerValue().

◆ createCallBrInst()

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

Definition at line 541 of file Context.cpp.

References CallBrInst, llvm::cast(), I, and registerValue().

◆ createCallInst()

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

Definition at line 531 of file Context.cpp.

References CallInst, llvm::cast(), I, and registerValue().

◆ createCastInst()

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

Definition at line 613 of file Context.cpp.

References llvm::cast(), CastInst, I, and registerValue().

◆ createCatchPadInst()

CatchPadInst * llvm::sandboxir::Context::createCatchPadInst ( llvm::CatchPadInst * I)
protected

Definition at line 555 of file Context.cpp.

References llvm::cast(), CatchPadInst, I, and registerValue().

◆ createCatchReturnInst()

CatchReturnInst * llvm::sandboxir::Context::createCatchReturnInst ( llvm::CatchReturnInst * I)
protected

Definition at line 563 of file Context.cpp.

References llvm::cast(), CatchReturnInst, I, and registerValue().

◆ createCatchSwitchInst()

CatchSwitchInst * llvm::sandboxir::Context::createCatchSwitchInst ( llvm::CatchSwitchInst * I)
protected

Definition at line 579 of file Context.cpp.

References llvm::cast(), CatchSwitchInst, I, and registerValue().

◆ createCleanupPadInst()

CleanupPadInst * llvm::sandboxir::Context::createCleanupPadInst ( llvm::CleanupPadInst * I)
protected

Definition at line 559 of file Context.cpp.

References llvm::cast(), CleanupPadInst, I, and registerValue().

◆ createCleanupReturnInst()

CleanupReturnInst * llvm::sandboxir::Context::createCleanupReturnInst ( llvm::CleanupReturnInst * I)
protected

Definition at line 568 of file Context.cpp.

References llvm::cast(), CleanupReturnInst, I, and registerValue().

◆ createCmpInst()

LLVM_ABI CmpInst * llvm::sandboxir::Context::createCmpInst ( llvm::CmpInst * I)
protected

References CmpInst, I, and LLVM_ABI.

◆ createExtractElementInst()

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

Definition at line 479 of file Context.cpp.

References llvm::cast(), ExtractElementInst, and registerValue().

◆ createExtractValueInst()

ExtractValueInst * llvm::sandboxir::Context::createExtractValueInst ( llvm::ExtractValueInst * IVI)
protected

Definition at line 499 of file Context.cpp.

References llvm::cast(), ExtractValueInst, and registerValue().

◆ createFCmpInst()

FCmpInst * llvm::sandboxir::Context::createFCmpInst ( llvm::FCmpInst * I)
protected

Definition at line 625 of file Context.cpp.

References llvm::cast(), FCmpInst, I, and registerValue().

◆ createFenceInst()

FenceInst * llvm::sandboxir::Context::createFenceInst ( llvm::FenceInst * SI)
protected

Definition at line 468 of file Context.cpp.

References llvm::cast(), FenceInst, and registerValue().

◆ createFreezeInst()

FreezeInst * llvm::sandboxir::Context::createFreezeInst ( llvm::FreezeInst * SI)
protected

Definition at line 463 of file Context.cpp.

References llvm::cast(), FreezeInst, and registerValue().

◆ createFunction()

Function * llvm::sandboxir::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. Note: this will not fully populate its parent module. The only globals that will be available are those used within the function.

Definition at line 664 of file Context.cpp.

References llvm::cast(), llvm::cast_or_null(), createBasicBlock(), detach(), F, getOrCreateArgument(), getOrCreateModule(), getValue(), and registerValue().

Referenced by createModule().

◆ createGetElementPtrInst()

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

Definition at line 574 of file Context.cpp.

References llvm::cast(), GetElementPtrInst, I, and registerValue().

◆ createICmpInst()

ICmpInst * llvm::sandboxir::Context::createICmpInst ( llvm::ICmpInst * I)
protected

Definition at line 621 of file Context.cpp.

References llvm::cast(), I, ICmpInst, and registerValue().

◆ createInsertElementInst()

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

Definition at line 486 of file Context.cpp.

References llvm::cast(), InsertElementInst, and registerValue().

◆ createInsertValueInst()

InsertValueInst * llvm::sandboxir::Context::createInsertValueInst ( llvm::InsertValueInst * IVI)
protected

Definition at line 505 of file Context.cpp.

References llvm::cast(), InsertValueInst, and registerValue().

◆ createInvokeInst()

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

Definition at line 536 of file Context.cpp.

References llvm::cast(), I, InvokeInst, and registerValue().

◆ createLandingPadInst()

LandingPadInst * llvm::sandboxir::Context::createLandingPadInst ( llvm::LandingPadInst * I)
protected

Definition at line 551 of file Context.cpp.

References llvm::cast(), I, LandingPadInst, and registerValue().

◆ createLoadInst()

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

Definition at line 516 of file Context.cpp.

References llvm::cast(), LoadInst, and registerValue().

◆ createModule()

Module * llvm::sandboxir::Context::createModule ( llvm::Module * LLVMM)

◆ createPHINode()

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

Definition at line 617 of file Context.cpp.

References llvm::cast(), I, PHINode, and registerValue().

◆ createResumeInst()

ResumeInst * llvm::sandboxir::Context::createResumeInst ( llvm::ResumeInst * I)
protected

Definition at line 583 of file Context.cpp.

References llvm::cast(), I, registerValue(), and ResumeInst.

◆ createReturnInst()

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

Definition at line 526 of file Context.cpp.

References llvm::cast(), I, registerValue(), and ReturnInst.

◆ createSelectInst()

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

Definition at line 473 of file Context.cpp.

References llvm::cast(), registerValue(), and SelectInst.

◆ createShuffleVectorInst()

ShuffleVectorInst * llvm::sandboxir::Context::createShuffleVectorInst ( llvm::ShuffleVectorInst * SVI)
protected

Definition at line 493 of file Context.cpp.

References llvm::cast(), registerValue(), and ShuffleVectorInst.

◆ createStoreInst()

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

Definition at line 521 of file Context.cpp.

References llvm::cast(), registerValue(), and StoreInst.

◆ createSwitchInst()

SwitchInst * llvm::sandboxir::Context::createSwitchInst ( llvm::SwitchInst * I)
protected

Definition at line 587 of file Context.cpp.

References llvm::cast(), I, registerValue(), and SwitchInst.

◆ createUnaryOperator()

UnaryOperator * llvm::sandboxir::Context::createUnaryOperator ( llvm::UnaryOperator * I)
protected

Definition at line 591 of file Context.cpp.

References llvm::cast(), I, registerValue(), and UnaryOperator.

◆ createUnreachableInst()

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

Definition at line 546 of file Context.cpp.

References llvm::cast(), registerValue(), and UnreachableInst.

◆ createVAArgInst()

VAArgInst * llvm::sandboxir::Context::createVAArgInst ( llvm::VAArgInst * SI)
protected

Definition at line 458 of file Context.cpp.

References llvm::cast(), registerValue(), and VAArgInst.

◆ detach()

std::unique_ptr< Value > llvm::sandboxir::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 28 of file Context.cpp.

References assert(), detachLLVMValue(), and Value.

Referenced by createFunction().

◆ detachLLVMValue()

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

Remove V from the maps and returns the unique_ptr.

Definition at line 17 of file Context.cpp.

References LLVMValueToValueMap.

Referenced by detach().

◆ getLLVMIRBuilder()

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

Definition at line 157 of file Context.h.

References LLVMIRBuilder.

◆ getModule()

Module * llvm::sandboxir::Context::getModule ( llvm::Module * LLVMM) const

Definition at line 648 of file Context.cpp.

References LLVMModuleToModuleMap.

◆ getNumValues()

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

\Returns the number of values registered with Context.

Definition at line 283 of file Context.h.

References LLVMValueToValueMap.

◆ getOrCreateArgument()

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

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

Definition at line 435 of file Context.cpp.

References llvm::cast(), and LLVMValueToValueMap.

Referenced by createFunction().

◆ getOrCreateConstant()

◆ getOrCreateModule()

Module * llvm::sandboxir::Context::getOrCreateModule ( llvm::Module * LLVMM)

Definition at line 655 of file Context.cpp.

References LLVMModuleToModuleMap, and Module.

Referenced by createFunction(), and createModule().

◆ 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 131 of file Context.h.

References getOrCreateValueInternal(), and Value.

Referenced by createModule(), and llvm::sandboxir::Utils::getMemInstructionBase().

◆ getOrCreateValueInternal()

◆ getTracker()

◆ getType()

◆ getValue() [1/2]

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

Definition at line 254 of file Context.h.

References getValue().

◆ getValue() [2/2]

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

◆ registerCreateInstrCallback()

Context::CallbackID llvm::sandboxir::Context::registerCreateInstrCallback ( CreateInstrCallback CB)

Register a callback that gets called right after a SandboxIR instruction is created.

Note that this will also be called when reverting the removal of an instruction. \Returns a callback ID for later deregistration.

Definition at line 742 of file Context.cpp.

References assert(), CreateInstrCallbacks, llvm::sandboxir::MaxRegisteredCallbacks, and NextCallbackID.

◆ registerEraseInstrCallback()

Context::CallbackID llvm::sandboxir::Context::registerEraseInstrCallback ( EraseInstrCallback CB)

Register a callback that gets called when a SandboxIR instruction is about to be removed from its parent.

Note that this will also be called when reverting the creation of an instruction. \Returns a callback ID for later deregistration.

Definition at line 728 of file Context.cpp.

References assert(), EraseInstrCallbacks, llvm::sandboxir::MaxRegisteredCallbacks, and NextCallbackID.

◆ registerMoveInstrCallback()

Context::CallbackID llvm::sandboxir::Context::registerMoveInstrCallback ( MoveInstrCallback CB)

Register a callback that gets called when a SandboxIR instruction is about to be moved.

Note that this will also be called when reverting a move. \Returns a callback ID for later deregistration.

Definition at line 755 of file Context.cpp.

References assert(), llvm::sandboxir::MaxRegisteredCallbacks, MoveInstrCallbacks, and NextCallbackID.

◆ registerSetUseCallback()

Context::CallbackID llvm::sandboxir::Context::registerSetUseCallback ( SetUseCallback CB)

Register a callback that gets called when a Use gets set.

\Returns a callback ID for later deregistration.

Definition at line 768 of file Context.cpp.

References assert(), llvm::sandboxir::MaxRegisteredCallbacks, NextCallbackID, and SetUseCallbacks.

◆ registerValue()

◆ revert()

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

Convenience function for getTracker().revert()

Definition at line 249 of file Context.h.

References IRTracker.

◆ runCreateInstrCallbacks()

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

Definition at line 708 of file Context.cpp.

References CreateInstrCallbacks, I, and Instruction.

Referenced by registerValue().

◆ runEraseInstrCallbacks()

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

Definition at line 703 of file Context.cpp.

References EraseInstrCallbacks, I, and Instruction.

◆ runMoveInstrCallbacks()

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

Definition at line 713 of file Context.cpp.

References I, Instruction, and MoveInstrCallbacks.

◆ runSetUseCallbacks()

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

Definition at line 718 of file Context.cpp.

References SetUseCallbacks, and Value.

◆ save()

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

Convenience function for getTracker().save()

Definition at line 247 of file Context.h.

References IRTracker.

Referenced by llvm::sandboxir::TransactionSave::runOnRegion().

◆ unregisterCreateInstrCallback()

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

Definition at line 749 of file Context.cpp.

References assert(), and CreateInstrCallbacks.

◆ unregisterEraseInstrCallback()

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

Definition at line 735 of file Context.cpp.

References assert(), and EraseInstrCallbacks.

◆ unregisterMoveInstrCallback()

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

Definition at line 762 of file Context.cpp.

References assert(), and MoveInstrCallbacks.

◆ unregisterSetUseCallback()

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

Definition at line 775 of file Context.cpp.

References assert(), and SetUseCallbacks.

◆ BasicBlock

friend class BasicBlock
friend

Various leaf nodes.

Definition at line 154 of file Context.h.

References BasicBlock.

Referenced by BasicBlock, and createBasicBlock().

◆ ConstantDataSequential

friend class ConstantDataSequential
friend

Definition at line 136 of file Context.h.

References ConstantDataSequential.

Referenced by ConstantDataSequential.

◆ EraseFromParent

friend class EraseFromParent
friend

Definition at line 123 of file Context.h.

References EraseFromParent, LLVM_ABI, and Value.

Referenced by EraseFromParent.

◆ Instruction

friend class Instruction
friend

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 <em>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

friend class IntegerType
friend

Definition at line 73 of file Context.h.

References IntegerType.

Referenced by IntegerType.

◆ IRSnapshotChecker

friend class IRSnapshotChecker
friend

Definition at line 76 of file Context.h.

References IRSnapshotChecker.

Referenced by IRSnapshotChecker.

◆ PointerType

friend class PointerType
friend

Definition at line 72 of file Context.h.

References PointerType.

Referenced by PointerType.

◆ Region

friend class Region
friend

Definition at line 75 of file Context.h.

References Region.

Referenced by Region.

◆ StructType

friend class StructType
friend

Definition at line 74 of file Context.h.

References StructType.

Referenced by StructType.

◆ Type

friend class Type
friend

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.

The types map onto corresponding union members of the Object struct.

Definition at line 71 of file Context.h.

References Type.

Referenced by getType(), llvm::sandboxir::Context::TypeDeleter::operator()(), and Type.

◆ User

friend class User
friend

Definition at line 144 of file Context.h.

References User.

Referenced by User.

◆ Utils

friend class Utils
friend

Definition at line 137 of file Context.h.

References I, Instruction, LLVM_ABI, Utils, and Value.

Referenced by Utils.

◆ Value

Member Data Documentation

◆ AllocaInst

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

Definition at line 225 of file Context.h.

Referenced by createAllocaInst(), and getOrCreateValueInternal().

◆ AtomicCmpXchgInst

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

Definition at line 223 of file Context.h.

Referenced by createAtomicCmpXchgInst(), and getOrCreateValueInternal().

◆ AtomicRMWInst

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

Definition at line 220 of file Context.h.

Referenced by createAtomicRMWInst(), and getOrCreateValueInternal().

◆ BinaryOperator

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

Definition at line 218 of file Context.h.

Referenced by createBinaryOperator(), and getOrCreateValueInternal().

◆ BranchInst

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

Definition at line 182 of file Context.h.

Referenced by createBranchInst(), and getOrCreateValueInternal().

◆ CallBrInst

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

Definition at line 194 of file Context.h.

Referenced by createCallBrInst(), and getOrCreateValueInternal().

◆ CallInst

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

Definition at line 190 of file Context.h.

Referenced by createCallInst(), and getOrCreateValueInternal().

◆ CastInst

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

Definition at line 227 of file Context.h.

Referenced by createCastInst(), and getOrCreateValueInternal().

◆ CatchPadInst

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

Definition at line 198 of file Context.h.

Referenced by createCatchPadInst(), and getOrCreateValueInternal().

◆ CatchReturnInst

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

Definition at line 202 of file Context.h.

Referenced by createCatchReturnInst(), and getOrCreateValueInternal().

◆ CatchSwitchInst

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

Definition at line 210 of file Context.h.

Referenced by createCatchSwitchInst(), and getOrCreateValueInternal().

◆ CleanupPadInst

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

Definition at line 200 of file Context.h.

Referenced by createCleanupPadInst(), and getOrCreateValueInternal().

◆ CleanupReturnInst

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

Definition at line 205 of file Context.h.

Referenced by createCleanupReturnInst(), and getOrCreateValueInternal().

◆ CmpInst

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

Definition at line 233 of file Context.h.

Referenced by createCmpInst().

◆ CreateInstrCallbacks

MapVector<CallbackID, CreateInstrCallback> llvm::sandboxir::Context::CreateInstrCallbacks
protected

Callbacks called when an IR instruction is about to get created.

Keys are used as IDs for deregistration.

Definition at line 102 of file Context.h.

Referenced by registerCreateInstrCallback(), runCreateInstrCallbacks(), and unregisterCreateInstrCallback().

◆ EraseInstrCallbacks

MapVector<CallbackID, EraseInstrCallback> llvm::sandboxir::Context::EraseInstrCallbacks
protected

Callbacks called when an IR instruction is about to get erased.

Keys are used as IDs for deregistration.

Definition at line 99 of file Context.h.

Referenced by registerEraseInstrCallback(), runEraseInstrCallbacks(), and unregisterEraseInstrCallback().

◆ ExtractElementInst

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

Definition at line 172 of file Context.h.

Referenced by createExtractElementInst(), and getOrCreateValueInternal().

◆ ExtractValueInst

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

Definition at line 178 of file Context.h.

Referenced by createExtractValueInst(), and getOrCreateValueInternal().

◆ FCmpInst

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

Definition at line 237 of file Context.h.

Referenced by createFCmpInst(), and getOrCreateValueInternal().

◆ FenceInst

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

Definition at line 164 of file Context.h.

Referenced by createFenceInst(), and getOrCreateValueInternal().

◆ FreezeInst

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

Definition at line 162 of file Context.h.

Referenced by createFreezeInst(), and getOrCreateValueInternal().

◆ GetElementPtrInst

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

Definition at line 208 of file Context.h.

Referenced by createGetElementPtrInst(), and getOrCreateValueInternal().

◆ ICmpInst

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

Definition at line 235 of file Context.h.

Referenced by createICmpInst(), and getOrCreateValueInternal().

◆ InsertElementInst

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

Definition at line 169 of file Context.h.

Referenced by createInsertElementInst(), and getOrCreateValueInternal().

◆ InsertValueInst

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

Definition at line 180 of file Context.h.

Referenced by createInsertValueInst(), and getOrCreateValueInternal().

◆ InvokeInst

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

Definition at line 192 of file Context.h.

Referenced by createInvokeInst(), and getOrCreateValueInternal().

◆ IRTracker

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

Definition at line 78 of file Context.h.

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

◆ LandingPadInst

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

Definition at line 196 of file Context.h.

Referenced by createLandingPadInst(), and getOrCreateValueInternal().

◆ LLVMCtx

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

Definition at line 70 of file Context.h.

Referenced by Context(), and llvm::sandboxir::CmpInst::makeCmpResultType().

◆ LLVMIRBuilder

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

Definition at line 156 of file Context.h.

Referenced by Context(), and getLLVMIRBuilder().

◆ LLVMModuleToModuleMap

DenseMap<llvm::Module *, std::unique_ptr<Module> > llvm::sandboxir::Context::LLVMModuleToModuleMap
protected

Maps an LLVM Module to the corresponding sandboxir::Module.

Definition at line 85 of file Context.h.

Referenced by getModule(), and getOrCreateModule().

◆ LLVMTypeToTypeMap

DenseMap<llvm::Type *, std::unique_ptr<Type, TypeDeleter> > llvm::sandboxir::Context::LLVMTypeToTypeMap
protected

Maps LLVM Type to the corresonding sandboxir::Type.

Owns all Sandbox IR Type objects.

Definition at line 95 of file Context.h.

Referenced by getType().

◆ LLVMValueToValueMap

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

Maps LLVM Value to the corresponding sandboxir::Value.

Owns all SandboxIR objects.

Definition at line 82 of file Context.h.

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

◆ LoadInst

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

Definition at line 184 of file Context.h.

Referenced by createLoadInst(), and getOrCreateValueInternal().

◆ MoveInstrCallbacks

MapVector<CallbackID, MoveInstrCallback> llvm::sandboxir::Context::MoveInstrCallbacks
protected

Callbacks called when an IR instruction is about to get moved.

Keys are used as IDs for deregistration.

Definition at line 105 of file Context.h.

Referenced by registerMoveInstrCallback(), runMoveInstrCallbacks(), and unregisterMoveInstrCallback().

◆ NextCallbackID

CallbackID::ValTy llvm::sandboxir::Context::NextCallbackID = 1
protected

A counter used for assigning callback IDs during registration.

The same counter is used for all kinds of callbacks so we can detect mismatched registration/deregistration.

Definition at line 113 of file Context.h.

Referenced by registerCreateInstrCallback(), registerEraseInstrCallback(), registerMoveInstrCallback(), and registerSetUseCallback().

◆ PHINode

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

Definition at line 229 of file Context.h.

Referenced by createPHINode(), and getOrCreateValueInternal().

◆ ResumeInst

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

Definition at line 212 of file Context.h.

Referenced by createResumeInst(), and getOrCreateValueInternal().

◆ ReturnInst

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

Definition at line 188 of file Context.h.

Referenced by createReturnInst(), and getOrCreateValueInternal().

◆ SelectInst

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

Definition at line 166 of file Context.h.

Referenced by createSelectInst(), and getOrCreateValueInternal().

◆ SetUseCallbacks

MapVector<CallbackID, SetUseCallback> llvm::sandboxir::Context::SetUseCallbacks
protected

Callbacks called when a Use gets its source set.

Keys are used as IDs for deregistration.

Definition at line 108 of file Context.h.

Referenced by registerSetUseCallback(), runSetUseCallbacks(), and unregisterSetUseCallback().

◆ ShuffleVectorInst

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

Definition at line 175 of file Context.h.

Referenced by createShuffleVectorInst(), and getOrCreateValueInternal().

◆ StoreInst

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

Definition at line 186 of file Context.h.

Referenced by createStoreInst(), and getOrCreateValueInternal().

◆ SwitchInst

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

Definition at line 214 of file Context.h.

Referenced by createSwitchInst(), and getOrCreateValueInternal().

◆ UnaryOperator

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

Definition at line 216 of file Context.h.

Referenced by createUnaryOperator(), and getOrCreateValueInternal().

◆ UnreachableInst

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

Definition at line 231 of file Context.h.

Referenced by createUnreachableInst(), and getOrCreateValueInternal().

◆ VAArgInst

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

Definition at line 160 of file Context.h.

Referenced by createVAArgInst(), and getOrCreateValueInternal().


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