MLIR  19.0.0git
Import.h
Go to the documentation of this file.
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 /// Translates the LLVM module into an MLIR module living in the given context.
34 /// The translation supports operations from any dialect that has a registered
35 /// implementation of the LLVMImportDialectInterface. It returns nullptr if the
36 /// translation fails and reports errors using the error handler registered with
37 /// the MLIR context. The `emitExpensiveWarnings` option controls if expensive
38 /// but uncritical diagnostics should be emitted.
39 OwningOpRef<ModuleOp>
40 translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule,
41  MLIRContext *context,
42  bool emitExpensiveWarnings = true);
43 
44 /// Translate the given LLVM data layout into an MLIR equivalent using the DLTI
45 /// dialect.
46 DataLayoutSpecInterface translateDataLayout(const llvm::DataLayout &dataLayout,
47  MLIRContext *context);
48 
49 } // namespace mlir
50 
51 #endif // MLIR_TARGET_LLVMIR_IMPORT_H
Include the generated interface declarations.
Definition: CallGraph.h:229
Include the generated interface declarations.
OwningOpRef< ModuleOp > translateLLVMIRToModule(std::unique_ptr< llvm::Module > llvmModule, MLIRContext *context, bool emitExpensiveWarnings=true)
Translates the LLVM module into an MLIR module living in the given context.
DataLayoutSpecInterface translateDataLayout(const llvm::DataLayout &dataLayout, MLIRContext *context)
Translate the given LLVM data layout into an MLIR equivalent using the DLTI dialect.