This is an archive of the discontinued LLVM Phabricator instance.

[mlir][PDLL] Allow numeric result indexing for unregistered op
ClosedPublic

Authored by Chia-hungDuan on May 24 2022, 2:30 PM.

Details

Summary

If we don't specify the result index while matching operand with the
result of certain operation, it's supposed to match all the results of
the operation with the operand. For registered op, it's easy to do that
by either indexing with number or name. For unregistered op, this commit
enables the numeric result indexing for this use case.

Diff Detail

Event Timeline

Chia-hungDuan created this revision.May 24 2022, 2:30 PM
Chia-hungDuan requested review of this revision.May 24 2022, 2:30 PM
Mogball added inline comments.
mlir/lib/Tools/PDLL/Parser/Parser.cpp
2687–2688

"Allow unchecked numeric indexing of the results of unregistered operations. It returns a single value."

Given that we can't know the "result groups" of an unregistered operation, I think defaulting to individual results is fine. That being said, we'll definitely want to document this behavior (given that it means we'll treat registered operations differently from registered). Can you document the handling for unregistered operations in the Accessing Operation Results section of PDLL.md?

mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
448

I don't think sharing this variable is useful given that the branches don't converge, can we just duplicate? Otherwise, I have to follow the control flow to make sure it isn't used in an uninitialized context.

Chia-hungDuan marked 2 inline comments as done.

Address review comment and update the op name in the test

mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
448

Yep, that's weird. was changing the structure at the last moment and forgot it. Done

rriddle added inline comments.May 25 2022, 10:13 AM
mlir/docs/PDLL.md
703

Can you have a dedicated sub-section for unregistered operations?

#### Unregistered Operations

...

Just want to make sure this gets the callout that it deserves, so that it isn't potentially lost inside of another paragraph.

Chia-hungDuan marked an inline comment as done.

Address review comment

mlir/docs/PDLL.md
703

Done, let me know if the description is fine.

rriddle accepted this revision.May 25 2022, 11:57 AM

LG, nice.

mlir/docs/PDLL.md
721–722
This revision is now accepted and ready to land.May 25 2022, 11:57 AM
Chia-hungDuan marked an inline comment as done.May 25 2022, 12:18 PM

address review comment

This revision was landed with ongoing or failed builds.May 25 2022, 12:30 PM
This revision was automatically updated to reflect the committed changes.