Fix rdar://8468087 - llvm-mc commutes fmul (and friend) operands.
authorChris Lattner <sabre@nondot.org>
Mon, 27 Sep 2010 07:08:21 +0000 (07:08 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 27 Sep 2010 07:08:21 +0000 (07:08 +0000)
My previous fix for rdar://8456371 should only apply to fmulp/faddp,
not to fmul/fadd.  Instruction set orthogonality is overrated or
something.

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

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

index 18fb173e1c1a178b99637ca4923f70aa53f765c9..698e282f265f75e29c128dc47e571d091634f688 100644 (file)
@@ -910,11 +910,10 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
     delete Operands[2];
     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 &&
+  
+  // 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 &&
       static_cast<X86Operand*>(Operands[1])->isReg() &&
       static_cast<X86Operand*>(Operands[1])->getReg() == X86::ST0) {
     delete Operands[1];
index 9725e9dcbfda915c23b6d33715bebb46c5947e4d..dda047e6fdbb2c02dc99e9aac7908b7b3329d9bd 100644 (file)
@@ -360,6 +360,22 @@ mov %rdx, %cr15
 faddp %st, %st(1)
 fmulp %st, %st(2)
 
+// rdar://8468087 - Encode these accurately, they are not synonyms.
+// CHECK: fmul %st(0), %st(1)
+// CHECK: encoding: [0xdc,0xc9]
+// CHECK: fmul %st(1)
+// CHECK: encoding: [0xd8,0xc9]
+fmul %st, %st(1)
+fmul %st(1), %st
+
+// CHECK: fadd %st(0), %st(1)
+// CHECK: encoding: [0xdc,0xc1]
+// CHECK: fadd %st(1)
+// CHECK: encoding: [0xd8,0xc1]
+fadd %st, %st(1)
+fadd %st(1), %st
+
+
 // rdar://8416805
 // CHECK: xorb %al, %al
 // CHECK: encoding: [0x30,0xc0]