MLIR  20.0.0git
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/DialectRegistry.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...
 
void insertDynamic (StringRef name, const DynamicDialectPopulationFunction &ctor)
 Add a new dynamic dialect constructor in 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...
 
void applyExtensions (Dialect *dialect) const
 Apply any held extensions that require the given dialect. More...
 
void applyExtensions (MLIRContext *ctx) const
 Apply any applicable extensions to the given context. More...
 
bool addExtension (TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
 Add the given extension to the registry. More...
 
template<typename... ExtensionsT>
void addExtensions ()
 Add the given extensions to the registry. More...
 
template<typename... DialectsT>
bool addExtension (void(*extensionFn)(MLIRContext *, DialectsT *...))
 Add an extension function that requires the given dialects. More...
 
bool isSubsetOf (const DialectRegistry &rhs) const
 Returns true if the current registry is a subset of 'rhs', i.e. 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 139 of file DialectRegistry.h.

Constructor & Destructor Documentation

◆ DialectRegistry()

DialectRegistry::DialectRegistry ( )
explicit

Definition at line 216 of file Dialect.cpp.

Member Function Documentation

◆ addExtension() [1/2]

bool mlir::DialectRegistry::addExtension ( TypeID  extensionID,
std::unique_ptr< DialectExtensionBase extension 
)
inline

Add the given extension to the registry.

Definition at line 210 of file DialectRegistry.h.

Referenced by addExtension(), addExtensions(), mlir::memref::registerAllocationOpInterfaceExternalModels(), mlir::registerAMXDialectTranslation(), mlir::registerArmNeonDialectTranslation(), mlir::registerArmSMEDialectTranslation(), mlir::registerArmSVEDialectTranslation(), mlir::arith::registerBufferDeallocationOpInterfaceExternalModels(), mlir::cf::registerBufferDeallocationOpInterfaceExternalModels(), mlir::gpu::registerBufferDeallocationOpInterfaceExternalModels(), mlir::scf::registerBufferDeallocationOpInterfaceExternalModels(), mlir::arith::registerBufferizableOpInterfaceExternalModels(), mlir::bufferization::func_ext::registerBufferizableOpInterfaceExternalModels(), mlir::cf::registerBufferizableOpInterfaceExternalModels(), mlir::linalg::registerBufferizableOpInterfaceExternalModels(), mlir::scf::registerBufferizableOpInterfaceExternalModels(), mlir::shape::registerBufferizableOpInterfaceExternalModels(), mlir::sparse_tensor::registerBufferizableOpInterfaceExternalModels(), mlir::tensor::registerBufferizableOpInterfaceExternalModels(), mlir::vector::registerBufferizableOpInterfaceExternalModels(), mlir::ml_program::registerBufferizableOpInterfaceExternalModels(), mlir::arith::registerBufferViewFlowOpInterfaceExternalModels(), mlir::memref::registerBufferViewFlowOpInterfaceExternalModels(), mlir::registerBuiltinDialectTranslation(), mlir::builtin::registerCastOpInterfaceExternalModels(), mlir::arith::registerConvertArithToLLVMInterface(), mlir::registerConvertComplexToLLVMInterface(), mlir::cf::registerConvertControlFlowToLLVMInterface(), mlir::registerConvertFuncToLLVMInterface(), mlir::index::registerConvertIndexToLLVMInterface(), mlir::registerConvertMathToLLVMInterface(), mlir::registerConvertMemRefToLLVMInterface(), mlir::registerConvertNVVMToLLVMInterface(), mlir::registerConvertOpenMPToLLVMInterface(), mlir::ub::registerConvertUBToLLVMInterface(), mlir::tensor::registerFindPayloadReplacementOpInterfaceExternalModels(), mlir::registerGPUDialectTranslation(), mlir::tensor::registerInferTypeOpInterfaceExternalModels(), mlir::func::registerInlinerExtension(), mlir::LLVM::registerInlinerInterface(), mlir::registerLLVMDialectImport(), mlir::registerLLVMDialectTranslation(), mlir::memref::registerMemorySlotExternalModels(), mlir::linalg::registerMeshShardingInterfaceExternalModels(), mlir::registerNVVMDialectImport(), mlir::registerNVVMDialectTranslation(), mlir::NVVM::registerNVVMTargetInterfaceExternalModels(), mlir::gpu::registerOffloadingLLVMTranslationInterfaceExternalModels(), mlir::registerOpenACCDialectTranslation(), mlir::registerOpenMPDialectTranslation(), mlir::registerROCDLDialectTranslation(), mlir::ROCDL::registerROCDLTargetInterfaceExternalModels(), mlir::linalg::registerRuntimeVerifiableOpInterfaceExternalModels(), mlir::memref::registerRuntimeVerifiableOpInterfaceExternalModels(), mlir::tensor::registerShardingInterfaceExternalModels(), mlir::tosa::registerShardingInterfaceExternalModels(), mlir::func::registerShardingInterfaceExternalModels(), mlir::spirv::registerSPIRVTargetInterfaceExternalModels(), mlir::linalg::registerSubsetOpInterfaceExternalModels(), mlir::tensor::registerSubsetOpInterfaceExternalModels(), mlir::vector::registerSubsetOpInterfaceExternalModels(), mlir::linalg::registerTilingInterfaceExternalModels(), mlir::tensor::registerTilingInterfaceExternalModels(), mlir::tensor::registerTilingInterfaceExternalModelsForPackUnPackOps(), mlir::affine::registerValueBoundsOpInterfaceExternalModels(), mlir::arith::registerValueBoundsOpInterfaceExternalModels(), mlir::linalg::registerValueBoundsOpInterfaceExternalModels(), mlir::memref::registerValueBoundsOpInterfaceExternalModels(), mlir::scf::registerValueBoundsOpInterfaceExternalModels(), mlir::tensor::registerValueBoundsOpInterfaceExternalModels(), mlir::vector::registerValueBoundsOpInterfaceExternalModels(), mlir::registerVCIXDialectTranslation(), and mlir::registerX86VectorDialectTranslation().

◆ addExtension() [2/2]

template<typename... DialectsT>
bool mlir::DialectRegistry::addExtension ( void(*)(MLIRContext *, DialectsT *...)  extensionFn)
inline

Add an extension function that requires the given dialects.

Note: This bare functor overload is provided in addition to the std::function variant to enable dialect type deduction, e.g.: registry.addExtension(+[](MLIRContext *ctx, MyDialect *dialect) { ... })

is equivalent to: registry.addExtension<MyDialect>( [](MLIRContext *ctx, MyDialect *dialect){ ... } )

Definition at line 233 of file DialectRegistry.h.

References addExtension(), and mlir::TypeID::getFromOpaquePointer().

◆ addExtensions()

template<typename... ExtensionsT>
void mlir::DialectRegistry::addExtensions ( )
inline

◆ appendTo()

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

◆ applyExtensions() [1/2]

void DialectRegistry::applyExtensions ( Dialect dialect) const

Apply any held extensions that require the given dialect.

Users are not expected to call this directly.

Definition at line 255 of file Dialect.cpp.

References mlir::Dialect::getContext(), mlir::MLIRContext::getLoadedDialect(), and mlir::Dialect::getNamespace().

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

◆ applyExtensions() [2/2]

void DialectRegistry::applyExtensions ( MLIRContext ctx) const

Apply any applicable extensions to the given context.

Users are not expected to call this directly.

Definition at line 304 of file Dialect.cpp.

References mlir::MLIRContext::getLoadedDialect(), and mlir::MLIRContext::getLoadedDialects().

◆ 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 219 of file Dialect.cpp.

◆ getDialectNames()

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

Return the names of dialects known to this registry.

Definition at line 195 of file DialectRegistry.h.

Referenced by printRegisteredDialects(), mlir::registerAndParseCLIOptions(), and mlir::linalg::registerMeshShardingInterfaceExternalModels().

◆ 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 159 of file DialectRegistry.h.

References insert().

◆ 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 226 of file Dialect.cpp.

◆ insertDynamic()

void DialectRegistry::insertDynamic ( StringRef  name,
const DynamicDialectPopulationFunction ctor 
)

Add a new dynamic dialect constructor in the registry.

The constructor provides as argument the created dynamic dialect, and is expected to register the dialect types, attributes, and ops, using the methods defined in ExtensibleDialect such as registerDynamicOperation.

Definition at line 237 of file Dialect.cpp.

References insert().

◆ isSubsetOf()

bool DialectRegistry::isSubsetOf ( const DialectRegistry rhs) const

Returns true if the current registry is a subset of 'rhs', i.e.

if 'rhs' contains all of the components of this registry.

Definition at line 329 of file Dialect.cpp.

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


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