MLIR: lib/IR/Value.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
13 #include "llvm/ADT/SmallPtrSet.h"
14
15 using namespace mlir;
17
18
19
21 if (auto result = llvm::dyn_cast(*this))
22 return result.getOwner();
23 return nullptr;
24 }
25
27 if (auto *op = getDefiningOp())
28 return op->getLoc();
29
30 return llvm::cast(*this).getLoc();
31 }
32
34 if (auto *op = getDefiningOp())
35 return op->setLoc(loc);
36
37 return llvm::cast(*this).setLoc(loc);
38 }
39
40
42 if (auto *op = getDefiningOp())
44 return llvm::cast(*this).getOwner()->getParent();
45 }
46
47
49 if (Operation *op = getDefiningOp())
50 return op->getBlock();
51 return llvm::cast(*this).getOwner();
52 }
53
55 return (unsigned)std::distance(use_begin(), use_end());
56 }
57
59 return hasNItems(use_begin(), use_end(), n);
60 }
61
63 return hasNItemsOrMore(use_begin(), use_end(), n);
64 }
65
66
67
68
69
70
71
72
75 for (OpOperand &use : llvm::make_early_inc_range(getUses())) {
76 if (exceptions.count(use.getOwner()) == 0)
77 use.set(newValue);
78 }
79 }
80
81
82
83
85 for (OpOperand &use : llvm::make_early_inc_range(getUses())) {
86 if (use.getOwner() != exceptedUser)
87 use.set(newValue);
88 }
89 }
90
91
92
95 for (OpOperand &use : llvm::make_early_inc_range(getUses()))
96 if (shouldReplace(use))
97 use.set(newValue);
98 }
99
100
102 return llvm::any_of(getUsers(), [block](Operation *user) {
103 return user->getBlock() != block;
104 });
105 }
106
107
109 getImpl()->shuffleUseList(indices);
110 }
111
112
113
114
115
116
118
119
120
121
122
123
124
125
126
127
128
129
130
131 if (const auto *result = dyn_cast(this)) {
132 result += result->getResultNumber() + 1;
134 }
135
136
139
140
141 const auto *inlineIt = reinterpret_cast<const InlineOpResult *>(outOfLineIt);
144 }
145
147 if (offset == 0)
148 return this;
149
150
151
152
153
154
155
156
157
158
159
160
162 if (auto *inlineResult = dyn_cast(this)) {
163
164
165
166
167
168
169
170
171
172
173 intptr_t leftBeforeTrailing =
175 if (leftBeforeTrailing >= offset)
176 return inlineResult - offset;
177
178
179
180
181
182
183
184
185
186 result = inlineResult - leftBeforeTrailing;
187 offset -= leftBeforeTrailing;
188 }
189
190
191
193 }
194
195
196
197 unsigned OpResult::getNumInline(unsigned numResults) {
199 }
200
201
202
203 unsigned OpResult::getNumTrailing(unsigned numResults) {
204
206 return numResults <= maxInline ? 0 : numResults - maxInline;
207 }
208
209
210
211
212
213
215 return value;
216 }
217
218
220 return this - &getOwner()->getBlockOperands()[0];
221 }
222
223
224
225
226
227
229 return this - &getOwner()->getOpOperands()[0];
230 }
static Value min(ImplicitLocOpBuilder &builder, Value value, Value bound)
unsigned getOperandNumber()
Return which operand this is in the BlockOperand list of the Operation.
static IRObjectWithUseList< BlockOperand > * getUseList(Block *value)
Provide the use list that is attached to the given block.
Block represents an ordered list of Operations.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class represents an operand of an operation.
unsigned getOperandNumber()
Return which operand this is in the OpOperand list of the Operation.
Operation is the basic unit of execution within MLIR.
Block * getBlock()
Returns the operation block that contains this operation.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Region * getParentRegion()
Return the region containing this region or nullptr if the region is attached to a top-level operatio...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
void setLoc(Location loc)
bool hasNUsesOrMore(unsigned n) const
Return true if this value has n uses or more.
void replaceUsesWithIf(Value newValue, function_ref< bool(OpOperand &)> shouldReplace)
Replace all uses of 'this' value with 'newValue' if the given callback returns true.
void shuffleUseList(ArrayRef< unsigned > indices)
Shuffle the use list order according to the provided indices.
Block * getParentBlock()
Return the Block in which this Value is defined.
void replaceAllUsesExcept(Value newValue, const SmallPtrSetImpl< Operation * > &exceptions)
Replace all uses of 'this' value with 'newValue', updating anything in the IR that uses 'this' to use...
unsigned getNumUses() const
This method computes the number of uses of this Value.
bool hasNUses(unsigned n) const
Return true if this Value has exactly n uses.
bool isUsedOutsideOfBlock(Block *block) const
Returns true if the value is used outside of the given block.
Location getLoc() const
Return the location of this value.
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
Region * getParentRegion()
Return the Region in which this Value is defined.
This class provides the implementation for an operation result.
OpResultImpl * getNextResultAtOffset(intptr_t offset)
Returns the next operation result at offset after this result.
Operation * getOwner() const
Returns the parent operation of this result.
static unsigned getMaxInlineResults()
Returns the maximum number of results that can be stored inline.
This class provides the implementation for an operation result whose index cannot be represented "inl...
uint64_t outOfLineIndex
The trailing result number, or the offset from the beginning of the OutOfLineOpResult array.
Include the generated interface declarations.
This class provides the implementation for an operation result whose index can be represented "inline...