MC/X86: Warn on scale factors > 1 without index register, instead of erroring,
authorDaniel Dunbar <daniel@zuster.org>
Tue, 24 Aug 2010 19:13:38 +0000 (19:13 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 24 Aug 2010 19:13:38 +0000 (19:13 +0000)
for 'as' compatibility.

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

lib/Target/X86/AsmParser/X86AsmParser.cpp
test/MC/AsmParser/X86/x86_instructions.s

index 09950e8f6666e74712c85106961ec56c058561b6..204ccf77a7580688a4a27ce0dc264dd7b35a0793 100644 (file)
@@ -588,7 +588,7 @@ X86Operand *X86ATTAsmParser::ParseMemOperand(unsigned SegReg, SMLoc MemStart) {
         }
       }
     } else if (getLexer().isNot(AsmToken::RParen)) {
-      // Otherwise we have the unsupported form of a scale amount without an
+      // A scale amount without an index is ignored.
       // index.
       SMLoc Loc = Parser.getTok().getLoc();
 
@@ -596,8 +596,9 @@ X86Operand *X86ATTAsmParser::ParseMemOperand(unsigned SegReg, SMLoc MemStart) {
       if (getParser().ParseAbsoluteExpression(Value))
         return 0;
 
-      Error(Loc, "cannot have scale factor without index register");
-      return 0;
+      if (Value != 1)
+        Warning(Loc, "scale factor without index register is ignored");
+      Scale = 1;
     }
   }
 
index 92fb1b243114058a8dc6a41de0022b4cd4c10170..8adcc9e0cdf015cd26760c8c65a27d0ce8e448a3 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -triple x86_64-unknown-unknown %s | FileCheck %s
+// RUN: llvm-mc -triple x86_64-unknown-unknown %s > %t 2> %t.err
+// RUN: FileCheck < %t %s
+// RUN: FileCheck --check-prefix=CHECK-STDERR < %t.err %s
 
 // CHECK: subb %al, %al
         subb %al, %al
@@ -151,3 +153,8 @@ fadd %st(7)
 // CHECK: int3
 INT3
 
+
+// Allow scale factor without index register.
+// CHECK: movaps       %xmm3, (%esi)
+// CHECK-STDERR: warning: scale factor without index register is ignored
+movaps %xmm3, (%esi, 2)