fix rdar://8456371 - Handle commutable instructions written backward.
authorChris Lattner <sabre@nondot.org>
Wed, 22 Sep 2010 06:26:39 +0000 (06:26 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 22 Sep 2010 06:26:39 +0000 (06:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114536 91177308-0d34-0410-b5e6-96231b3b80d8

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

index bb6e05c286402657ecb3320d9ef5f5c980ab6eda..01ccc50adf92302be5e885da479d4fddd7f21454 100644 (file)
@@ -911,6 +911,16 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
     Operands.erase(Operands.begin() + 2);
   }
 
+  // FIXME: Hack to handle "f{mul*,add*} st(0), $op" the same as
+  // "f{mul*,add*} $op", since they commute.
+  if ((Name.startswith("fmul") || Name.startswith("fadd")) &&
+      Operands.size() == 3 &&
+      static_cast<X86Operand*>(Operands[1])->isReg() &&
+      static_cast<X86Operand*>(Operands[1])->getReg() == X86::ST0) {
+    delete Operands[1];
+    Operands.erase(Operands.begin() + 1);
+  }
+  
   // FIXME: Hack to handle "imul <imm>, B" which is an alias for "imul <imm>, B,
   // B".
   if (Name.startswith("imul") && Operands.size() == 3 &&
index aea617dff004e5107b79536e057b078fe9710189..b72374db46f41bde9e68b3e243312d1bc2091158 100644 (file)
@@ -353,3 +353,11 @@ mov %rdx, %cr8
 mov %rdx, %cr15
 // CHECK: movq %rdx, %cr15
 // CHECK: encoding: [0x44,0x0f,0x22,0xfa]
+
+// rdar://8456371 - Handle commutable instructions written backward.
+// CHECK:      faddp   %st(1)
+// CHECK:      fmulp   %st(2)
+faddp %st, %st(1)
+fmulp %st, %st(2)
+
+