|
MLIR 23.0.0git
|
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect. More...
#include "mlir/IR/DialectRegistry.h"
Public Member Functions | |
| DialectRegistry () | |
| DialectRegistry (const DialectRegistry &)=delete | |
| DialectRegistry & | operator= (const DialectRegistry &other)=delete |
| DialectRegistry (DialectRegistry &&)=default | |
| DialectRegistry & | operator= (DialectRegistry &&other)=default |
| 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. | |
| void | addDialectToPreload (StringRef name) |
| Request that the dialect with the given name be preloaded into the MLIRContext, without providing an allocator. | |
| void | insertDynamic (StringRef name, const DynamicDialectPopulationFunction &ctor) |
| Add a new dynamic dialect constructor in the registry. | |
| 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. | |
| void | appendTo (DialectRegistry &destination) const |
| SmallVector< StringRef > | getRegisteredDialectNames () const |
| Return the names of dialects registered in this registry with an allocator function. | |
| ArrayRef< std::string > | getDialectsToPreload () const |
| Return the names of dialects that should be preloaded into the context but whose allocator is expected to be resolved from the context's own registry (added via addDialectToPreload(StringRef)). | |
| LogicalResult | preloadSelectDialects (MLIRContext *ctx, function_ref< InFlightDiagnostic()> emitError={}) const |
| Load into ctx every dialect previously added via addDialectToPreload(StringRef). | |
| void | applyExtensions (Dialect *dialect) const |
| Apply any held extensions that require the given dialect. | |
| void | applyExtensions (MLIRContext *ctx) const |
| Apply any applicable extensions to the given context. | |
| bool | addExtension (TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension) |
| Add the given extension to the registry. | |
| template<typename... ExtensionsT> | |
| void | addExtensions () |
| Add the given extensions to the registry. | |
| template<typename... DialectsT> | |
| bool | addExtension (void(*extensionFn)(MLIRContext *, DialectsT *...)) |
| Add an extension function that requires the given dialects. | |
| bool | isSubsetOf (const DialectRegistry &rhs) const |
| Returns true if the current registry is a subset of 'rhs', i.e. | |
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.
In addition to allocator-backed registrations, the registry can also carry a set of dialect names that some caller has asked to be preloaded into the context (see addDialectToPreload(StringRef)). The registry itself does not load those dialects — it merely records the request; the allocator is expected to live in the MLIRContext's own registry, and actually loading them is the caller's responsibility via preloadSelectDialects(MLIRContext *).
Definition at line 150 of file DialectRegistry.h.
|
explicit |
Definition at line 207 of file Dialect.cpp.
References insert().
Referenced by appendTo(), DialectRegistry(), DialectRegistry(), isSubsetOf(), operator=(), and operator=().
|
delete |
References DialectRegistry().
|
default |
References DialectRegistry().
| void DialectRegistry::addDialectToPreload | ( | StringRef | name | ) |
Request that the dialect with the given name be preloaded into the MLIRContext, without providing an allocator.
Useful when a caller knows a dialect is required but expects its allocator to be available in the MLIRContext's own registry at load time (e.g. a pass learning dialect names from string-valued options).
Definition at line 241 of file Dialect.cpp.
Referenced by appendTo().
|
inline |
Add the given extension to the registry.
Definition at line 255 of file DialectRegistry.h.
Referenced by addExtension(), addExtensions(), mlir::memref::registerAllocationOpInterfaceExternalModels(), 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::ml_program::registerBufferizableOpInterfaceExternalModels(), mlir::scf::registerBufferizableOpInterfaceExternalModels(), mlir::shape::registerBufferizableOpInterfaceExternalModels(), mlir::sparse_tensor::registerBufferizableOpInterfaceExternalModels(), mlir::tensor::registerBufferizableOpInterfaceExternalModels(), mlir::vector::registerBufferizableOpInterfaceExternalModels(), mlir::arith::registerBufferViewFlowOpInterfaceExternalModels(), mlir::memref::registerBufferViewFlowOpInterfaceExternalModels(), mlir::registerBuiltinDialectTranslation(), mlir::builtin::registerCastOpInterfaceExternalModels(), mlir::registerConvertArithToEmitCInterface(), mlir::arith::registerConvertArithToLLVMInterface(), mlir::registerConvertComplexToLLVMInterface(), mlir::cf::registerConvertControlFlowToLLVMInterface(), mlir::registerConvertFuncToEmitCInterface(), mlir::registerConvertFuncToLLVMInterface(), mlir::gpu::registerConvertGpuToLLVMInterface(), mlir::NVVM::registerConvertGpuToNVVMInterface(), mlir::index::registerConvertIndexToLLVMInterface(), mlir::registerConvertMathToLLVMInterface(), mlir::registerConvertMemRefToEmitCInterface(), mlir::registerConvertMemRefToLLVMInterface(), mlir::mpi::registerConvertMPIToLLVMInterface(), mlir::registerConvertNVVMToLLVMInterface(), mlir::registerConvertOpenMPToLLVMInterface(), mlir::ptr::registerConvertPtrToLLVMInterface(), mlir::registerConvertSCFToEmitCInterface(), mlir::ub::registerConvertUBToLLVMInterface(), mlir::vector::registerConvertVectorToLLVMInterface(), mlir::registerConvertX86ToLLVMInterface(), mlir::tensor::registerFindPayloadReplacementOpInterfaceExternalModels(), mlir::registerGPUDialectTranslation(), mlir::gpu::registerIndexedAccessOpInterfaceExternalModels(), mlir::vector::registerIndexedAccessOpInterfaceExternalModels(), mlir::tensor::registerInferTypeOpInterfaceExternalModels(), mlir::func::registerInlinerExtension(), mlir::LLVM::registerInlinerInterface(), mlir::NVVM::registerInlinerInterface(), mlir::registerLLVMDialectImport(), mlir::registerLLVMDialectTranslation(), mlir::nvgpu::registerMemoryAccessOpInterfacesExternalModels(), mlir::memref::registerMemorySlotExternalModels(), mlir::registerNVVMDialectImport(), mlir::registerNVVMDialectTranslation(), mlir::NVVM::registerNVVMTargetInterfaceExternalModels(), mlir::gpu::registerOffloadingLLVMTranslationInterfaceExternalModels(), mlir::registerOpenACCDialectTranslation(), mlir::registerOpenMPDialectTranslation(), mlir::registerPtrDialectTranslation(), mlir::registerROCDLDialectTranslation(), mlir::ROCDL::registerROCDLTargetInterfaceExternalModels(), mlir::linalg::registerRuntimeVerifiableOpInterfaceExternalModels(), mlir::memref::registerRuntimeVerifiableOpInterfaceExternalModels(), mlir::tensor::registerRuntimeVerifiableOpInterfaceExternalModels(), mlir::arith::registerShardingInterfaceExternalModels(), mlir::bufferization::shard_ext::registerShardingInterfaceExternalModels(), mlir::func::registerShardingInterfaceExternalModels(), mlir::linalg::registerShardingInterfaceExternalModels(), mlir::tensor::registerShardingInterfaceExternalModels(), mlir::tosa::registerShardingInterfaceExternalModels(), mlir::spirv::registerSPIRVTargetInterfaceExternalModels(), mlir::linalg::registerSubsetOpInterfaceExternalModels(), mlir::tensor::registerSubsetOpInterfaceExternalModels(), mlir::vector::registerSubsetOpInterfaceExternalModels(), mlir::linalg::registerTilingInterfaceExternalModels(), mlir::tensor::registerTilingInterfaceExternalModels(), mlir::linalg::registerTilingInterfaceExternalModelsForPackUnPackOps(), mlir::affine::registerValueBoundsOpInterfaceExternalModels(), mlir::arith::registerValueBoundsOpInterfaceExternalModels(), mlir::gpu::registerValueBoundsOpInterfaceExternalModels(), mlir::linalg::registerValueBoundsOpInterfaceExternalModels(), mlir::memref::registerValueBoundsOpInterfaceExternalModels(), mlir::scf::registerValueBoundsOpInterfaceExternalModels(), mlir::tensor::registerValueBoundsOpInterfaceExternalModels(), mlir::vector::registerValueBoundsOpInterfaceExternalModels(), mlir::registerVCIXDialectTranslation(), and mlir::xevm::registerXeVMTargetInterfaceExternalModels().
|
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 278 of file DialectRegistry.h.
References addExtension(), and mlir::TypeID::getFromOpaquePointer().
|
inline |
Add the given extensions to the registry.
Definition at line 262 of file DialectRegistry.h.
References addExtension(), and mlir::TypeID::get().
Referenced by mlir::registerConvertToLLVMDependentDialectLoading(), mlir::transform::registerDebugExtension(), mlir::transform::registerIRDLExtension(), mlir::transform::registerLoopExtension(), mlir::transform::registerPDLExtension(), mlir::transform::registerSMTExtension(), mlir::affine::registerTransformDialectExtension(), mlir::arm_neon::registerTransformDialectExtension(), mlir::arm_sve::registerTransformDialectExtension(), mlir::bufferization::registerTransformDialectExtension(), mlir::dlti::registerTransformDialectExtension(), mlir::func::registerTransformDialectExtension(), mlir::gpu::registerTransformDialectExtension(), mlir::linalg::registerTransformDialectExtension(), mlir::memref::registerTransformDialectExtension(), mlir::sparse_tensor::registerTransformDialectExtension(), mlir::tensor::registerTransformDialectExtension(), mlir::vector::registerTransformDialectExtension(), mlir::x86::registerTransformDialectExtension(), mlir::xegpu::registerTransformDialectExtension(), and mlir::transform::registerTuneExtension().
|
inline |
Definition at line 206 of file DialectRegistry.h.
References addDialectToPreload(), DialectRegistry(), and insert().
Referenced by mlir::MLIRContext::appendDialectRegistry(), and mlir::MLIRContext::MLIRContext().
Apply any held extensions that require the given dialect.
Users are not expected to call this directly.
Definition at line 269 of file Dialect.cpp.
References mlir::Dialect::getContext(), mlir::MLIRContext::getLoadedDialect(), and mlir::Dialect::getNamespace().
Referenced by mlir::MLIRContext::appendDialectRegistry().
| 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 318 of file Dialect.cpp.
References mlir::MLIRContext::getLoadedDialect(), and mlir::MLIRContext::getLoadedDialects().
| 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 210 of file Dialect.cpp.
|
inline |
Return the names of dialects that should be preloaded into the context but whose allocator is expected to be resolved from the context's own registry (added via addDialectToPreload(StringRef)).
Definition at line 233 of file DialectRegistry.h.
|
inline |
Return the names of dialects registered in this registry with an allocator function.
Does not include preload-only entries added via addDialectToPreload(StringRef) — use getDialectsToPreload() for those.
Definition at line 222 of file DialectRegistry.h.
Referenced by printRegisteredDialects(), mlir::registerCLIOptions(), mlir::linalg::registerShardingInterfaceExternalModels(), and mlir::PassManager::run().
|
inline |
Definition at line 163 of file DialectRegistry.h.
References mlir::TypeID::get(), mlir::MLIRContext::getOrLoadDialect(), and insert().
Referenced by appendTo(), mlir::tosa::createTosaArithConstantToTosaConstPass(), DialectRegistry(), insert(), insertDynamic(), loadIRDLDialects(), mlir::registerAllDialects(), mlir::shard::registerAllSliceOpLoweringDialects(), mlir::registerArmNeonDialectTranslation(), mlir::registerArmSMEDialectTranslation(), mlir::registerArmSVEDialectTranslation(), mlir::registerGPUDialectTranslation(), mlir::registerLLVMDialectImport(), mlir::registerLLVMDialectTranslation(), mlir::registerNVVMDialectImport(), mlir::registerNVVMDialectTranslation(), mlir::registerOpenACCDialectTranslation(), mlir::registerOpenMPDialectTranslation(), mlir::shard::registerProcessMultiIndexOpLoweringDialects(), mlir::registerPtrDialectTranslation(), mlir::registerROCDLDialectTranslation(), mlir::linalg::registerShardingInterfaceExternalModels(), mlir::registerSPIRVDialectTranslation(), mlir::registerVCIXDialectTranslation(), and mlir::shard::reshardingRegisterDependentDialects().
|
inline |
Definition at line 175 of file DialectRegistry.h.
References insert().
| 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 217 of file Dialect.cpp.
References inserted().
| 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 251 of file Dialect.cpp.
References mlir::TypeID::get(), mlir::MLIRContext::getOrLoadDynamicDialect(), and insert().
| 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 343 of file Dialect.cpp.
References DialectRegistry(), and rhs.
Referenced by mlir::MLIRContext::appendDialectRegistry().
|
delete |
References DialectRegistry().
|
default |
References DialectRegistry().
| LogicalResult DialectRegistry::preloadSelectDialects | ( | MLIRContext * | ctx, |
| function_ref< InFlightDiagnostic()> | emitError = {} ) const |
Load into ctx every dialect previously added via addDialectToPreload(StringRef).
The allocator is resolved from the context's own registry. On failure, if emitError is provided, it is invoked to produce a diagnostic naming the offending dialect; otherwise the failure is silent.
Definition at line 228 of file Dialect.cpp.
References mlir::emitError(), mlir::MLIRContext::getOrLoadDialect(), and success().
Referenced by mlir::PassManager::run().