MLIR  19.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
mlir::AbstractType Class Reference

This class contains all of the static information common to all instances of a registered Type. More...

#include "mlir/IR/TypeSupport.h"

Public Types

using HasTraitFn = llvm::unique_function< bool(TypeID) const >
 
using WalkImmediateSubElementsFn = function_ref< void(Type, function_ref< void(Attribute)>, function_ref< void(Type)>)>
 
using ReplaceImmediateSubElementsFn = function_ref< Type(Type, ArrayRef< Attribute >, ArrayRef< Type >)>
 

Public Member Functions

DialectgetDialect () const
 Return the dialect this type was registered to. More...
 
template<typename T >
T::Concept * getInterface () const
 Returns an instance of the concept object for the given interface if it was registered to this type, null otherwise. More...
 
bool hasInterface (TypeID interfaceID) const
 Returns true if the type has the interface with the given ID. More...
 
template<template< typename T > class Trait>
bool hasTrait () const
 Returns true if the type has a particular trait. More...
 
bool hasTrait (TypeID traitID) const
 Returns true if the type has a particular trait. More...
 
void walkImmediateSubElements (Type type, function_ref< void(Attribute)> walkAttrsFn, function_ref< void(Type)> walkTypesFn) const
 Walk the immediate sub-elements of the given type. More...
 
Type replaceImmediateSubElements (Type type, ArrayRef< Attribute > replAttrs, ArrayRef< Type > replTypes) const
 Replace the immediate sub-elements of the given type. More...
 
TypeID getTypeID () const
 Return the unique identifier representing the concrete type class. More...
 
StringRef getName () const
 Return the unique name representing the type. More...
 

Static Public Member Functions

static const AbstractTypelookup (TypeID typeID, MLIRContext *context)
 Look up the specified abstract type in the MLIRContext and return a reference to it. More...
 
static std::optional< std::reference_wrapper< const AbstractType > > lookup (StringRef name, MLIRContext *context)
 Look up the specified abstract type in the MLIRContext and return a reference to it if it exists. More...
 
template<typename T >
static AbstractType get (Dialect &dialect)
 This method is used by Dialect objects when they register the list of types they contain. More...
 
static AbstractType get (Dialect &dialect, detail::InterfaceMap &&interfaceMap, HasTraitFn &&hasTrait, WalkImmediateSubElementsFn walkImmediateSubElementsFn, ReplaceImmediateSubElementsFn replaceImmediateSubElementsFn, TypeID typeID, StringRef name)
 This method is used by Dialect objects to register types with custom TypeIDs. More...
 

Friends

template<typename ConcreteT , typename BaseT , typename StorageT , typename UniquerT , template< typename T > class... Traits>
class detail::StorageUserBase
 Give StorageUserBase access to the mutable lookup. More...
 

Detailed Description

This class contains all of the static information common to all instances of a registered Type.

Definition at line 30 of file TypeSupport.h.

Member Typedef Documentation

◆ HasTraitFn

using mlir::AbstractType::HasTraitFn = llvm::unique_function<bool(TypeID) const>

Definition at line 32 of file TypeSupport.h.

◆ ReplaceImmediateSubElementsFn

Definition at line 35 of file TypeSupport.h.

◆ WalkImmediateSubElementsFn

Definition at line 33 of file TypeSupport.h.

Member Function Documentation

◆ get() [1/2]

template<typename T >
static AbstractType mlir::AbstractType::get ( Dialect dialect)
inlinestatic

This method is used by Dialect objects when they register the list of types they contain.

Definition at line 50 of file TypeSupport.h.

Referenced by mlir::ExtensibleDialect::registerDynamicType().

◆ get() [2/2]

static AbstractType mlir::AbstractType::get ( Dialect dialect,
detail::InterfaceMap &&  interfaceMap,
HasTraitFn &&  hasTrait,
WalkImmediateSubElementsFn  walkImmediateSubElementsFn,
ReplaceImmediateSubElementsFn  replaceImmediateSubElementsFn,
TypeID  typeID,
StringRef  name 
)
inlinestatic

This method is used by Dialect objects to register types with custom TypeIDs.

The use of this method is in general discouraged in favor of 'get<CustomType>(dialect)';

Definition at line 62 of file TypeSupport.h.

References hasTrait().

◆ getDialect()

Dialect& mlir::AbstractType::getDialect ( ) const
inline

Return the dialect this type was registered to.

Definition at line 73 of file TypeSupport.h.

◆ getInterface()

template<typename T >
T::Concept* mlir::AbstractType::getInterface ( ) const
inline

Returns an instance of the concept object for the given interface if it was registered to this type, null otherwise.

This should not be used directly.

Definition at line 79 of file TypeSupport.h.

References mlir::detail::InterfaceMap::lookup().

Referenced by mlir::TypeInterface< ConcreteType, Traits >::getInterfaceFor().

◆ getName()

StringRef mlir::AbstractType::getName ( ) const
inline

Return the unique name representing the type.

Definition at line 110 of file TypeSupport.h.

Referenced by mlir::irdl::BaseTypeConstraint::verify().

◆ getTypeID()

TypeID mlir::AbstractType::getTypeID ( ) const
inline

Return the unique identifier representing the concrete type class.

Definition at line 107 of file TypeSupport.h.

◆ hasInterface()

bool mlir::AbstractType::hasInterface ( TypeID  interfaceID) const
inline

Returns true if the type has the interface with the given ID.

Definition at line 84 of file TypeSupport.h.

References mlir::detail::InterfaceMap::contains().

◆ hasTrait() [1/2]

template<template< typename T > class Trait>
bool mlir::AbstractType::hasTrait ( ) const
inline

Returns true if the type has a particular trait.

Definition at line 90 of file TypeSupport.h.

Referenced by get(), and mlir::Type::hasTrait().

◆ hasTrait() [2/2]

bool mlir::AbstractType::hasTrait ( TypeID  traitID) const
inline

Returns true if the type has a particular trait.

Definition at line 95 of file TypeSupport.h.

◆ lookup() [1/2]

std::optional< std::reference_wrapper< const AbstractType > > AbstractType::lookup ( StringRef  name,
MLIRContext context 
)
static

Look up the specified abstract type in the MLIRContext and return a reference to it if it exists.

Definition at line 995 of file MLIRContext.cpp.

References mlir::MLIRContext::getImpl().

◆ lookup() [2/2]

const AbstractType & AbstractType::lookup ( TypeID  typeID,
MLIRContext context 
)
static

Look up the specified abstract type in the MLIRContext and return a reference to it.

Definition at line 981 of file MLIRContext.cpp.

Referenced by mlir::transform::detail::checkImplementsTransformHandleTypeInterface(), mlir::detail::TypeUniquer::getWithTypeID(), and mlir::detail::TypeUniquer::registerType().

◆ replaceImmediateSubElements()

Type AbstractType::replaceImmediateSubElements ( Type  type,
ArrayRef< Attribute replAttrs,
ArrayRef< Type replTypes 
) const

Replace the immediate sub-elements of the given type.

Definition at line 25 of file Types.cpp.

Referenced by mlir::Type::replaceImmediateSubElements().

◆ walkImmediateSubElements()

void AbstractType::walkImmediateSubElements ( Type  type,
function_ref< void(Attribute)>  walkAttrsFn,
function_ref< void(Type)>  walkTypesFn 
) const

Walk the immediate sub-elements of the given type.

Definition at line 19 of file Types.cpp.

Referenced by mlir::Type::walkImmediateSubElements().

Friends And Related Function Documentation

◆ detail::StorageUserBase

template<typename ConcreteT , typename BaseT , typename StorageT , typename UniquerT , template< typename T > class... Traits>
friend class detail::StorageUserBase
friend

Give StorageUserBase access to the mutable lookup.

Definition at line 127 of file TypeSupport.h.


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