[PATCH] D73819: [mlir] Add $_op hook to RewriterGen.

Lei Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 4 07:27:49 PST 2020


antiagainst added inline comments.


================
Comment at: mlir/test/lib/TestDialect/TestOps.td:608
+            (OpNativeCodeCall3 $input),
+            [(CheckResultCount $result_count)]>;
+
----------------
I think this is misleading at least, if not problematic. The current way to support this is that we capture both the op's result and its operands and then pass them in as positional parameters so `CheckResultCount` can be written as

```
def CheckResultCount : Constraint<CPred<"$0.getOperation()->getNumResults() == $1.getInt()">>;
```

and used as

```
[(CheckResultCount $op, $result_count)]
```

One thing to note that we can have multiple source ops matched (as the source pattern can match a DAG of ops) so it's unclear which matchec op  `$_op` will point to, so it's misleading at least. I think the above explicitly capturing is a better way to handle this case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73819/new/

https://reviews.llvm.org/D73819





More information about the llvm-commits mailing list