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
21void mlir::bufferization::buildBufferDeallocationPipeline(
22 OpPassManager &pm, const BufferDeallocationPipelineOptions &options) {
23 pm.addPass(memref::pass: createExpandReallocPass(/*emitDeallocs=*/false));
24 pm.addPass(pass: createCanonicalizerPass());
25 pm.addPass(pass: createOwnershipBasedBufferDeallocationPass(options));
26 pm.addPass(pass: createCanonicalizerPass());
27 pm.addPass(pass: createBufferDeallocationSimplificationPass());
28 pm.addPass(pass: createLowerDeallocationsPass());
29 pm.addPass(pass: createCSEPass());
30 pm.addPass(pass: createCanonicalizerPass());
31}
32
33//===----------------------------------------------------------------------===//
34// Pipeline registration.
35//===----------------------------------------------------------------------===//
36
37void mlir::bufferization::registerBufferizationPipelines() {
38 PassPipelineRegistration<BufferDeallocationPipelineOptions>(
39 "buffer-deallocation-pipeline",
40 "The default pipeline for automatically inserting deallocation "
41 "operations after one-shot bufferization. Deallocation operations "
42 "(except `memref.realloc`) may not be present already.",
43 buildBufferDeallocationPipeline);
44}
45

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