This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Make .option arch parser less mind-bending
ClosedPublic

Authored by jrtc27 on Jun 5 2023, 1:26 PM.

Details

Summary

Currently the early-return flow in the infinite loop makes it hard to
find the non-error termination points amongst the sea of errors. Rewrite
it with a more conventional control flow that has a clear loop guard (in
place of one of the early returns) and a break (in place of the other),
and with greater code reuse.

This has a small effect on the errors given for malformed input, as seen
in the affected test, and is probably more helpful as a result. Note
that we also bail early now if parseComma fails, as is standard.

Diff Detail

Event Timeline

jrtc27 created this revision.Jun 5 2023, 1:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 1:26 PM
jrtc27 requested review of this revision.Jun 5 2023, 1:26 PM
craig.topper added inline comments.Jun 5 2023, 3:50 PM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
2745

I think you could use !IsExtensionList here and avoid the IsFull flag. That might make the code less readable, but maybe that can be fixed with renaming IsExtensionList

craig.topper added inline comments.Jun 5 2023, 3:56 PM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
2745

Nevermind, I see the followup patch changes this to remove IsExtensionList

This revision is now accepted and ready to land.Jun 5 2023, 3:57 PM
jrtc27 added inline comments.Jun 5 2023, 7:25 PM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
2745

I guess I could still as the interim state rather than introduce an unnecessary extra variable, though probably not worth the hassle of changing this revision for code that's going to immediately be deleted

This revision was automatically updated to reflect the committed changes.