MLIR  20.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 <memory>
18 
19 // Forward-declare LLVM classes.
20 namespace llvm {
21 class DataLayout;
22 class Module;
23 } // namespace llvm
24 
25 namespace mlir {
26 
27 class DataLayoutSpecInterface;
28 class MLIRContext;
29 class ModuleOp;
30 
31 /// Translates the LLVM module into an MLIR module living in the given context.
32 /// The translation supports operations from any dialect that has a registered
33 /// implementation of the LLVMImportDialectInterface. It returns nullptr if the
34 /// translation fails and reports errors using the error handler registered with
35 /// the MLIR context.
36 /// The `emitExpensiveWarnings` option controls if expensive
37 /// but uncritical diagnostics should be emitted.
38 /// The `dropDICompositeTypeElements` option controls if DICompositeTypes should
39 /// be imported without elements. If set, the option avoids the recursive
40 /// traversal of composite type debug information, which can be expensive for
41 /// adversarial inputs.
42 OwningOpRef<ModuleOp>
43 translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule,
44  MLIRContext *context, bool emitExpensiveWarnings = true,
45  bool dropDICompositeTypeElements = false);
46 
47 /// Translate the given LLVM data layout into an MLIR equivalent using the DLTI
48 /// dialect.
49 DataLayoutSpecInterface translateDataLayout(const llvm::DataLayout &dataLayout,
50  MLIRContext *context);
51 
52 } // namespace mlir
53 
54 #endif // MLIR_TARGET_LLVMIR_IMPORT_H
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition: CallGraph.h:229
Include the generated interface declarations.
OwningOpRef< ModuleOp > translateLLVMIRToModule(std::unique_ptr< llvm::Module > llvmModule, MLIRContext *context, bool emitExpensiveWarnings=true, bool dropDICompositeTypeElements=false)
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.