[mlir][linalg][bufferize] Move bufferizesToAliasOnly to extraClassDecls

By doing so, the method can no longer be reimplemented.

Differential Revision: https://reviews.llvm.org/D113248
This commit is contained in:
Matthias Springer 2021-11-05 17:47:44 +09:00
parent fce529fc6e
commit 020ca1747d
1 changed files with 17 additions and 26 deletions
mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize

View File

@ -60,32 +60,6 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
llvm_unreachable("bufferizesToMemoryWrite not implemented");
}]
>,
InterfaceMethod<
/*desc=*/[{
Return `true` if the given OpOperand creates an alias but does neither
read nor write. This implies that `bufferizesToMemoryRead` and
`bufferizesToMemoryWrite` must return `false`. This method will never
be called on OpOperands that do not have a tensor type.
Examples of such ops are `tensor.extract_slice` and `tensor.cast`.
Note: This method is not meant to be reimplemented.
}],
/*retType=*/"bool",
/*methodName=*/"bufferizesToAliasOnly",
/*args=*/(ins "OpOperand &":$opOperand),
/*methodBody=*/"",
// TODO: This should be in methodBody instead of defaultImplementation.
// Due to a bug in TableGen codegen, this does not compile.
/*defaultImplementation=*/[{
auto bufferizableOp =
cast<BufferizableOpInterface>($_op.getOperation());
return !bufferizableOp.bufferizesToMemoryRead(opOperand)
&& !bufferizableOp.bufferizesToMemoryWrite(opOperand)
&& static_cast<bool>(
bufferizableOp.getAliasingOpResult(opOperand));
}]
>,
InterfaceMethod<
/*desc=*/[{
Return the OpResult that aliases with a given OpOperand when
@ -174,6 +148,23 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
}]
>
];
let extraClassDeclaration = [{
/// Return `true` if the given OpOperand creates an alias but does neither
/// read nor write. This implies that `bufferizesToMemoryRead` and
/// `bufferizesToMemoryWrite` must return `false`. This method will never
/// be called on OpOperands that do not have a tensor type.
///
/// Examples of such ops are `tensor.extract_slice` and `tensor.cast`.
bool bufferizesToAliasOnly(OpOperand &opOperand) {
auto bufferizableOp =
cast<BufferizableOpInterface>(getOperation());
return !bufferizableOp.bufferizesToMemoryRead(opOperand)
&& !bufferizableOp.bufferizesToMemoryWrite(opOperand)
&& static_cast<bool>(
bufferizableOp.getAliasingOpResult(opOperand));
}
}];
}
#endif // BUFFERIZABLE_OP_INTERFACE