1//===- ConvertToLLVMIR.cpp - MLIR to LLVM IR conversion -------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements a translation between the MLIR LLVM dialect and LLVM IR.
10//
11//===----------------------------------------------------------------------===//
12
13#include "mlir/Dialect/DLTI/DLTI.h"
14#include "mlir/Dialect/Func/IR/FuncOps.h"
15#include "mlir/IR/BuiltinOps.h"
16#include "mlir/Target/LLVMIR/Dialect/All.h"
17#include "mlir/Target/LLVMIR/Export.h"
18#include "mlir/Tools/mlir-translate/Translation.h"
19#include "llvm/IR/DebugProgramInstruction.h"
20#include "llvm/IR/LLVMContext.h"
21#include "llvm/IR/Module.h"
22
23using namespace mlir;
24
25namespace mlir {
26void registerToLLVMIRTranslation() {
27 TranslateFromMLIRRegistration registration(
28 "mlir-to-llvmir", "Translate MLIR to LLVMIR",
29 [](Operation *op, raw_ostream &output) {
30 llvm::LLVMContext llvmContext;
31 auto llvmModule = translateModuleToLLVMIR(module: op, llvmContext);
32 if (!llvmModule)
33 return failure();
34
35 llvmModule->removeDebugIntrinsicDeclarations();
36 llvmModule->print(OS&: output, AAW: nullptr);
37 return success();
38 },
39 [](DialectRegistry &registry) {
40 registry.insert<DLTIDialect, func::FuncDialect>();
41 registerAllToLLVMIRTranslations(registry);
42 });
43}
44} // namespace mlir
45

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp