MLIR  20.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;
30 
31 /// Convert input FunctionOpInterface operation to LLVMFuncOp by using the
32 /// provided LLVMTypeConverter. Return failure if failed to so.
33 FailureOr<LLVM::LLVMFuncOp>
34 convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
35  ConversionPatternRewriter &rewriter,
36  const LLVMTypeConverter &converter);
37 
38 /// Collect the default pattern to convert a FuncOp to the LLVM dialect. If
39 /// `emitCWrappers` is set, the pattern will also produce functions
40 /// that pass memref descriptors by pointer-to-structure in addition to the
41 /// default unpacked form.
43  RewritePatternSet &patterns);
44 
45 /// Collect the patterns to convert from the Func dialect to LLVM. The
46 /// conversion patterns capture the LLVMTypeConverter and the LowerToLLVMOptions
47 /// by reference meaning the references have to remain alive during the entire
48 /// pattern lifetime.
49 ///
50 /// The `symbolTable` parameter can be used to speed up function lookups in the
51 /// module. It's good to provide it, but only if we know that the patterns will
52 /// be applied to a single module and the symbols referenced by the symbol table
53 /// will not be removed and new symbols will not be added during the usage of
54 /// the patterns. If provided, the lookups will have O(calls) cumulative
55 /// runtime, otherwise O(calls * functions). The symbol table is currently not
56 /// needed if `converter.getOptions().useBarePtrCallConv` is `true`, but it's
57 /// not an error to provide it anyway.
59  LLVMTypeConverter &converter, RewritePatternSet &patterns,
60  const SymbolTable *symbolTable = nullptr);
61 
63 
64 } // namespace mlir
65 
66 #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: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:683
void registerConvertFuncToLLVMInterface(DialectRegistry &registry)
Definition: FuncToLLVM.cpp:788
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:271
void populateFuncToLLVMFuncOpConversionPattern(LLVMTypeConverter &converter, RewritePatternSet &patterns)
Collect the default pattern to convert a FuncOp to the LLVM dialect.
Definition: FuncToLLVM.cpp:678