13 #ifndef MLIR_IR_TYPERANGE_H
14 #define MLIR_IR_TYPERANGE_H
19 #include "llvm/ADT/PointerUnion.h"
20 #include "llvm/ADT/Sequence.h"
35 llvm::PointerUnion<const Value *, const Type *,
36 OpOperand *, detail::OpResultImpl *>,
39 using RangeBaseT::RangeBaseT;
44 template <
typename ValueRangeT>
47 values.end().getCurrent()))) {}
48 template <
typename Arg,
typename = std::enable_if_t<std::is_constructible<
52 TypeRange(std::initializer_list<Type> types LLVM_LIFETIME_BOUND)
65 static OwnerT offset_base(OwnerT
object, ptrdiff_t index);
67 static Type dereference_iterator(OwnerT
object, ptrdiff_t index);
75 return ::llvm::hash_combine_range(arg.begin(), arg.end());
80 llvm::interleaveComma(types, os);
89 llvm::mapped_iterator<llvm::iota_range<unsigned>::iterator,
97 template <
typename RangeT>
102 template <
typename RangeT>
103 TypeRangeRange(llvm::iota_range<unsigned> sizeRange,
const RangeT &range)
105 {sizeRange.begin(), getRangeFn(range)},
106 {sizeRange.end(),
nullptr}) {}
108 template <
typename RangeT>
109 static std::function<TypeRange(
unsigned)> getRangeFn(
const RangeT &range) {
110 return [=](
unsigned index) -> TypeRange {
return TypeRange(range[index]); };
119 template <
typename ValueIteratorT>
121 :
public llvm::mapped_iterator_base<ValueTypeIterator<ValueIteratorT>,
122 ValueIteratorT, Type> {
124 using llvm::mapped_iterator_base<ValueTypeIterator<ValueIteratorT>,
125 ValueIteratorT,
Type>::mapped_iterator_base;
132 template <
typename ValueRangeT>
135 ValueTypeIterator<typename ValueRangeT::iterator>> {
139 template <
typename Container>
144 assert(index <
size() &&
"invalid index into type range");
145 return *(this->begin() + index);
149 size_t size()
const {
return llvm::size(*
this); }
155 template <
typename OtherT>
157 return llvm::size(*
this) == llvm::size(other) &&
158 std::equal(this->begin(), this->end(), other.begin());
160 template <
typename OtherT>
162 return !(*
this == other);
166 template <
typename RangeT>
168 return lhs.size() ==
static_cast<size_t>(llvm::size(rhs)) &&
169 std::equal(lhs.begin(), lhs.end(), rhs.begin());
208 return isEmptyKey(lhs);
209 if (isTombstoneKey(rhs))
210 return isTombstoneKey(lhs);
215 static const mlir::Type *getEmptyKeyPointer() {
219 static const mlir::Type *getTombstoneKeyPointer() {
220 return DenseMapInfo<mlir::Type *>::getTombstoneKey();
224 if (
const auto *type =
225 llvm::dyn_cast_if_present<const mlir::Type *>(range.getBase()))
226 return type == getEmptyKeyPointer();
231 if (
const auto *type =
232 llvm::dyn_cast_if_present<const mlir::Type *>(range.getBase()))
233 return type == getTombstoneKeyPointer();
This class is used by AttrTypeSubElementHandler instances to process sub element replacements.
ArrayRef< T > take_front(unsigned n)
Take the first N replacements as an ArrayRef, dropping them from this replacement list.
This class represents an operand of an operation.
This class implements the operand iterators for the Operation class.
This class implements the result iterators for the Operation class.
This class provides an abstraction for a range of TypeRange.
TypeRangeRange(const RangeT &range)
This class provides an abstraction over the various different ranges of value types.
TypeRange(ValueTypeRange< ValueRangeT > values)
TypeRange(Arg &&arg LLVM_LIFETIME_BOUND)
TypeRange(std::initializer_list< Type > types LLVM_LIFETIME_BOUND)
TypeRange(ArrayRef< Type > types=std::nullopt)
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class provides an abstraction over the different types of ranges over Values.
This class implements iteration on the types of a given range of values.
Type mapElement(Value value) const
Map the element to the iterator result type.
This class implements iteration on the types of a given range of values.
size_t size() const
Return the size of this range.
ValueTypeRange(Container &&c)
Type operator[](size_t index) const
Return the type at the given index.
bool operator==(const OtherT &other) const
Compare this range with another.
bool operator!=(const OtherT &other) const
Type front()
Return first type in the range.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
This class provides the implementation for an operation result.
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Include the generated interface declarations.
llvm::mapped_iterator< llvm::iota_range< unsigned >::iterator, std::function< TypeRange(unsigned)> > TypeRangeRangeIterator
bool operator==(StringAttr lhs, std::nullptr_t)
Define comparisons for StringAttr against nullptr and itself to avoid the StringRef overloads from be...
inline ::llvm::hash_code hash_value(TypeRange arg)
Make TypeRange hashable.
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)
static bool isEqual(mlir::TypeRange lhs, mlir::TypeRange rhs)
static unsigned getHashValue(mlir::TypeRange val)
static mlir::TypeRange getEmptyKey()
static mlir::TypeRange getTombstoneKey()
static void walk(TypeRange param, AttrTypeImmediateSubElementWalker &walker)
static TypeRange replace(TypeRange param, AttrSubElementReplacements &attrRepls, TypeSubElementReplacements &typeRepls)
This class provides support for interacting with the SubElementInterfaces for different types of para...