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 /// The `preferUnregisteredIntrinsics` flag (default off) controls whether to
45 /// import all intrinsics using `llvm.intrinsic_call` even if a dialect
46 /// registered an explicit intrinsic operation. Warning: passes that rely on
47 /// matching explicit intrinsic operations may not work properly if this flag is
48 /// enabled.
49 OwningOpRef<ModuleOp> translateLLVMIRToModule(
50  std::unique_ptr<llvm::Module> llvmModule, MLIRContext *context,
51  bool emitExpensiveWarnings = true, bool dropDICompositeTypeElements = false,
52  bool loadAllDialects = true, bool preferUnregisteredIntrinsics = false);
53 
54 /// Translate the given LLVM data layout into an MLIR equivalent using the DLTI
55 /// dialect.
56 DataLayoutSpecInterface translateDataLayout(const llvm::DataLayout &dataLayout,
57  MLIRContext *context);
58 
59 } // namespace mlir
60 
61 #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, bool preferUnregisteredIntrinsics=false)
Translates the LLVM module into an MLIR module living in the given context.