Page MenuHomePhabricator

[TableGen] Add useDeprecatedPositionallyEncodedOperands option.

Authored by jyknight on Sep 16 2022, 1:18 PM.



The existing undefined-bitfield-to-operand matching behavior is very
hard to understand, due to the combination of positional and named
matching. This can make it difficult to track down a bug in a target's
instruction definitions.

Over the last decade, folks have tried to work-around this in various
ways, but it's time to finally ditch the positional matching. With, there are no longer cases that
_require_ positional matching, and it's time to start removing usage
and support for it.

Therefore: add a (default-false) option, and set it to true only in
those targets that require positional matching today. Subsequent
changes will start cleaning up additional in-tree targets.


If this change breaks your build, you may restore the previous
behavior simply by adding:

let useDeprecatedPositionallyEncodedOperands = 1;

to your target's InstrInfo tablegen definition. However, this is
temporary -- the option will be removed in the future.

If your target does not set 'decodePositionallyEncodedOperands', you
may thus start migrating to named operands. However, if you _do_
currently set that option, I recommend waiting until a subsequent
change lands, which adds decoder support for named sub-operands.

Diff Detail

Event Timeline

jyknight created this revision.Sep 16 2022, 1:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2022, 1:18 PM
jyknight requested review of this revision.Sep 16 2022, 1:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2022, 1:18 PM
MaskRay added inline comments.Sep 18 2022, 10:51 PM

Perhaps use a TODO as a minder that the support will be removed.


Add CHECK-NEXT: note: Dumping record for previous error: then use --implicit-check-not=error:

Q: by changing $xd, do we lose test coverage by not testing an undefined operand name?


addCodeToMergeInOperand now that the signature has changed


Does this need a TODO that this branch will be removed?


Drop the change to this code block


Since PrintError takes a Twine. You may remove E and S and just construct the long Twine as an argument

jyknight updated this revision to Diff 461541.Sep 20 2022, 5:33 AM
jyknight marked 6 inline comments as done.

Address review feedback. Also tweak error reporting to improve consistency for the "too few operands" case.


Done, and good point about losing test coverage. Switched this test to useDeprecatedPositionalOperands to preserve testing the positional error, and another test added for when positional matching is off.

MaskRay accepted this revision.Sep 20 2022, 9:36 AM

Looks great!


Does early return pattern apply?

This revision is now accepted and ready to land.Sep 20 2022, 9:36 AM
This revision was landed with ongoing or failed builds.Sep 24 2022, 6:41 AM
This revision was automatically updated to reflect the committed changes.