1//===- ConvertFuncToLLVM.h - Convert Func to LLVM ---------------*- 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// Provides a set of conversion patterns from the Func dialect to the LLVM IR
10// dialect.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MLIR_CONVERSION_FUNCTOLLVM_CONVERTFUNCTOLLVM_H
15#define MLIR_CONVERSION_FUNCTOLLVM_CONVERTFUNCTOLLVM_H
16
17#include "mlir/Interfaces/FunctionInterfaces.h"
18#include "mlir/Support/LogicalResult.h"
19
20namespace mlir {
21
22namespace LLVM {
23class LLVMFuncOp;
24} // namespace LLVM
25
26class ConversionPatternRewriter;
27class DialectRegistry;
28class LLVMTypeConverter;
29class RewritePatternSet;
30class SymbolTable;
31
32/// Convert input FunctionOpInterface operation to LLVMFuncOp by using the
33/// provided LLVMTypeConverter. Return failure if failed to so.
34FailureOr<LLVM::LLVMFuncOp>
35convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
36 ConversionPatternRewriter &rewriter,
37 const LLVMTypeConverter &converter);
38
39/// Collect the default pattern to convert a FuncOp to the LLVM dialect. If
40/// `emitCWrappers` is set, the pattern will also produce functions
41/// that pass memref descriptors by pointer-to-structure in addition to the
42/// default unpacked form.
43void populateFuncToLLVMFuncOpConversionPattern(LLVMTypeConverter &converter,
44 RewritePatternSet &patterns);
45
46/// Collect the patterns to convert from the Func dialect to LLVM. The
47/// conversion patterns capture the LLVMTypeConverter and the LowerToLLVMOptions
48/// by reference meaning the references have to remain alive during the entire
49/// pattern lifetime.
50///
51/// The `symbolTable` parameter can be used to speed up function lookups in the
52/// module. It's good to provide it, but only if we know that the patterns will
53/// be applied to a single module and the symbols referenced by the symbol table
54/// will not be removed and new symbols will not be added during the usage of
55/// the patterns. If provided, the lookups will have O(calls) cumulative
56/// runtime, otherwise O(calls * functions). The symbol table is currently not
57/// needed if `converter.getOptions().useBarePtrCallConv` is `true`, but it's
58/// not an error to provide it anyway.
59void populateFuncToLLVMConversionPatterns(
60 LLVMTypeConverter &converter, RewritePatternSet &patterns,
61 const SymbolTable *symbolTable = nullptr);
62
63void registerConvertFuncToLLVMInterface(DialectRegistry &registry);
64
65} // namespace mlir
66
67#endif // MLIR_CONVERSION_FUNCTOLLVM_CONVERTFUNCTOLLVM_H
68

source code of mlir/include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h