[llvm] 077497d - [MCParser] Remove parseParenExprOfDepth
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 1 16:52:50 PST 2025
Author: Fangrui Song
Date: 2025-03-01T16:52:45-08:00
New Revision: 077497d180c6ad52d7c3ee6c36ee5ae56ac8c1d1
URL: https://github.com/llvm/llvm-project/commit/077497d180c6ad52d7c3ee6c36ee5ae56ac8c1d1
DIFF: https://github.com/llvm/llvm-project/commit/077497d180c6ad52d7c3ee6c36ee5ae56ac8c1d1.diff
LOG: [MCParser] Remove parseParenExprOfDepth
Introduced by http://reviews.llvm.org/D9742 as a hack, which then became
unneeded.
Primary test: llvm/test/MC/Mips/memory-offsets.s
Added:
Modified:
llvm/include/llvm/MC/MCParser/MCAsmParser.h
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCParser/MCAsmParser.h b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
index 70fba69778536..021577c85bc25 100644
--- a/llvm/include/llvm/MC/MCParser/MCAsmParser.h
+++ b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
@@ -331,17 +331,6 @@ class MCAsmParser {
/// \return - False on success.
virtual bool checkForValidSection() = 0;
- /// Parse an arbitrary expression of a specified parenthesis depth,
- /// assuming that the initial '(' characters have already been consumed.
- ///
- /// \param ParenDepth - Specifies how many trailing expressions outside the
- /// current parentheses we have to parse.
- /// \param Res - The value of the expression. The result is undefined
- /// on error.
- /// \return - False on success.
- virtual bool parseParenExprOfDepth(unsigned ParenDepth, const MCExpr *&Res,
- SMLoc &EndLoc) = 0;
-
/// Parse a .gnu_attribute.
bool parseGNUAttribute(SMLoc L, int64_t &Tag, int64_t &IntegerValue);
};
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index c1ca690df95f9..fccd89eec00ff 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -272,8 +272,6 @@ class AsmParser : public MCAsmParser {
bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
AsmTypeInfo *TypeInfo) override;
bool parseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) override;
- bool parseParenExprOfDepth(unsigned ParenDepth, const MCExpr *&Res,
- SMLoc &EndLoc) override;
bool parseAbsoluteExpression(int64_t &Res) override;
/// Parse a floating point expression using the float \p Semantics
@@ -1536,26 +1534,6 @@ bool AsmParser::parseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) {
return parseParenExpr(Res, EndLoc) || parseBinOpRHS(1, Res, EndLoc);
}
-bool AsmParser::parseParenExprOfDepth(unsigned ParenDepth, const MCExpr *&Res,
- SMLoc &EndLoc) {
- if (parseParenExpr(Res, EndLoc))
- return true;
-
- for (; ParenDepth > 0; --ParenDepth) {
- if (parseBinOpRHS(1, Res, EndLoc))
- return true;
-
- // We don't Lex() the last RParen.
- // This is the same behavior as parseParenExpression().
- if (ParenDepth - 1 > 0) {
- EndLoc = getTok().getEndLoc();
- if (parseRParen())
- return true;
- }
- }
- return false;
-}
-
bool AsmParser::parseAbsoluteExpression(int64_t &Res) {
const MCExpr *Expr;
diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index b2c956e0a4598..6df83026903ec 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -547,8 +547,6 @@ class MasmParser : public MCAsmParser {
bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
AsmTypeInfo *TypeInfo) override;
bool parseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) override;
- bool parseParenExprOfDepth(unsigned ParenDepth, const MCExpr *&Res,
- SMLoc &EndLoc) override;
bool parseAbsoluteExpression(int64_t &Res) override;
/// Parse a floating point expression using the float \p Semantics
@@ -1905,26 +1903,6 @@ bool MasmParser::parseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) {
return parseParenExpr(Res, EndLoc) || parseBinOpRHS(1, Res, EndLoc);
}
-bool MasmParser::parseParenExprOfDepth(unsigned ParenDepth, const MCExpr *&Res,
- SMLoc &EndLoc) {
- if (parseParenExpr(Res, EndLoc))
- return true;
-
- for (; ParenDepth > 0; --ParenDepth) {
- if (parseBinOpRHS(1, Res, EndLoc))
- return true;
-
- // We don't Lex() the last RParen.
- // This is the same behavior as parseParenExpression().
- if (ParenDepth - 1 > 0) {
- EndLoc = getTok().getEndLoc();
- if (parseRParen())
- return true;
- }
- }
- return false;
-}
-
bool MasmParser::parseAbsoluteExpression(int64_t &Res) {
const MCExpr *Expr;
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 7fdf02d29e173..bed1ef882ffe1 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -6516,7 +6516,7 @@ bool MipsAsmParser::parseMemOffset(const MCExpr *&Res, bool isParenExpr) {
SMLoc S;
if (isParenExpr)
- return getParser().parseParenExprOfDepth(0, Res, S);
+ return getParser().parseExpression(Res, S) || getParser().parseRParen();
return getParser().parseExpression(Res);
}
More information about the llvm-commits
mailing list