This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Refactor parseVTypeI and use ParseFail if we parsed more than one identifier.
ClosedPublic

Authored by craig.topper on May 16 2023, 11:04 PM.

Details

Summary

Previously we lexed into a SmallVector and unlexed the tokens if
the parsing failed.

This patch gets rid of the SmallVector and the unlexing.

If the first token fails to parse, return MatchFail. This allows us
to fallback to parsing as an immediate. If we successfully parsed the
first token, use ParseFail if any later tokens fail to parse. This
avoids needing to UnLex the tokens.

I've used a state machine to keep track of what component we've
parsed so far.

Diff Detail

Event Timeline

craig.topper created this revision.May 16 2023, 11:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2023, 11:04 PM
craig.topper requested review of this revision.May 16 2023, 11:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2023, 11:04 PM
asb accepted this revision.May 17 2023, 3:27 AM

LGTM, but perhaps you could add a brief comment to parseVTypeToken explaining that VTypeState is used to track the parsing state machine, maybe indicated it should be set to VTypeState_SEW for the first call? It's not particularly hard to work out from the code, but I normally find just a little signposting useful when skimming.

This revision is now accepted and ready to land.May 17 2023, 3:27 AM
This revision was landed with ongoing or failed builds.May 17 2023, 10:31 AM
This revision was automatically updated to reflect the committed changes.