brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 51feec7 Raw
49 lines · cpp
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-exception6//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(memref::createExpandReallocPass(expandAllocPassOptions));25  pm.addPass(createCanonicalizerPass());26 27  OwnershipBasedBufferDeallocationPassOptions deallocationOptions{28      options.privateFunctionDynamicOwnership};29  pm.addPass(createOwnershipBasedBufferDeallocationPass(deallocationOptions));30  pm.addPass(createCanonicalizerPass());31  pm.addPass(createBufferDeallocationSimplificationPass());32  pm.addPass(createLowerDeallocationsPass());33  pm.addPass(createCSEPass());34  pm.addPass(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