|
26 | 26 |
|
27 | 27 | namespace mlir { |
28 | 28 | namespace bufferization { |
29 | | -#define GEN_PASS_DEF_FINALIZINGBUFFERIZE |
30 | 29 | #define GEN_PASS_DEF_BUFFERIZATIONBUFFERIZE |
31 | 30 | #define GEN_PASS_DEF_ONESHOTBUFFERIZE |
32 | 31 | #include "mlir/Dialect/Bufferization/Transforms/Passes.h.inc" |
@@ -98,75 +97,6 @@ void mlir::bufferization::populateBufferizeMaterializationLegality( |
98 | 97 | } |
99 | 98 |
|
100 | 99 | namespace { |
101 | | -// In a finalizing bufferize conversion, we know that all tensors have been |
102 | | -// converted to memrefs, thus, this op becomes an identity. |
103 | | -class BufferizeToTensorOp |
104 | | - : public OpConversionPattern<bufferization::ToTensorOp> { |
105 | | -public: |
106 | | - using OpConversionPattern::OpConversionPattern; |
107 | | - LogicalResult |
108 | | - matchAndRewrite(bufferization::ToTensorOp op, OpAdaptor adaptor, |
109 | | - ConversionPatternRewriter &rewriter) const override { |
110 | | - rewriter.replaceOp(op, adaptor.getMemref()); |
111 | | - return success(); |
112 | | - } |
113 | | -}; |
114 | | -} // namespace |
115 | | - |
116 | | -namespace { |
117 | | -// In a finalizing bufferize conversion, we know that all tensors have been |
118 | | -// converted to memrefs, thus, this op becomes an identity. |
119 | | -class BufferizeToMemrefOp |
120 | | - : public OpConversionPattern<bufferization::ToMemrefOp> { |
121 | | -public: |
122 | | - using OpConversionPattern::OpConversionPattern; |
123 | | - LogicalResult |
124 | | - matchAndRewrite(bufferization::ToMemrefOp op, OpAdaptor adaptor, |
125 | | - ConversionPatternRewriter &rewriter) const override { |
126 | | - rewriter.replaceOp(op, adaptor.getTensor()); |
127 | | - return success(); |
128 | | - } |
129 | | -}; |
130 | | -} // namespace |
131 | | - |
132 | | -void mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns( |
133 | | - const BufferizeTypeConverter &typeConverter, RewritePatternSet &patterns) { |
134 | | - patterns.add<BufferizeToTensorOp, BufferizeToMemrefOp>(typeConverter, |
135 | | - patterns.getContext()); |
136 | | -} |
137 | | - |
138 | | -namespace { |
139 | | -struct FinalizingBufferizePass |
140 | | - : public bufferization::impl::FinalizingBufferizeBase< |
141 | | - FinalizingBufferizePass> { |
142 | | - using FinalizingBufferizeBase< |
143 | | - FinalizingBufferizePass>::FinalizingBufferizeBase; |
144 | | - |
145 | | - void runOnOperation() override { |
146 | | - auto func = getOperation(); |
147 | | - auto *context = &getContext(); |
148 | | - |
149 | | - BufferizeTypeConverter typeConverter; |
150 | | - RewritePatternSet patterns(context); |
151 | | - ConversionTarget target(*context); |
152 | | - |
153 | | - populateEliminateBufferizeMaterializationsPatterns(typeConverter, patterns); |
154 | | - |
155 | | - // If all result types are legal, and all block arguments are legal (ensured |
156 | | - // by func conversion above), then all types in the program are legal. |
157 | | - // |
158 | | - // We also check that the operand types are legal to avoid creating invalid |
159 | | - // IR. For example, this prevents |
160 | | - // populateEliminateBufferizeMaterializationsPatterns from updating the |
161 | | - // types of the operands to a return op without updating the enclosing |
162 | | - // function. |
163 | | - target.markUnknownOpDynamicallyLegal( |
164 | | - [&](Operation *op) { return typeConverter.isLegal(op); }); |
165 | | - |
166 | | - if (failed(applyFullConversion(func, target, std::move(patterns)))) |
167 | | - signalPassFailure(); |
168 | | - } |
169 | | -}; |
170 | 100 |
|
171 | 101 | static LayoutMapOption parseLayoutMapOption(const std::string &s) { |
172 | 102 | if (s == "fully-dynamic-layout-map") |
@@ -331,11 +261,6 @@ std::unique_ptr<Pass> mlir::bufferization::createOneShotBufferizePass( |
331 | 261 | return std::make_unique<OneShotBufferizePass>(options); |
332 | 262 | } |
333 | 263 |
|
334 | | -std::unique_ptr<OperationPass<func::FuncOp>> |
335 | | -mlir::bufferization::createFinalizingBufferizePass() { |
336 | | - return std::make_unique<FinalizingBufferizePass>(); |
337 | | -} |
338 | | - |
339 | 264 | //===----------------------------------------------------------------------===// |
340 | 265 | // BufferizableOpInterface-based Bufferization |
341 | 266 | //===----------------------------------------------------------------------===// |
|
0 commit comments