MLIR
20.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/Bufferization.h
"
12
#include "
mlir/Dialect/Bufferization/IR/UnstructuredControlFlow.h
"
13
#include "
mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h
"
14
#include "
mlir/Dialect/ControlFlow/IR/ControlFlowOps.h
"
15
#include "
mlir/Dialect/MemRef/IR/MemRef.h
"
16
#include "
mlir/IR/Dialect.h
"
17
#include "
mlir/IR/Operation.h
"
18
19
using namespace
mlir
;
20
using namespace
mlir::bufferization
;
21
22
namespace
mlir
{
23
namespace
cf {
24
namespace
{
25
26
template
<
typename
ConcreteModel,
typename
ConcreteOp>
27
struct
BranchLikeOpInterface
28
:
public
BranchOpBufferizableOpInterfaceExternalModel
<ConcreteModel,
29
ConcreteOp> {
30
bool
bufferizesToMemoryRead(
Operation
*op,
OpOperand
&opOperand,
31
const
AnalysisState
&state)
const
{
32
return
false
;
33
}
34
35
bool
bufferizesToMemoryWrite(
Operation
*op,
OpOperand
&opOperand,
36
const
AnalysisState
&state)
const
{
37
return
false
;
38
}
39
40
LogicalResult verifyAnalysis(
Operation
*op,
41
const
AnalysisState
&state)
const
{
42
return
success();
43
}
44
45
LogicalResult bufferize(
Operation
*op,
RewriterBase
&rewriter,
46
const
BufferizationOptions
&
options
)
const
{
47
// The operands of this op are bufferized together with the block signature.
48
return
success();
49
}
50
};
51
52
/// Bufferization of cf.br.
53
struct
BranchOpInterface
54
:
public
BranchLikeOpInterface<BranchOpInterface, cf::BranchOp> {};
55
56
/// Bufferization of cf.cond_br.
57
struct
CondBranchOpInterface
58
:
public
BranchLikeOpInterface<CondBranchOpInterface, cf::CondBranchOp> {};
59
60
}
// namespace
61
}
// namespace cf
62
}
// namespace mlir
63
64
void
mlir::cf::registerBufferizableOpInterfaceExternalModels
(
65
DialectRegistry
®istry) {
66
registry.
addExtension
(+[](
MLIRContext
*ctx, cf::ControlFlowDialect *dialect) {
67
cf::BranchOp::attachInterface<BranchOpInterface>(*ctx);
68
cf::CondBranchOp::attachInterface<CondBranchOpInterface>(*ctx);
69
});
70
}
Bufferization.h
ControlFlowOps.h
BufferizableOpInterfaceImpl.h
Dialect.h
Operation.h
OneShotAnalysis.h
options
static llvm::ManagedStatic< PassManagerOptions > options
Definition:
PassManagerOptions.cpp:89
UnstructuredControlFlow.h
mlir::AnalysisState
Base class for generic analysis states.
Definition:
DataFlowFramework.h:447
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:211
mlir::MLIRContext
MLIRContext is the top-level object for a collection of MLIR operations.
Definition:
MLIRContext.h:60
mlir::OpOperand
This class represents an operand of an operation.
Definition:
Value.h:267
mlir::Operation
Operation is the basic unit of execution within MLIR.
Definition:
Operation.h:88
mlir::RewriterBase
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
Definition:
PatternMatch.h:400
MemRef.h
mlir::bufferization
Definition:
BufferDeallocationOpInterface.h:18
mlir::cf::registerBufferizableOpInterfaceExternalModels
void registerBufferizableOpInterfaceExternalModels(DialectRegistry ®istry)
Definition:
BufferizableOpInterfaceImpl.cpp:64
mlir
Include the generated interface declarations.
Definition:
LocalAliasAnalysis.h:20
mlir::bufferization::BranchOpBufferizableOpInterfaceExternalModel
A template that provides a default implementation of getAliasingValues for ops that implement the Bra...
Definition:
UnstructuredControlFlow.h:139
mlir::bufferization::BufferizationOptions
Options for BufferizableOpInterface-based bufferization.
Definition:
BufferizableOpInterface.h:252
Generated on Tue Nov 19 2024 04:32:25 for MLIR by
1.9.1