This is an archive of the discontinued LLVM Phabricator instance.

[drr] Enable specifying range in replacement.
ClosedPublic

Authored by jpienaar on Jun 25 2021, 3:13 PM.

Details

Summary

This enables creating a replacement rule where range of positional replacements
need not be spelled out, or are not known (e.g., enable having a rewrite that
forward all operands to a call generically).

Diff Detail

Event Timeline

jpienaar created this revision.Jun 25 2021, 3:13 PM
jpienaar requested review of this revision.Jun 25 2021, 3:13 PM
Chia-hungDuan added inline comments.Jun 28 2021, 3:05 AM
mlir/test/mlir-tblgen/rewriter-indexing.td
92

I'm thinking the form like "$...", which maps all the remaining. so in this case, we don't need to write down v1 ~ v3. Will this be clear?

In addition, for me, this form looks it will appear in something like,
// Binding the remaining args of SomeOp and select the range of arguments from $arg for AnotherOp.
def : Pat<(SomeOp $a0, $a1, $arg...), (AnotherOp $arg__3...)

jpienaar added inline comments.Jun 28 2021, 6:08 AM
mlir/test/mlir-tblgen/rewriter-indexing.td
92

Yes this one just changes it in the native call, not in the DAG specification.

With ops we have an explicit and fixed set of args, today one would match them by name or elide in matching with $_. We can already use native codecall expansion without changing dag matching (so these are independent but could work together). A potential problem with the dag format is it would be confusing with variadics.

rriddle accepted this revision.Jun 28 2021, 11:15 AM

Can you update the description to specifically mention that this is for NativeCodeCalls? It wasn't clear on the first read.

Can you also add documentation for this feature to the .md docs?

mlir/lib/TableGen/Format.cpp
101

Can you just pass std::isdigit as is?

109

Can you add a comment here on what this is?

181–185

interleaveComma here? (using llvm::seq, or llvm::make_range on adaptors)

utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
1501

This change looks unrelated.

This revision is now accepted and ready to land.Jun 28 2021, 11:15 AM
jpienaar updated this revision to Diff 355001.Jun 28 2021, 12:58 PM
jpienaar marked 2 inline comments as done.

use interleaveComma, update doc

jpienaar updated this revision to Diff 355005.Jun 28 2021, 1:04 PM

Remove unrelated change

jpienaar updated this revision to Diff 355009.Jun 28 2021, 1:09 PM

drop unrelated change really this time

jpienaar added inline comments.Jun 28 2021, 1:41 PM
mlir/lib/TableGen/Format.cpp
101

Depends on compiler, some yes others no it seems. Reverting to explicit lambda.

This revision was landed with ongoing or failed builds.Jun 28 2021, 1:42 PM
This revision was automatically updated to reflect the committed changes.
rriddle added inline comments.Jun 28 2021, 1:42 PM
mlir/lib/TableGen/Format.cpp
101

(You should be able to use llvm::isDigit then)