[llvm-commits] [llvm] r74685 - in /llvm/trunk/tools/llvm-mc: AsmParser.cpp AsmParser.h MC-X86Specific.cpp
Daniel Dunbar
daniel at zuster.org
Wed Jul 1 19:09:07 PDT 2009
Author: ddunbar
Date: Wed Jul 1 21:09:07 2009
New Revision: 74685
URL: http://llvm.org/viewvc/llvm-project?rev=74685&view=rev
Log:
llvm-mc/x86: Fix bug in disambiguation of displacement operand, introduced by me
(I think).
- We weren't properly parsing the leading parenthesized expression in something
like 'push (4)(%eax)'.
- Added ParseParenRelocatableExpression to support this. I suspect we should
just use lookahead, though.
- Test case to follow.
Modified:
llvm/trunk/tools/llvm-mc/AsmParser.cpp
llvm/trunk/tools/llvm-mc/AsmParser.h
llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp
Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=74685&r1=74684&r2=74685&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Wed Jul 1 21:09:07 2009
@@ -167,6 +167,19 @@
return false;
}
+bool AsmParser::ParseParenRelocatableExpression(MCValue &Res) {
+ AsmExpr *Expr;
+
+ SMLoc StartLoc = Lexer.getLoc();
+ if (ParseParenExpr(Expr))
+ return true;
+
+ if (!Expr->EvaluateAsRelocatable(Ctx, Res))
+ return Error(StartLoc, "expected relocatable expression");
+
+ return false;
+}
+
static unsigned getBinOpPrecedence(asmtok::TokKind K,
AsmBinaryExpr::Opcode &Kind) {
switch (K) {
Modified: llvm/trunk/tools/llvm-mc/AsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.h?rev=74685&r1=74684&r2=74685&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.h Wed Jul 1 21:09:07 2009
@@ -73,6 +73,16 @@
/// @result - False on success.
bool ParseRelocatableExpression(MCValue &Res);
+ /// ParseParenRelocatableExpression - Parse an expression which must be
+ /// relocatable, assuming that an initial '(' has already been consumed.
+ ///
+ /// @param Res - The relocatable expression value. The result is undefined on
+ /// error.
+ /// @result - False on success.
+ ///
+ /// @see ParseRelocatableExpression, ParseParenExpr.
+ bool ParseParenRelocatableExpression(MCValue &Res);
+
bool ParsePrimaryExpr(AsmExpr *&Res);
bool ParseBinOpRHS(unsigned Precedence, AsmExpr *&Res);
bool ParseParenExpr(AsmExpr *&Res);
Modified: llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp?rev=74685&r1=74684&r2=74685&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp (original)
+++ llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp Wed Jul 1 21:09:07 2009
@@ -152,7 +152,7 @@
// memory operand consumed.
} else {
// It must be an parenthesized expression, parse it now.
- if (ParseRelocatableExpression(Disp))
+ if (ParseParenRelocatableExpression(Disp))
return true;
// After parsing the base expression we could either have a parenthesized
More information about the llvm-commits
mailing list