MLIR  19.0.0git
Bufferize.cpp
Go to the documentation of this file.
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 
10 
18 #include "mlir/Pass/Pass.h"
19 
20 namespace mlir {
21 #define GEN_PASS_DEF_SHAPEBUFFERIZE
22 #include "mlir/Dialect/Shape/Transforms/Passes.h.inc"
23 } // namespace mlir
24 
25 using namespace mlir;
26 using namespace bufferization;
27 
28 namespace {
29 struct ShapeBufferizePass
30  : public impl::ShapeBufferizeBase<ShapeBufferizePass> {
31  void runOnOperation() override {
33  options.opFilter.allowDialect<shape::ShapeDialect>();
34 
35  if (failed(bufferizeOp(getOperation(), options)))
36  signalPassFailure();
37  }
38 
39  void getDependentDialects(DialectRegistry &registry) const override {
40  registry.insert<bufferization::BufferizationDialect, memref::MemRefDialect,
41  shape::ShapeDialect>();
43  }
44 };
45 } // namespace
46 
47 std::unique_ptr<OperationPass<func::FuncOp>> mlir::createShapeBufferizePass() {
48  return std::make_unique<ShapeBufferizePass>();
49 }
static llvm::ManagedStatic< PassManagerOptions > options
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
LogicalResult bufferizeOp(Operation *op, const BufferizationOptions &options, BufferizationStatistics *statistics=nullptr)
Bufferize op and its nested ops that implement BufferizableOpInterface.
Definition: Bufferize.cpp:441
BufferizationOptions getPartialBufferizationOptions()
Return BufferizationOptions such that the bufferizeOp behaves like the old (deprecated) partial,...
Definition: Bufferize.cpp:645
void registerBufferizableOpInterfaceExternalModels(DialectRegistry &registry)
Include the generated interface declarations.
std::unique_ptr< OperationPass< func::FuncOp > > createShapeBufferizePass()
Definition: Bufferize.cpp:47
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
Definition: LogicalResult.h:72
Options for BufferizableOpInterface-based bufferization.