MLIR 24.0.0git
ConvertToLLVMIR.cpp
Go to the documentation of this file.
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
18#include "llvm/IR/DebugProgramInstruction.h"
19#include "llvm/IR/LLVMContext.h"
20#include "llvm/IR/Module.h"
21
22using namespace mlir;
23
24namespace mlir {
28 "mlir-to-llvmir", "Translate MLIR to LLVMIR",
29 [](Operation *op, raw_ostream &output) {
30 llvm::LLVMContext llvmContext;
31 auto llvmModule = translateModuleToLLVMIR(op, llvmContext);
32 if (!llvmModule)
33 return failure();
34
35 llvmModule->renumberMetadataForAssembly();
36 llvmModule->print(output, nullptr);
37 return success();
38 },
39 [](DialectRegistry &registry) {
40 registry.insert<DLTIDialect, func::FuncDialect>();
42 });
43}
44} // namespace mlir
return success()
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
Include the generated interface declarations.
void registerToLLVMIRTranslation()
std::unique_ptr< llvm::Module > translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext, llvm::StringRef name="LLVMDialectModule", bool disableVerification=false, llvm::vfs::FileSystem *fs=nullptr)
Translates a given LLVM dialect module into an LLVM IR module living in the given context.
static void registerAllToLLVMIRTranslations(DialectRegistry &registry)
Registers all dialects that can be translated to LLVM IR and the corresponding translation interfaces...
Definition All.h:38
void registerOpenMPTranslationCLOptions()
Register OpenMP translation command-line options before parsing them.