LLVM: include/llvm/SandboxIR/Context.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_SANDBOXIR_CONTEXT_H
10#define LLVM_SANDBOXIR_CONTEXT_H
11
19
20#include
21
22namespace llvm {
24
26class BBIterator;
32
34public:
35
37
39
40
42 std::function<void(Instruction *, const BBIterator &)>;
43
45
46
47
48
49 class CallbackID {
50 public:
51
52
55
56 private:
57
61 }
62
63 public:
67 };
68
69protected:
77
79
80
81
83
84
86
87
88
89
93
94
96
97
98
100
101
103
104
106
107
109
110
111
112
114
115
117
118
121
124
125
128
130
134
138
143
146
147
148#define DEF_CONST(ID, CLASS) friend class CLASS;
149#include "llvm/SandboxIR/Values.def"
150
151
152
154 friend class BasicBlock;
155
158
238
239public:
242
244
246
248
250
252
257
259
261
263 if (LLVMTy == nullptr)
264 return nullptr;
266 auto It = Pair.first;
267 if (Pair.second)
268 It->second = std::unique_ptr<Type, TypeDeleter>(new Type(LLVMTy, *this));
269 return It->second.get();
270 }
271
272
273
274
275
276
278
279
281
282
284
285
286
287
288
291
292
293
294
295
298
299
300
301
304
305
306
309};
310
311}
312
313
317
319 return CallbackID{ReprInfo::getEmptyKey()};
320 }
322 return CallbackID{ReprInfo::getTombstoneKey()};
323 }
325 return ReprInfo::getHashValue(ID.Val);
326 }
328 return ReprInfo::isEqual(LHS.Val, RHS.Val);
329 }
330};
331
332}
333
334#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the DenseMap class.
This file implements a map that provides insertion order iteration.
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.
An ID for a registered callback.
Definition Context.h:49
uint64_t ValTy
Definition Context.h:53
static constexpr ValTy InvalidVal
Definition Context.h:54
friend class Context
Definition Context.h:65
LLVM_ABI BasicBlock * createBasicBlock(llvm::BasicBlock *BB)
Create a sandboxir::BasicBlock for an existing LLVM IR BB.
std::function< void(Instruction *)> CreateInstrCallback
Definition Context.h:38
friend LandingPadInst
Definition Context.h:196
friend PHINode
Definition Context.h:229
LLVM_ABI GetElementPtrInst * createGetElementPtrInst(llvm::GetElementPtrInst *I)
MapVector< CallbackID, CreateInstrCallback > CreateInstrCallbacks
Callbacks called when an IR instruction is about to get created.
Definition Context.h:102
friend class Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition Context.h:71
friend UnreachableInst
Definition Context.h:231
friend class EraseFromParent
Definition Context.h:123
LLVM_ABI CallBrInst * createCallBrInst(llvm::CallBrInst *I)
LLVM_ABI Module * createModule(llvm::Module *LLVMM)
Create a sandboxir::Module corresponding to LLVMM.
IRBuilder< ConstantFolder > LLVMIRBuilder
Definition Context.h:156
friend CatchReturnInst
Definition Context.h:202
std::function< void(const Use &, Value *)> SetUseCallback
Definition Context.h:44
friend CatchSwitchInst
Definition Context.h:210
MapVector< CallbackID, EraseInstrCallback > EraseInstrCallbacks
Callbacks called when an IR instruction is about to get erased.
Definition Context.h:99
LLVM_ABI sandboxir::Value * getValue(llvm::Value *V) const
friend StoreInst
Definition Context.h:186
LLVM_ABI Argument * getOrCreateArgument(llvm::Argument *LLVMArg)
Get or create a sandboxir::Argument for an existing LLVM IR LLVMArg.
LLVM_ABI void unregisterSetUseCallback(CallbackID ID)
friend class IRSnapshotChecker
Definition Context.h:76
friend class User
Definition Context.h:144
LLVM_ABI ReturnInst * createReturnInst(llvm::ReturnInst *I)
LLVM_ABI void runEraseInstrCallbacks(Instruction *I)
friend AllocaInst
Definition Context.h:225
LLVM_ABI Module * getModule(llvm::Module *LLVMM) const
friend ExtractElementInst
Definition Context.h:172
LLVM_ABI VAArgInst * createVAArgInst(llvm::VAArgInst *SI)
auto & getLLVMIRBuilder()
Definition Context.h:157
LLVM_ABI CleanupReturnInst * createCleanupReturnInst(llvm::CleanupReturnInst *I)
LLVM_ABI AllocaInst * createAllocaInst(llvm::AllocaInst *I)
friend UnaryOperator
Definition Context.h:216
Type * getType(llvm::Type *LLVMTy)
Definition Context.h:262
LLVM_ABI void runCreateInstrCallbacks(Instruction *I)
LLVM_ABI AtomicRMWInst * createAtomicRMWInst(llvm::AtomicRMWInst *I)
LLVM_ABI InsertValueInst * createInsertValueInst(llvm::InsertValueInst *IVI)
friend ICmpInst
Definition Context.h:235
friend ExtractValueInst
Definition Context.h:178
const sandboxir::Value * getValue(const llvm::Value *V) const
Definition Context.h:254
DenseMap< llvm::Type *, std::unique_ptr< Type, TypeDeleter > > LLVMTypeToTypeMap
Maps LLVM Type to the corresonding sandboxir::Type.
Definition Context.h:95
void accept()
Convenience function for getTracker().accept()
Definition Context.h:251
friend CmpInst
Definition Context.h:233
LLVM_ABI FCmpInst * createFCmpInst(llvm::FCmpInst *I)
std::function< void(Instruction *)> EraseInstrCallback
Definition Context.h:36
friend class ConstantDataSequential
Definition Context.h:136
CallbackID::ValTy NextCallbackID
A counter used for assigning callback IDs during registration.
Definition Context.h:113
friend InsertValueInst
Definition Context.h:180
LLVM_ABI ExtractElementInst * createExtractElementInst(llvm::ExtractElementInst *EEI)
friend CastInst
Definition Context.h:227
LLVM_ABI Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
LLVM_ABI CallbackID registerSetUseCallback(SetUseCallback CB)
Register a callback that gets called when a Use gets set.
LLVM_ABI BranchInst * createBranchInst(llvm::BranchInst *I)
LLVM_ABI ShuffleVectorInst * createShuffleVectorInst(llvm::ShuffleVectorInst *SVI)
LLVM_ABI BinaryOperator * createBinaryOperator(llvm::BinaryOperator *I)
friend CatchPadInst
Definition Context.h:198
Tracker IRTracker
Definition Context.h:78
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition Context.h:120
LLVM_ABI Module * getOrCreateModule(llvm::Module *LLVMM)
LLVM_ABI LoadInst * createLoadInst(llvm::LoadInst *LI)
DenseMap< llvm::Value *, std::unique_ptr< Value > > LLVMValueToValueMap
Maps LLVM Value to the corresponding sandboxir::Value.
Definition Context.h:82
friend InvokeInst
Definition Context.h:192
LLVM_ABI FreezeInst * createFreezeInst(llvm::FreezeInst *SI)
LLVM_ABI PHINode * createPHINode(llvm::PHINode *I)
LLVM_ABI CallbackID registerCreateInstrCallback(CreateInstrCallback CB)
Register a callback that gets called right after a SandboxIR instruction is created.
LLVM_ABI Context(LLVMContext &LLVMCtx)
LLVM_ABI CatchPadInst * createCatchPadInst(llvm::CatchPadInst *I)
LLVM_ABI void clear()
Clears function-level state.
friend CleanupReturnInst
Definition Context.h:205
friend class IntegerType
Definition Context.h:73
friend CleanupPadInst
Definition Context.h:200
LLVM_ABI ICmpInst * createICmpInst(llvm::ICmpInst *I)
friend CallInst
Definition Context.h:190
friend ShuffleVectorInst
Definition Context.h:175
friend VAArgInst
Definition Context.h:160
friend class Region
Definition Context.h:75
MapVector< CallbackID, MoveInstrCallback > MoveInstrCallbacks
Callbacks called when an IR instruction is about to get moved.
Definition Context.h:105
friend SelectInst
Definition Context.h:166
LLVM_ABI std::unique_ptr< Value > detach(Value *V)
Remove SBV from all SandboxIR maps and stop owning it.
LLVM_ABI void unregisterCreateInstrCallback(CallbackID ID)
LLVM_ABI ExtractValueInst * createExtractValueInst(llvm::ExtractValueInst *IVI)
friend ResumeInst
Definition Context.h:212
void revert()
Convenience function for getTracker().revert()
Definition Context.h:249
friend ReturnInst
Definition Context.h:188
LLVM_ABI CastInst * createCastInst(llvm::CastInst *I)
DenseMap< llvm::Module *, std::unique_ptr< Module > > LLVMModuleToModuleMap
Maps an LLVM Module to the corresponding sandboxir::Module.
Definition Context.h:85
friend class PointerType
Definition Context.h:72
LLVM_ABI StoreInst * createStoreInst(llvm::StoreInst *SI)
friend class Utils
Definition Context.h:137
LLVM_ABI CatchReturnInst * createCatchReturnInst(llvm::CatchReturnInst *I)
friend BranchInst
Definition Context.h:182
LLVM_ABI CatchSwitchInst * createCatchSwitchInst(llvm::CatchSwitchInst *I)
friend AtomicRMWInst
Definition Context.h:220
std::function< void(Instruction *, const BBIterator &)> MoveInstrCallback
Definition Context.h:41
friend SwitchInst
Definition Context.h:214
friend FenceInst
Definition Context.h:164
friend FreezeInst
Definition Context.h:162
LLVM_ABI void unregisterMoveInstrCallback(CallbackID ID)
void save()
Convenience function for getTracker().save()
Definition Context.h:247
LLVM_ABI CleanupPadInst * createCleanupPadInst(llvm::CleanupPadInst *I)
Value * getOrCreateValue(llvm::Value *LLVMV)
Get or create a sandboxir::Value for an existing LLVM IR LLVMV.
Definition Context.h:131
LLVM_ABI FenceInst * createFenceInst(llvm::FenceInst *SI)
friend BinaryOperator
Definition Context.h:218
LLVM_ABI CallInst * createCallInst(llvm::CallInst *I)
LLVM_ABI SwitchInst * createSwitchInst(llvm::SwitchInst *I)
LLVM_ABI void runMoveInstrCallbacks(Instruction *I, const BBIterator &Where)
LLVM_ABI UnaryOperator * createUnaryOperator(llvm::UnaryOperator *I)
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 instruc...
LLVM_ABI InvokeInst * createInvokeInst(llvm::InvokeInst *I)
friend FCmpInst
Definition Context.h:237
LLVM_ABI Value * registerValue(std::unique_ptr< Value > &&VPtr)
Take ownership of VPtr and store it in LLVMValueToValueMap.
LLVM_ABI LandingPadInst * createLandingPadInst(llvm::LandingPadInst *I)
LLVM_ABI InsertElementInst * createInsertElementInst(llvm::InsertElementInst *IEI)
LLVM_ABI CmpInst * createCmpInst(llvm::CmpInst *I)
friend class StructType
Definition Context.h:74
LLVM_ABI Function * createFunction(llvm::Function *F)
Create a sandboxir::Function for an existing LLVM IR F, including all blocks and instructions.
LLVM_ABI SelectInst * createSelectInst(llvm::SelectInst *SI)
friend LoadInst
Definition Context.h:184
friend InsertElementInst
Definition Context.h:169
friend class Value
Definition Context.h:145
friend AtomicCmpXchgInst
Definition Context.h:223
LLVM_ABI ResumeInst * createResumeInst(llvm::ResumeInst *I)
LLVM_ABI void unregisterEraseInstrCallback(CallbackID ID)
LLVMContext & LLVMCtx
Definition Context.h:70
MapVector< CallbackID, SetUseCallback > SetUseCallbacks
Callbacks called when a Use gets its source set.
Definition Context.h:108
Tracker & getTracker()
Definition Context.h:245
friend class BasicBlock
Various leaf nodes.
Definition Context.h:154
LLVM_ABI CallbackID registerMoveInstrCallback(MoveInstrCallback CB)
Register a callback that gets called when a SandboxIR instruction is about to be moved.
LLVM_ABI UnreachableInst * createUnreachableInst(llvm::UnreachableInst *UI)
LLVM_ABI AtomicCmpXchgInst * createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I)
friend GetElementPtrInst
Definition Context.h:208
LLVM_ABI void runSetUseCallbacks(const Use &U, Value *NewSrc)
LLVM_ABI CallbackID registerEraseInstrCallback(EraseInstrCallback CB)
Register a callback that gets called when a SandboxIR instruction is about to be removed from its par...
friend CallBrInst
Definition Context.h:194
size_t getNumValues() const
\Returns the number of values registered with Context.
Definition Context.h:283
LLVM_ABI std::unique_ptr< Value > detachLLVMValue(llvm::Value *V)
Remove V from the maps and returns the unique_ptr.
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...
Represents a Def-use/Use-def edge in SandboxIR.
A SandboxIR Value has users. This is the base class.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
static unsigned getHashValue(const CallbackID &ID)
Definition Context.h:324
DenseMapInfo< CallbackID::ValTy > ReprInfo
Definition Context.h:316
static CallbackID getEmptyKey()
Definition Context.h:318
static CallbackID getTombstoneKey()
Definition Context.h:321
sandboxir::Context::CallbackID CallbackID
Definition Context.h:315
static bool isEqual(const CallbackID &LHS, const CallbackID &RHS)
Definition Context.h:327
An information struct used to provide DenseMap with the various necessary components for a given valu...
Type has a protected destructor to prohibit the user from managing the lifetime of the Type objects.
Definition Context.h:90
void operator()(Type *Ty)
Definition Context.h:91