19 #include "llvm/IR/Module.h"
20 #include "llvm/IRReader/IRReader.h"
21 #include "llvm/Support/SourceMgr.h"
28 "import-llvm",
"translate llvmir to mlir",
29 [](llvm::SourceMgr &sourceMgr,
31 llvm::SMDiagnostic err;
32 llvm::LLVMContext llvmContext;
33 std::unique_ptr<llvm::Module> llvmModule =
34 llvm::parseIR(*sourceMgr.getMemoryBuffer(sourceMgr.getMainFileID()),
38 llvm::raw_string_ostream errStream(errStr);
39 err.print(
"", errStream);
40 emitError(UnknownLoc::get(context)) << errStream.str();
48 registry.insert<DLTIDialect>();
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
MLIRContext is the top-level object for a collection of MLIR operations.
This class acts as an owning reference to an op, and will automatically destroy the held op on destru...
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
static void registerAllFromLLVMIRTranslations(DialectRegistry ®istry)
Registers all dialects that can be translated from LLVM IR and the corresponding translation interfac...
void registerFromLLVMIRTranslation()
OwningOpRef< ModuleOp > translateLLVMIRToModule(std::unique_ptr< llvm::Module > llvmModule, MLIRContext *context)
Translates the LLVM module into an MLIR module living in the given context.
Use Translate[ToMLIR|FromMLIR]Registration as an initializer that registers a function and associates...