Skip to content

Commit fbf611a

Browse files
authored
Register LLVM Dialect with the context. (#232)
We need to register the LLVM Dialect as a valid translation target. This had previously been done later in the pipeline, but since registering dialects is not thread safe, we need to register it earlier before we start the ThreadedCompilationManager.
1 parent 93f4a09 commit fbf611a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/API/api.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
#include "mlir/Support/LLVM.h"
5656
#include "mlir/Support/LogicalResult.h"
5757
#include "mlir/Support/Timing.h"
58+
#include "mlir/Target/LLVMIR/Dialect/Builtin/BuiltinToLLVMIRTranslation.h"
59+
#include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h"
5860
#include "mlir/Tools/ParseUtilities.h"
5961

6062
#include "llvm/ADT/StringRef.h"
@@ -432,6 +434,11 @@ llvm::Error compile_(int argc, char const **argv, std::string *outputString,
432434
context.allowUnregisteredDialects(config.shouldAllowUnregisteredDialects());
433435
context.printOpOnDiagnostic(!config.shouldVerifyDiagnostics());
434436

437+
// Register LLVM dialect and all infrastructure required for translation to
438+
// LLVM IR
439+
mlir::registerBuiltinDialectTranslation(context);
440+
mlir::registerLLVMDialectTranslation(context);
441+
435442
if (config.shouldShowDialects()) {
436443
showDialects_(registry);
437444
return llvm::Error::success();

0 commit comments

Comments
 (0)