comparison mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 79ff65ed7e25
children 1f2b6ac9f198
comparison
equal deleted inserted replaced
232:70dce7da266c 236:c4bab56944e8
8 // 8 //
9 // This file implements a translation between the MLIR LLVM dialect and LLVM IR. 9 // This file implements a translation between the MLIR LLVM dialect and LLVM IR.
10 // 10 //
11 //===----------------------------------------------------------------------===// 11 //===----------------------------------------------------------------------===//
12 12
13 #include "mlir/Dialect/DLTI/DLTI.h"
14 #include "mlir/Dialect/Func/IR/FuncOps.h"
13 #include "mlir/IR/BuiltinOps.h" 15 #include "mlir/IR/BuiltinOps.h"
14 #include "mlir/Target/LLVMIR/Dialect/All.h" 16 #include "mlir/Target/LLVMIR/Dialect/All.h"
15 #include "mlir/Target/LLVMIR/Export.h" 17 #include "mlir/Target/LLVMIR/Export.h"
16 #include "mlir/Translation.h" 18 #include "mlir/Tools/mlir-translate/Translation.h"
17 #include "llvm/IR/LLVMContext.h" 19 #include "llvm/IR/LLVMContext.h"
18 #include "llvm/IR/Module.h" 20 #include "llvm/IR/Module.h"
19 21
20 using namespace mlir; 22 using namespace mlir;
21 23
22 namespace mlir { 24 namespace mlir {
23 void registerToLLVMIRTranslation() { 25 void registerToLLVMIRTranslation() {
24 TranslateFromMLIRRegistration registration( 26 TranslateFromMLIRRegistration registration(
25 "mlir-to-llvmir", 27 "mlir-to-llvmir", "translate mlir to llvmir",
26 [](ModuleOp module, raw_ostream &output) { 28 [](Operation *op, raw_ostream &output) {
27 llvm::LLVMContext llvmContext; 29 llvm::LLVMContext llvmContext;
28 auto llvmModule = translateModuleToLLVMIR(module, llvmContext); 30 auto llvmModule = translateModuleToLLVMIR(op, llvmContext);
29 if (!llvmModule) 31 if (!llvmModule)
30 return failure(); 32 return failure();
31 33
32 llvmModule->print(output, nullptr); 34 llvmModule->print(output, nullptr);
33 return success(); 35 return success();
34 }, 36 },
35 [](DialectRegistry &registry) { 37 [](DialectRegistry &registry) {
38 registry.insert<DLTIDialect, func::FuncDialect>();
36 registerAllToLLVMIRTranslations(registry); 39 registerAllToLLVMIRTranslations(registry);
37 }); 40 });
38 } 41 }
39 } // namespace mlir 42 } // namespace mlir