implement rdar://8491845 - Gas supports commuted forms of non-commutable instructions.
authorChris Lattner <sabre@nondot.org>
Wed, 29 Sep 2010 18:39:16 +0000 (18:39 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 29 Sep 2010 18:39:16 +0000 (18:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115061 91177308-0d34-0410-b5e6-96231b3b80d8

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

index c8b25cea30b986f90e1187a571c0d49ce41ee675..3ecf273a088c7d5ec0551b1c79c819b589d42ca7 100644 (file)
@@ -921,8 +921,10 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
   }
   
   // FIXME: Hack to handle "f{mulp,addp} st(0), $op" the same as
-  // "f{mulp,addp} $op", since they commute.
-  if ((Name == "fmulp" || Name == "faddp") && Operands.size() == 3 &&
+  // "f{mulp,addp} $op", since they commute.  We also allow fdivrp/fsubrp even
+  // though they don't commute, solely because gas does support this.
+  if ((Name=="fmulp" || Name=="faddp" || Name=="fsubrp" || Name=="fdivrp") &&
+      Operands.size() == 3 &&
       static_cast<X86Operand*>(Operands[1])->isReg() &&
       static_cast<X86Operand*>(Operands[1])->getReg() == X86::ST0) {
     delete Operands[1];
index d182917d2da0a49d2bc192d89e218ea7280962e8..6da446821d8a3af27f18911f1f33c38310c6550e 100644 (file)
@@ -466,3 +466,11 @@ movmskpd   %xmm6, %rax
 movmskpd       %xmm6, %eax
 // CHECK: movmskpd     %xmm6, %eax
 // CHECK: encoding: [0x66,0x0f,0x50,0xc6]
+
+// rdar://8491845 - Gas supports commuted forms of non-commutable instructions.
+fdivrp %st(0), %st(1) // CHECK: encoding: [0xde,0xf9]
+fdivrp %st(1), %st(0) // CHECK: encoding: [0xde,0xf9]
+
+fsubrp %ST(0), %ST(1) // CHECK: encoding: [0xde,0xe9]
+fsubrp %ST(1), %ST(0) // CHECK: encoding: [0xde,0xe9]
+