MLIR
22.0.0git
lib
Dialect
ControlFlow
Transforms
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
9
#include "
mlir/Dialect/ControlFlow/Transforms/BufferizableOpInterfaceImpl.h
"
10
11
#include "
mlir/Dialect/Bufferization/IR/UnstructuredControlFlow.h
"
12
#include "
mlir/Dialect/ControlFlow/IR/ControlFlowOps.h
"
13
#include "
mlir/IR/Operation.h
"
14
15
using namespace
mlir
;
16
using namespace
mlir::bufferization
;
17
18
namespace
mlir
{
19
namespace
cf
{
20
namespace
{
21
22
template
<
typename
ConcreteModel,
typename
ConcreteOp>
23
struct
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.
50
struct
BranchOpInterface
51
:
public
BranchLikeOpInterface<BranchOpInterface, cf::BranchOp> {};
52
53
/// Bufferization of cf.cond_br.
54
struct
CondBranchOpInterface
55
:
public
BranchLikeOpInterface<CondBranchOpInterface, cf::CondBranchOp> {};
56
57
}
// namespace
58
}
// namespace cf
59
}
// namespace mlir
60
61
void
mlir::cf::registerBufferizableOpInterfaceExternalModels
(
62
DialectRegistry
®istry) {
63
registry.
addExtension
(+[](
MLIRContext
*ctx, cf::ControlFlowDialect *dialect) {
64
cf::BranchOp::attachInterface<BranchOpInterface>(*ctx);
65
cf::CondBranchOp::attachInterface<CondBranchOpInterface>(*ctx);
66
});
67
}
success
return success()
ControlFlowOps.h
BufferizableOpInterfaceImpl.h
Operation.h
options
static llvm::ManagedStatic< PassManagerOptions > options
Definition
PassManagerOptions.cpp:89
UnstructuredControlFlow.h
mlir::DialectRegistry
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Definition
DialectRegistry.h:139
mlir::DialectRegistry::addExtension
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
Definition
DialectRegistry.h:215
mlir::MLIRContext
MLIRContext is the top-level object for a collection of MLIR operations.
Definition
MLIRContext.h:63
mlir::bufferization
Definition
BufferDeallocationOpInterface.h:18
mlir::cf
Definition
ControlFlowToLLVM.h:28
mlir::cf::registerBufferizableOpInterfaceExternalModels
void registerBufferizableOpInterfaceExternalModels(DialectRegistry ®istry)
Definition
BufferizableOpInterfaceImpl.cpp:61
mlir
Include the generated interface declarations.
Definition
AliasAnalysis.h:19
Generated on
for MLIR by
1.14.0