[SampleProfileLoader] Fix integer overflow in generateMDProfMetadata (#90217)
[llvm-project.git] / mlir / lib / Target / LLVMIR / ConvertToLLVMIR.cpp
blob4558893779534860dac7e4cb03a45706e6cbf8e4
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.
11 //===----------------------------------------------------------------------===//
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/LLVMContext.h"
20 #include "llvm/IR/Module.h"
22 using namespace mlir;
24 namespace mlir {
25 void registerToLLVMIRTranslation() {
26 TranslateFromMLIRRegistration registration(
27 "mlir-to-llvmir", "Translate MLIR to LLVMIR",
28 [](Operation *op, raw_ostream &output) {
29 llvm::LLVMContext llvmContext;
30 auto llvmModule = translateModuleToLLVMIR(op, llvmContext);
31 if (!llvmModule)
32 return failure();
34 llvmModule->print(output, nullptr);
35 return success();
37 [](DialectRegistry &registry) {
38 registry.insert<DLTIDialect, func::FuncDialect>();
39 registerAllToLLVMIRTranslations(registry);
40 });
42 } // namespace mlir