9 #ifndef MLIR_IR_TYPES_H
10 #define MLIR_IR_TYPES_H
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/DenseMapInfo.h"
15 #include "llvm/Support/PointerLikeTypeTraits.h"
77 template <
typename ConcreteType,
typename BaseType,
typename StorageType,
78 template <
typename T>
class... Traits>
86 constexpr
Type() =
default;
95 explicit operator bool()
const {
return impl; }
99 template <
typename... Tys>
101 template <
typename... Tys>
103 template <
typename U>
105 template <
typename U>
107 template <
typename U>
168 void print(raw_ostream &os)
const;
176 return static_cast<const void *
>(
impl);
179 return Type(
reinterpret_cast<ImplType *
>(
const_cast<void *
>(pointer)));
183 template <
template <
typename T>
class Trait>
207 namespace TypeTrait {
209 template <
typename ConcreteType,
template <
typename>
class TraitType>
219 template <
typename ConcreteType,
typename Traits>
221 TypeTrait::TraitBase> {
245 namespace TypeTrait {
246 template <
typename ConcreteType>
259 template <
typename... Tys>
261 return llvm::isa<Tys...>(*this);
264 template <
typename... Tys>
266 return llvm::isa_and_present<Tys...>(*this);
269 template <
typename U>
271 return llvm::dyn_cast<U>(*
this);
274 template <
typename U>
276 return llvm::dyn_cast_or_null<U>(*
this);
279 template <
typename U>
281 return llvm::cast<U>(*
this);
302 template <
typename T>
303 struct DenseMapInfo<T, std::enable_if_t<std::is_base_of<mlir::Type, T>::value &&
304 !mlir::detail::IsInterface<T>::value>>
308 return T::getFromOpaquePointer(pointer);
312 return T::getFromOpaquePointer(pointer);
318 struct PointerLikeTypeTraits<
mlir::Type> {
326 static constexpr
int NumLowBitsAvailable = 3;
332 template <
typename To,
typename From>
335 std::enable_if_t<std::is_same_v<mlir::Type, std::remove_const_t<From>> ||
336 std::is_base_of_v<mlir::Type, From>>>
349 return std::is_same_v<To, std::remove_const_t<From>> ||
350 std::is_base_of_v<To, From> || To::classof(ty);
This class contains all of the static information common to all instances of a registered Type.
T::Concept * getInterface() const
Returns an instance of the concept object for the given interface if it was registered to this type,...
bool hasTrait() const
Returns true if the type has a particular trait.
This class provides management for the lifetime of the state used when printing the IR.
Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...
MLIRContext is the top-level object for a collection of MLIR operations.
This class provides an efficient unique identifier for a specific C++ type.
This class represents the base of a type interface.
detail::Interface< ConcreteType, Type, Traits, Type, TypeTrait::TraitBase > InterfaceBase
Base storage class appearing in a Type.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
void print(raw_ostream &os) const
Print the current type.
const void * getAsOpaquePointer() const
Methods for supporting PointerLikeTypeTraits.
bool isInteger(unsigned width) const
Return true if this is an integer type with the specified width.
static bool classof(Type)
Dialect & getDialect() const
Get the dialect this type is registered to.
Type(const Type &other)=default
bool isSignlessIntOrIndex() const
Return true if this is a signless integer or index type.
U dyn_cast_or_null() const
MLIRContext * getContext() const
Return the MLIRContext in which this type was uniqued.
bool isa_and_nonnull() const
bool isSignedInteger() const
Return true if this is a signed integer type (with the specified width).
bool isFloat8E4M3FN() const
bool isSignlessInteger() const
Return true if this is a signless integer type (with the specified width).
friend ::llvm::hash_code hash_value(Type arg)
static Type getFromOpaquePointer(const void *pointer)
bool hasTrait()
Returns true if the type was registered with a particular trait.
bool isIntOrIndexOrFloat() const
Return true if this is an integer (of any signedness), index, or float type.
const AbstractTy & getAbstractType()
Return the abstract type descriptor for this type.
bool isUnsignedInteger() const
Return true if this is an unsigned integer type (with the specified width).
bool isIntOrIndex() const
Return true if this is an integer (of any signedness) or an index type.
Type & operator=(const Type &other)=default
ImplType * getImpl() const
Return the Type implementation.
bool isIntOrFloat() const
Return true if this is an integer (of any signedness) or a float type.
Type(const ImplType *impl)
bool isFloat8E5M2() const
bool operator==(Type other) const
TypeID getTypeID()
Return a unique identifier for the concrete type.
bool operator!=(Type other) const
bool isSignlessIntOrFloat() const
Return true of this is a signless integer or a float type.
unsigned getIntOrFloatBitWidth() const
Return the bit width of an integer or a float type, assert failure on other types.
bool isSignlessIntOrIndexOrFloat() const
Return true if this is a signless integer, index, or float type.
This class represents an abstract interface.
Interface< ConcreteType, Type, Traits, Type, TypeTrait::TraitBase > InterfaceBase
typename Traits::Concept Concept
Utility class for implementing users of storage classes uniqued by a StorageUniquer.
Helper class for implementing traits for storage classes.
Include the generated interface declarations.
Include the generated interface declarations.
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)
static bool isPossible(mlir::Type ty)
Arguments are taken as mlir::Type here and not as From, because when casting from an intermediate typ...
static To doCast(mlir::Type ty)
static T getTombstoneKey()
static mlir::Type getEmptyKey()
static unsigned getHashValue(mlir::Type val)
static mlir::Type getTombstoneKey()
static bool isEqual(mlir::Type LHS, mlir::Type RHS)
static void * getAsVoidPointer(mlir::Type I)
static mlir::Type getFromVoidPointer(void *P)
This trait is used to determine if a storage user, like Type, is mutable or not.
A utility class to get, or create, unique instances of types within an MLIRContext.