[llvm] ea273f9 - [MSP430] Use parseOptionalToken. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 15 11:45:26 PDT 2023
Author: Fangrui Song
Date: 2023-06-15T11:45:23-07:00
New Revision: ea273f9b52af30722d012791ea6c30d1d648f02c
URL: https://github.com/llvm/llvm-project/commit/ea273f9b52af30722d012791ea6c30d1d648f02c
DIFF: https://github.com/llvm/llvm-project/commit/ea273f9b52af30722d012791ea6c30d1d648f02c.diff
LOG: [MSP430] Use parseOptionalToken. NFC
Added:
Modified:
llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp b/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
index a2ed148aae9b3..1389f0a76888b 100644
--- a/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
+++ b/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
@@ -363,8 +363,7 @@ bool MSP430AsmParser::parseJccInstruction(ParseInstructionInfo &Info,
}
// Skip optional '$' sign.
- if (getLexer().getKind() == AsmToken::Dollar)
- getLexer().Lex(); // Eat '$'
+ (void)parseOptionalToken(AsmToken::Dollar);
const MCExpr *Val;
SMLoc ExprLoc = getLexer().getLoc();
@@ -411,11 +410,8 @@ bool MSP430AsmParser::ParseInstruction(ParseInstructionInfo &Info,
return true;
// Parse second operand if any
- if (getLexer().is(AsmToken::Comma)) {
- getLexer().Lex(); // Eat ','
- if (ParseOperand(Operands))
- return true;
- }
+ if (parseOptionalToken(AsmToken::Comma) && ParseOperand(Operands))
+ return true;
if (getLexer().isNot(AsmToken::EndOfStatement)) {
SMLoc Loc = getLexer().getLoc();
@@ -474,15 +470,13 @@ bool MSP430AsmParser::ParseOperand(OperandVector &Operands) {
MCRegister RegNo = MSP430::PC;
SMLoc EndLoc = getParser().getTok().getLoc();
// Try (rN)
- if (getLexer().getKind() == AsmToken::LParen) {
- getLexer().Lex(); // Eat '('
+ if (parseOptionalToken(AsmToken::LParen)) {
SMLoc RegStartLoc;
if (parseRegister(RegNo, RegStartLoc, EndLoc))
return true;
- if (getLexer().getKind() != AsmToken::RParen)
- return true;
EndLoc = getParser().getTok().getEndLoc();
- getLexer().Lex(); // Eat ')'
+ if (!parseOptionalToken(AsmToken::RParen))
+ return true;
}
Operands.push_back(MSP430Operand::CreateMem(RegNo, Val, StartLoc,
EndLoc));
@@ -511,9 +505,8 @@ bool MSP430AsmParser::ParseOperand(OperandVector &Operands) {
SMLoc RegStartLoc, EndLoc;
if (parseRegister(RegNo, RegStartLoc, EndLoc))
return true;
- if (getLexer().getKind() == AsmToken::Plus) {
+ if (parseOptionalToken(AsmToken::Plus)) {
Operands.push_back(MSP430Operand::CreatePostIndReg(RegNo, StartLoc, EndLoc));
- getLexer().Lex(); // Eat '+'
return false;
}
if (Operands.size() > 1) // Emulate @rd in destination position as 0(rd)
More information about the llvm-commits
mailing list