MLIR  21.0.0git
ConvertFuncToLLVM.h
Go to the documentation of this file.
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 
18 
19 namespace mlir {
20 
21 namespace LLVM {
22 class LLVMFuncOp;
23 } // namespace LLVM
24 
26 class DialectRegistry;
27 class LLVMTypeConverter;
28 class RewritePatternSet;
29 class SymbolTable;
31 
32 /// Convert input FunctionOpInterface operation to LLVMFuncOp by using the
33 /// provided LLVMTypeConverter. Return failure if failed to so.
34 FailureOr<LLVM::LLVMFuncOp>
35 convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
36  ConversionPatternRewriter &rewriter,
37  const LLVMTypeConverter &converter,
38  SymbolTableCollection *symbolTables = nullptr);
39 
40 /// Collect the default pattern to convert a FuncOp to the LLVM dialect. If
41 /// `emitCWrappers` is set, the pattern will also produce functions
42 /// that pass memref descriptors by pointer-to-structure in addition to the
43 /// default unpacked form.
45  const LLVMTypeConverter &converter, RewritePatternSet &patterns,
46  SymbolTableCollection *symbolTables = nullptr);
47 
48 /// Collect the patterns to convert from the Func dialect to LLVM. The
49 /// conversion patterns capture the LLVMTypeConverter and the LowerToLLVMOptions
50 /// by reference meaning the references have to remain alive during the entire
51 /// pattern lifetime.
52 ///
53 /// The `symbolTable` parameter can be used to speed up function lookups in the
54 /// module. It's good to provide it, but only if we know that the patterns will
55 /// be applied to a single module and the symbols referenced by the symbol table
56 /// will not be removed and new symbols will not be added during the usage of
57 /// the patterns. If provided, the lookups will have O(calls) cumulative
58 /// runtime, otherwise O(calls * functions). The symbol table is currently not
59 /// needed if `converter.getOptions().useBarePtrCallConv` is `true`, but it's
60 /// not an error to provide it anyway.
62  const LLVMTypeConverter &converter, RewritePatternSet &patterns,
63  SymbolTableCollection *symbolTables = nullptr);
64 
66 
67 } // namespace mlir
68 
69 #endif // MLIR_CONVERSION_FUNCTOLLVM_CONVERTFUNCTOLLVM_H
This class implements a pattern rewriter for use with ConversionPatterns.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Conversion from types to the LLVM IR dialect.
Definition: TypeConverter.h:35
This class represents a collection of SymbolTables.
Definition: SymbolTable.h:283
This class allows for representing and managing the symbol table used by operations with the 'SymbolT...
Definition: SymbolTable.h:24
Include the generated interface declarations.
void registerConvertFuncToLLVMInterface(DialectRegistry &registry)
Definition: FuncToLLVM.cpp:853
void populateFuncToLLVMConversionPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns, SymbolTableCollection *symbolTables=nullptr)
Collect the patterns to convert from the Func dialect to LLVM.
Definition: FuncToLLVM.cpp:757
void populateFuncToLLVMFuncOpConversionPattern(const LLVMTypeConverter &converter, RewritePatternSet &patterns, SymbolTableCollection *symbolTables=nullptr)
Collect the default pattern to convert a FuncOp to the LLVM dialect.
Definition: FuncToLLVM.cpp:751
const FrozenRewritePatternSet & patterns
FailureOr< LLVM::LLVMFuncOp > convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp, ConversionPatternRewriter &rewriter, const LLVMTypeConverter &converter, SymbolTableCollection *symbolTables=nullptr)
Convert input FunctionOpInterface operation to LLVMFuncOp by using the provided LLVMTypeConverter.
Definition: FuncToLLVM.cpp:302