This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][AsmParser] Fix parsing of the components of the vtype immediate of vsetvli
Needs ReviewPublic

Authored by rogfer01 on Apr 21 2022, 5:32 AM.

Details

Summary

This was discovered due to a typo in an assembly file when using an assertion-enabled build.

We are getting the tokens as "identifiers". This triggers an assertion failure when the token is not a proper identifier (e.g an integer literal) and also has the side-effect that we were accepting quoted syntax.

Diff Detail

Event Timeline

rogfer01 created this revision.Apr 21 2022, 5:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2022, 5:32 AM
rogfer01 requested review of this revision.Apr 21 2022, 5:32 AM

Thanks for fixing it! @rogfer01

llvm/test/MC/RISCV/rvv/invalid.s
81

This error message seems a little bad. Would you mind improving the error message? Since improving this error message may cause other cases' error messages badly, doing this may require trade-offs in many cases.
IMO, we can report specific errors and return MatchOperand_ParseFail when the operand must be a VTypeI operand (Maybe if the operand can get 7 tokens or other judge condition, then it must a vtypeI) and we get into trouble in parsing VTypeI's elements.

rogfer01 added inline comments.Apr 25 2022, 2:15 AM
llvm/test/MC/RISCV/rvv/invalid.s
81

Sure. I also noticed the diagnostic always points at the beginning of the whole operand.

I will check that the operand parser routine is not speculatively executed and see if we can be more precise in the diagnostic.

craig.topper added inline comments.Apr 25 2022, 9:31 AM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
1724

Should we have been checking that they were identifiers up here?

I think this patch is obsolete now.

evandro removed a subscriber: evandro.May 17 2023, 3:50 PM