@@ -30,6 +30,25 @@ using DeallocHelperMap = llvm::DenseMap<Operation *, func::FuncOp>;
30
30
#define GEN_PASS_DECL
31
31
#include " mlir/Dialect/Bufferization/Transforms/Passes.h.inc"
32
32
33
+ // / Creates an instance of the OwnershipBasedBufferDeallocation pass to free all
34
+ // / allocated buffers.
35
+ std::unique_ptr<Pass> createOwnershipBasedBufferDeallocationPass (
36
+ DeallocationOptions options = DeallocationOptions());
37
+
38
+ // / Creates a pass that finds all temporary allocations
39
+ // / and attempts to move the deallocation after the last user/dependency
40
+ // / of the allocation, thereby optimizing allocation liveness.
41
+ std::unique_ptr<Pass> createOptimizeAllocationLivenessPass ();
42
+
43
+ // / Creates a pass that optimizes `bufferization.dealloc` operations. For
44
+ // / example, it reduces the number of alias checks needed at runtime using
45
+ // / static alias analysis.
46
+ std::unique_ptr<Pass> createBufferDeallocationSimplificationPass ();
47
+
48
+ // / Creates an instance of the LowerDeallocations pass to lower
49
+ // / `bufferization.dealloc` operations to the `memref` dialect.
50
+ std::unique_ptr<Pass> createLowerDeallocationsPass ();
51
+
33
52
// / Adds the conversion pattern of the `bufferization.dealloc` operation to the
34
53
// / given pattern set for use in other transformation passes.
35
54
void populateBufferizationDeallocLoweringPattern (
@@ -122,6 +141,14 @@ func::FuncOp buildDeallocationLibraryFunction(OpBuilder &builder, Location loc,
122
141
LogicalResult deallocateBuffersOwnershipBased (FunctionOpInterface op,
123
142
DeallocationOptions options);
124
143
144
+ // / Creates a pass that moves allocations upwards to reduce the number of
145
+ // / required copies that are inserted during the BufferDeallocation pass.
146
+ std::unique_ptr<Pass> createBufferHoistingPass ();
147
+
148
+ // / Creates a pass that moves allocations upwards out of loops. This avoids
149
+ // / reallocations inside of loops.
150
+ std::unique_ptr<Pass> createBufferLoopHoistingPass ();
151
+
125
152
// Options struct for BufferResultsToOutParams pass.
126
153
// Note: defined only here, not in tablegen.
127
154
struct BufferResultsToOutParamsOpts {
@@ -165,20 +192,51 @@ struct BufferResultsToOutParamsOpts {
165
192
bool hoistStaticAllocs = false ;
166
193
};
167
194
195
+ // / Creates a pass that converts memref function results to out-params.
196
+ std::unique_ptr<Pass> createBufferResultsToOutParamsPass (
197
+ const BufferResultsToOutParamsOpts &options = {});
198
+
168
199
// / Replace buffers that are returned from a function with an out parameter.
169
200
// / Also update all call sites.
170
201
LogicalResult
171
202
promoteBufferResultsToOutParams (ModuleOp module ,
172
203
const BufferResultsToOutParamsOpts &options);
173
204
205
+ // / Creates a pass that drops memref function results that are equivalent to a
206
+ // / function argument.
207
+ std::unique_ptr<Pass> createDropEquivalentBufferResultsPass ();
208
+
209
+ // / Create a pass that rewrites tensor.empty to bufferization.alloc_tensor.
210
+ std::unique_ptr<Pass> createEmptyTensorToAllocTensorPass ();
211
+
174
212
// / Drop all memref function results that are equivalent to a function argument.
175
213
LogicalResult dropEquivalentBufferResults (ModuleOp module );
176
214
215
+ // / Create a pass that bufferizes all ops that implement BufferizableOpInterface
216
+ // / with One-Shot Bufferize.
217
+ std::unique_ptr<Pass> createOneShotBufferizePass ();
218
+
219
+ // / Create a pass that bufferizes all ops that implement BufferizableOpInterface
220
+ // / with One-Shot Bufferize and the specified bufferization options.
221
+ std::unique_ptr<Pass>
222
+ createOneShotBufferizePass (const OneShotBufferizationOptions &options);
223
+
224
+ // / Creates a pass that promotes heap-based allocations to stack-based ones.
225
+ // / Only buffers smaller than the provided size are promoted.
226
+ // / Dynamic shaped buffers are promoted up to the given rank.
227
+ std::unique_ptr<Pass>
228
+ createPromoteBuffersToStackPass (unsigned maxAllocSizeInBytes = 1024 ,
229
+ unsigned maxRankOfAllocatedMemRef = 1 );
230
+
177
231
// / Creates a pass that promotes heap-based allocations to stack-based ones.
178
232
// / Only buffers smaller with `isSmallAlloc(alloc) == true` are promoted.
179
233
std::unique_ptr<Pass>
180
234
createPromoteBuffersToStackPass (std::function<bool (Value)> isSmallAlloc);
181
235
236
+ // / Create a pass that tries to eliminate tensor.empty ops that are anchored on
237
+ // / insert_slice ops.
238
+ std::unique_ptr<Pass> createEmptyTensorEliminationPass ();
239
+
182
240
// ===----------------------------------------------------------------------===//
183
241
// Registration
184
242
// ===----------------------------------------------------------------------===//
0 commit comments