aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-02 02:09:07 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-02 02:09:07 +0000
commit5ebef275a99ca0d3cf7772925ec6387cbf214c64 (patch)
tree236f920f671e85be986c4d43031e004d1addfc7c
parentb336eac43096e6f7b6dc7e1154b3a1a29a50b06b (diff)
downloadexternal_llvm-5ebef275a99ca0d3cf7772925ec6387cbf214c64.zip
external_llvm-5ebef275a99ca0d3cf7772925ec6387cbf214c64.tar.gz
external_llvm-5ebef275a99ca0d3cf7772925ec6387cbf214c64.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74685 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/llvm-mc/AsmParser.cpp13
-rw-r--r--tools/llvm-mc/AsmParser.h10
-rw-r--r--tools/llvm-mc/MC-X86Specific.cpp2
3 files changed, 24 insertions, 1 deletions
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index 931e460..339a16d 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/tools/llvm-mc/AsmParser.cpp
@@ -167,6 +167,19 @@ bool AsmParser::ParseRelocatableExpression(MCValue &Res) {
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) {
diff --git a/tools/llvm-mc/AsmParser.h b/tools/llvm-mc/AsmParser.h
index ae5c414..333b284 100644
--- a/tools/llvm-mc/AsmParser.h
+++ b/tools/llvm-mc/AsmParser.h
@@ -73,6 +73,16 @@ private:
/// @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);
diff --git a/tools/llvm-mc/MC-X86Specific.cpp b/tools/llvm-mc/MC-X86Specific.cpp
index 71d7080..a186618 100644
--- a/tools/llvm-mc/MC-X86Specific.cpp
+++ b/tools/llvm-mc/MC-X86Specific.cpp
@@ -152,7 +152,7 @@ bool AsmParser::ParseX86MemOperand(X86Operand &Op) {
// 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