The $_op hook makes it possible to access information about the current operation in a TableGen pattern. This is already implemented in OpDefinitionsGen; this change adds it to RewriterGen as well.
This is needed for a lowering in the TF dialect.
Differential D73819
[mlir] Add $_op hook to RewriterGen. lucyrfox on Jan 31 2020, 4:20 PM. Authored by
Details
The $_op hook makes it possible to access information about the current operation in a TableGen pattern. This is already implemented in OpDefinitionsGen; this change adds it to RewriterGen as well. This is needed for a lowering in the TF dialect.
Diff Detail
Event TimelineComment Actions Unit tests: unknown. clang-tidy: pass. clang-format: pass. Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project. Comment Actions Can you expand on the commit description of what is this about / why are you doing this? (also is this something that a test can be written for?) Comment Actions Unit tests: pass. 62430 tests passed, 0 failed and 845 were skipped. clang-tidy: pass. clang-format: pass. Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.
|
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
and used as
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.