This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Simplify matchRegisterNameHelper interface. NFC
ClosedPublic

Authored by craig.topper on May 6 2023, 12:53 PM.

Details

Summary

This previously returned a bool to indicate success or failure and
returns a register through an output parameter.

Some callers used the bool to check for success. Some callers checked
for RISCV::NoRegister.

To make everything uniform, return the MCRegister directly and update
all callers to use MCRegister::isValid().

Diff Detail

Event Timeline

craig.topper created this revision.May 6 2023, 12:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2023, 12:53 PM
craig.topper requested review of this revision.May 6 2023, 12:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2023, 12:53 PM
This revision is now accepted and ready to land.May 7 2023, 10:26 PM
VincentWu requested changes to this revision.EditedMay 7 2023, 11:32 PM

plz update usage of matchRegisterNameHelper in function parseReglist at llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

tkx )

This revision now requires changes to proceed.May 7 2023, 11:32 PM

Just a few suggestions, not mandatory.

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
1516

Stray //

1518

Since you are refactoring this, RegNo could be renamed to Reg.

1525–1530

Why change this? NoRegister was fine.

1546
1549

Just if (!RegNo)?

craig.topper added inline comments.May 7 2023, 11:58 PM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
1549

Isn't that relying on the operator unsigned that's supposed to get removed from MCRegister eventually?

barannikov88 added inline comments.May 8 2023, 12:00 AM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
1549

It does currently, but I think adding explicit operator bool() const to MCRegister should be fine?

Rebase and address comments

barannikov88 accepted this revision.May 8 2023, 12:46 AM

LGTM
There is still // in the comment.

This revision was not accepted when it landed; it landed in state Needs Review.May 8 2023, 9:48 AM
This revision was automatically updated to reflect the committed changes.