MLIR 22.0.0git
BufferizableOpInterfaceImpl.cpp
Go to the documentation of this file.
1//===- BufferizableOpInterfaceImpl.cpp - Impl. of BufferizableOpInterface -===//
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
13#include "mlir/IR/Operation.h"
14
15using namespace mlir;
16using namespace mlir::bufferization;
17
18namespace mlir {
19namespace cf {
20namespace {
21
22template <typename ConcreteModel, typename ConcreteOp>
23struct BranchLikeOpInterface
24 : public BranchOpBufferizableOpInterfaceExternalModel<ConcreteModel,
25 ConcreteOp> {
26 bool bufferizesToMemoryRead(Operation *op, OpOperand &opOperand,
27 const AnalysisState &state) const {
28 return false;
29 }
30
31 bool bufferizesToMemoryWrite(Operation *op, OpOperand &opOperand,
32 const AnalysisState &state) const {
33 return false;
34 }
35
36 LogicalResult verifyAnalysis(Operation *op,
37 const AnalysisState &state) const {
38 return success();
39 }
40
41 LogicalResult bufferize(Operation *op, RewriterBase &rewriter,
42 const BufferizationOptions &options,
43 BufferizationState &state) const {
44 // The operands of this op are bufferized together with the block signature.
45 return success();
46 }
47};
48
49/// Bufferization of cf.br.
50struct BranchOpInterface
51 : public BranchLikeOpInterface<BranchOpInterface, cf::BranchOp> {};
52
53/// Bufferization of cf.cond_br.
54struct CondBranchOpInterface
55 : public BranchLikeOpInterface<CondBranchOpInterface, cf::CondBranchOp> {};
56
57} // namespace
58} // namespace cf
59} // namespace mlir
60
62 DialectRegistry &registry) {
63 registry.addExtension(+[](MLIRContext *ctx, cf::ControlFlowDialect *dialect) {
64 cf::BranchOp::attachInterface<BranchOpInterface>(*ctx);
65 cf::CondBranchOp::attachInterface<CondBranchOpInterface>(*ctx);
66 });
67}
return success()
static llvm::ManagedStatic< PassManagerOptions > options
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:63
void registerBufferizableOpInterfaceExternalModels(DialectRegistry &registry)
Include the generated interface declarations.