[llvm] 4e6c48f - [RISCV] Merge RegStart with RegEnd in parseRegListCommon. NFC (#133867)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 1 08:04:36 PDT 2025
Author: Craig Topper
Date: 2025-04-01T08:04:32-07:00
New Revision: 4e6c48f1e74c46e62342f24ac879fd32d9a6c783
URL: https://github.com/llvm/llvm-project/commit/4e6c48f1e74c46e62342f24ac879fd32d9a6c783
DIFF: https://github.com/llvm/llvm-project/commit/4e6c48f1e74c46e62342f24ac879fd32d9a6c783.diff
LOG: [RISCV] Merge RegStart with RegEnd in parseRegListCommon. NFC (#133867)
We only need to keep track of the last register seen. We never need the
first register once we've parsed. Currently if s0/x8 is used RegStart
will point to that and not ra/s1 so it already isn't the start.
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 6384a1c44196b..f1ccf0cd052ba 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2583,9 +2583,8 @@ ParseStatus RISCVAsmParser::parseRegListCommon(OperandVector &Operands,
return Error(getLoc(), "register list must start from 'ra' or 'x1'");
StringRef RegName = getLexer().getTok().getIdentifier();
- MCRegister RegStart = matchRegisterNameHelper(RegName);
- MCRegister RegEnd;
- if (RegStart != RISCV::X1)
+ MCRegister RegEnd = matchRegisterNameHelper(RegName);
+ if (RegEnd != RISCV::X1)
return Error(getLoc(), "register list must start from 'ra' or 'x1'");
getLexer().Lex();
@@ -2606,10 +2605,10 @@ ParseStatus RISCVAsmParser::parseRegListCommon(OperandVector &Operands,
if (getLexer().isNot(AsmToken::Identifier))
return Error(getLoc(), "invalid register");
StringRef RegName = getLexer().getTok().getIdentifier();
- RegStart = matchRegisterNameHelper(RegName);
- if (!RegStart)
+ RegEnd = matchRegisterNameHelper(RegName);
+ if (!RegEnd)
return Error(getLoc(), "invalid register");
- if (RegStart != RISCV::X8)
+ if (RegEnd != RISCV::X8)
return Error(getLoc(),
"continuous register list must start from 's0' or 'x8'");
getLexer().Lex(); // eat reg
@@ -2668,9 +2667,6 @@ ParseStatus RISCVAsmParser::parseRegListCommon(OperandVector &Operands,
if (parseToken(AsmToken::RCurly, "register list must end with '}'"))
return ParseStatus::Failure;
- if (!RegEnd)
- RegEnd = RegStart;
-
auto Encode = RISCVZC::encodeRlist(RegEnd, IsEABI);
assert(Encode != RISCVZC::INVALID_RLIST);
if (MustIncludeS0)
More information about the llvm-commits
mailing list