This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Use custom operand parsing for FenceArg.
ClosedPublic

Authored by craig.topper on Jan 29 2023, 10:00 PM.

Details

Summary

Rather than parsing a symbol and checking its name, look for an
identifier during parsing.

I've also handled the 0 immediate during parsing, though we could
let that go through the normal immediate parsing if we need to support
expressions that evaluate to 0. We don't have tests for that currently.

Diff Detail

Event Timeline

craig.topper created this revision.Jan 29 2023, 10:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 29 2023, 10:00 PM
craig.topper requested review of this revision.Jan 29 2023, 10:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 29 2023, 10:00 PM
frasercrmck accepted this revision.Jan 30 2023, 12:29 AM

LGTM other than nits

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

I don't think you need the braces in this statement because Valid was declared outside of the switch scope?

1876

Not sure it's worth it but having three uses of the exact same string made me wonder if this should be a shared variable.

This revision is now accepted and ready to land.Jan 30 2023, 12:29 AM
luismarques added inline comments.Jan 30 2023, 1:19 AM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
1854–1865

In a follow-up patch, we should reject repeated letters, like iiorrrrrw. Binutils seems to reject that, which IMO is the right decision.

frasercrmck added inline comments.Jan 30 2023, 3:39 AM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
1854–1865

I took the c <= Prev check below to do just that

luismarques added inline comments.Jan 30 2023, 4:08 AM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
1854–1865

Oops, for some reason I didn't notice that. Thanks, @frasercrmck.
The tests should be extended to cover this tighter checking, though.
The patch summary should also mention that change. I'm not sure if that is noteworthy enough for release notes? It is a user-visible change...

asb accepted this revision.Jan 30 2023, 7:40 AM

Nice cleanup - thanks!

IMHO a mention in the release notes is not necessary for such a minor change to accepted input.

craig.topper added inline comments.Jan 30 2023, 8:40 AM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
1854–1865

That code isn’t new. It was already in isFenceArg in the old code.

This revision was landed with ongoing or failed builds.Jan 30 2023, 12:45 PM
This revision was automatically updated to reflect the committed changes.