From ba985d9dd5bef503a1fc7544039378dc76f3f59d Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Wed, 27 Oct 2010 00:59:28 +0000 Subject: [PATCH] Added some aliases to the fcomip and fucompi Intel instructions. So that llvm-mc will accept versions that the darwin assembler allows. Forms ending in "pi" and forms without all the operands. llvm-svn: 117427 --- .../lib/Target/X86/AsmParser/X86AsmParser.cpp | 15 +++++++++++- llvm/test/MC/X86/x86-32.s | 24 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index 4aad817f13d6..9bf0f6415eb2 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -703,6 +703,8 @@ ParseInstruction(StringRef Name, SMLoc NameLoc, .Case("fwait", "wait") .Case("movzx", "movzb") // FIXME: Not correct. .Case("fildq", "fildll") + .Case("fcompi", "fcomip") + .Case("fucompi", "fucomip") .Default(Name); // FIXME: Hack to recognize cmp{ss,sd,ps,pd}. @@ -991,9 +993,20 @@ ParseInstruction(StringRef Name, SMLoc NameLoc, NameLoc, NameLoc)); } + // The assembler accepts this instruction with no operand as a synonym for an + // instruction taking %st(1),%st(0). e.g. "fcompi" -> "fcompi %st(1),st(0)". + if (Name == "fcompi" && Operands.size() == 1) { + Operands.push_back(X86Operand::CreateReg(MatchRegisterName("st(1)"), + NameLoc, NameLoc)); + Operands.push_back(X86Operand::CreateReg(MatchRegisterName("st(0)"), + NameLoc, NameLoc)); + } + // The assembler accepts these instructions with two few operands as a synonym // for taking %st(1),%st(0) or X, %st(0). - if ((Name == "fcomi" || Name == "fucomi") && Operands.size() < 3) { + if ((Name == "fcomi" || Name == "fucomi" || Name == "fucompi" || + Name == "fcompi" ) && + Operands.size() < 3) { if (Operands.size() == 1) Operands.push_back(X86Operand::CreateReg(MatchRegisterName("st(1)"), NameLoc, NameLoc)); diff --git a/llvm/test/MC/X86/x86-32.s b/llvm/test/MC/X86/x86-32.s index c474b1c589c5..9bce1a8da29f 100644 --- a/llvm/test/MC/X86/x86-32.s +++ b/llvm/test/MC/X86/x86-32.s @@ -702,3 +702,27 @@ pshufw $90, %mm4, %mm0 // CHECK: sidt 4(%eax) // CHECK: encoding: [0x0f,0x01,0x48,0x04] sidtl 4(%eax) + +// CHECK: fcomip %st(2), %st(0) +// CHECK: encoding: [0xdf,0xf2] + fcompi %st(2),%st + +// CHECK: fcomip %st(2), %st(0) +// CHECK: encoding: [0xdf,0xf2] + fcompi %st(2) + +// CHECK: fcomip %st(1), %st(0) +// CHECK: encoding: [0xdf,0xf1] + fcompi + +// CHECK: fucomip %st(2), %st(0) +// CHECK: encoding: [0xdf,0xea] + fucompi %st(2),%st + +// CHECK: fucomip %st(2), %st(0) +// CHECK: encoding: [0xdf,0xea] + fucompi %st(2) + +// CHECK: fucomip %st(1), %st(0) +// CHECK: encoding: [0xdf,0xe9] + fucompi