@@ -91,7 +91,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface {
9191 /// previously returned by the call operation with the operands of the
9292 /// return.
9393 void handleTerminator(Operation * op,
94- MutableArrayRef< Value > valuesToRepl) const final {
94+ ValueRange valuesToRepl) const final {
9595 // Only "toy.return" needs to be handled here.
9696 auto returnOp = cast<ReturnOp >(op);
9797
@@ -147,7 +147,7 @@ and add it to the traits list of `GenericCallOp`:
147147
148148``` tablegen
149149def FuncOp : Toy_Op<"func",
150- [DeclareOpInterfaceMethods<CallableOpInterface> ]> {
150+ [FunctionOpInterface, IsolatedFromAbove ]> {
151151 ...
152152}
153153
@@ -159,7 +159,8 @@ def GenericCallOp : Toy_Op<"generic_call",
159159
160160In the above we also use the ` DeclareOpInterfaceMethods ` directive to
161161auto-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:
163164
164165``` c++
165166// / Returns the region on the function operation that is callable.
@@ -170,7 +171,7 @@ Region *FuncOp::getCallableRegion() { return &getBody(); }
170171/// Return the callee of the generic call operation, this is required by the
171172/// call interface.
172173CallInterfaceCallable GenericCallOp::getCallableForCallee() {
173- return getAttrOfType<SymbolRefAttr >("callee");
174+ return ( * this)-> getAttrOfType<SymbolRefAttr >("callee");
174175}
175176
176177// / Set the callee for the generic call operation, this is required by the call
@@ -181,7 +182,13 @@ void GenericCallOp::setCalleeFromCallable(CallInterfaceCallable callee) {
181182
182183/// Get the argument operands to the called function, this is required by the
183184/// 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+ }
185192```
186193
187194Now 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) {
255262 if (inputs.size() != 1 || outputs.size() != 1)
256263 return false;
257264 // 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() );
260267 if (!input || !output || input.getElementType() != output.getElementType())
261268 return false;
262269 // The shape is required to match if both types are ranked.
0 commit comments