13 #ifndef MLIR_IR_VALUE_H 14 #define MLIR_IR_VALUE_H 29 class BlockArgumentImpl;
68 enum { NumLowBitsAvailable = 3 };
70 using ImplType = llvm::PointerIntPair<void *, 2, Kind, ImplTypeTraits>;
73 Value(std::nullptr_t) : ownerAndKind() {}
78 template <
typename U>
bool isa()
const {
79 assert(*
this &&
"isa<> used on a null type.");
80 return U::classof(*
this);
83 return isa<U>() ? U(ownerAndKind) : U(
nullptr);
86 return (*
this && isa<U>()) ? U(ownerAndKind) : U(
nullptr);
88 template <
typename U> U
cast()
const {
90 return U(ownerAndKind);
99 operator bool()
const {
return ownerAndKind.getPointer(); }
106 Type getType()
const;
117 void setType(
Type newType);
128 Region *getParentRegion();
138 void dropAllUses()
const;
143 void replaceAllUsesWith(
Value newValue)
const;
159 bool hasOneUse()
const;
162 bool use_empty()
const;
180 void print(raw_ostream &os);
187 value.
ownerAndKind.setFromOpaqueValue(const_cast<void *>(pointer));
196 return resultNo < static_cast<unsigned>(Kind::TrailingOpResult);
245 return value.
getKind() == Kind::BlockArgument;
258 unsigned getArgNumber()
const;
267 void destroy() {
delete getImpl(); }
272 ownerAndKind.getPointer());
298 return value.
getKind() != Kind::BlockArgument;
305 unsigned getResultNumber()
const;
310 static unsigned getNumTrailing(
unsigned numResults);
341 template <>
struct PointerLikeTypeTraits<
mlir::Value> {
350 NumLowBitsAvailable =
351 PointerLikeTypeTraits<mlir::Value::ImplType>::NumLowBitsAvailable
359 mlir::Value::ImplType::getFromOpaqueValue(pointer));
364 mlir::Value::ImplType::getFromOpaqueValue(pointer));
375 template <>
struct PointerLikeTypeTraits<
mlir::BlockArgument> {
384 NumLowBitsAvailable =
385 PointerLikeTypeTraits<mlir::Value>::NumLowBitsAvailable
Kind getKind() const
Returns the kind of this value.
Definition: Value.h:178
Definition: InferTypeOpInterface.cpp:20
Definition: PassRegistry.cpp:413
static bool classof(Value value)
Definition: Value.h:244
Definition: Operation.h:27
The internal implementation of a BlockArgument.
Definition: Value.h:220
This is a value defined by a result of an operation.
Definition: Value.h:287
Type getType() const
Return the type of this value.
Definition: Value.h:252
Block represents an ordered list of Operations.
Definition: Block.h:21
OpResult operator*()
Definition: Value.h:294
OpResult * operator->()
Definition: Value.h:295
An iterator over all users of a ValueBase.
Definition: UseDefLists.h:27
static mlir::Value getTombstoneKey()
Definition: Value.h:330
static bool isEqual(mlir::Value lhs, mlir::Value rhs)
Definition: Value.h:337
user_range getUsers() const
Definition: Value.h:172
bool operator!=(const Value &other) const
Definition: Value.h:103
void * getAsOpaquePointer() const
Methods for supporting PointerLikeTypeTraits.
Definition: Value.h:184
Definition: Location.h:52
Value operator*() const
Definition: Value.h:96
Block * getOwner() const
Returns the block that owns this argument.
Definition: Value.h:249
static Value getFromOpaquePointer(const void *pointer)
Definition: Value.h:185
void print(raw_ostream &os)
Definition: AsmPrinter.cpp:2109
static unsigned getHashValue(mlir::BlockArgument val)
Definition: Value.h:366
static unsigned getHashValue(mlir::Value val)
Definition: Value.h:334
U dyn_cast() const
Definition: Value.h:82
user_iterator user_begin() const
Definition: Value.h:170
static void * getAsVoidPointer(mlir::Value I)
Definition: Value.h:343
static mlir::BlockArgument getEmptyKey()
Definition: Value.h:356
void setType(Type newType)
Set the type of this value.
Definition: Value.h:255
static bool isEqual(mlir::BlockArgument LHS, mlir::BlockArgument RHS)
Definition: Value.h:369
static bool canPackResultInline(unsigned resultNo)
Returns true if the given operation result can be packed inline.
Definition: Value.h:195
bool operator==(const Value &other) const
Definition: Value.h:100
ImplType ownerAndKind
Definition: Value.h:206
Block arguments are values.
Definition: Value.h:235
static void * getAsVoidPointer(mlir::Value I)
Definition: Value.h:377
use_iterator use_end() const
Definition: Value.h:153
BlockArgument * operator->()
Definition: Value.h:242
user_iterator user_end() const
Definition: Value.h:171
MLIRContext * getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Types.cpp:27
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
Definition: AffineExpr.h:201
bool isa() const
Definition: Value.h:78
inline ::llvm::hash_code hash_value(Value arg)
Make Value hashable.
Definition: Value.h:317
llvm::PointerIntPair< void *, 2, Kind, ImplTypeTraits > ImplType
Definition: Value.h:70
Value(std::nullptr_t)
Definition: Value.h:73
U dyn_cast_or_null() const
Definition: Value.h:85
Definition: MLIRContext.h:34
void print(OpAsmPrinter &p, AffineIfOp op)
Definition: AffineOps.cpp:1671
static bool classof(Value value)
Definition: Value.h:297
Value(ImplType ownerAndKind={})
Definition: Value.h:74
Definition: UseDefLists.h:26
U cast() const
Definition: Value.h:88
static mlir::BlockArgument getTombstoneKey()
Definition: Value.h:361
raw_ostream & operator<<(raw_ostream &os, SubViewOp::Range &range)
Definition: Ops.cpp:2759
Kind
Definition: Value.h:43
static mlir::Value getFromVoidPointer(void *P)
Definition: Value.h:346
Value * operator->() const
Definition: Value.h:97
use_range getUses() const
Returns a range of all uses, which is useful for iterating over all uses.
Definition: Value.h:156
static mlir::BlockArgument getFromVoidPointer(void *P)
Definition: Value.h:380
MLIRContext * getContext() const
Utility to get the associated MLIRContext that this value is defined in.
Definition: Value.h:109
static mlir::Value getEmptyKey()
Definition: Value.h:326