mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 09:13:38 +08:00
Add a utility method to MLIRContext get a registered dialect with the derived type instead of the string name. The derived dialect type must provide a static 'getDialectNamespace' method.
This means that we can now do something like:
ctx->getRegisteredDialect<LLVMDialect>();
as opposed to:
static_cast<LLVMDialect *>(ctx->getRegisteredDialect("llvm");
--
PiperOrigin-RevId: 247989896
This commit is contained in:
committed by
Mehdi Amini
parent
d39a30626e
commit
bc5c7378b2
@@ -409,11 +409,10 @@ bool ModuleTranslation::convertFunctions() {
|
||||
}
|
||||
|
||||
std::unique_ptr<llvm::Module> ModuleTranslation::prepareLLVMModule(Module &m) {
|
||||
Dialect *dialect = m.getContext()->getRegisteredDialect("llvm");
|
||||
auto *dialect = m.getContext()->getRegisteredDialect<LLVM::LLVMDialect>();
|
||||
assert(dialect && "LLVM dialect must be registered");
|
||||
auto *llvmDialect = static_cast<LLVM::LLVMDialect *>(dialect);
|
||||
|
||||
auto llvmModule = llvm::CloneModule(llvmDialect->getLLVMModule());
|
||||
auto llvmModule = llvm::CloneModule(dialect->getLLVMModule());
|
||||
if (!llvmModule)
|
||||
return nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user