• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- Bufferize.cpp - scf bufferize pass ---------------------------------===//
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/Transforms/Bufferize.h"
10 #include "PassDetail.h"
11 #include "mlir/Dialect/SCF/Passes.h"
12 #include "mlir/Dialect/SCF/SCF.h"
13 #include "mlir/Dialect/SCF/Transforms.h"
14 #include "mlir/Dialect/StandardOps/IR/Ops.h"
15 #include "mlir/Transforms/DialectConversion.h"
16 
17 using namespace mlir;
18 using namespace mlir::scf;
19 
20 namespace {
21 struct SCFBufferizePass : public SCFBufferizeBase<SCFBufferizePass> {
runOnFunction__anondaeefbd00111::SCFBufferizePass22   void runOnFunction() override {
23     auto func = getOperation();
24     auto *context = &getContext();
25 
26     BufferizeTypeConverter typeConverter;
27     OwningRewritePatternList patterns;
28     ConversionTarget target(*context);
29 
30     populateBufferizeMaterializationLegality(target);
31     populateSCFStructuralTypeConversionsAndLegality(context, typeConverter,
32                                                     patterns, target);
33     if (failed(applyPartialConversion(func, target, std::move(patterns))))
34       return signalPassFailure();
35   };
36 };
37 } // end anonymous namespace
38 
createSCFBufferizePass()39 std::unique_ptr<Pass> mlir::createSCFBufferizePass() {
40   return std::make_unique<SCFBufferizePass>();
41 }
42