Skip to content

Commit 25a391c

Browse files
authored
[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.
1 parent e5f9de8 commit 25a391c

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class RISCVAsmParser : public MCTargetAsmParser {
117117

118118
ParseStatus parseDirective(AsmToken DirectiveID) override;
119119

120-
bool parseVTypeToken(StringRef Identifier, VTypeState &State, unsigned &Sew,
120+
bool parseVTypeToken(const AsmToken &Tok, VTypeState &State, unsigned &Sew,
121121
unsigned &Lmul, bool &Fractional, bool &TailAgnostic,
122122
bool &MaskAgnostic);
123123
bool generateVTypeError(SMLoc ErrorLoc);
@@ -2125,10 +2125,15 @@ ParseStatus RISCVAsmParser::parseJALOffset(OperandVector &Operands) {
21252125
return parseImmediate(Operands);
21262126
}
21272127

2128-
bool RISCVAsmParser::parseVTypeToken(StringRef Identifier, VTypeState &State,
2128+
bool RISCVAsmParser::parseVTypeToken(const AsmToken &Tok, VTypeState &State,
21292129
unsigned &Sew, unsigned &Lmul,
21302130
bool &Fractional, bool &TailAgnostic,
21312131
bool &MaskAgnostic) {
2132+
if (Tok.isNot(AsmToken::Identifier))
2133+
return true;
2134+
2135+
StringRef Identifier = Tok.getIdentifier();
2136+
21322137
switch (State) {
21332138
case VTypeState_SEW:
21342139
if (!Identifier.consume_front("e"))
@@ -2187,24 +2192,14 @@ ParseStatus RISCVAsmParser::parseVTypeI(OperandVector &Operands) {
21872192

21882193
VTypeState State = VTypeState_SEW;
21892194

2190-
if (getLexer().isNot(AsmToken::Identifier))
2191-
return ParseStatus::NoMatch;
2192-
2193-
StringRef Identifier = getTok().getIdentifier();
2194-
2195-
if (parseVTypeToken(Identifier, State, Sew, Lmul, Fractional, TailAgnostic,
2195+
if (parseVTypeToken(getTok(), State, Sew, Lmul, Fractional, TailAgnostic,
21962196
MaskAgnostic))
21972197
return ParseStatus::NoMatch;
21982198

21992199
getLexer().Lex();
22002200

22012201
while (parseOptionalToken(AsmToken::Comma)) {
2202-
if (getLexer().isNot(AsmToken::Identifier))
2203-
break;
2204-
2205-
Identifier = getTok().getIdentifier();
2206-
2207-
if (parseVTypeToken(Identifier, State, Sew, Lmul, Fractional, TailAgnostic,
2202+
if (parseVTypeToken(getTok(), State, Sew, Lmul, Fractional, TailAgnostic,
22082203
MaskAgnostic))
22092204
break;
22102205

0 commit comments

Comments
 (0)