[llvm] 25a391c - [RISCV] Sink some repeated code into parseVTypeToken. NFC (#89694)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 22 21:13:15 PDT 2024
Author: Craig Topper
Date: 2024-04-22T21:13:12-07:00
New Revision: 25a391c7718ee8ed22e85dec212b5b77722c7f4e
URL: https://github.com/llvm/llvm-project/commit/25a391c7718ee8ed22e85dec212b5b77722c7f4e
DIFF: https://github.com/llvm/llvm-project/commit/25a391c7718ee8ed22e85dec212b5b77722c7f4e.diff
LOG: [RISCV] Sink some repeated code into parseVTypeToken. NFC (#89694)
Both calls to parseVTypeToken were proceeded by check for an Identifier
token and a call to getIdentifier. Sync those into the parseVTypeToken
to reduce repetition.
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 d926ccdb59e19b..3f4a73ad89bf8a 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -117,7 +117,7 @@ class RISCVAsmParser : public MCTargetAsmParser {
ParseStatus parseDirective(AsmToken DirectiveID) override;
- bool parseVTypeToken(StringRef Identifier, VTypeState &State, unsigned &Sew,
+ bool parseVTypeToken(const AsmToken &Tok, VTypeState &State, unsigned &Sew,
unsigned &Lmul, bool &Fractional, bool &TailAgnostic,
bool &MaskAgnostic);
bool generateVTypeError(SMLoc ErrorLoc);
@@ -2125,10 +2125,15 @@ ParseStatus RISCVAsmParser::parseJALOffset(OperandVector &Operands) {
return parseImmediate(Operands);
}
-bool RISCVAsmParser::parseVTypeToken(StringRef Identifier, VTypeState &State,
+bool RISCVAsmParser::parseVTypeToken(const AsmToken &Tok, VTypeState &State,
unsigned &Sew, unsigned &Lmul,
bool &Fractional, bool &TailAgnostic,
bool &MaskAgnostic) {
+ if (Tok.isNot(AsmToken::Identifier))
+ return true;
+
+ StringRef Identifier = Tok.getIdentifier();
+
switch (State) {
case VTypeState_SEW:
if (!Identifier.consume_front("e"))
@@ -2187,24 +2192,14 @@ ParseStatus RISCVAsmParser::parseVTypeI(OperandVector &Operands) {
VTypeState State = VTypeState_SEW;
- if (getLexer().isNot(AsmToken::Identifier))
- return ParseStatus::NoMatch;
-
- StringRef Identifier = getTok().getIdentifier();
-
- if (parseVTypeToken(Identifier, State, Sew, Lmul, Fractional, TailAgnostic,
+ if (parseVTypeToken(getTok(), State, Sew, Lmul, Fractional, TailAgnostic,
MaskAgnostic))
return ParseStatus::NoMatch;
getLexer().Lex();
while (parseOptionalToken(AsmToken::Comma)) {
- if (getLexer().isNot(AsmToken::Identifier))
- break;
-
- Identifier = getTok().getIdentifier();
-
- if (parseVTypeToken(Identifier, State, Sew, Lmul, Fractional, TailAgnostic,
+ if (parseVTypeToken(getTok(), State, Sew, Lmul, Fractional, TailAgnostic,
MaskAgnostic))
break;
More information about the llvm-commits
mailing list