Intel syntax: There is no need to create unary expr for simple negative displacement.
authorDevang Patel <dpatel@apple.com>
Thu, 19 Jan 2012 18:15:51 +0000 (18:15 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 19 Jan 2012 18:15:51 +0000 (18:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148486 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmParser/X86AsmParser.cpp
test/MC/X86/intel-syntax-encoding.s

index 5fc38d39d91f4e5360247ba5efb80b329690ccf1..1763419408dd4d1df4fb144c79977f4a22318758 100644 (file)
@@ -651,7 +651,7 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned Size) {
         Scale = Val;
       } else if (getLexer().is(AsmToken::RBrac)) {
         const MCExpr *ValExpr = MCConstantExpr::Create(Val, getContext());
-        Disp = isPlus ? ValExpr : MCUnaryExpr::CreateMinus(ValExpr, getContext());
+        Disp = isPlus ? ValExpr : MCConstantExpr::Create(0-Val, getContext());
       } else
         return ErrorOperand(PlusLoc, "unexpected token after +");
     } else if (getLexer().is(AsmToken::Identifier)) {
index 0d1b2fa9932a00d4ee8ba9a7cdf59da88534dd95..23eff016910e53e31620d27a9d17b14cebf5cd16 100644 (file)
@@ -20,3 +20,7 @@
        cmp     eax, 12
 // CHECK: encoding: [0x48,0x83,0xf8,0x0c]
        cmp     rax, 12
+
+// CHECK: encoding: [0x48,0x89,0x44,0x24,0xf0] 
+       mov     QWORD PTR [RSP - 16], RAX
+