13 #ifndef MLIR_IR_VALUE_H 14 #define MLIR_IR_VALUE_H 19 #include "llvm/Support/PointerLikeTypeTraits.h" 27 class OpPrintingFlags;
91 assert(*
this &&
"isa<> used on a null type.");
92 return U::classof(*
this);
95 template <
typename First,
typename Second,
typename... Rest>
97 return isa<First>() || isa<Second, Rest...>();
101 return isa<U>() ? U(
impl) : U(
nullptr);
103 template <
typename U>
105 return (*
this && isa<U>()) ? U(
impl) : U(
nullptr);
107 template <
typename U>
113 explicit operator bool()
const {
return impl; }
137 template <
typename OpTy>
139 return llvm::dyn_cast_or_null<OpTy>(getDefiningOp());
147 Region *getParentRegion();
150 Block *getParentBlock();
163 impl->replaceAllUsesWith(newValue);
170 replaceAllUsesExcept(
Value newValue,
176 void replaceAllUsesExcept(
Value newValue,
Operation *exceptedUser)
const;
180 void replaceUsesWithIf(
Value newValue,
184 bool isUsedOutsideOfBlock(
Block *block);
218 void print(raw_ostream &os);
224 void printAsOperand(raw_ostream &os,
AsmState &state);
259 unsigned getOperandNumber();
264 friend class OperandStorage;
305 return llvm::isa<detail::BlockArgumentImpl>(value.
getImpl());
326 void destroy() {
delete getImpl(); }
334 void setArgNumber(int64_t index) { getImpl()->index = index; }
361 unsigned getResultNumber()
const;
382 assert(resultNo < getMaxInlineResults());
399 outOfLineIndex(outOfLineIndex) {}
407 return outOfLineIndex + getMaxInlineResults();
417 if (
const auto *outOfLineResult = dyn_cast<OutOfLineOpResult>(
this))
418 return outOfLineResult->getResultNumber();
419 return cast<InlineOpResult>(
this)->getResultNumber();
430 return llvm::isa<detail::OpResultImpl>(value.
getImpl());
447 static unsigned getNumInline(
unsigned numResults);
451 static unsigned getNumTrailing(
unsigned numResults);
506 struct PointerLikeTypeTraits<
mlir::Value> {
515 NumLowBitsAvailable =
516 PointerLikeTypeTraits<mlir::detail::ValueImpl *>::NumLowBitsAvailable
521 :
public PointerLikeTypeTraits<mlir::Value> {
528 struct PointerLikeTypeTraits<
mlir::OpResult>
529 :
public PointerLikeTypeTraits<mlir::Value> {
TODO: Remove this file when SCCP and integer range analysis have been ported to the new framework...
void setLoc(Location loc)
OutOfLineOpResult(Type type, uint64_t outOfLineIndex)
This class contains a list of basic blocks and a link to the parent operation it is attached to...
static mlir::OpResult getFromVoidPointer(void *pointer)
static bool classof(const ValueImpl *value)
constexpr Value(detail::ValueImpl *impl=nullptr)
The OpAsmOpInterface, see OpAsmInterface.td for more details.
static bool classof(Value value)
Operation is a basic unit of execution within MLIR.
unsigned getResultNumber() const
Return the result number of this op result.
The internal implementation of a BlockArgument.
This is a value defined by a result of an operation.
Block represents an ordered list of Operations.
llvm::PointerIntPair< Type, 3, Kind > typeAndKind
The type of this result and the kind.
use_iterator use_end() const
static mlir::OpResult getTombstoneKey()
Kind getKind() const
Return the kind of this value.
user_iterator user_begin() const
An iterator over the users of an IRObject.
static mlir::Value getTombstoneKey()
ValueUseIterator< OpOperand > use_iterator
InlineOpResult(Type type, unsigned resultNo)
ValueImpl(Type type, Kind kind)
unsigned getArgNumber() const
Returns the number of this argument.
void dropAllUses() const
Drop all uses of this object from their respective owners.
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)
static bool isEqual(mlir::Value lhs, mlir::Value rhs)
user_range getUsers() const
void replaceAllUsesWith(Value newValue) const
Replace all uses of 'this' value with the new value, updating anything in the IR that uses 'this' to ...
bool operator!=(const Value &other) const
static constexpr const bool value
void * getAsOpaquePointer() const
Methods for supporting PointerLikeTypeTraits.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
The next kind represents a 'out-of-line' operation result.
Operation * getOwner() const
Returns the operation that owns this result.
uint64_t outOfLineIndex
The trailing result number, or the offset from the beginning of the OutOfLineOpResult array...
user_iterator user_end() const
static IRObjectWithUseList< OpOperand > * getUseList(Value value)
Provide the use list that is attached to the given value.
Block * getOwner() const
Returns the block that owns this argument.
static mlir::OpResult getEmptyKey()
This class represents a single IR object that contains a use list.
static Value getFromOpaquePointer(const void *pointer)
void print(raw_ostream &os)
void setType(Type type)
Set the type of this value.
static unsigned getHashValue(mlir::Value val)
bool hasOneUse() const
Returns true if this value has exactly one use.
static void print(spirv::VerCapExtAttr triple, DialectAsmPrinter &printer)
user_iterator user_begin() const
unsigned getResultNumber() const
Returns the number of this result.
static mlir::BlockArgument getEmptyKey()
static mlir::Value getFromVoidPointer(void *pointer)
bool operator==(const Value &other) const
The last kind represents a block argument.
This class represents an argument of a Block.
unsigned getResultNumber() const
Returns the result number of this op result.
use_iterator use_begin() const
Type getType() const
Return the type of this value.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
use_iterator use_end() const
user_iterator user_end() const
OpTy getDefiningOp() const
If this value is the result of an operation of type OpTy, return the operation that defines it...
static bool classof(const ValueImpl *value)
MLIRContext * getContext() const
Return the MLIRContext in which this type was uniqued.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
bool use_empty() const
Returns true if this value has no uses.
static mlir::BlockArgument getFromVoidPointer(void *pointer)
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
The base class for all derived Value classes.
static bool classof(const OpResultImpl *value)
Set of flags used to control the behavior of the various IR print methods (e.g.
inline ::llvm::hash_code hash_value(Value arg)
Make Value hashable.
Type getType() const
Return the type of this value.
use_iterator use_begin() const
This class provides the implementation for an operation result whose index cannot be represented "inl...
static void * getAsVoidPointer(mlir::Value value)
U dyn_cast_or_null() const
MLIRContext is the top-level object for a collection of MLIR operations.
This class represents an operand of an operation.
static bool classof(Value value)
This class provides the implementation for an operation result.
static mlir::BlockArgument getTombstoneKey()
detail::ValueImpl * impl
A pointer to the internal implementation of the value.
detail::ValueImpl * getImpl() const
Kind
The enumeration represents the various different kinds of values the internal representation may take...
A reference to a value, suitable for use as an operand of an operation.
unsigned getResultNumber() const
Return the result number of this op result.
use_range getUses() const
Returns a range of all uses, which is useful for iterating over all uses.
This class provides the implementation for an operation result whose index can be represented "inline...
void setType(Type newType)
Mutate the type of this Value to be of the specified type.
static bool classof(const OpResultImpl *value)
Location getLoc() const
Return the location for this argument.
MLIRContext * getContext() const
Utility to get the associated MLIRContext that this value is defined in.
static mlir::Value getEmptyKey()
This class provides management for the lifetime of the state used when printing the IR...
static unsigned getMaxInlineResults()
Returns the maximum number of results that can be stored inline.