From 19b30d56b224ab3507f7a93743eac2b01c5861dd Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 13 Jun 2013 15:45:24 +0000 Subject: [PATCH] X86: Make the cmov aliases work with intel syntax too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183907 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86InstrInfo.td | 44 ++++++++++++++++++---------------- test/MC/X86/intel-syntax.s | 29 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/lib/Target/X86/X86InstrInfo.td b/lib/Target/X86/X86InstrInfo.td index 817bd6cc348..d67203e29c1 100644 --- a/lib/Target/X86/X86InstrInfo.td +++ b/lib/Target/X86/X86InstrInfo.td @@ -1921,29 +1921,31 @@ def : MnemonicAlias<"fucomip", "fucompi", "att">; def : MnemonicAlias<"fwait", "wait", "att">; -class CondCodeAlias +class CondCodeAlias : MnemonicAlias; + !strconcat(Prefix, NewCond, Suffix), VariantName>; /// IntegerCondCodeMnemonicAlias - This multiclass defines a bunch of /// MnemonicAlias's that canonicalize the condition code in a mnemonic, for /// example "setz" -> "sete". -multiclass IntegerCondCodeMnemonicAlias { - def C : CondCodeAlias; // setc -> setb - def Z : CondCodeAlias; // setz -> sete - def NA : CondCodeAlias; // setna -> setbe - def NB : CondCodeAlias; // setnb -> setae - def NC : CondCodeAlias; // setnc -> setae - def NG : CondCodeAlias; // setng -> setle - def NL : CondCodeAlias; // setnl -> setge - def NZ : CondCodeAlias; // setnz -> setne - def PE : CondCodeAlias; // setpe -> setp - def PO : CondCodeAlias; // setpo -> setnp +multiclass IntegerCondCodeMnemonicAlias { + def C : CondCodeAlias; // setc -> setb + def Z : CondCodeAlias; // setz -> sete + def NA : CondCodeAlias; // setna -> setbe + def NB : CondCodeAlias; // setnb -> setae + def NC : CondCodeAlias; // setnc -> setae + def NG : CondCodeAlias; // setng -> setle + def NL : CondCodeAlias; // setnl -> setge + def NZ : CondCodeAlias; // setnz -> setne + def PE : CondCodeAlias; // setpe -> setp + def PO : CondCodeAlias; // setpo -> setnp - def NAE : CondCodeAlias; // setnae -> setb - def NBE : CondCodeAlias; // setnbe -> seta - def NGE : CondCodeAlias; // setnge -> setl - def NLE : CondCodeAlias; // setnle -> setg + def NAE : CondCodeAlias; // setnae -> setb + def NBE : CondCodeAlias; // setnbe -> seta + def NGE : CondCodeAlias; // setnge -> setl + def NLE : CondCodeAlias; // setnle -> setg } // Aliases for set @@ -1951,9 +1953,11 @@ defm : IntegerCondCodeMnemonicAlias<"set", "">; // Aliases for j defm : IntegerCondCodeMnemonicAlias<"j", "">; // Aliases for cmov{w,l,q} -defm : IntegerCondCodeMnemonicAlias<"cmov", "w">; -defm : IntegerCondCodeMnemonicAlias<"cmov", "l">; -defm : IntegerCondCodeMnemonicAlias<"cmov", "q">; +defm : IntegerCondCodeMnemonicAlias<"cmov", "w", "att">; +defm : IntegerCondCodeMnemonicAlias<"cmov", "l", "att">; +defm : IntegerCondCodeMnemonicAlias<"cmov", "q", "att">; +// No size suffix for intel-style asm. +defm : IntegerCondCodeMnemonicAlias<"cmov", "", "intel">; //===----------------------------------------------------------------------===// diff --git a/test/MC/X86/intel-syntax.s b/test/MC/X86/intel-syntax.s index fa1ba5ba543..1a519aa186c 100644 --- a/test/MC/X86/intel-syntax.s +++ b/test/MC/X86/intel-syntax.s @@ -325,3 +325,32 @@ _main: // CHECK: outb %al, $4 out 4, al ret + +// CHECK: cmovbl %ebx, %eax + cmovc eax, ebx +// CHECK: cmovel %ebx, %eax + cmovz eax, ebx +// CHECK: cmovbel %ebx, %eax + cmovna eax, ebx +// CHECK: cmovael %ebx, %eax + cmovnb eax, ebx +// CHECK: cmovael %ebx, %eax + cmovnc eax, ebx +// CHECK: cmovlel %ebx, %eax + cmovng eax, ebx +// CHECK: cmovgel %ebx, %eax + cmovnl eax, ebx +// CHECK: cmovnel %ebx, %eax + cmovnz eax, ebx +// CHECK: cmovpl %ebx, %eax + cmovpe eax, ebx +// CHECK: cmovnpl %ebx, %eax + cmovpo eax, ebx +// CHECK: cmovbl %ebx, %eax + cmovnae eax, ebx +// CHECK: cmoval %ebx, %eax + cmovnbe eax, ebx +// CHECK: cmovll %ebx, %eax + cmovnge eax, ebx +// CHECK: cmovgl %ebx, %eax + cmovnle eax, ebx