| 1 | //===- BufferizationPipelines.cpp - Pipelines for bufferization -----------===// |
|---|---|
| 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 | #include "mlir/Dialect/Bufferization/Pipelines/Passes.h" |
| 10 | |
| 11 | #include "mlir/Dialect/Bufferization/Transforms/Passes.h" |
| 12 | #include "mlir/Dialect/Func/IR/FuncOps.h" |
| 13 | #include "mlir/Dialect/MemRef/Transforms/Passes.h" |
| 14 | #include "mlir/Pass/PassManager.h" |
| 15 | #include "mlir/Transforms/Passes.h" |
| 16 | |
| 17 | //===----------------------------------------------------------------------===// |
| 18 | // Pipeline implementation. |
| 19 | //===----------------------------------------------------------------------===// |
| 20 | |
| 21 | void mlir::bufferization::buildBufferDeallocationPipeline( |
| 22 | OpPassManager &pm, const BufferDeallocationPipelineOptions &options) { |
| 23 | memref::ExpandReallocPassOptions expandAllocPassOptions{ |
| 24 | /*emitDeallocs=*/false}; |
| 25 | pm.addPass(memref::createExpandReallocPass(expandAllocPassOptions)); |
| 26 | pm.addPass(pass: createCanonicalizerPass()); |
| 27 | |
| 28 | OwnershipBasedBufferDeallocationPassOptions deallocationOptions{ |
| 29 | options.privateFunctionDynamicOwnership}; |
| 30 | pm.addPass(pass: createOwnershipBasedBufferDeallocationPass(deallocationOptions)); |
| 31 | pm.addPass(pass: createCanonicalizerPass()); |
| 32 | pm.addPass(pass: createBufferDeallocationSimplificationPass()); |
| 33 | pm.addPass(pass: createLowerDeallocationsPass()); |
| 34 | pm.addPass(pass: createCSEPass()); |
| 35 | pm.addPass(pass: createCanonicalizerPass()); |
| 36 | } |
| 37 | |
| 38 | //===----------------------------------------------------------------------===// |
| 39 | // Pipeline registration. |
| 40 | //===----------------------------------------------------------------------===// |
| 41 | |
| 42 | void mlir::bufferization::registerBufferizationPipelines() { |
| 43 | PassPipelineRegistration<BufferDeallocationPipelineOptions>( |
| 44 | "buffer-deallocation-pipeline", |
| 45 | "The default pipeline for automatically inserting deallocation " |
| 46 | "operations after one-shot bufferization. Deallocation operations " |
| 47 | "(except `memref.realloc`) may not be present already.", |
| 48 | buildBufferDeallocationPipeline); |
| 49 | } |
| 50 |
