This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Improve tracking of EndLoc in the assembly parser.
ClosedPublic

Authored by craig.topper on Dec 6 2021, 2:59 PM.

Details

Summary

The SMLoc::getFromPointer(S.getPointer() - 1) pattern used in
several place didn't make sense since that puts the End before the
Start location.

This patch corrects this to properly calculate the end location as
we parse. Unsure how much this matters, a lot of these are for custom
operand parsing. If the custom parsing succeeds, the instruction
matching probably won't fail, so the end loc won't be used to build
a range for a diagnostic.

I've also fixed the creation functions for the CSR and VType operands
to assign the EndLoc of the RISCVOperand class using the StartLoc
instead of an empty SMLoc. I don't think these will ever be accessed,
but it makes the code look less like we forgot to assign it. This is
consistent with some operands on the ARM target.

Diff Detail

Event Timeline

craig.topper created this revision.Dec 6 2021, 2:59 PM
craig.topper requested review of this revision.Dec 6 2021, 2:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2021, 2:59 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
luismarques accepted this revision.Dec 8 2021, 3:07 PM

LGTM.

If the custom parsing succeeds, the instruction matching probably won't fail, so the end loc won't be used to build a range for a diagnostic.

Indeed, currently that seems to be the case. Still, good idea to fix it. Thanks!

This revision is now accepted and ready to land.Dec 8 2021, 3:07 PM