diff --git a/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.td b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.td --- a/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.td +++ b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.td @@ -60,32 +60,6 @@ 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($_op.getOperation()); - return !bufferizableOp.bufferizesToMemoryRead(opOperand) - && !bufferizableOp.bufferizesToMemoryWrite(opOperand) - && static_cast( - bufferizableOp.getAliasingOpResult(opOperand)); - }] - >, InterfaceMethod< /*desc=*/[{ Return the OpResult that aliases with a given OpOperand when @@ -174,6 +148,23 @@ }] > ]; + + 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(getOperation()); + return !bufferizableOp.bufferizesToMemoryRead(opOperand) + && !bufferizableOp.bufferizesToMemoryWrite(opOperand) + && static_cast( + bufferizableOp.getAliasingOpResult(opOperand)); + } + }]; } #endif // BUFFERIZABLE_OP_INTERFACE