• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //====----- Bufferize.cpp - Bufferization of shape ops  ---------*- C++-*--===//
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/Shape/Transforms/Passes.h"
12 #include "mlir/Pass/Pass.h"
13 
14 using namespace mlir;
15 
16 namespace {
17 struct ShapeBufferizePass : public ShapeBufferizeBase<ShapeBufferizePass> {
runOnFunction__anon17b079250111::ShapeBufferizePass18   void runOnFunction() override {
19     MLIRContext &ctx = getContext();
20 
21     OwningRewritePatternList patterns;
22     BufferizeTypeConverter typeConverter;
23     ConversionTarget target(getContext());
24 
25     populateBufferizeMaterializationLegality(target);
26     populateShapeStructuralTypeConversionsAndLegality(&ctx, typeConverter,
27                                                       patterns, target);
28 
29     if (failed(
30             applyPartialConversion(getFunction(), target, std::move(patterns))))
31       signalPassFailure();
32   }
33 };
34 } // namespace
35 
createShapeBufferizePass()36 std::unique_ptr<FunctionPass> mlir::createShapeBufferizePass() {
37   return std::make_unique<ShapeBufferizePass>();
38 }
39