9#ifndef LLVM_SANDBOXIR_CONTEXT_H
10#define LLVM_SANDBOXIR_CONTEXT_H
115#define DEF_CONST(ID, CLASS) friend class CLASS;
116#include "llvm/SandboxIR/Values.def"
221 if (LLVMTy ==
nullptr)
224 auto It = Pair.first;
226 It->second = std::unique_ptr<Type, TypeDeleter>(
new Type(LLVMTy, *
this));
227 return It->second.get();
This file defines the DenseMap class.
Machine Check Debug Module
This file implements a map that provides insertion order iteration.
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
This file defines the SmallVector class.
an instruction to allocate memory on the stack
This class represents an incoming formal argument to a Function.
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
This class represents a function call, abstracting a target machine's calling convention.
This is the base class for all instructions that perform data casts.
This class is the base class for the comparison instructions.
This is an important base class in LLVM.
This instruction compares its operands according to the predicate given to the constructor.
An instruction for ordering other memory operations.
This class represents a freeze function that returns random concrete value if an operand is either a ...
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
This instruction compares its operands according to the predicate given to the constructor.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This instruction inserts a single (scalar) element into a VectorType value.
This instruction inserts a struct field of array element value into an aggregate value.
This is an important class for using LLVM in a threaded context.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
An instruction for reading from memory.
This class implements a map that also provides access to all stored values in a deterministic order.
A Module instance is used to store all the information related to an LLVM module.
Resume the propagation of an exception.
Return a value (possibly void), from a function.
This class represents the LLVM 'select' instruction.
This instruction constructs a fixed permutation of two input vectors.
An instruction for storing to memory.
The instances of the Type class are immutable: once they are created, they are never changed.
This function has undefined behavior.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
Argument of a sandboxir::Function.
Iterator for Instructions in a `BasicBlock.
Contains a list of sandboxir::Instruction's.
BasicBlock * createBasicBlock(llvm::BasicBlock *BB)
Create a sandboxir::BasicBlock for an existing LLVM IR BB.
std::function< void(Instruction *)> CreateInstrCallback
GetElementPtrInst * createGetElementPtrInst(llvm::GetElementPtrInst *I)
MapVector< CallbackID, CreateInstrCallback > CreateInstrCallbacks
Callbacks called when an IR instruction is about to get created.
friend class Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
CmpInst * createCmpInst(llvm::CmpInst *I)
CallBrInst * createCallBrInst(llvm::CallBrInst *I)
Module * createModule(llvm::Module *LLVMM)
Create a sandboxir::Module corresponding to LLVMM.
IRBuilder< ConstantFolder > LLVMIRBuilder
MapVector< CallbackID, EraseInstrCallback > EraseInstrCallbacks
Callbacks called when an IR instruction is about to get erased.
sandboxir::Value * getValue(llvm::Value *V) const
Argument * getOrCreateArgument(llvm::Argument *LLVMArg)
Get or create a sandboxir::Argument for an existing LLVM IR LLVMArg.
ReturnInst * createReturnInst(llvm::ReturnInst *I)
void runEraseInstrCallbacks(Instruction *I)
Module * getModule(llvm::Module *LLVMM) const
friend ExtractElementInst
VAArgInst * createVAArgInst(llvm::VAArgInst *SI)
auto & getLLVMIRBuilder()
CleanupReturnInst * createCleanupReturnInst(llvm::CleanupReturnInst *I)
AllocaInst * createAllocaInst(llvm::AllocaInst *I)
Type * getType(llvm::Type *LLVMTy)
void runCreateInstrCallbacks(Instruction *I)
AtomicRMWInst * createAtomicRMWInst(llvm::AtomicRMWInst *I)
InsertValueInst * createInsertValueInst(llvm::InsertValueInst *IVI)
const sandboxir::Value * getValue(const llvm::Value *V) const
DenseMap< llvm::Type *, std::unique_ptr< Type, TypeDeleter > > LLVMTypeToTypeMap
Maps LLVM Type to the corresonding sandboxir::Type.
void accept()
Convenience function for getTracker().accept()
FCmpInst * createFCmpInst(llvm::FCmpInst *I)
std::function< void(Instruction *)> EraseInstrCallback
std::function< void(Instruction *, const BBIterator &)> MoveInstrCallback
ExtractElementInst * createExtractElementInst(llvm::ExtractElementInst *EEI)
Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
BranchInst * createBranchInst(llvm::BranchInst *I)
ShuffleVectorInst * createShuffleVectorInst(llvm::ShuffleVectorInst *SVI)
BinaryOperator * createBinaryOperator(llvm::BinaryOperator *I)
Module * getOrCreateModule(llvm::Module *LLVMM)
LoadInst * createLoadInst(llvm::LoadInst *LI)
DenseMap< llvm::Value *, std::unique_ptr< Value > > LLVMValueToValueMap
Maps LLVM Value to the corresponding sandboxir::Value.
FreezeInst * createFreezeInst(llvm::FreezeInst *SI)
PHINode * createPHINode(llvm::PHINode *I)
CallbackID registerCreateInstrCallback(CreateInstrCallback CB)
Register a callback that gets called right after a SandboxIR instruction is created.
CatchPadInst * createCatchPadInst(llvm::CatchPadInst *I)
ICmpInst * createICmpInst(llvm::ICmpInst *I)
MapVector< CallbackID, MoveInstrCallback > MoveInstrCallbacks
Callbacks called when an IR instruction is about to get moved.
std::unique_ptr< Value > detach(Value *V)
Remove SBV from all SandboxIR maps and stop owning it.
void unregisterCreateInstrCallback(CallbackID ID)
ExtractValueInst * createExtractValueInst(llvm::ExtractValueInst *IVI)
void revert()
Convenience function for getTracker().revert()
uint64_t CallbackID
An ID for a registered callback.
CastInst * createCastInst(llvm::CastInst *I)
DenseMap< llvm::Module *, std::unique_ptr< Module > > LLVMModuleToModuleMap
Maps an LLVM Module to the corresponding sandboxir::Module.
CallbackID NextCallbackID
A counter used for assigning callback IDs during registration.
StoreInst * createStoreInst(llvm::StoreInst *SI)
CatchReturnInst * createCatchReturnInst(llvm::CatchReturnInst *I)
CatchSwitchInst * createCatchSwitchInst(llvm::CatchSwitchInst *I)
void unregisterMoveInstrCallback(CallbackID ID)
void save()
Convenience function for getTracker().save()
CleanupPadInst * createCleanupPadInst(llvm::CleanupPadInst *I)
Value * getOrCreateValue(llvm::Value *LLVMV)
Get or create a sandboxir::Value for an existing LLVM IR LLVMV.
FenceInst * createFenceInst(llvm::FenceInst *SI)
CallInst * createCallInst(llvm::CallInst *I)
SwitchInst * createSwitchInst(llvm::SwitchInst *I)
void runMoveInstrCallbacks(Instruction *I, const BBIterator &Where)
UnaryOperator * createUnaryOperator(llvm::UnaryOperator *I)
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 instruc...
InvokeInst * createInvokeInst(llvm::InvokeInst *I)
Value * registerValue(std::unique_ptr< Value > &&VPtr)
Take ownership of VPtr and store it in LLVMValueToValueMap.
LandingPadInst * createLandingPadInst(llvm::LandingPadInst *I)
InsertElementInst * createInsertElementInst(llvm::InsertElementInst *IEI)
Function * createFunction(llvm::Function *F)
Create a sandboxir::Function for an existing LLVM IR F, including all blocks and instructions.
SelectInst * createSelectInst(llvm::SelectInst *SI)
ResumeInst * createResumeInst(llvm::ResumeInst *I)
void unregisterEraseInstrCallback(CallbackID ID)
friend class BasicBlock
Various leaf nodes.
CallbackID registerMoveInstrCallback(MoveInstrCallback CB)
Register a callback that gets called when a SandboxIR instruction is about to be moved.
UnreachableInst * createUnreachableInst(llvm::UnreachableInst *UI)
AtomicCmpXchgInst * createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I)
CallbackID registerEraseInstrCallback(EraseInstrCallback CB)
Register a callback that gets called when a SandboxIR instruction is about to be removed from its par...
size_t getNumValues() const
\Returns the number of values registered with Context.
std::unique_ptr< Value > detachLLVMValue(llvm::Value *V)
Remove V from the maps and returns the unique_ptr.
A class that saves hashes and textual IR snapshots of functions in a SandboxIR Context,...
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
Class to represent integer types.
In SandboxIR the Module is mainly used to access the list of global objects.
The main job of the Region is to point to new instructions generated by vectorization passes.
The tracker collects all the change objects and implements the main API for saving / reverting / acce...
void revert()
Stops tracking and reverts to saved state.
void save()
Turns on IR tracking.
void accept()
Stops tracking and accept changes.
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
A SandboxIR Value has users. This is the base class.
Type has a protected destructor to prohibit the user from managing the lifetime of the Type objects.
void operator()(Type *Ty)