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;
164 static TypeID registerImplicitTypeID(StringRef name);
178 template <
typename T,
typename Enable =
void>
187 template <
typename U>
189 template <
typename U>
194 "TypeID::get<> requires the complete definition of `T`");
195 static TypeID id = registerImplicitTypeID(llvm::getTypeName<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;
321 operator TypeID()
const {
return getTypeID(); }
360 static constexpr
int NumLowBitsAvailable = 3;
365 #endif // MLIR_SUPPORT_TYPEID_H Include the generated interface declarations.
static void * getAsVoidPointer(mlir::TypeID info)
Explicitly register a set of "builtin" types.
This class provides a resolver for getting the ID for a given class T.
TypeID allocate()
Allocate a new TypeID, that is ensured to be unique for the lifetime of the TypeIDAllocator.
bool operator!=(const TypeID &other) const
This class provides utilities for resolving the TypeID of a class that provides a static TypeID resol...
static TypeID get()
Construct a type info object for the given type T.
static mlir::TypeID getFromVoidPointer(void *ptr)
llvm::is_detected< is_fully_resolved_trait, U > is_fully_resolved
#define MLIR_DECLARE_EXPLICIT_TYPE_ID(CLASS_NAME)
static mlir::TypeID getTombstoneKey()
This class provides a fallback for resolving TypeIDs.
This class provides an efficient unique identifier for a specific C++ type.
static TypeID resolveTypeID()
const void * getAsOpaquePointer() const
Methods for supporting PointerLikeTypeTraits.
static unsigned getHashValue(mlir::TypeID val)
static mlir::TypeID getEmptyKey()
static TypeID resolveTypeID()
decltype(sizeof(U)) is_fully_resolved_trait
Trait to check if U is fully resolved.
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
static TypeID getFromOpaquePointer(const void *pointer)
bool operator==(const TypeID &other) const
Comparison operations.
llvm::is_detected< has_resolve_typeid_trait, T > has_resolve_typeid
decltype(T::resolveTypeID()) has_resolve_typeid_trait
Trait to check if T provides a static resolveTypeID method.
friend ::llvm::hash_code hash_value(TypeID id)
Enable hashing TypeID.
This class provides a way to define new TypeIDs at runtime.
Defines a TypeID for each instance of this class by using a pointer to the instance.
static bool isEqual(mlir::TypeID lhs, mlir::TypeID rhs)
TypeID getTypeID() const
Return the TypeID owned by this object.
static TypeID resolveTypeID()