13#ifndef MLIR_IR_TYPERANGE_H
14#define MLIR_IR_TYPERANGE_H
19#include "llvm/ADT/PointerUnion.h"
20#include "llvm/ADT/Repeated.h"
21#include "llvm/ADT/Sequence.h"
37 llvm::PointerUnion<const Value *, const Type *, OpOperand *,
38 detail::OpResultImpl *, const Repeated<Type> *,
39 const Repeated<Value> *>,
42 using RangeBaseT::RangeBaseT;
47 template <
typename ValueRangeT>
50 values.end().getCurrent()))) {}
51 template <
typename Arg,
typename = std::enable_if_t<std::is_constructible<
55 TypeRange(std::initializer_list<Type> types LLVM_LIFETIME_BOUND)
60 : RangeBaseT(&repeatedValue, repeatedValue.count) {}
77 static OwnerT offset_base(OwnerT
object, ptrdiff_t
index);
79 static Type dereference_iterator(OwnerT
object, ptrdiff_t
index);
87 return ::llvm::hash_combine_range(arg);
92 llvm::interleaveComma(types, os);
101 llvm::mapped_iterator<llvm::iota_range<unsigned>::iterator,
109 template <
typename RangeT>
114 template <
typename RangeT>
115 TypeRangeRange(llvm::iota_range<unsigned> sizeRange,
const RangeT &range)
117 {sizeRange.begin(), getRangeFn(range)},
118 {sizeRange.end(),
nullptr}) {}
120 template <
typename RangeT>
121 static std::function<
TypeRange(
unsigned)> getRangeFn(
const RangeT &range) {
131template <
typename ValueIteratorT>
133 :
public llvm::mapped_iterator_base<ValueTypeIterator<ValueIteratorT>,
134 ValueIteratorT, Type> {
137 ValueIteratorT,
Type>::mapped_iterator_base;
144template <
typename ValueRangeT>
147 ValueTypeIterator<typename ValueRangeT::iterator>> {
151 template <
typename Container>
156 assert(
index <
size() &&
"invalid index into type range");
157 return *(this->begin() +
index);
161 size_t size()
const {
return llvm::size(*
this); }
167 template <
typename OtherT>
169 return llvm::size(*
this) == llvm::size(other) &&
170 std::equal(this->begin(), this->end(), other.begin());
172 template <
typename OtherT>
174 return !(*
this == other);
178template <
typename RangeT>
180 return lhs.size() ==
static_cast<size_t>(llvm::size(
rhs)) &&
181 std::equal(
lhs.begin(),
lhs.end(),
rhs.begin());
220 return isEmptyKey(
lhs);
221 if (isTombstoneKey(
rhs))
222 return isTombstoneKey(
lhs);
227 static const mlir::Type *getEmptyKeyPointer() {
231 static const mlir::Type *getTombstoneKeyPointer() {
232 return DenseMapInfo<mlir::Type *>::getTombstoneKey();
235 static bool isEmptyKey(mlir::TypeRange range) {
236 if (
const auto *type =
237 llvm::dyn_cast_if_present<const mlir::Type *>(range.getBase()))
238 return type == getEmptyKeyPointer();
242 static bool isTombstoneKey(mlir::TypeRange range) {
243 if (
const auto *type =
244 llvm::dyn_cast_if_present<const mlir::Type *>(range.getBase()))
245 return type == getTombstoneKeyPointer();
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.
TypeRangeRange(const RangeT &range)
This class provides an abstraction over the various different ranges of value types.
TypeRange(ArrayRef< Type > types={})
TypeRange(ValueTypeRange< ValueRangeT > values)
TypeRange(Arg &&arg LLVM_LIFETIME_BOUND)
TypeRange(const Repeated< Type > &repeatedValue LLVM_LIFETIME_BOUND)
Constructs a range from a repeated type.
TypeRange(std::initializer_list< Type > types LLVM_LIFETIME_BOUND)
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.
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)
bool operator==(StringAttr lhs, std::nullptr_t)
Define comparisons for StringAttr against nullptr and itself to avoid the StringRef overloads from be...
llvm::mapped_iterator< llvm::iota_range< unsigned >::iterator, std::function< TypeRange(unsigned)> > TypeRangeRangeIterator
AttrTypeSubElementReplacements< Attribute > AttrSubElementReplacements
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
AttrTypeSubElementReplacements< Type > TypeSubElementReplacements
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...