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

The DialectRegistry maps a dialect namespace to a constructor for the matching dialect. More...

#include "mlir/IR/Dialect.h"

Public Member Functions

 DialectRegistry ()
 
template<typename ConcreteDialect >
void insert ()
 
template<typename ConcreteDialect , typename OtherDialect , typename... MoreDialects>
void insert ()
 
void insert (TypeID typeID, StringRef name, const DialectAllocatorFunction &ctor)
 Add a new dialect constructor to the registry. More...
 
DialectAllocatorFunctionRef getDialectAllocator (StringRef name) const
 Return an allocation function for constructing the dialect identified by its namespace, or nullptr if the namespace is not in this registry. More...
 
void appendTo (DialectRegistry &destination) const
 
auto getDialectNames () const
 Return the names of dialects known to this registry. More...
 
template<typename DialectTy >
void addDialectInterface (TypeID interfaceTypeID, DialectInterfaceAllocatorFunction allocator)
 Add an interface constructed with the given allocation function to the dialect provided as template parameter. More...
 
template<typename DialectTy , typename InterfaceTy >
void addDialectInterface ()
 Add an interface to the dialect, both provided as template parameter. More...
 
template<typename OpTy , typename ModelTy >
void addOpInterface ()
 Add an external op interface model for an op that belongs to a dialect, both provided as template parameters. More...
 
template<typename DialectTy , typename AttrTy , typename ModelTy >
void addAttrInterface ()
 Add an external attribute interface model for an attribute type AttrTy that is going to belong to DialectTy. More...
 
template<typename DialectTy , typename TypeTy , typename ModelTy >
void addTypeInterface ()
 Add an external type interface model for an type class TypeTy that is going to belong to DialectTy. More...
 
void registerDelayedInterfaces (Dialect *dialect) const
 Register any interfaces required for the given dialect (based on its TypeID). More...
 

Detailed Description

The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.

This allows for decoupling the list of dialects "available" from the dialects loaded in the Context. The parser in particular will lazily load dialects in the Context as operations are encountered.

Definition at line 282 of file Dialect.h.

Constructor & Destructor Documentation

◆ DialectRegistry()

DialectRegistry::DialectRegistry ( )
explicit

Definition at line 31 of file Dialect.cpp.

References addDialectInterface(), and DEBUG_TYPE.

Member Function Documentation

◆ addAttrInterface()

template<typename DialectTy , typename AttrTy , typename ModelTy >
void mlir::DialectRegistry::addAttrInterface ( )
inline

Add an external attribute interface model for an attribute type AttrTy that is going to belong to DialectTy.

The dialect must be present in the registry.

Definition at line 396 of file Dialect.h.

◆ addDialectInterface() [1/2]

template<typename DialectTy >
void mlir::DialectRegistry::addDialectInterface ( TypeID  interfaceTypeID,
DialectInterfaceAllocatorFunction  allocator 
)
inline

◆ addDialectInterface() [2/2]

template<typename DialectTy , typename InterfaceTy >
void mlir::DialectRegistry::addDialectInterface ( )
inline

Add an interface to the dialect, both provided as template parameter.

The dialect must be present in the registry.

Definition at line 372 of file Dialect.h.

Referenced by DialectRegistry().

◆ addOpInterface()

template<typename OpTy , typename ModelTy >
void mlir::DialectRegistry::addOpInterface ( )
inline

◆ addTypeInterface()

template<typename DialectTy , typename TypeTy , typename ModelTy >
void mlir::DialectRegistry::addTypeInterface ( )
inline

Add an external type interface model for an type class TypeTy that is going to belong to DialectTy.

The dialect must be present in the registry.

Definition at line 404 of file Dialect.h.

◆ appendTo()

void mlir::DialectRegistry::appendTo ( DialectRegistry destination) const
inline

Definition at line 329 of file Dialect.h.

References insert().

Referenced by mlir::MLIRContext::appendDialectRegistry(), and mlir::MLIRContext::MLIRContext().

◆ getDialectAllocator()

DialectAllocatorFunctionRef DialectRegistry::getDialectAllocator ( StringRef  name) const

Return an allocation function for constructing the dialect identified by its namespace, or nullptr if the namespace is not in this registry.

Definition at line 83 of file Dialect.cpp.

◆ getDialectNames()

auto mlir::DialectRegistry::getDialectNames ( ) const
inline

Return the names of dialects known to this registry.

Definition at line 353 of file Dialect.h.

Referenced by mlir::MlirOptMain(), and mlir::PassManager::run().

◆ insert() [1/3]

template<typename ConcreteDialect >
void mlir::DialectRegistry::insert ( )
inline

◆ insert() [2/3]

template<typename ConcreteDialect , typename OtherDialect , typename... MoreDialects>
void mlir::DialectRegistry::insert ( )
inline

Definition at line 312 of file Dialect.h.

◆ insert() [3/3]

void DialectRegistry::insert ( TypeID  typeID,
StringRef  name,
const DialectAllocatorFunction ctor 
)

Add a new dialect constructor to the registry.

The constructor must be calling MLIRContext::getOrLoadDialect in order for the context to take ownership of the dialect and for delayed interface registration to happen.

Definition at line 90 of file Dialect.cpp.

◆ registerDelayedInterfaces()

void DialectRegistry::registerDelayedInterfaces ( Dialect dialect) const

Register any interfaces required for the given dialect (based on its TypeID).

Users are not expected to call this directly.

Definition at line 101 of file Dialect.cpp.

References mlir::Dialect::addInterface(), mlir::Dialect::getContext(), mlir::Dialect::getRegisteredInterface(), and mlir::Dialect::getTypeID().

Referenced by mlir::MLIRContext::appendDialectRegistry().


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