[mlir][Rewrite] Add support for using an operation with no results as location
authorMarkus Böck <markus.boeck02@gmail.com>
Thu, 3 Feb 2022 14:07:46 +0000 (15:07 +0100)
committerMarkus Böck <markus.boeck02@gmail.com>
Thu, 3 Feb 2022 14:08:09 +0000 (15:08 +0100)
commit7b196f1b093b49e5ab00c0483a8cda48c05e3e98
treece0ab6fdc4e041d2666c8a4be41a7de9ef368478
parente7361469bbb64d80a70d23bb24d45402b4644e3e
[mlir][Rewrite] Add support for using an operation with no results as location

Prior to this patch, using an operation without any results as the location would result in the generation of invalid C++ code. It'd try to format using the result values, which would would end up being an empty string for an operation without any.
This patch fixes that issue by instead using getValueAndRangeUse which handles both ranges as well as the case for an op without any results.

Differential Revision: https://reviews.llvm.org/D118885
mlir/lib/TableGen/Pattern.cpp
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/mlir-tblgen/pattern.mlir
mlir/tools/mlir-tblgen/RewriterGen.cpp