MLIR  20.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 
15 namespace mlir {
16 namespace 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.
21 template <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 
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_
This class represents an operand of an operation.
Definition: Value.h:267
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
AnalysisState provides a variety of helper functions for dealing with tensor values.
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