1 //===- Import.h - LLVM IR To MLIR translation -------------------*- 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 // This file declares the entry point for the LLVM IR to MLIR conversion. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef MLIR_TARGET_LLVMIR_IMPORT_H 14 #define MLIR_TARGET_LLVMIR_IMPORT_H 15 16 #include "mlir/IR/OwningOpRef.h" 17 #include "mlir/Support/LLVM.h" 18 #include "llvm/ADT/StringRef.h" 19 #include <memory> 20 21 // Forward-declare LLVM classes. 22 namespace llvm { 23 class DataLayout; 24 class Module; 25 } // namespace llvm 26 27 namespace mlir { 28 29 class DataLayoutSpecInterface; 30 class MLIRContext; 31 class ModuleOp; 32 33 /// Convert the given LLVM module into MLIR's LLVM dialect. The LLVM context is 34 /// extracted from the registered LLVM IR dialect. In case of error, report it 35 /// to the error handler registered with the MLIR context, if any (obtained from 36 /// the MLIR module), and return `{}`. 37 OwningOpRef<ModuleOp> 38 translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule, 39 MLIRContext *context); 40 41 /// Translate the given LLVM data layout into an MLIR equivalent using the DLTI 42 /// dialect. 43 DataLayoutSpecInterface translateDataLayout(const llvm::DataLayout &dataLayout, 44 MLIRContext *context); 45 46 } // namespace mlir 47 48 #endif // MLIR_TARGET_LLVMIR_IMPORT_H 49