1 | //===- Passes.h - Bufferization pipeline entry points -----------*- 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 | // This header file defines prototypes of all bufferization pipelines. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #ifndef MLIR_DIALECT_BUFFERIZATION_PIPELINES_PASSES_H |
14 | #define MLIR_DIALECT_BUFFERIZATION_PIPELINES_PASSES_H |
15 | |
16 | #include "mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.h" |
17 | #include "mlir/Pass/PassOptions.h" |
18 | |
19 | namespace mlir { |
20 | namespace bufferization { |
21 | |
22 | /// Options for the buffer deallocation pipeline. |
23 | struct BufferDeallocationPipelineOptions |
24 | : public PassPipelineOptions<BufferDeallocationPipelineOptions> { |
25 | PassOptions::Option<bool> privateFunctionDynamicOwnership{ |
26 | *this, "private-function-dynamic-ownership" , |
27 | llvm::cl::desc( |
28 | "Allows to add additional results to private functions to return " |
29 | "ownership of returned memrefs to callers. This can avoid spurious " |
30 | "buffer clones in the callee." ), |
31 | llvm::cl::init(Val: false)}; |
32 | |
33 | /// Implicit conversion to `DeallocationOptions`. |
34 | operator DeallocationOptions() const { |
35 | DeallocationOptions options; |
36 | options.privateFuncDynamicOwnership = privateFunctionDynamicOwnership; |
37 | return options; |
38 | } |
39 | }; |
40 | |
41 | //===----------------------------------------------------------------------===// |
42 | // Building and Registering. |
43 | //===----------------------------------------------------------------------===// |
44 | |
45 | /// Adds the buffer deallocation pipeline to the `OpPassManager`. This |
46 | /// is the standard pipeline for deallocating the MemRefs introduced by the |
47 | /// One-Shot bufferization pass. |
48 | void buildBufferDeallocationPipeline( |
49 | OpPassManager &pm, const BufferDeallocationPipelineOptions &options); |
50 | |
51 | /// Registers all pipelines for the `bufferization` dialect. Currently, |
52 | /// this includes only the "buffer-deallocation-pipeline". |
53 | void registerBufferizationPipelines(); |
54 | |
55 | } // namespace bufferization |
56 | } // namespace mlir |
57 | |
58 | #endif // MLIR_DIALECT_BUFFERIZATION_PIPELINES_PASSES_H |
59 | |