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

source code of mlir/lib/Dialect/Bufferization/Pipelines/BufferizationPipelines.cpp