MLIR 22.0.0git
DstBufferizableOpInterfaceImpl.h
Go to the documentation of this file.
1//===- DstBufferizableOpInterfaceImpl.h - Dst Op Bufferization --*- 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
9#ifndef MLIR_DIALECT_BUFFERIZATION_IR_DSTBUFFERIZABLEOPINTERFACEIMPL_H_
10#define MLIR_DIALECT_BUFFERIZATION_IR_DSTBUFFERIZABLEOPINTERFACEIMPL_H_
11
14
15namespace mlir {
16namespace bufferization {
17
18/// Bufferizable ops that implement the DestinationStyleOpInterface can use this
19/// external model base class. It provides default implementations for various
20/// required interface methods.
21template <typename ConcreteModel, typename ConcreteOp>
23 : public BufferizableOpInterface::ExternalModel<ConcreteModel, ConcreteOp> {
25 const AnalysisState &state) const {
26 // All inputs and outputs bufferize to a memory read.
27 assert(isa<DestinationStyleOpInterface>(op) &&
28 "expected that op implements DestinationStyleOpInterface");
29 return true;
30 }
31
33 const AnalysisState &state) const {
34 // Only outputs bufferize to a memory write.
35 auto dstOp = cast<DestinationStyleOpInterface>(op);
36 return dstOp.isDpsInit(&opOperand);
37 }
38
39 AliasingValueList getAliasingValues(Operation *op, OpOperand &opOperand,
40 const AnalysisState &state) const {
41 // Output operands alias with their respective tied OpResults.
42 auto dstOp = cast<DestinationStyleOpInterface>(op);
43 if (dstOp.isDpsInit(&opOperand))
44 return {{dstOp.getTiedOpResult(&opOperand), BufferRelation::Equivalent}};
45 return {};
46 }
47};
48
49} // namespace bufferization
50} // namespace mlir
51
52#endif // MLIR_DIALECT_BUFFERIZATION_IR_DSTBUFFERIZABLEOPINTERFACEIMPL_H_
Base class for generic analysis states.
This class represents an operand of an operation.
Definition Value.h:257
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88
Include the generated interface declarations.
Bufferizable ops that implement the DestinationStyleOpInterface can use this external model base clas...
AliasingValueList getAliasingValues(Operation *op, OpOperand &opOperand, const AnalysisState &state) const
bool bufferizesToMemoryWrite(Operation *op, OpOperand &opOperand, const AnalysisState &state) const
bool bufferizesToMemoryRead(Operation *op, OpOperand &opOperand, const AnalysisState &state) const