MLIR 23.0.0git
Value.h
Go to the documentation of this file.
1//===- Value.h - Base of the SSA Value hierarchy ----------------*- 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// This file defines generic Value type and manipulation utilities.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MLIR_IR_VALUE_H
14#define MLIR_IR_VALUE_H
15
16#include "mlir/IR/Types.h"
17#include "mlir/IR/UseDefLists.h"
18#include "mlir/Support/LLVM.h"
19#include "llvm/Support/PointerLikeTypeTraits.h"
20
21namespace mlir {
22class AsmState;
23class Block;
24class BlockArgument;
25class Operation;
26class OpOperand;
27class OpPrintingFlags;
28class OpResult;
29class Region;
30class Value;
31
32//===----------------------------------------------------------------------===//
33// Value
34//===----------------------------------------------------------------------===//
35
36namespace detail {
37
38/// The base class for all derived Value classes. It contains all of the
39/// components that are shared across Value classes.
40class alignas(8) ValueImpl : public IRObjectWithUseList<OpOperand> {
41public:
42 /// The enumeration represents the various different kinds of values the
43 /// internal representation may take. We use all of the bits from Type that we
44 /// can to store indices inline.
45 enum class Kind {
46 /// The first N kinds are all inline operation results. An inline operation
47 /// result means that the kind represents the result number. This removes
48 /// the need to store an additional index value. The derived class here is
49 /// an `OpResultImpl`.
51
52 /// The next kind represents a 'out-of-line' operation result. This is for
53 /// results with numbers larger than we can represent inline. The derived
54 /// class here is an `OpResultImpl`.
56
57 /// The last kind represents a block argument. The derived class here is an
58 /// `BlockArgumentImpl`.
60 };
61
62 /// Return the type of this value.
63 Type getType() const { return typeAndKind.getPointer(); }
64
65 /// Set the type of this value.
66 void setType(Type type) { return typeAndKind.setPointer(type); }
67
68 /// Return the kind of this value.
69 Kind getKind() const { return typeAndKind.getInt(); }
70
71protected:
72 ValueImpl(Type type, Kind kind) : typeAndKind(type, kind) {}
73
74 /// Expose a few methods explicitly for the debugger to call for
75 /// visualization.
76#ifndef NDEBUG
77 LLVM_DUMP_METHOD Type debug_getType() const { return getType(); }
78 LLVM_DUMP_METHOD Kind debug_getKind() const { return getKind(); }
79
80#endif
81
82 /// The type of this result and the kind.
83 llvm::PointerIntPair<Type, 3, Kind> typeAndKind;
84};
85} // namespace detail
86
87/// This class represents an instance of an SSA value in the MLIR system,
88/// representing a computable value that has a type and a set of users. An SSA
89/// value is either a BlockArgument or the result of an operation. Note: This
90/// class has value-type semantics and is just a simple wrapper around a
91/// ValueImpl that is either owner by a block(in the case of a BlockArgument) or
92/// an Operation(in the case of an OpResult).
93/// As most IR constructs, this isn't const-correct, but we keep method
94/// consistent and as such method that immediately modify this Value aren't
95/// marked `const` (include modifying the Value use-list).
96class Value {
97public:
98 constexpr Value(detail::ValueImpl *impl = nullptr) : impl(impl) {}
99
100 explicit operator bool() const { return impl; }
101 bool operator==(const Value &other) const { return impl == other.impl; }
102 bool operator!=(const Value &other) const { return !(*this == other); }
103
104 /// Return the type of this value.
105 Type getType() const { return impl->getType(); }
106
107 /// Utility to get the associated MLIRContext that this value is defined in.
108 MLIRContext *getContext() const { return getType().getContext(); }
109
110 /// Mutate the type of this Value to be of the specified type.
111 ///
112 /// Note that this is an extremely dangerous operation which can create
113 /// completely invalid IR very easily. It is strongly recommended that you
114 /// recreate IR objects with the right types instead of mutating them in
115 /// place.
116 void setType(Type newType) { impl->setType(newType); }
117
118 /// If this value is the result of an operation, return the operation that
119 /// defines it.
120 Operation *getDefiningOp() const;
121
122 /// If this value is the result of an operation of type OpTy, return the
123 /// operation that defines it.
124 template <typename OpTy>
125 OpTy getDefiningOp() const {
126 return llvm::dyn_cast_or_null<OpTy>(getDefiningOp());
127 }
128
129 /// Return the location of this value.
130 Location getLoc() const;
131 void setLoc(Location loc);
132
133 /// Return the Region in which this Value is defined.
135
136 /// Return the Block in which this Value is defined.
138
139 //===--------------------------------------------------------------------===//
140 // UseLists
141 //===--------------------------------------------------------------------===//
142
143 /// Drop all uses of this object from their respective owners.
144 void dropAllUses() { return impl->dropAllUses(); }
145
146 /// Replace all uses of 'this' value with the new value, updating anything in
147 /// the IR that uses 'this' to use the other value instead. When this returns
148 /// there are zero uses of 'this'.
149 void replaceAllUsesWith(Value newValue) {
150 impl->replaceAllUsesWith(newValue);
151 }
152
153 /// Replace all uses of 'this' value with 'newValue', updating anything in the
154 /// IR that uses 'this' to use the other value instead except if the user is
155 /// listed in 'exceptions' .
156 void replaceAllUsesExcept(Value newValue,
157 const SmallPtrSetImpl<Operation *> &exceptions);
158
159 /// Replace all uses of 'this' value with 'newValue', updating anything in the
160 /// IR that uses 'this' to use the other value instead except if the user is
161 /// 'exceptedUser'.
162 void replaceAllUsesExcept(Value newValue, Operation *exceptedUser);
163
164 /// Replace all uses of 'this' value with 'newValue' if the given callback
165 /// returns true.
166 void replaceUsesWithIf(Value newValue,
167 function_ref<bool(OpOperand &)> shouldReplace);
168
169 /// Returns true if the value is used outside of the given block.
170 bool isUsedOutsideOfBlock(Block *block) const;
171
172 /// Shuffle the use list order according to the provided indices. It is
173 /// responsibility of the caller to make sure that the indices map the current
174 /// use-list chain to another valid use-list chain.
176
177 //===--------------------------------------------------------------------===//
178 // Uses
179
180 /// This class implements an iterator over the uses of a value.
183
184 use_iterator use_begin() const { return impl->use_begin(); }
185 use_iterator use_end() const { return use_iterator(); }
186
187 /// Returns a range of all uses, which is useful for iterating over all uses.
188 use_range getUses() const { return {use_begin(), use_end()}; }
189
190 /// This method computes the number of uses of this Value.
191 ///
192 /// This is a linear time operation. Use hasOneUse, hasNUses, or
193 /// hasNUsesOrMore to check for specific values.
194 unsigned getNumUses() const;
195
196 /// Returns true if this value has exactly one use.
197 bool hasOneUse() const { return impl->hasOneUse(); }
198
199 /// Return true if this Value has exactly n uses.
200 bool hasNUses(unsigned n) const;
201
202 /// Return true if this value has n uses or more.
203 ///
204 /// This is logically equivalent to getNumUses() >= N.
205 bool hasNUsesOrMore(unsigned n) const;
206
207 /// Returns true if this value has no uses.
208 bool use_empty() const { return impl->use_empty(); }
209
210 //===--------------------------------------------------------------------===//
211 // Users
212
215
216 user_iterator user_begin() const { return use_begin(); }
217 user_iterator user_end() const { return use_end(); }
218 user_range getUsers() const { return {user_begin(), user_end()}; }
219
220 //===--------------------------------------------------------------------===//
221 // Utilities
222
223 void print(raw_ostream &os) const;
224 void print(raw_ostream &os, const OpPrintingFlags &flags) const;
225 void print(raw_ostream &os, AsmState &state) const;
226 void dump() const;
227
228 /// Print this value as if it were an operand.
229 void printAsOperand(raw_ostream &os, AsmState &state) const;
230 void printAsOperand(raw_ostream &os, const OpPrintingFlags &flags) const;
231
232 /// Methods for supporting PointerLikeTypeTraits.
233 void *getAsOpaquePointer() const { return impl; }
234 static Value getFromOpaquePointer(const void *pointer) {
235 return reinterpret_cast<detail::ValueImpl *>(const_cast<void *>(pointer));
236 }
237 detail::ValueImpl *getImpl() const { return impl; }
238
239 friend ::llvm::hash_code hash_value(Value arg);
240
241protected:
242 /// A pointer to the internal implementation of the value.
244};
245
247
248//===----------------------------------------------------------------------===//
249// OpOperand
250//===----------------------------------------------------------------------===//
251
252/// This class represents an operand of an operation. Instances of this class
253/// contain a reference to a specific `Value`.
254class OpOperand : public IROperand<OpOperand, Value> {
255public:
256 /// Provide the use list that is attached to the given value.
258 return value.getImpl();
259 }
260
261 /// Return which operand this is in the OpOperand list of the Operation.
262 unsigned getOperandNumber();
263
264 /// Set the current value being used by this operand.
265 void assign(Value value) { set(value); }
266
267private:
268 /// Keep the constructor private and accessible to the OperandStorage class
269 /// only to avoid hard-to-debug typo/programming mistakes.
270 friend class OperandStorage;
272};
273
274//===----------------------------------------------------------------------===//
275// BlockArgument
276//===----------------------------------------------------------------------===//
277
278namespace detail {
279/// The internal implementation of a BlockArgument.
280class BlockArgumentImpl : public ValueImpl {
281public:
282 static bool classof(const ValueImpl *value) {
283 return value->getKind() == ValueImpl::Kind::BlockArgument;
284 }
285
286private:
288 : ValueImpl(type, Kind::BlockArgument), owner(owner), index(index),
289 loc(loc) {}
290
291 /// The owner of this argument.
292 Block *owner;
293
294 /// The position in the argument list.
296
297 /// The source location of this argument.
298 Location loc;
299
300 /// Allow access to owner and constructor.
301 friend BlockArgument;
302};
303} // namespace detail
304
305/// This class represents an argument of a Block.
306class BlockArgument : public Value {
307public:
308 using Value::Value;
309
310 static bool classof(Value value) {
311 return llvm::isa<detail::BlockArgumentImpl>(value.getImpl());
312 }
313
314 /// Returns the block that owns this argument.
315 Block *getOwner() const { return getImpl()->owner; }
316
317 /// Returns the number of this argument.
318 unsigned getArgNumber() const { return getImpl()->index; }
319
320 /// Return the location for this argument.
321 Location getLoc() const { return getImpl()->loc; }
322 void setLoc(Location loc) { getImpl()->loc = loc; }
323
324private:
325 /// Allocate a new argument with the given type and owner.
326 static BlockArgument create(Type type, Block *owner, int64_t index,
327 Location loc) {
328 return new detail::BlockArgumentImpl(type, owner, index, loc);
329 }
330
331 /// Destroy and deallocate this argument.
332 void destroy() { delete getImpl(); }
333
334 /// Get a raw pointer to the internal implementation.
335 detail::BlockArgumentImpl *getImpl() const {
336 return reinterpret_cast<detail::BlockArgumentImpl *>(impl);
337 }
338
339 /// Cache the position in the block argument list.
340 void setArgNumber(int64_t index) { getImpl()->index = index; }
341
342 /// Allow access to `create`, `destroy` and `setArgNumber`.
343 friend Block;
344
345 /// Allow access to 'getImpl'.
346 friend Value;
347};
348
349//===----------------------------------------------------------------------===//
350// OpResult
351//===----------------------------------------------------------------------===//
352
353namespace detail {
354/// This class provides the implementation for an operation result.
355class alignas(8) OpResultImpl : public ValueImpl {
356public:
358
359 static bool classof(const ValueImpl *value) {
360 return value->getKind() != ValueImpl::Kind::BlockArgument;
361 }
362
363 /// Returns the parent operation of this result.
364 Operation *getOwner() const;
365
366 /// Returns the result number of this op result.
367 unsigned getResultNumber() const;
368
369 /// Returns the next operation result at `offset` after this result. This
370 /// method is useful when indexing the result storage of an operation, given
371 /// that there is more than one kind of operation result (with the different
372 /// kinds having different sizes) and that operations are stored in reverse
373 /// order.
375
376 /// Returns the maximum number of results that can be stored inline.
377 static unsigned getMaxInlineResults() {
378 return static_cast<unsigned>(Kind::OutOfLineOpResult);
379 }
380};
381
382/// This class provides the implementation for an operation result whose index
383/// can be represented "inline" in the underlying ValueImpl.
385public:
386 InlineOpResult(Type type, unsigned resultNo)
387 : OpResultImpl(type, static_cast<ValueImpl::Kind>(resultNo)) {
388 assert(resultNo < getMaxInlineResults());
389 }
390
391 /// Return the result number of this op result.
392 unsigned getResultNumber() const { return static_cast<unsigned>(getKind()); }
393
394 static bool classof(const OpResultImpl *value) {
396 }
397};
398
399/// This class provides the implementation for an operation result whose index
400/// cannot be represented "inline", and thus requires an additional index field.
402public:
406
407 static bool classof(const OpResultImpl *value) {
409 }
410
411 /// Return the result number of this op result.
412 unsigned getResultNumber() const {
414 }
415
416 /// The trailing result number, or the offset from the beginning of the
417 /// `OutOfLineOpResult` array.
419};
420
421/// Return the result number of this op result.
422inline unsigned OpResultImpl::getResultNumber() const {
423 if (const auto *outOfLineResult = dyn_cast<OutOfLineOpResult>(this))
424 return outOfLineResult->getResultNumber();
425 return cast<InlineOpResult>(this)->getResultNumber();
426}
427
428/// TypedValue is a Value with a statically know type.
429/// TypedValue can be null/empty
430template <typename Ty>
432 using Value::Value;
433 using ValueType = Ty;
434
435 static bool classof(Value value) { return llvm::isa<Ty>(value.getType()); }
436
437 /// TypedValue<B> can implicitly convert to TypedValue<A> if B is assignable
438 /// to A.
439 template <typename ToTy,
440 typename = typename std::enable_if<std::is_assignable<
441 typename ToTy::ValueType &, Ty>::value>::type>
442 operator ToTy() const {
443 return llvm::cast<ToTy>(*this);
444 }
445
446 /// Return the known Type
447 Ty getType() const { return llvm::cast<Ty>(Value::getType()); }
448 void setType(Ty ty) { Value::setType(ty); }
449};
450
451} // namespace detail
452
453/// This is a value defined by a result of an operation.
454class OpResult : public Value {
455public:
456 using Value::Value;
457
458 static bool classof(Value value) {
459 return llvm::isa<detail::OpResultImpl>(value.getImpl());
460 }
461
462 /// Returns the operation that owns this result.
463 Operation *getOwner() const { return getImpl()->getOwner(); }
464
465 /// Returns the number of this result.
466 unsigned getResultNumber() const { return getImpl()->getResultNumber(); }
467
468private:
469 /// Get a raw pointer to the internal implementation.
471 return reinterpret_cast<detail::OpResultImpl *>(impl);
472 }
473
474 /// Given a number of operation results, returns the number that need to be
475 /// stored inline.
476 static unsigned getNumInline(unsigned numResults);
477
478 /// Given a number of operation results, returns the number that need to be
479 /// stored as trailing.
480 static unsigned getNumTrailing(unsigned numResults);
481
482 /// Allow access to constructor.
483 friend Operation;
484};
485
486/// Make Value hashable.
487inline ::llvm::hash_code hash_value(Value arg) {
488 return ::llvm::hash_value(arg.getImpl());
489}
490
491template <typename Ty, typename Value = mlir::Value>
492/// If Ty is mlir::Type this will select `Value` instead of having a wrapper
493/// around it. This helps resolve ambiguous conversion issues.
494using TypedValue = std::conditional_t<std::is_same_v<Ty, mlir::Type>,
496
497} // namespace mlir
498
499namespace llvm {
500
501template <>
502struct DenseMapInfo<mlir::Value> {
505 return mlir::Value::getFromOpaquePointer(pointer);
506 }
511 static unsigned getHashValue(mlir::Value val) {
512 return mlir::hash_value(val);
513 }
514 static bool isEqual(mlir::Value lhs, mlir::Value rhs) { return lhs == rhs; }
515};
516template <>
517struct DenseMapInfo<mlir::BlockArgument> : public DenseMapInfo<mlir::Value> {
520 return reinterpret_cast<mlir::detail::BlockArgumentImpl *>(pointer);
521 }
524 return reinterpret_cast<mlir::detail::BlockArgumentImpl *>(pointer);
525 }
526};
527template <>
528struct DenseMapInfo<mlir::OpResult> : public DenseMapInfo<mlir::Value> {
531 return reinterpret_cast<mlir::detail::OpResultImpl *>(pointer);
532 }
535 return reinterpret_cast<mlir::detail::OpResultImpl *>(pointer);
536 }
537};
538template <typename T>
539struct DenseMapInfo<mlir::detail::TypedValue<T>>
540 : public DenseMapInfo<mlir::Value> {
543 return reinterpret_cast<mlir::detail::ValueImpl *>(pointer);
544 }
547 return reinterpret_cast<mlir::detail::ValueImpl *>(pointer);
548 }
549};
550
551/// Allow stealing the low bits of a value.
552template <>
553struct PointerLikeTypeTraits<mlir::Value> {
554public:
555 static inline void *getAsVoidPointer(mlir::Value value) {
556 return const_cast<void *>(value.getAsOpaquePointer());
557 }
558 static inline mlir::Value getFromVoidPointer(void *pointer) {
559 return mlir::Value::getFromOpaquePointer(pointer);
560 }
561 enum {
563 PointerLikeTypeTraits<mlir::detail::ValueImpl *>::NumLowBitsAvailable
564 };
565};
566template <>
567struct PointerLikeTypeTraits<mlir::BlockArgument>
568 : public PointerLikeTypeTraits<mlir::Value> {
569public:
570 static inline mlir::BlockArgument getFromVoidPointer(void *pointer) {
571 return reinterpret_cast<mlir::detail::BlockArgumentImpl *>(pointer);
572 }
573};
574template <>
575struct PointerLikeTypeTraits<mlir::OpResult>
576 : public PointerLikeTypeTraits<mlir::Value> {
577public:
578 static inline mlir::OpResult getFromVoidPointer(void *pointer) {
579 return reinterpret_cast<mlir::detail::OpResultImpl *>(pointer);
580 }
581};
582template <typename T>
583struct PointerLikeTypeTraits<mlir::detail::TypedValue<T>>
584 : public PointerLikeTypeTraits<mlir::Value> {
585public:
586 static inline mlir::detail::TypedValue<T> getFromVoidPointer(void *pointer) {
587 return reinterpret_cast<mlir::detail::ValueImpl *>(pointer);
588 }
589};
590
591/// Add support for llvm style casts. We provide a cast between To and From if
592/// From is mlir::Value or derives from it.
593template <typename To, typename From>
594struct CastInfo<
595 To, From,
596 std::enable_if_t<std::is_same_v<mlir::Value, std::remove_const_t<From>> ||
597 std::is_base_of_v<mlir::Value, From>>>
599 DefaultDoCastIfPossible<To, From, CastInfo<To, From>> {
600 /// Arguments are taken as mlir::Value here and not as `From`, because
601 /// when casting from an intermediate type of the hierarchy to one of its
602 /// children, the val.getKind() inside T::classof will use the static
603 /// getKind() of the parent instead of the non-static ValueImpl::getKind()
604 /// that returns the dynamic type. This means that T::classof would end up
605 /// comparing the static Kind of the children to the static Kind of its
606 /// parent, making it impossible to downcast from the parent to the child.
607 static inline bool isPossible(mlir::Value ty) {
608 /// Return a constant true instead of a dynamic true when casting to self or
609 /// up the hierarchy.
610 if constexpr (std::is_base_of_v<To, From>) {
611 return true;
612 } else {
613 return To::classof(ty);
614 }
615 }
616 static inline To doCast(mlir::Value value) { return To(value.getImpl()); }
617};
618
619} // namespace llvm
620
621#endif
lhs
This class provides management for the lifetime of the state used when printing the IR.
Definition AsmState.h:542
This class represents an argument of a Block.
Definition Value.h:306
Location getLoc() const
Return the location for this argument.
Definition Value.h:321
unsigned getArgNumber() const
Returns the number of this argument.
Definition Value.h:318
Block * getOwner() const
Returns the block that owns this argument.
Definition Value.h:315
static bool classof(Value value)
Definition Value.h:310
void setLoc(Location loc)
Definition Value.h:322
Block represents an ordered list of Operations.
Definition Block.h:33
This class represents a single IR object that contains a use list.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition Location.h:76
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:63
This class represents an operand of an operation.
Definition Value.h:254
static IRObjectWithUseList< OpOperand > * getUseList(Value value)
Provide the use list that is attached to the given value.
Definition Value.h:257
unsigned getOperandNumber()
Return which operand this is in the OpOperand list of the Operation.
Definition Value.cpp:226
friend class OperandStorage
Keep the constructor private and accessible to the OperandStorage class only to avoid hard-to-debug t...
Definition Value.h:270
void assign(Value value)
Set the current value being used by this operand.
Definition Value.h:265
Set of flags used to control the behavior of the various IR print methods (e.g.
This is a value defined by a result of an operation.
Definition Value.h:454
constexpr Value(detail::ValueImpl *impl=nullptr)
Definition Value.h:98
static bool classof(Value value)
Definition Value.h:458
Operation * getOwner() const
Returns the operation that owns this result.
Definition Value.h:463
unsigned getResultNumber() const
Returns the number of this result.
Definition Value.h:466
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Definition Region.h:26
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition Types.h:74
MLIRContext * getContext() const
Return the MLIRContext in which this type was uniqued.
Definition Types.cpp:35
An iterator class that allows for iterating over the uses of an IR operand type.
An iterator over the users of an IRObject.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
bool use_empty() const
Returns true if this value has no uses.
Definition Value.h:208
constexpr Value(detail::ValueImpl *impl=nullptr)
Definition Value.h:98
void dump() const
use_iterator use_end() const
Definition Value.h:185
void setLoc(Location loc)
Definition Value.cpp:31
void dropAllUses()
Drop all uses of this object from their respective owners.
Definition Value.h:144
static Value getFromOpaquePointer(const void *pointer)
Definition Value.h:234
bool hasNUsesOrMore(unsigned n) const
Return true if this value has n uses or more.
Definition Value.cpp:60
detail::ValueImpl * impl
A pointer to the internal implementation of the value.
Definition Value.h:243
friend::llvm::hash_code hash_value(Value arg)
detail::ValueImpl * getImpl() const
Definition Value.h:237
void replaceUsesWithIf(Value newValue, function_ref< bool(OpOperand &)> shouldReplace)
Replace all uses of 'this' value with 'newValue' if the given callback returns true.
Definition Value.cpp:91
void setType(Type newType)
Mutate the type of this Value to be of the specified type.
Definition Value.h:116
MLIRContext * getContext() const
Utility to get the associated MLIRContext that this value is defined in.
Definition Value.h:108
void print(raw_ostream &os) const
Type getType() const
Return the type of this value.
Definition Value.h:105
void shuffleUseList(ArrayRef< unsigned > indices)
Shuffle the use list order according to the provided indices.
Definition Value.cpp:106
use_range getUses() const
Returns a range of all uses, which is useful for iterating over all uses.
Definition Value.h:188
bool operator==(const Value &other) const
Definition Value.h:101
bool operator!=(const Value &other) const
Definition Value.h:102
user_iterator user_begin() const
Definition Value.h:216
iterator_range< use_iterator > use_range
Definition Value.h:182
OpTy getDefiningOp() const
If this value is the result of an operation of type OpTy, return the operation that defines it.
Definition Value.h:125
user_iterator user_end() const
Definition Value.h:217
Block * getParentBlock()
Return the Block in which this Value is defined.
Definition Value.cpp:46
void * getAsOpaquePointer() const
Methods for supporting PointerLikeTypeTraits.
Definition Value.h:233
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...
Definition Value.cpp:71
iterator_range< user_iterator > user_range
Definition Value.h:214
void printAsOperand(raw_ostream &os, AsmState &state) const
Print this value as if it were an operand.
ValueUseIterator< OpOperand > use_iterator
This class implements an iterator over the uses of a value.
Definition Value.h:181
unsigned getNumUses() const
This method computes the number of uses of this Value.
Definition Value.cpp:52
bool hasNUses(unsigned n) const
Return true if this Value has exactly n uses.
Definition Value.cpp:56
void replaceAllUsesWith(Value newValue)
Replace all uses of 'this' value with the new value, updating anything in the IR that uses 'this' to ...
Definition Value.h:149
user_range getUsers() const
Definition Value.h:218
ValueUserIterator< use_iterator, OpOperand > user_iterator
Definition Value.h:213
bool hasOneUse() const
Returns true if this value has exactly one use.
Definition Value.h:197
bool isUsedOutsideOfBlock(Block *block) const
Returns true if the value is used outside of the given block.
Definition Value.cpp:99
Location getLoc() const
Return the location of this value.
Definition Value.cpp:24
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
Definition Value.cpp:18
Region * getParentRegion()
Return the Region in which this Value is defined.
Definition Value.cpp:39
use_iterator use_begin() const
Definition Value.h:184
The internal implementation of a BlockArgument.
Definition Value.h:280
static bool classof(const ValueImpl *value)
Definition Value.h:282
This class provides the implementation for an operation result.
Definition Value.h:355
unsigned getResultNumber() const
Returns the result number of this op result.
Definition Value.h:422
OpResultImpl * getNextResultAtOffset(intptr_t offset)
Returns the next operation result at offset after this result.
Definition Value.cpp:144
Operation * getOwner() const
Returns the parent operation of this result.
Definition Value.cpp:115
ValueImpl(Type type, Kind kind)
Definition Value.h:72
static bool classof(const ValueImpl *value)
Definition Value.h:359
static unsigned getMaxInlineResults()
Returns the maximum number of results that can be stored inline.
Definition Value.h:377
uint64_t outOfLineIndex
The trailing result number, or the offset from the beginning of the OutOfLineOpResult array.
Definition Value.h:418
static bool classof(const OpResultImpl *value)
Definition Value.h:407
unsigned getResultNumber() const
Return the result number of this op result.
Definition Value.h:412
OutOfLineOpResult(Type type, uint64_t outOfLineIndex)
Definition Value.h:403
The base class for all derived Value classes.
Definition Value.h:40
Kind
The enumeration represents the various different kinds of values the internal representation may take...
Definition Value.h:45
@ OutOfLineOpResult
The next kind represents a 'out-of-line' operation result.
Definition Value.h:55
@ BlockArgument
The last kind represents a block argument.
Definition Value.h:59
@ InlineOpResult
The first N kinds are all inline operation results.
Definition Value.h:50
ValueImpl(Type type, Kind kind)
Definition Value.h:72
llvm::PointerIntPair< Type, 3, Kind > typeAndKind
The type of this result and the kind.
Definition Value.h:83
LLVM_DUMP_METHOD Kind debug_getKind() const
Definition Value.h:78
void setType(Type type)
Set the type of this value.
Definition Value.h:66
LLVM_DUMP_METHOD Type debug_getType() const
Expose a few methods explicitly for the debugger to call for visualization.
Definition Value.h:77
Type getType() const
Return the type of this value.
Definition Value.h:63
Kind getKind() const
Return the kind of this value.
Definition Value.h:69
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition CallGraph.h:229
AttrTypeReplacer.
Include the generated interface declarations.
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)
std::conditional_t< std::is_same_v< Ty, mlir::Type >, mlir::Value, detail::TypedValue< Ty > > TypedValue
If Ty is mlir::Type this will select Value instead of having a wrapper around it.
Definition Value.h:494
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
Definition AffineExpr.h:247
llvm::function_ref< Fn > function_ref
Definition LLVM.h:144
static bool isPossible(mlir::Value ty)
Arguments are taken as mlir::Value here and not as From, because when casting from an intermediate ty...
Definition Value.h:607
static mlir::BlockArgument getEmptyKey()
Definition Value.h:518
static mlir::BlockArgument getTombstoneKey()
Definition Value.h:522
static mlir::OpResult getEmptyKey()
Definition Value.h:529
static mlir::OpResult getTombstoneKey()
Definition Value.h:533
static mlir::Value getEmptyKey()
Definition Value.h:503
static unsigned getHashValue(mlir::Value val)
Definition Value.h:511
static bool isEqual(mlir::Value lhs, mlir::Value rhs)
Definition Value.h:514
static mlir::Value getTombstoneKey()
Definition Value.h:507
static mlir::detail::TypedValue< T > getEmptyKey()
Definition Value.h:541
static mlir::detail::TypedValue< T > getTombstoneKey()
Definition Value.h:545
static mlir::BlockArgument getFromVoidPointer(void *pointer)
Definition Value.h:570
static mlir::OpResult getFromVoidPointer(void *pointer)
Definition Value.h:578
static mlir::Value getFromVoidPointer(void *pointer)
Definition Value.h:558
static void * getAsVoidPointer(mlir::Value value)
Definition Value.h:555
static mlir::detail::TypedValue< T > getFromVoidPointer(void *pointer)
Definition Value.h:586
unsigned getResultNumber() const
Return the result number of this op result.
Definition Value.h:392
static bool classof(const OpResultImpl *value)
Definition Value.h:394
InlineOpResult(Type type, unsigned resultNo)
Definition Value.h:386
TypedValue is a Value with a statically know type.
Definition Value.h:431
constexpr Value(detail::ValueImpl *impl=nullptr)
Definition Value.h:98
static bool classof(Value value)
Definition Value.h:435
Ty getType() const
Return the known Type.
Definition Value.h:447
void setType(Ty ty)
Definition Value.h:448