LLVM: lib/SandboxIR/Value.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
12#include
13
15
18#ifndef NDEBUG
20#endif
21}
22
25 if (->uses().empty())
26 LLVMUse = &*Val->use_begin();
28 Val->use_begin()->getUser()))
29 : nullptr;
31}
32
34 auto UseBegin = Val->use_begin();
35 auto UseEnd = Val->use_end();
36 bool AtEnd = UseBegin == UseEnd;
37 llvm::Use *LLVMUse = AtEnd ? nullptr : &*UseBegin;
39 AtEnd ? nullptr
42}
43
45
47
50 assert(getType() == OtherV->getType() && "Can't replace with different type");
52
54 OtherVal, [&ShouldReplace, this, OtherV](llvm::Use &LLVMUse) -> bool {
56 if (DstU == nullptr)
57 return false;
58 Use UseToReplace(&LLVMUse, DstU, Ctx);
59 if (!ShouldReplace(UseToReplace))
60 return false;
61 Ctx.getTracker().emplaceIfTracking(UseToReplace);
62 Ctx.runSetUseCallbacks(UseToReplace, OtherV);
63 return true;
64 });
65}
66
69 "Replacing with Value of different type!");
75 }
78}
79
80#ifndef NDEBUG
82 std::stringstream SS;
83 SS << "SB" << UID << ".";
84 return SS.str();
85}
86
90
92 OS.indent(2) << "Val: ";
94 OS << *Val;
95 else
96 OS << "NULL";
97 OS << "\n";
98}
99
102 OS << *Val;
103 else
104 OS << "NULL ";
105}
106
110
114 else
115 OS << "NULL ";
116}
117
122#endif
123
124}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition Value.cpp:546
LLVM_ABI 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.
LLVM_ABI 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...
Definition Value.cpp:554
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.
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.
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
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
Definition Value.cpp:91
virtual void dumpCommonHeader(raw_ostream &OS) const
Definition Value.cpp:87
void dumpCommonSuffix(raw_ostream &OS) const
Definition Value.cpp:107
LLVM_ABI void replaceAllUsesWith(Value *Other)
Definition Value.cpp:67
LLVM_ABI unsigned getNumUses() const
\Returns the number of user edges (not necessarily to unique users).
Definition Value.cpp:44
UserUseIterator use_iterator
void printAsOperandCommon(raw_ostream &OS) const
Definition Value.cpp:111
Context & Ctx
All values point to the context.
ClassID SubclassID
For isa/dyn_cast.
LLVM_DUMP_METHOD void dump() const
Definition Value.cpp:118
LLVM_ABI Type * getType() const
Definition Value.cpp:46
LLVM_ABI Value(ClassID SubclassID, llvm::Value *Val, Context &Ctx)
Definition Value.cpp:16
std::string getUid() const
Returns the unique id in the form 'SB.' like 'SB1.'.
Definition Value.cpp:81
LLVM_ABI void replaceUsesWithIf(Value *OtherV, llvm::function_ref< bool(const Use &)> ShouldReplace)
Definition Value.cpp:48
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
Definition Value.cpp:100
iterator_range< use_iterator > uses()
static const char * getSubclassIDStr(ClassID ID)
LLVM_ABI use_iterator use_begin()
Definition Value.cpp:23
LLVM_ABI user_iterator user_begin()
Definition Value.cpp:33
auto cast_or_null(const Y &Val)
constexpr size_t range_size(R &&Range)
Returns the size of the Range, i.e., the number of elements.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.