MLIR 22.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.
20namespace llvm {
21class DataLayout;
22class Module;
23} // namespace llvm
24
25namespace mlir {
26
27class DataLayoutSpecInterface;
28class MLIRContext;
29class 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/// The `importStructsAsLiterals` flag (default off) ensures that all structs
50/// are imported as literal structs, even when they are named in the LLVM
51/// module.
53 std::unique_ptr<llvm::Module> llvmModule, MLIRContext *context,
54 bool emitExpensiveWarnings = true, bool dropDICompositeTypeElements = false,
55 bool loadAllDialects = true, bool preferUnregisteredIntrinsics = false,
56 bool importStructsAsLiterals = false);
57
58/// Translate the given LLVM data layout into an MLIR equivalent using the DLTI
59/// dialect.
60DataLayoutSpecInterface translateDataLayout(const llvm::DataLayout &dataLayout,
61 MLIRContext *context);
62
63} // namespace mlir
64
65#endif // MLIR_TARGET_LLVMIR_IMPORT_H
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:63
This class acts as an owning reference to an op, and will automatically destroy the held op on destru...
Definition OwningOpRef.h:29
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, bool importStructsAsLiterals=false)
Translates the LLVM module into an MLIR module living in the given context.