@@ -60,32 +60,6 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
60
60
llvm_unreachable("bufferizesToMemoryWrite not implemented");
61
61
}]
62
62
>,
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
- >,
89
63
InterfaceMethod<
90
64
/*desc=*/[{
91
65
Return the OpResult that aliases with a given OpOperand when
@@ -174,6 +148,23 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
174
148
}]
175
149
>
176
150
];
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
+ }];
177
168
}
178
169
179
170
#endif // BUFFERIZABLE_OP_INTERFACE
0 commit comments