MLIR  14.0.0git
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
mlir::TypeID Class Reference

This class provides an efficient unique identifier for a specific C++ type. More...

#include "mlir/Support/TypeID.h"

Public Member Functions

 TypeID ()
 
bool operator== (const TypeID &other) const
 Comparison operations. More...
 
bool operator!= (const TypeID &other) const
 
const voidgetAsOpaquePointer () const
 Methods for supporting PointerLikeTypeTraits. More...
 

Static Public Member Functions

template<typename T >
static TypeID get ()
 Construct a type info object for the given type T. More...
 
template<template< typename > class Trait>
static TypeID get ()
 
static TypeID getFromOpaquePointer (const void *pointer)
 

Friends

struct detail::TypeIDExported
 
::llvm::hash_code hash_value (TypeID id)
 Enable hashing TypeID. More...
 

Detailed Description

This class provides an efficient unique identifier for a specific C++ type.

This allows for a C++ type to be compared, hashed, and stored in an opaque context. This class is similar in some ways to std::type_index, but can be used for any type. For example, this class could be used to implement LLVM style isa/dyn_cast functionality for a type hierarchy:

struct Base { Base(TypeID typeID) : typeID(typeID) {} TypeID typeID; };

struct DerivedA : public Base { DerivedA() : Base(TypeID::get<DerivedA>()) {}

static bool classof(const Base *base) { return base->typeID == TypeID::get<DerivedA>(); } };

void foo(Base *base) { if (DerivedA *a = llvm::dyn_cast<DerivedA>(base)) ... }

Definition at line 52 of file TypeID.h.

Constructor & Destructor Documentation

◆ TypeID()

mlir::TypeID::TypeID ( )
inline

Definition at line 60 of file TypeID.h.

Member Function Documentation

◆ get() [1/2]

template<template< typename > class Trait>
TypeID mlir::TypeID::get ( )
static

Construct a type info object for the given type T.

Definition at line 133 of file TypeID.h.

◆ get() [2/2]

template<template< typename > class Trait>
static TypeID mlir::TypeID::get ( )
static

◆ getAsOpaquePointer()

const void* mlir::TypeID::getAsOpaquePointer ( ) const
inline

Methods for supporting PointerLikeTypeTraits.

Definition at line 77 of file TypeID.h.

Referenced by llvm::PointerLikeTypeTraits< mlir::TypeID >::getAsVoidPointer().

◆ getFromOpaquePointer()

static TypeID mlir::TypeID::getFromOpaquePointer ( const void pointer)
inlinestatic

◆ operator!=()

bool mlir::TypeID::operator!= ( const TypeID other) const
inline

Definition at line 66 of file TypeID.h.

◆ operator==()

bool mlir::TypeID::operator== ( const TypeID other) const
inline

Comparison operations.

Definition at line 63 of file TypeID.h.

Friends And Related Function Documentation

◆ detail::TypeIDExported

Definition at line 94 of file TypeID.h.

◆ hash_value

::llvm::hash_code hash_value ( TypeID  id)
friend

Enable hashing TypeID.

Definition at line 98 of file TypeID.h.


The documentation for this class was generated from the following file: