LLVM 24.0.0git
Context.h
Go to the documentation of this file.
1//===- Context.h ------------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_SANDBOXIR_CONTEXT_H
10#define LLVM_SANDBOXIR_CONTEXT_H
11
12#include "llvm/ADT/DenseMap.h"
13#include "llvm/ADT/MapVector.h"
15#include "llvm/IR/LLVMContext.h"
17#include "llvm/SandboxIR/Type.h"
19
20#include <cstdint>
21
22namespace llvm {
23namespace sandboxir {
24
25class Argument;
26class BBIterator;
27class Constant;
28class Module;
29class Region;
30class Value;
31class Use;
32
34public:
35 // A EraseInstrCallback receives the instruction about to be erased.
36 using EraseInstrCallback = std::function<void(Instruction *)>;
37 // A CreateInstrCallback receives the instruction about to be created.
38 using CreateInstrCallback = std::function<void(Instruction *)>;
39 // A MoveInstrCallback receives the instruction about to be moved, the
40 // destination BB and an iterator pointing to the insertion position.
42 std::function<void(Instruction *, const BBIterator &)>;
43 // A SetUseCallback receives the Use that is about to get its source set.
44 using SetUseCallback = std::function<void(const Use &, Value *)>;
45
46 /// An ID for a registered callback. Used for deregistration. A dedicated type
47 /// is employed so as to keep IDs opaque to the end user; only Context should
48 /// deal with its underlying representation.
49 class CallbackID {
50 public:
51 // Uses a 64-bit integer so we don't have to worry about the unlikely case
52 // of overflowing a 32-bit counter.
53 using ValTy = uint64_t;
54 static constexpr ValTy InvalidVal = 0;
55
56 private:
57 // Default initialization results in an invalid ID.
58 ValTy Val = InvalidVal;
59 explicit CallbackID(ValTy Val) : Val{Val} {
60 assert(Val != InvalidVal && "newly-created ID is invalid!");
61 }
62
63 public:
64 CallbackID() = default;
65 bool operator==(const CallbackID &Other) const { return Val == Other.Val; }
66 friend class Context;
67 friend struct DenseMapInfo<CallbackID>;
68 };
69
70protected:
72 friend class Type; // For LLVMCtx.
73 friend class PointerType; // For LLVMCtx.
74 friend class IntegerType; // For LLVMCtx.
75 friend class ByteType; // For LLVMCtx.
76 friend class StructType; // For LLVMCtx.
77 friend class Region; // For LLVMCtx.
78 friend class IRSnapshotChecker; // To snapshot LLVMModuleToModuleMap.
79
81
82 /// Maps LLVM Value to the corresponding sandboxir::Value. Owns all
83 /// SandboxIR objects.
85
86 /// Maps an LLVM Module to the corresponding sandboxir::Module.
88
89 /// Type has a protected destructor to prohibit the user from managing the
90 /// lifetime of the Type objects. Context is friend of Type, and this custom
91 /// deleter can destroy Type.
92 struct TypeDeleter {
93 void operator()(Type *Ty) { delete Ty; }
94 };
95 /// Maps LLVM Type to the corresonding sandboxir::Type. Owns all Sandbox IR
96 /// Type objects.
98
99 template <typename FnT> struct CallbackEntry {
104 std::string CBName;
105 };
106 /// Callbacks called when an IR instruction is about to get erased. CallbackID
107 /// is used as an identifier for deregistration.
109 /// Callbacks called when an IR instruction is about to get created.
110 /// CallbackID is used as an identifier for deregistration.
112 /// Callbacks called when an IR instruction is about to get moved. CallbackID
113 /// is used as an identifier for deregistration.
115 /// Callbacks called when a Use gets its source set. CallbackID is used as an
116 /// identifier for deregistration.
118
119 /// A counter used for assigning callback IDs during registration. The same
120 /// counter is used for all kinds of callbacks so we can detect mismatched
121 /// registration/deregistration.
123
124 /// Remove \p V from the maps and returns the unique_ptr.
125 std::unique_ptr<Value> detachLLVMValue(llvm::Value *V);
126 /// Remove \p SBV from all SandboxIR maps and stop owning it. This effectively
127 /// detaches \p V from the underlying IR.
128 std::unique_ptr<Value> detach(Value *V);
129 friend class Instruction; // For detach().
130 /// Take ownership of VPtr and store it in `LLVMValueToValueMap`.
131 Value *registerValue(std::unique_ptr<Value> &&VPtr);
132 friend class EraseFromParent; // For registerValue().
133 /// This is the actual function that creates sandboxir values for \p V,
134 /// and among others handles all instruction types.
136 /// Get or create a sandboxir::Argument for an existing LLVM IR \p LLVMArg.
138 /// Get or create a sandboxir::Value for an existing LLVM IR \p LLVMV.
140 return getOrCreateValueInternal(LLVMV, 0);
141 }
142 /// Get or create a sandboxir::Constant from an existing LLVM IR \p LLVMC.
143 Constant *getOrCreateConstant(llvm::Constant *LLVMC);
144 friend class ConstantDataSequential; // For getOrCreateConstant().
145 friend class Utils; // For getMemoryBase
146
149 void runMoveInstrCallbacks(Instruction *I, const BBIterator &Where);
150 void runSetUseCallbacks(const Use &U, Value *NewSrc);
151
152 friend class User; // For runSetUseCallbacks().
153 friend class Value; // For runSetUseCallbacks().
154
155 // Friends for getOrCreateConstant().
156#define DEF_CONST(ID, CLASS) friend class CLASS;
157#include "llvm/SandboxIR/Values.def"
158
159 /// Create a sandboxir::BasicBlock for an existing LLVM IR \p BB. This will
160 /// also create all contents of the block.
161 BasicBlock *createBasicBlock(llvm::BasicBlock *BB);
162 friend class BasicBlock; // For getOrCreateValue().
163
165 friend VAArgInst; // For createVAArgInst()
167 friend FreezeInst; // For createFreezeInst()
169 friend FenceInst; // For createFenceInst()
171 friend SelectInst; // For createSelectInst()
173 friend InsertElementInst; // For createInsertElementInst()
175 friend ExtractElementInst; // For createExtractElementInst()
177 friend ShuffleVectorInst; // For createShuffleVectorInst()
179 friend ExtractValueInst; // For createExtractValueInst()
181 friend InsertValueInst; // For createInsertValueInst()
183 friend UncondBrInst; // For createUncondBrInst()
185 friend CondBrInst; // For createCondBrInst()
187 friend LoadInst; // For createLoadInst()
189 friend StoreInst; // For createStoreInst()
191 friend ReturnInst; // For createReturnInst()
193 friend CallInst; // For createCallInst()
195 friend InvokeInst; // For createInvokeInst()
197 friend CallBrInst; // For createCallBrInst()
199 friend LandingPadInst; // For createLandingPadInst()
201 friend CatchPadInst; // For createCatchPadInst()
203 friend CleanupPadInst; // For createCleanupPadInst()
205 friend CatchReturnInst; // For createCatchReturnInst()
207 friend CleanupReturnInst; // For createCleanupReturnInst()
209 friend GetElementPtrInst; // For createGetElementPtrInst()
211 friend CatchSwitchInst; // For createCatchSwitchInst()
213 friend ResumeInst; // For createResumeInst()
215 friend SwitchInst; // For createSwitchInst()
217 friend UnaryOperator; // For createUnaryOperator()
219 friend BinaryOperator; // For createBinaryOperator()
221 friend AtomicRMWInst; // For createAtomicRMWInst()
223 friend AtomicCmpXchgInst; // For createAtomicCmpXchgInst()
225 friend AllocaInst; // For createAllocaInst()
227 friend CastInst; // For createCastInst()
229 friend PHINode; // For createPHINode()
231 friend UnreachableInst; // For createUnreachableInst()
233 friend CmpInst; // For createCmpInst()
235 friend ICmpInst; // For createICmpInst()
237 friend FCmpInst; // For createFCmpInst()
238
239public:
241 Context(const Context &) = delete;
242 Context &operator=(const Context &) = delete;
243 virtual ~Context();
244 /// Clears function-level state.
245 void clear();
246
248 return LLVMCtx.getLibraryOptions();
249 }
251 /// Convenience function for `getTracker().save()`
252 void save() { IRTracker.save(); }
253 /// Convenience function for `getTracker().revert()`
254 void revert(bool RevertAll = false) { IRTracker.revert(RevertAll); }
255 /// Convenience function for `getTracker().accept()`
256 void accept(bool AcceptAll = false) { IRTracker.accept(AcceptAll); }
257
259 const sandboxir::Value *getValue(const llvm::Value *V) const {
260 return getValue(const_cast<llvm::Value *>(V));
261 }
262
263 Module *getModule(llvm::Module *LLVMM) const;
264
265 Module *getOrCreateModule(llvm::Module *LLVMM);
266
268 if (LLVMTy == nullptr)
269 return nullptr;
270 auto Pair = LLVMTypeToTypeMap.try_emplace(LLVMTy);
271 auto It = Pair.first;
272 if (Pair.second)
273 It->second = std::unique_ptr<Type, TypeDeleter>(new Type(LLVMTy, *this));
274 return It->second.get();
275 }
276
277 /// Create a sandboxir::Function for an existing LLVM IR \p F, including all
278 /// blocks and instructions.
279 /// This is the main API function for creating Sandbox IR.
280 /// Note: this will not fully populate its parent module. The only globals
281 /// that will be available are those used within the function.
282 Function *createFunction(llvm::Function *F);
283
284 /// Create a sandboxir::Module corresponding to \p LLVMM.
285 Module *createModule(llvm::Module *LLVMM);
286
287 /// \Returns the number of values registered with Context.
288 size_t getNumValues() const { return LLVMValueToValueMap.size(); }
289
290private:
291 // An arbitrary limit, to check for accidental misuse. We expect a small
292 // number of callbacks to be registered at a time, but we can increase this
293 // number if we discover we needed more.
294 [[maybe_unused]] static constexpr int MaxRegisteredCallbacks = 16;
295
296 template <typename CBT, typename CBVecT>
297 CallbackID registerCallbackCommon(CBT CB, StringRef CBName,
298 bool AllowDuplicateNames, CBVecT &CBVec,
299 std::optional<CallbackID> BeforeID) {
300 assert(CBVec.size() <= MaxRegisteredCallbacks &&
301 "EraseInstrCallbacks size limit exceeded");
302 assert((AllowDuplicateNames || none_of(CBVec,
303 [CBName](const auto &Entry) {
304 return Entry.CBName == CBName;
305 })) &&
306 "Callback with CBName already exists!");
307 auto BeforeIt = CBVec.end();
308 if (BeforeID) {
309 BeforeIt = find_if(CBVec, [BeforeID](const auto &Entry) {
310 return Entry.ID == *BeforeID;
311 });
312 assert(BeforeIt != CBVec.end() && "Not found!");
313 }
314 CallbackID ID{NextCallbackID++};
315 CBVec.insert(BeforeIt, CallbackEntry<CBT>(ID, std::move(CB), CBName));
316 return ID;
317 }
318
319public:
320 /// Register a callback that gets called when a SandboxIR instruction is about
321 /// to be removed from its parent. Note that this will also be called when
322 /// reverting the creation of an instruction.
323 /// If \p BeforeID is specified, CB will be ordered just before \p BeforeID,
324 /// so it will be called first once the callbacks get executed.
325 /// \Returns a callback ID for later deregistration.
326 /// \p CBName helps prevent multiple registrations with the same name. If this
327 /// is intentional you can set \p AllowDuplicateNames to true.
328 CallbackID
329 registerEraseInstrCallback(EraseInstrCallback CB, StringRef CBName,
330 bool AllowDuplicateNames = false,
331 std::optional<CallbackID> BeforeID = std::nullopt);
332 void unregisterEraseInstrCallback(CallbackID ID);
333
334 /// Register a callback that gets called right after a SandboxIR instruction
335 /// is created. Note that this will also be called when reverting the removal
336 /// of an instruction.
337 /// If \p BeforeID is specified, CB will be ordered just before \p BeforeID,
338 /// so it will be called first once the callbacks get executed.
339 /// \Returns a callback ID for later deregistration.
340 /// \p CBName helps prevent multiple registrations with the same name. If this
341 /// is intentional you can set \p AllowDuplicateNames to true.
342 CallbackID registerCreateInstrCallback(
343 CreateInstrCallback CB, StringRef CBName,
344 bool AllowDuplicateNames = false,
345 std::optional<CallbackID> BeforeID = std::nullopt);
346 void unregisterCreateInstrCallback(CallbackID ID);
347
348 /// Register a callback that gets called when a SandboxIR instruction is about
349 /// to be moved. Note that this will also be called when reverting a move.
350 /// If \p BeforeID is specified, CB will be ordered just before \p BeforeID,
351 /// so it will be called first once the callbacks get executed.
352 /// \Returns a callback ID for later deregistration.
353 /// \p CBName helps prevent multiple registrations with the same name. If this
354 /// is intentional you can set \p AllowDuplicateNames to true.
355 CallbackID
356 registerMoveInstrCallback(MoveInstrCallback CB, StringRef CBName,
357 bool AllowDuplicateNames = false,
358 std::optional<CallbackID> BeforeID = std::nullopt);
359 void unregisterMoveInstrCallback(CallbackID ID);
360
361 /// Register a callback that gets called when a Use gets set.
362 /// If \p BeforeID is specified, CB will be ordered just before \p BeforeID,
363 /// so it will be called first once the callbacks get executed.
364 /// \Returns a callback ID for later deregistration.
365 /// \p CBName helps prevent multiple registrations with the same name. If this
366 /// is intentional you can set \p AllowDuplicateNames to true.
367 CallbackID
368 registerSetUseCallback(SetUseCallback CB, StringRef CBName,
369 bool AllowDuplicateNames = false,
370 std::optional<CallbackID> BeforeID = std::nullopt);
371 void unregisterSetUseCallback(CallbackID ID);
372};
373
374} // namespace sandboxir
375
376// DenseMap info for CallbackIDs
377template <> struct DenseMapInfo<sandboxir::Context::CallbackID> {
380
381 static unsigned getHashValue(const CallbackID &ID) {
382 return ReprInfo::getHashValue(ID.Val);
383 }
384 static bool isEqual(const CallbackID &LHS, const CallbackID &RHS) {
385 return ReprInfo::isEqual(LHS.Val, RHS.Val);
386 }
387};
388
389} // namespace llvm
390
391#endif // LLVM_SANDBOXIR_CONTEXT_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
#define LLVM_ABI
Definition Compiler.h:211
This file defines the DenseMap class.
static constexpr Value * getValue(Ty &ValueOrUse)
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
This file implements a map that provides insertion order iteration.
This file defines the SmallVector class.
Value * RHS
Value * LHS
an instruction to allocate memory on the stack
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
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.
Definition BasicBlock.h:62
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.
Definition InstrTypes.h:512
This class is the base class for the comparison instructions.
Definition InstrTypes.h:728
Conditional Branch instruction.
This is an important base class in LLVM.
Definition Constant.h:44
This instruction extracts a single (scalar) element from a VectorType value.
This instruction extracts a struct member or array element value from an aggregate value.
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 instruction inserts a single (scalar) element into a VectorType value.
This instruction inserts a struct field of array element value into an aggregate value.
Invoke instruction.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:76
The landingpad instruction holds all of the information necessary to generate correct exception handl...
An instruction for reading from memory.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
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.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Multiway switch.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
Unconditional Branch instruction.
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.
Definition Value.h:75
Argument of a sandboxir::Function.
Definition Argument.h:18
An ID for a registered callback.
Definition Context.h:49
static constexpr ValTy InvalidVal
Definition Context.h:54
bool operator==(const CallbackID &Other) const
Definition Context.h:65
std::function< void(Instruction *)> CreateInstrCallback
Definition Context.h:38
GetElementPtrInst * createGetElementPtrInst(llvm::GetElementPtrInst *I)
Definition Context.cpp:585
friend class Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition Context.h:72
friend class EraseFromParent
Definition Context.h:132
CmpInst * createCmpInst(llvm::CmpInst *I)
CallBrInst * createCallBrInst(llvm::CallBrInst *I)
Definition Context.cpp:552
std::function< void(const Use &, Value *)> SetUseCallback
Definition Context.h:44
SmallVector< CallbackEntry< CreateInstrCallback > > CreateInstrCallbacks
Callbacks called when an IR instruction is about to get created.
Definition Context.h:111
Argument * getOrCreateArgument(llvm::Argument *LLVMArg)
Get or create a sandboxir::Argument for an existing LLVM IR LLVMArg.
Definition Context.cpp:441
void revert(bool RevertAll=false)
Convenience function for getTracker().revert()
Definition Context.h:254
friend class IRSnapshotChecker
Definition Context.h:78
Context & operator=(const Context &)=delete
ReturnInst * createReturnInst(llvm::ReturnInst *I)
Definition Context.cpp:537
UncondBrInst * createUncondBrInst(llvm::UncondBrInst *UBI)
Definition Context.cpp:517
void runEraseInstrCallbacks(Instruction *I)
Definition Context.cpp:712
SmallVector< CallbackEntry< EraseInstrCallback > > EraseInstrCallbacks
Callbacks called when an IR instruction is about to get erased.
Definition Context.h:108
VAArgInst * createVAArgInst(llvm::VAArgInst *SI)
Definition Context.cpp:464
CleanupReturnInst * createCleanupReturnInst(llvm::CleanupReturnInst *I)
Definition Context.cpp:579
void accept(bool AcceptAll=false)
Convenience function for getTracker().accept()
Definition Context.h:256
AllocaInst * createAllocaInst(llvm::AllocaInst *I)
Definition Context.cpp:620
Type * getType(llvm::Type *LLVMTy)
Definition Context.h:267
void runCreateInstrCallbacks(Instruction *I)
Definition Context.cpp:717
AtomicRMWInst * createAtomicRMWInst(llvm::AtomicRMWInst *I)
Definition Context.cpp:610
InsertValueInst * createInsertValueInst(llvm::InsertValueInst *IVI)
Definition Context.cpp:511
const sandboxir::Value * getValue(const llvm::Value *V) const
Definition Context.h:259
DenseMap< llvm::Type *, std::unique_ptr< Type, TypeDeleter > > LLVMTypeToTypeMap
Maps LLVM Type to the corresonding sandboxir::Type.
Definition Context.h:97
FCmpInst * createFCmpInst(llvm::FCmpInst *I)
Definition Context.cpp:636
std::function< void(Instruction *)> EraseInstrCallback
Definition Context.h:36
friend class ConstantDataSequential
Definition Context.h:144
CallbackID::ValTy NextCallbackID
A counter used for assigning callback IDs during registration.
Definition Context.h:122
ExtractElementInst * createExtractElementInst(llvm::ExtractElementInst *EEI)
Definition Context.cpp:485
ShuffleVectorInst * createShuffleVectorInst(llvm::ShuffleVectorInst *SVI)
Definition Context.cpp:499
BinaryOperator * createBinaryOperator(llvm::BinaryOperator *I)
Definition Context.cpp:606
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition Context.h:129
LoadInst * createLoadInst(llvm::LoadInst *LI)
Definition Context.cpp:527
DenseMap< llvm::Value *, std::unique_ptr< Value > > LLVMValueToValueMap
Maps LLVM Value to the corresponding sandboxir::Value.
Definition Context.h:84
FreezeInst * createFreezeInst(llvm::FreezeInst *SI)
Definition Context.cpp:469
PHINode * createPHINode(llvm::PHINode *I)
Definition Context.cpp:628
Context(LLVMContext &LLVMCtx)
Definition Context.cpp:647
CatchPadInst * createCatchPadInst(llvm::CatchPadInst *I)
Definition Context.cpp:566
void clear()
Clears function-level state.
Definition Context.cpp:651
CondBrInst * createCondBrInst(llvm::CondBrInst *CBI)
Definition Context.cpp:522
SmallVector< CallbackEntry< SetUseCallback > > SetUseCallbacks
Callbacks called when a Use gets its source set.
Definition Context.h:117
friend class IntegerType
Definition Context.h:74
ICmpInst * createICmpInst(llvm::ICmpInst *I)
Definition Context.cpp:632
friend class Region
Definition Context.h:77
Context(const Context &)=delete
std::unique_ptr< Value > detach(Value *V)
Remove SBV from all SandboxIR maps and stop owning it.
Definition Context.cpp:28
ExtractValueInst * createExtractValueInst(llvm::ExtractValueInst *IVI)
Definition Context.cpp:505
CastInst * createCastInst(llvm::CastInst *I)
Definition Context.cpp:624
DenseMap< llvm::Module *, std::unique_ptr< Module > > LLVMModuleToModuleMap
Maps an LLVM Module to the corresponding sandboxir::Module.
Definition Context.h:87
friend class PointerType
Definition Context.h:73
StoreInst * createStoreInst(llvm::StoreInst *SI)
Definition Context.cpp:532
CatchReturnInst * createCatchReturnInst(llvm::CatchReturnInst *I)
Definition Context.cpp:574
CatchSwitchInst * createCatchSwitchInst(llvm::CatchSwitchInst *I)
Definition Context.cpp:590
std::function< void(Instruction *, const BBIterator &)> MoveInstrCallback
Definition Context.h:41
void save()
Convenience function for getTracker().save()
Definition Context.h:252
CleanupPadInst * createCleanupPadInst(llvm::CleanupPadInst *I)
Definition Context.cpp:570
Value * getOrCreateValue(llvm::Value *LLVMV)
Get or create a sandboxir::Value for an existing LLVM IR LLVMV.
Definition Context.h:139
cl::LibraryOptionsContext & getLibraryOptions() const
Definition Context.h:247
FenceInst * createFenceInst(llvm::FenceInst *SI)
Definition Context.cpp:474
CallInst * createCallInst(llvm::CallInst *I)
Definition Context.cpp:542
SwitchInst * createSwitchInst(llvm::SwitchInst *I)
Definition Context.cpp:598
void runMoveInstrCallbacks(Instruction *I, const BBIterator &Where)
Definition Context.cpp:722
UnaryOperator * createUnaryOperator(llvm::UnaryOperator *I)
Definition Context.cpp:602
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...
Definition Context.cpp:56
InvokeInst * createInvokeInst(llvm::InvokeInst *I)
Definition Context.cpp:547
Value * registerValue(std::unique_ptr< Value > &&VPtr)
Take ownership of VPtr and store it in LLVMValueToValueMap.
Definition Context.cpp:35
LandingPadInst * createLandingPadInst(llvm::LandingPadInst *I)
Definition Context.cpp:562
InsertElementInst * createInsertElementInst(llvm::InsertElementInst *IEI)
Definition Context.cpp:492
friend class StructType
Definition Context.h:76
SelectInst * createSelectInst(llvm::SelectInst *SI)
Definition Context.cpp:479
SmallVector< CallbackEntry< MoveInstrCallback > > MoveInstrCallbacks
Callbacks called when an IR instruction is about to get moved.
Definition Context.h:114
friend class ByteType
Definition Context.h:75
ResumeInst * createResumeInst(llvm::ResumeInst *I)
Definition Context.cpp:594
LLVMContext & LLVMCtx
Definition Context.h:71
Tracker & getTracker()
Definition Context.h:250
friend class BasicBlock
Various leaf nodes.
Definition Context.h:162
UnreachableInst * createUnreachableInst(llvm::UnreachableInst *UI)
Definition Context.cpp:557
AtomicCmpXchgInst * createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I)
Definition Context.cpp:615
void runSetUseCallbacks(const Use &U, Value *NewSrc)
Definition Context.cpp:727
size_t getNumValues() const
\Returns the number of values registered with Context.
Definition Context.h:288
std::unique_ptr< Value > detachLLVMValue(llvm::Value *V)
Remove V from the maps and returns the unique_ptr.
Definition Context.cpp:17
In SandboxIR the Module is mainly used to access the list of global objects.
Definition Module.h:34
The tracker collects all the change objects and implements the main API for saving / reverting / acce...
Definition Tracker.h:450
Represents a Def-use/Use-def edge in SandboxIR.
Definition Use.h:43
A SandboxIR Value has users. This is the base class.
Definition Value.h:72
This is an optimization pass for GlobalISel generic memory operations.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1769
@ Other
Any other memory.
Definition ModRef.h:68
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1788
static unsigned getHashValue(const CallbackID &ID)
Definition Context.h:381
DenseMapInfo< CallbackID::ValTy > ReprInfo
Definition Context.h:379
sandboxir::Context::CallbackID CallbackID
Definition Context.h:378
static bool isEqual(const CallbackID &LHS, const CallbackID &RHS)
Definition Context.h:384
An information struct used to provide DenseMap with the various necessary components for a given valu...
CallbackEntry(CallbackID ID, FnT Fn, StringRef CBName)
Definition Context.h:100
Type has a protected destructor to prohibit the user from managing the lifetime of the Type objects.
Definition Context.h:92