MLIR 24.0.0git
Export.h
Go to the documentation of this file.
1//===- Export.h - MLIR to LLVM IR translation entry point -------*- 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#ifndef MLIR_TARGET_LLVMIR_EXPORT_H
10#define MLIR_TARGET_LLVMIR_EXPORT_H
11
12#include "llvm/ADT/StringRef.h"
13#include "llvm/Support/VirtualFileSystemFwd.h"
14#include <memory>
15
16namespace llvm {
17class LLVMContext;
18class Module;
19} // namespace llvm
20
21namespace mlir {
22class Operation;
23
24/// Translates a given LLVM dialect `module` into an LLVM IR module living in
25/// the given context. Operates on any operation from dialects that provide a
26/// registered implementation of the LLVMTranslationDialectInterface. Returns
27/// nullptr when the translation fails.
28/// Verifies the produced LLVM module, except when `disableVerification` is set.
29/// An optional \p fs can be provided to avoid direct filesystem access (e.g.,
30/// to comply with the IO sandbox in clang -cc1). When null, the real filesystem
31/// is used.
32std::unique_ptr<llvm::Module>
33translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
34 llvm::StringRef name = "LLVMDialectModule",
35 bool disableVerification = false,
36 llvm::vfs::FileSystem *fs = nullptr);
37} // namespace mlir
38
39#endif // MLIR_TARGET_LLVMIR_EXPORT_H
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition CallGraph.h:227
Include the generated interface declarations.
std::unique_ptr< llvm::Module > translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext, llvm::StringRef name="LLVMDialectModule", bool disableVerification=false, llvm::vfs::FileSystem *fs=nullptr)
Translates a given LLVM dialect module into an LLVM IR module living in the given context.