Skip to content

Commit 020ca17

Browse files
[mlir][linalg][bufferize] Move bufferizesToAliasOnly to extraClassDecls
By doing so, the method can no longer be reimplemented. Differential Revision: https://reviews.llvm.org/D113248
1 parent fce529f commit 020ca17

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.td

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,6 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
6060
llvm_unreachable("bufferizesToMemoryWrite not implemented");
6161
}]
6262
>,
63-
InterfaceMethod<
64-
/*desc=*/[{
65-
Return `true` if the given OpOperand creates an alias but does neither
66-
read nor write. This implies that `bufferizesToMemoryRead` and
67-
`bufferizesToMemoryWrite` must return `false`. This method will never
68-
be called on OpOperands that do not have a tensor type.
69-
70-
Examples of such ops are `tensor.extract_slice` and `tensor.cast`.
71-
72-
Note: This method is not meant to be reimplemented.
73-
}],
74-
/*retType=*/"bool",
75-
/*methodName=*/"bufferizesToAliasOnly",
76-
/*args=*/(ins "OpOperand &":$opOperand),
77-
/*methodBody=*/"",
78-
// TODO: This should be in methodBody instead of defaultImplementation.
79-
// Due to a bug in TableGen codegen, this does not compile.
80-
/*defaultImplementation=*/[{
81-
auto bufferizableOp =
82-
cast<BufferizableOpInterface>($_op.getOperation());
83-
return !bufferizableOp.bufferizesToMemoryRead(opOperand)
84-
&& !bufferizableOp.bufferizesToMemoryWrite(opOperand)
85-
&& static_cast<bool>(
86-
bufferizableOp.getAliasingOpResult(opOperand));
87-
}]
88-
>,
8963
InterfaceMethod<
9064
/*desc=*/[{
9165
Return the OpResult that aliases with a given OpOperand when
@@ -174,6 +148,23 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
174148
}]
175149
>
176150
];
151+
152+
let extraClassDeclaration = [{
153+
/// Return `true` if the given OpOperand creates an alias but does neither
154+
/// read nor write. This implies that `bufferizesToMemoryRead` and
155+
/// `bufferizesToMemoryWrite` must return `false`. This method will never
156+
/// be called on OpOperands that do not have a tensor type.
157+
///
158+
/// Examples of such ops are `tensor.extract_slice` and `tensor.cast`.
159+
bool bufferizesToAliasOnly(OpOperand &opOperand) {
160+
auto bufferizableOp =
161+
cast<BufferizableOpInterface>(getOperation());
162+
return !bufferizableOp.bufferizesToMemoryRead(opOperand)
163+
&& !bufferizableOp.bufferizesToMemoryWrite(opOperand)
164+
&& static_cast<bool>(
165+
bufferizableOp.getAliasingOpResult(opOperand));
166+
}
167+
}];
177168
}
178169

179170
#endif // BUFFERIZABLE_OP_INTERFACE

0 commit comments

Comments
 (0)