[llvm] [RISCV] Merge RegStart with RegEnd in parseRegListCommon. NFC (PR #133867)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 31 23:20:32 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: Craig Topper (topperc)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/133867.diff
1 Files Affected:
- (modified) llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp (+5-9)
``````````diff
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index c1670326143e3..d34463ef9c2b1 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2579,9 +2579,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();
@@ -2602,10 +2601,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
@@ -2663,9 +2662,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)
``````````
</details>
https://github.com/llvm/llvm-project/pull/133867
More information about the llvm-commits
mailing list