14 #ifndef MLIR_SUPPORT_TYPEID_H
15 #define MLIR_SUPPORT_TYPEID_H
18 #include "llvm/ADT/DenseMapInfo.h"
19 #include "llvm/ADT/Hashing.h"
20 #include "llvm/ADT/STLExtras.h"
21 #include "llvm/Support/Allocator.h"
22 #include "llvm/Support/PointerLikeTypeTraits.h"
23 #include "llvm/Support/TypeName.h"
109 struct alignas(8) Storage {};
116 return storage == other.storage;
119 return !(*
this == other);
123 template <
typename T>
125 template <
template <
typename>
class Trait>
130 return static_cast<const void *
>(storage);
133 return TypeID(
reinterpret_cast<const Storage *
>(pointer));
140 TypeID(
const Storage *storage) : storage(storage) {}
143 const Storage *storage;
178 template <
typename T,
typename Enable =
void>
187 template <
typename U>
189 template <
typename U>
194 "TypeID::get<> requires the complete definition of `T`");
208 template <
typename T>
210 template <
typename T>
213 template <
typename T>
215 return T::resolveTypeID();
221 template <
typename T>
223 T, std::enable_if_t<InlineTypeIDResolver::has_resolve_typeid<T>::value>> {
226 return InlineTypeIDResolver::resolveTypeID<T>();
231 template <
typename T>
235 template <
template <
typename>
class Trait>
239 return TypeID::get<Trait<Empty>>();
249 #define MLIR_DECLARE_EXPLICIT_TYPE_ID(CLASS_NAME) \
253 class TypeIDResolver<CLASS_NAME> { \
255 static TypeID resolveTypeID() { return id; } \
258 static SelfOwningTypeID id; \
263 #define MLIR_DEFINE_EXPLICIT_TYPE_ID(CLASS_NAME) \
266 SelfOwningTypeID TypeIDResolver<CLASS_NAME>::id = {}; \
274 #define MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CLASS_NAME) \
275 static ::mlir::TypeID resolveTypeID() { \
276 static ::mlir::SelfOwningTypeID id; \
280 ::mlir::detail::InlineTypeIDResolver::has_resolve_typeid< \
281 CLASS_NAME>::value, \
282 "`MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID` must be placed in a " \
283 "public section of `" #CLASS_NAME "`");
301 llvm::SpecificBumpPtrAllocator<TypeID::Storage> ids;
355 struct PointerLikeTypeTraits<
mlir::TypeID> {
362 static constexpr
int NumLowBitsAvailable = 3;
#define MLIR_DECLARE_EXPLICIT_TYPE_ID(CLASS_NAME)
Defines a TypeID for each instance of this class by using a pointer to the instance.
SelfOwningTypeID(SelfOwningTypeID &&)=delete
TypeID getTypeID() const
Return the TypeID owned by this object.
SelfOwningTypeID & operator=(SelfOwningTypeID &&)=delete
SelfOwningTypeID & operator=(const SelfOwningTypeID &)=delete
SelfOwningTypeID(const SelfOwningTypeID &)=delete
SelfOwningTypeID()=default
This class provides a way to define new TypeIDs at runtime.
TypeID allocate()
Allocate a new TypeID, that is ensured to be unique for the lifetime of the TypeIDAllocator.
This class provides an efficient unique identifier for a specific C++ type.
bool operator==(const TypeID &other) const
Comparison operations.
static TypeID get()
Construct a type info object for the given type T.
friend ::llvm::hash_code hash_value(TypeID id)
Enable hashing TypeID.
static TypeID getFromOpaquePointer(const void *pointer)
bool operator!=(const TypeID &other) const
const void * getAsOpaquePointer() const
Methods for supporting PointerLikeTypeTraits.
This class provides a fallback for resolving TypeIDs.
static TypeID registerImplicitTypeID(StringRef name)
Register an implicit type ID for the given type name.
static TypeID resolveTypeID()
This class provides a resolver for getting the ID for a given class T.
llvm::is_detected< is_fully_resolved_trait, U > is_fully_resolved
decltype(sizeof(U)) is_fully_resolved_trait
Trait to check if U is fully resolved.
static TypeID resolveTypeID()
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Include the generated interface declarations.
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
static unsigned getHashValue(mlir::TypeID val)
static bool isEqual(mlir::TypeID lhs, mlir::TypeID rhs)
static mlir::TypeID getEmptyKey()
static mlir::TypeID getTombstoneKey()
static void * getAsVoidPointer(mlir::TypeID info)
static mlir::TypeID getFromVoidPointer(void *ptr)
This class provides utilities for resolving the TypeID of a class that provides a static TypeID resol...
decltype(T::resolveTypeID()) has_resolve_typeid_trait
Trait to check if T provides a static resolveTypeID method.
static TypeID resolveTypeID()
llvm::is_detected< has_resolve_typeid_trait, T > has_resolve_typeid