process memory operands with a parenthesized expression for a displacement,
authorChris Lattner <sabre@nondot.org>
Mon, 22 Jun 2009 06:35:58 +0000 (06:35 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 22 Jun 2009 06:35:58 +0000 (06:35 +0000)
like "(4+5)(%eax)".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73878 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-mc/AsmParser.cpp

index 397c5fe9c7cebe523df4cd16433d6fd7926eec32..715ff3932bc6940ba8fe596e401048b4f61cd7cc 100644 (file)
@@ -167,8 +167,18 @@ bool AsmParser::ParseX86MemOperand(X86Operand &Op) {
       // Nothing to do here, fall into the code below with the '(' part of the
       // memory operand consumed.
     } else {
-      // FIXME: Call ParseParenExpression with the leading ( consumed.
-      return TokError("FIXME: Paren expr not implemented yet!");
+      // It must be an parenthesized expression, parse it now.
+      if (ParseParenExpr(Disp)) return true;
+      
+      // After parsing the base expression we could either have a parenthesized
+      // memory address or not.  If not, return now.  If so, eat the (.
+      if (Lexer.isNot(asmtok::LParen)) {
+        Op = X86Operand::CreateMem(SegReg, Disp, 0, 0, 0);
+        return false;
+      }
+      
+      // Eat the '('.
+      Lexer.Lex();
     }
   }