[Mlir-commits] [mlir] [MLIR][Transform] Add attribute in MatchOp to filter by operand type (PR #67994)

Pablo Antonio Martinez llvmlistbot at llvm.org
Thu Nov 16 08:12:23 PST 2023


================
@@ -556,7 +558,8 @@ def MatchOp : Op<Transform_Dialect, "structured.match",
                        OptionalAttr<StrArrayAttr>:$ops,
                        OptionalAttr<MatchInterfaceEnum>:$interface,
                        OptionalAttr<DictionaryAttr>:$op_attrs,
-                       OptionalAttr<TypeAttr>:$filter_result_type);
+                       OptionalAttr<TypeAttr>:$filter_result_type,
+                       OptionalAttr<TypeAttr>:$filter_operand_type);
----------------
pabloantoniom wrote:

Thanks for suggesting this. Actually, I considered doing it, but I didn't because it was unclear to me how the list should work.

After considering it again, I have added a new commit which adds supports for this. The list expects to have a length equal to the number of operands, and the `match.op` will only succeed if the list of operand types match exactly the operand types in the target op (following the same order).

Besides, I was not sure how to report the error when the length of the list is incorrect, because the error cannot be reported inside the lambda. Thus, I have created an auxiliary variable `wrong_operand_filter` that is checked after the lambda, but I'm open to change it if there is a more elegant way.

PS: For the `result_types` I agree, but I feel like it is more appropriate for a separate PR

https://github.com/llvm/llvm-project/pull/67994


More information about the Mlir-commits mailing list