LLVM: lib/SandboxIR/Value.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
12#include
13
15
17 : SubclassID(SubclassID), Val(Val), Ctx(Ctx) {
18#ifndef NDEBUG
20#endif
21}
22
27 User *User = LLVMUse != nullptr ? cast_or_nullsandboxir::User(Ctx.getValue(
29 : nullptr;
31}
32
36 bool AtEnd = UseBegin == UseEnd;
37 llvm::Use *LLVMUse = AtEnd ? nullptr : &*UseBegin;
39 AtEnd ? nullptr
40 : cast_or_nullsandboxir::User(Ctx.getValue(&*LLVMUse->getUser()));
42}
43
45
47
50 assert(getType() == OtherV->getType() && "Can't replace with different type");
52
54 OtherVal, [&ShouldReplace, this](llvm::Use &LLVMUse) -> bool {
56 if (DstU == nullptr)
57 return false;
58 Use UseToReplace(&LLVMUse, DstU, Ctx);
59 if (!ShouldReplace(UseToReplace))
60 return false;
62 return true;
63 });
64}
65
68 "Replacing with Value of different type!");
73 }
74
77
78#ifndef NDEBUG
80 std::stringstream SS;
81 SS << "SB" << UID << ".";
82 return SS.str();
83}
84
87}
88
93 else
94 OS << "NULL";
95 OS << "\n";
96}
97
101 else
102 OS << "NULL ";
103}
104
107}
108
112 else
113 OS << "NULL ";
114}
115
118 dbgs() << "\n";
119}
120#endif
121
122}
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A Use represents the edge between a Value definition and its users.
User * getUser() const
Returns the User that contains this Use.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
iterator_range< user_iterator > users()
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
void replaceUsesWithIf(Value *New, llvm::function_ref< bool(Use &U)> ShouldReplace)
Go through the uses list for this definition and make each use point to "V" if the callback ShouldRep...
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
sandboxir::Value * getValue(llvm::Value *V) const
Type * getType(llvm::Type *LLVMTy)
size_t getNumValues() const
\Returns the number of values registered with Context.
The tracker collects all the change objects and implements the main API for saving / reverting / acce...
bool isTracking() const
\Returns true if the tracker is recording changes.
void track(std::unique_ptr< IRChangeBase > &&Change)
Record Change and take ownership.
bool emplaceIfTracking(ArgsT... Args)
A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled...
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Represents a Def-use/Use-def edge in SandboxIR.
Iterator for the Use edges of a Value's users.
A sandboxir::User has operands.
A SandboxIR Value has users. This is the base class.
mapped_iterator< sandboxir::UserUseIterator, UseToUser > user_iterator
llvm::Value * Val
The LLVM Value that corresponds to this SandboxIR Value.
void dumpCommonFooter(raw_ostream &OS) const
virtual void dumpCommonHeader(raw_ostream &OS) const
void dumpCommonSuffix(raw_ostream &OS) const
void replaceAllUsesWith(Value *Other)
unsigned getNumUses() const
\Returns the number of user edges (not necessarily to unique users).
UserUseIterator use_iterator
void printAsOperandCommon(raw_ostream &OS) const
Context & Ctx
All values point to the context.
ClassID SubclassID
For isa/dyn_cast.
LLVM_DUMP_METHOD void dump() const
Value(ClassID SubclassID, llvm::Value *Val, Context &Ctx)
std::string getUid() const
Returns the unique id in the form 'SB.' like 'SB1.'.
void replaceUsesWithIf(Value *OtherV, llvm::function_ref< bool(const Use &)> ShouldReplace)
unsigned UID
A unique ID used for forming the name (used for debugging).
virtual void dumpOS(raw_ostream &OS) const =0
void dumpCommonPrefix(raw_ostream &OS) const
iterator_range< use_iterator > uses()
static const char * getSubclassIDStr(ClassID ID)
user_iterator user_begin()
constexpr size_t range_size(R &&Range)
Returns the size of the Range, i.e., the number of elements.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.