1 //===- Export.h - MLIR to LLVM IR translation entry point -------*- C++ -*-===// 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 #ifndef MLIR_TARGET_LLVMIR_EXPORT_H 10 #define MLIR_TARGET_LLVMIR_EXPORT_H 11 12 #include "llvm/ADT/StringRef.h" 13 #include <memory> 14 15 namespace llvm { 16 class LLVMContext; 17 class Module; 18 } // namespace llvm 19 20 namespace mlir { 21 class Operation; 22 23 /// Translates a given LLVM dialect `module` into an LLVM IR module living in 24 /// the given context. Operates on any operation from dialects that provide a 25 /// registered implementation of the LLVMTranslationDialectInterface. Returns 26 /// nullptr when the translation fails. 27 /// Verifies the produced LLVM module, except when `disableVerification` is set. 28 std::unique_ptr<llvm::Module> 29 translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext, 30 llvm::StringRef name = "LLVMDialectModule", 31 bool disableVerification = false); 32 } // namespace mlir 33 34 #endif // MLIR_TARGET_LLVMIR_EXPORT_H 35