13 #ifndef MLIR_IR_TYPERANGE_H
14 #define MLIR_IR_TYPERANGE_H
19 #include "llvm/ADT/PointerUnion.h"
20 #include "llvm/ADT/Sequence.h"
34 llvm::PointerUnion<const Value *, const Type *,
35 OpOperand *, detail::OpResultImpl *>,
38 using RangeBaseT::RangeBaseT;
43 template <
typename ValueRangeT>
46 values.end().getCurrent()))) {}
47 template <
typename Arg,
typename = std::enable_if_t<std::is_constructible<
63 static OwnerT offset_base(OwnerT
object, ptrdiff_t index);
65 static Type dereference_iterator(OwnerT
object, ptrdiff_t index);
73 return ::llvm::hash_combine_range(arg.begin(), arg.end());
78 llvm::interleaveComma(types, os);
86 llvm::mapped_iterator<llvm::iota_range<unsigned>::iterator,
94 template <
typename RangeT>
99 template <
typename RangeT>
100 TypeRangeRange(llvm::iota_range<unsigned> sizeRange,
const RangeT &range)
102 {sizeRange.begin(), getRangeFn(range)},
103 {sizeRange.end(),
nullptr}) {}
105 template <
typename RangeT>
106 static std::function<TypeRange(
unsigned)> getRangeFn(
const RangeT &range) {
107 return [=](
unsigned index) -> TypeRange {
return TypeRange(range[index]); };
115 template <
typename ValueIteratorT>
117 :
public llvm::mapped_iterator_base<ValueTypeIterator<ValueIteratorT>,
118 ValueIteratorT, Type> {
120 using llvm::mapped_iterator_base<ValueTypeIterator<ValueIteratorT>,
121 ValueIteratorT,
Type>::mapped_iterator_base;
128 template <
typename ValueRangeT>
131 ValueTypeIterator<typename ValueRangeT::iterator>> {
135 template <
typename Container>
140 assert(index <
size() &&
"invalid index into type range");
141 return *(this->begin() + index);
145 size_t size()
const {
return llvm::size(*
this); }
151 template <
typename OtherT>
153 return llvm::size(*
this) == llvm::size(other) &&
154 std::equal(this->begin(), this->end(), other.begin());
156 template <
typename OtherT>
158 return !(*
this == other);
162 template <
typename RangeT>
164 return lhs.size() ==
static_cast<size_t>(llvm::size(rhs)) &&
165 std::equal(lhs.begin(), lhs.end(), rhs.begin());
204 return isEmptyKey(lhs);
205 if (isTombstoneKey(rhs))
206 return isTombstoneKey(lhs);
211 static const mlir::Type *getEmptyKeyPointer() {
215 static const mlir::Type *getTombstoneKeyPointer() {
216 return DenseMapInfo<mlir::Type *>::getTombstoneKey();
220 if (
const auto *type =
221 llvm::dyn_cast_if_present<const mlir::Type *>(range.getBase()))
222 return type == getEmptyKeyPointer();
227 if (
const auto *type =
228 llvm::dyn_cast_if_present<const mlir::Type *>(range.getBase()))
229 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(std::initializer_list< Type > types)
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...