MLIR  19.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 
19 
20 namespace mlir {
21 
22 namespace LLVM {
23 class LLVMFuncOp;
24 } // namespace LLVM
25 
27 class DialectRegistry;
28 class LLVMTypeConverter;
29 class RewritePatternSet;
30 class SymbolTable;
31 
32 /// Convert input FunctionOpInterface operation to LLVMFuncOp by using the
33 /// provided LLVMTypeConverter. Return failure if failed to so.
35 convertFuncOpToLLVMFuncOp(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.
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.
60  LLVMTypeConverter &converter, RewritePatternSet &patterns,
61  const SymbolTable *symbolTable = nullptr);
62 
64 
65 } // namespace mlir
66 
67 #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.
This class provides support for representing a failure result, or a valid value of type T.
Definition: LogicalResult.h:78
Conversion from types to the LLVM IR dialect.
Definition: TypeConverter.h:34
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 populateFuncToLLVMConversionPatterns(LLVMTypeConverter &converter, RewritePatternSet &patterns, const SymbolTable *symbolTable=nullptr)
Collect the patterns to convert from the Func dialect to LLVM.
Definition: FuncToLLVM.cpp:737
void registerConvertFuncToLLVMInterface(DialectRegistry &registry)
Definition: FuncToLLVM.cpp:842
FailureOr< LLVM::LLVMFuncOp > convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp, ConversionPatternRewriter &rewriter, const LLVMTypeConverter &converter)
Convert input FunctionOpInterface operation to LLVMFuncOp by using the provided LLVMTypeConverter.
Definition: FuncToLLVM.cpp:321
void populateFuncToLLVMFuncOpConversionPattern(LLVMTypeConverter &converter, RewritePatternSet &patterns)
Collect the default pattern to convert a FuncOp to the LLVM dialect.
Definition: FuncToLLVM.cpp:732