[llvm] 9896d72 - [RISCV] Use parseToken to simplify code. Add missing check for Identifier token.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon May 8 10:47:02 PDT 2023
Author: Craig Topper
Date: 2023-05-08T10:46:21-07:00
New Revision: 9896d7223386ed539aecc0b7cea888a6421d9026
URL: https://github.com/llvm/llvm-project/commit/9896d7223386ed539aecc0b7cea888a6421d9026
DIFF: https://github.com/llvm/llvm-project/commit/9896d7223386ed539aecc0b7cea888a6421d9026.diff
LOG: [RISCV] Use parseToken to simplify code. Add missing check for Identifier token.
Added:
Modified:
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 8562473845f2..03e00cbac8cd 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2314,13 +2314,17 @@ OperandMatchResultTy RISCVAsmParser::parseReglist(OperandVector &Operands) {
// Rlist: {ra [, s0[-sN]]}
// XRlist: {x1 [, x8[-x9][, x18[-xN]]]}
SMLoc S = getLoc();
- if (getLexer().isNot(AsmToken::LCurly)) {
- Error(getLoc(), "register list must start with '{'");
+
+ if (parseToken(AsmToken::LCurly, "register list must start with '{'"))
return MatchOperand_ParseFail;
- }
- getLexer().Lex(); // eat '{'
+
bool IsEABI = isRVE();
+ if (getLexer().isNot(AsmToken::Identifier)) {
+ Error(getLoc(), "register list must start from 'ra' or 'x1'");
+ return MatchOperand_ParseFail;
+ }
+
StringRef RegName = getLexer().getTok().getIdentifier();
MCRegister RegStart = matchRegisterNameHelper(IsEABI, RegName);
MCRegister RegEnd;
@@ -2416,11 +2420,8 @@ OperandMatchResultTy RISCVAsmParser::parseReglist(OperandVector &Operands) {
return MatchOperand_ParseFail;
}
- if (getLexer().isNot(AsmToken::RCurly)) {
- Error(getLoc(), "register list must end with '}'");
+ if (parseToken(AsmToken::RCurly, "register list must end with '}'"))
return MatchOperand_ParseFail;
- }
- getLexer().Lex(); // eat '}'
if (RegEnd == RISCV::NoRegister)
RegEnd = RegStart;
More information about the llvm-commits
mailing list