MLIR
20.0.0git
lib
Dialect
MemRef
Transforms
BufferViewFlowOpInterfaceImpl.cpp
Go to the documentation of this file.
1
//===- BufferViewFlowOpInterfaceImpl.cpp - Buffer View Flow Analysis ------===//
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/MemRef/Transforms/BufferViewFlowOpInterfaceImpl.h
"
10
11
#include "
mlir/Dialect/Bufferization/IR/BufferViewFlowOpInterface.h
"
12
#include "
mlir/Dialect/MemRef/IR/MemRef.h
"
13
14
using namespace
mlir
;
15
using namespace
mlir::bufferization
;
16
17
namespace
mlir
{
18
namespace
memref {
19
namespace
{
20
21
struct
ReallocOpInterface
22
:
public
BufferViewFlowOpInterface::ExternalModel<ReallocOpInterface,
23
ReallocOp> {
24
void
25
populateDependencies(
Operation
*op,
26
RegisterDependenciesFn
registerDependenciesFn)
const
{
27
auto
reallocOp = cast<ReallocOp>(op);
28
// memref.realloc may return the source operand.
29
registerDependenciesFn(reallocOp.getSource(), reallocOp.getResult());
30
}
31
32
bool
mayBeTerminalBuffer(
Operation
*op,
Value
value)
const
{
33
// The return value of memref.realloc is a terminal buffer because the op
34
// may return a newly allocated buffer.
35
return
true
;
36
}
37
};
38
39
}
// namespace
40
}
// namespace memref
41
}
// namespace mlir
42
43
void
memref::registerBufferViewFlowOpInterfaceExternalModels
(
44
DialectRegistry
®istry) {
45
registry.
addExtension
(+[](
MLIRContext
*ctx, memref::MemRefDialect *dialect) {
46
ReallocOp::attachInterface<ReallocOpInterface>(*ctx);
47
});
48
}
BufferViewFlowOpInterface.h
BufferViewFlowOpInterfaceImpl.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:211
mlir::MLIRContext
MLIRContext is the top-level object for a collection of MLIR operations.
Definition:
MLIRContext.h:60
mlir::Operation
Operation is the basic unit of execution within MLIR.
Definition:
Operation.h:88
mlir::Value
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition:
Value.h:96
MemRef.h
mlir::bufferization
Definition:
BufferDeallocationOpInterface.h:18
mlir::bufferization::RegisterDependenciesFn
std::function< void(ValueRange, ValueRange)> RegisterDependenciesFn
Definition:
BufferViewFlowOpInterface.h:20
mlir::memref::registerBufferViewFlowOpInterfaceExternalModels
void registerBufferViewFlowOpInterfaceExternalModels(DialectRegistry ®istry)
Definition:
BufferViewFlowOpInterfaceImpl.cpp:43
mlir
Include the generated interface declarations.
Definition:
LocalAliasAnalysis.h:20
Generated on Sat Dec 7 2024 20:31:28 for MLIR by
1.9.1