Skip to content

[RISCV] Sink some repeated code into parseVTypeToken. NFC #89694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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;

Expand Down