MLIR  20.0.0git
FuncBufferizableOpInterfaceImpl.h
Go to the documentation of this file.
1 //===- BufferizableOpInterfaceImpl.h - Impl. of BufferizableOpInterface ---===//
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_BUFFERIZATION_TRANSFORMS_FUNCBUFFERIZABLEOPINTERFACEIMPL_H
10 #define MLIR_BUFFERIZATION_TRANSFORMS_FUNCBUFFERIZABLEOPINTERFACEIMPL_H
11 
15 #include "llvm/ADT/SmallVector.h"
16 
17 namespace mlir {
18 class DialectRegistry;
19 
20 namespace func {
21 class FuncOp;
22 } // namespace func
23 
24 namespace bufferization {
25 /// Helper function that returns all func.return ops in the given function.
26 SmallVector<func::ReturnOp> getReturnOps(func::FuncOp funcOp);
27 
28 namespace func_ext {
29 /// The state of analysis of a FuncOp.
31 
32 using func::FuncOp;
33 
34 /// Extra analysis state that is required for bufferization of function
35 /// boundaries.
38  : OneShotAnalysisState::Extension(state) {}
39 
40  // Note: Function arguments and/or function return values may disappear during
41  // bufferization. Functions and their CallOps are analyzed and bufferized
42  // separately. To ensure that a CallOp analysis/bufferization can access an
43  // already bufferized function's analysis results, we store bbArg/return value
44  // indices instead of BlockArguments/OpOperand pointers.
45 
46  /// A set of block argument indices.
48 
49  /// A mapping of indices to indices.
51 
52  /// A mapping of indices to a list of indices.
54 
55  /// A mapping of ReturnOp OpOperand indices to equivalent FuncOp BBArg
56  /// indices.
58 
59  /// A mapping of FuncOp BBArg indices to aliasing ReturnOp OpOperand indices.
61 
62  /// A set of all read BlockArguments of FuncOps.
64 
65  /// A set of all written-to BlockArguments of FuncOps.
67 
68  /// Keep track of which FuncOps are fully analyzed or currently being
69  /// analyzed.
71 
72  /// This function is called right before analyzing the given FuncOp. It
73  /// initializes the data structures for the FuncOp in this state object.
74  void startFunctionAnalysis(FuncOp funcOp);
75 };
76 
78 } // namespace func_ext
79 } // namespace bufferization
80 } // namespace mlir
81 
82 #endif // MLIR_BUFFERIZATION_TRANSFORMS_FUNCBUFFERIZABLEOPINTERFACEIMPL_H
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Base class for OneShotAnalysisState extensions that allow OneShotAnalysisState to contain user-specif...
Extension(OneShotAnalysisState &state)
Constructs an extension of the given state object.
State for analysis-enabled bufferization.
FuncOpAnalysisState
The state of analysis of a FuncOp.
void registerBufferizableOpInterfaceExternalModels(DialectRegistry &registry)
SmallVector< func::ReturnOp > getReturnOps(func::FuncOp funcOp)
Helper function that returns all func.return ops in the given function.
Include the generated interface declarations.
Extra analysis state that is required for bufferization of function boundaries.
DenseMap< FuncOp, IndexMapping > equivalentFuncArgs
A mapping of ReturnOp OpOperand indices to equivalent FuncOp BBArg indices.
DenseMap< FuncOp, IndexToIndexListMapping > aliasingReturnVals
A mapping of FuncOp BBArg indices to aliasing ReturnOp OpOperand indices.
DenseMap< FuncOp, BbArgIndexSet > readBbArgs
A set of all read BlockArguments of FuncOps.
DenseMap< FuncOp, BbArgIndexSet > writtenBbArgs
A set of all written-to BlockArguments of FuncOps.
DenseMap< FuncOp, FuncOpAnalysisState > analyzedFuncOps
Keep track of which FuncOps are fully analyzed or currently being analyzed.
void startFunctionAnalysis(FuncOp funcOp)
This function is called right before analyzing the given FuncOp.