MLIR  21.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 /// The `loadAllDialects` flag (default on) will load all dialects in the
43 /// context.
44 OwningOpRef<ModuleOp>
45 translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule,
46  MLIRContext *context, bool emitExpensiveWarnings = true,
47  bool dropDICompositeTypeElements = false,
48  bool loadAllDialects = true);
49 
50 /// Translate the given LLVM data layout into an MLIR equivalent using the DLTI
51 /// dialect.
52 DataLayoutSpecInterface translateDataLayout(const llvm::DataLayout &dataLayout,
53  MLIRContext *context);
54 
55 } // namespace mlir
56 
57 #endif // MLIR_TARGET_LLVMIR_IMPORT_H
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition: CallGraph.h:229
Include the generated interface declarations.
DataLayoutSpecInterface translateDataLayout(const llvm::DataLayout &dataLayout, MLIRContext *context)
Translate the given LLVM data layout into an MLIR equivalent using the DLTI dialect.
OwningOpRef< ModuleOp > translateLLVMIRToModule(std::unique_ptr< llvm::Module > llvmModule, MLIRContext *context, bool emitExpensiveWarnings=true, bool dropDICompositeTypeElements=false, bool loadAllDialects=true)
Translates the LLVM module into an MLIR module living in the given context.