@@ -91,7 +91,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface {
91
91
/// previously returned by the call operation with the operands of the
92
92
/// return.
93
93
void handleTerminator(Operation * op,
94
- MutableArrayRef< Value > valuesToRepl) const final {
94
+ ValueRange valuesToRepl) const final {
95
95
// Only "toy.return" needs to be handled here.
96
96
auto returnOp = cast<ReturnOp >(op);
97
97
@@ -147,7 +147,7 @@ and add it to the traits list of `GenericCallOp`:
147
147
148
148
``` tablegen
149
149
def FuncOp : Toy_Op<"func",
150
- [DeclareOpInterfaceMethods<CallableOpInterface> ]> {
150
+ [FunctionOpInterface, IsolatedFromAbove ]> {
151
151
...
152
152
}
153
153
@@ -159,7 +159,8 @@ def GenericCallOp : Toy_Op<"generic_call",
159
159
160
160
In the above we also use the ` DeclareOpInterfaceMethods ` directive to
161
161
auto-declare all of the interface methods in the class declaration of
162
- GenericCallOp. This means that we just need to provide a definition:
162
+ GenericCallOp. We have already provided the definition in the ` extraClassDeclaration `
163
+ field of the ` FuncOp ` class:
163
164
164
165
``` c++
165
166
// / Returns the region on the function operation that is callable.
@@ -170,7 +171,7 @@ Region *FuncOp::getCallableRegion() { return &getBody(); }
170
171
/// Return the callee of the generic call operation, this is required by the
171
172
/// call interface.
172
173
CallInterfaceCallable GenericCallOp::getCallableForCallee() {
173
- return getAttrOfType<SymbolRefAttr >("callee");
174
+ return ( * this)-> getAttrOfType<SymbolRefAttr >("callee");
174
175
}
175
176
176
177
// / Set the callee for the generic call operation, this is required by the call
@@ -181,7 +182,13 @@ void GenericCallOp::setCalleeFromCallable(CallInterfaceCallable callee) {
181
182
182
183
/// Get the argument operands to the called function, this is required by the
183
184
/// call interface.
184
- Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); }
185
+ Operation::operand_range GenericCallOp::getArgOperands() { return getInputs(); }
186
+
187
+ /// Get the argument operands to the called function as a mutable range, this is
188
+ /// required by the call interface.
189
+ MutableOperandRange GenericCallOp::getArgOperandsMutable() {
190
+ return getInputsMutable();
191
+ }
185
192
```
186
193
187
194
Now that the inliner has been informed about the Toy dialect, we can add the
@@ -255,8 +262,8 @@ bool CastOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
255
262
if (inputs.size() != 1 || outputs.size() != 1)
256
263
return false;
257
264
// The inputs must be Tensors with the same element type.
258
- TensorType input = inputs.front(). dyn_cast<TensorType >();
259
- TensorType output = outputs.front(). dyn_cast<TensorType >();
265
+ TensorType input = llvm:: dyn_cast<TensorType >(inputs.front() );
266
+ TensorType output = llvm:: dyn_cast<TensorType >(outputs.front() );
260
267
if (!input || !output || input.getElementType() != output.getElementType())
261
268
return false;
262
269
// The shape is required to match if both types are ranked.
0 commit comments