[llvm] 2cb8056 - PPCAsmParser: Use parseOptionalToken
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 17 12:34:53 PDT 2023
Author: Fangrui Song
Date: 2023-06-17T12:34:49-07:00
New Revision: 2cb805666ad432fd28bd197ece096ba27b0cb9ce
URL: https://github.com/llvm/llvm-project/commit/2cb805666ad432fd28bd197ece096ba27b0cb9ce
DIFF: https://github.com/llvm/llvm-project/commit/2cb805666ad432fd28bd197ece096ba27b0cb9ce.diff
LOG: PPCAsmParser: Use parseOptionalToken
to simplify code near __tls_get_addr parsing.
Added:
Modified:
llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
index 414a57d9e0aad..56fdf19a0720c 100644
--- a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
+++ b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
@@ -1548,24 +1548,20 @@ bool PPCAsmParser::ParseOperand(OperandVector &Operands) {
if (const MCSymbolRefExpr *Ref = dyn_cast<MCSymbolRefExpr>(EVal))
TLSCall = Ref->getSymbol().getName() == "__tls_get_addr";
- if (TLSCall && getLexer().is(AsmToken::LParen)) {
+ if (TLSCall && parseOptionalToken(AsmToken::LParen)) {
const MCExpr *TLSSym;
-
- Parser.Lex(); // Eat the '('.
S = Parser.getTok().getLoc();
if (ParseExpression(TLSSym))
return Error(S, "invalid TLS call expression");
- if (getLexer().isNot(AsmToken::RParen))
- return Error(Parser.getTok().getLoc(), "missing ')'");
+ if (parseToken(AsmToken::RParen, "expected ')'"))
+ return true;
E = Parser.getTok().getLoc();
- Parser.Lex(); // Eat the ')'.
Operands.push_back(PPCOperand::CreateFromMCExpr(TLSSym, S, E, isPPC64()));
}
// Otherwise, check for D-form memory operands
- if (!TLSCall && getLexer().is(AsmToken::LParen)) {
- Parser.Lex(); // Eat the '('.
+ if (!TLSCall && parseOptionalToken(AsmToken::LParen)) {
S = Parser.getTok().getLoc();
int64_t IntVal;
More information about the llvm-commits
mailing list