[llvm] r198753 - [x86] Add PUSHA16, POPA16 instructions, and fix aliases for 16-bit mode

David Woodhouse dwmw2 at infradead.org
Wed Jan 8 04:57:45 PST 2014


Author: dwmw2
Date: Wed Jan  8 06:57:45 2014
New Revision: 198753

URL: http://llvm.org/viewvc/llvm-project?rev=198753&view=rev
Log:
[x86] Add PUSHA16,POPA16 instructions, and fix aliases for 16-bit mode

Modified:
    llvm/trunk/lib/Target/X86/X86InstrInfo.td
    llvm/trunk/test/MC/X86/x86-16.s
    llvm/trunk/test/MC/X86/x86-32.s

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=198753&r1=198752&r2=198753&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Wed Jan  8 06:57:45 2014
@@ -974,13 +974,17 @@ def PUSHF64    : I<0x9C, RawFrm, (outs),
 
 let Defs = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP], Uses = [ESP],
     mayLoad = 1, neverHasSideEffects = 1, SchedRW = [WriteLoad] in {
-def POPA32   : I<0x61, RawFrm, (outs), (ins), "popa{l}", [], IIC_POP_A>,
+def POPA32   : I<0x61, RawFrm, (outs), (ins), "popal", [], IIC_POP_A>,
                OpSize16, Requires<[Not64BitMode]>;
+def POPA16   : I<0x61, RawFrm, (outs), (ins), "popaw", [], IIC_POP_A>,
+               OpSize, Requires<[Not64BitMode]>;
 }
 let Defs = [ESP], Uses = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP],
     mayStore = 1, neverHasSideEffects = 1, SchedRW = [WriteStore] in {
-def PUSHA32  : I<0x60, RawFrm, (outs), (ins), "pusha{l}", [], IIC_PUSH_A>,
+def PUSHA32  : I<0x60, RawFrm, (outs), (ins), "pushal", [], IIC_PUSH_A>,
                OpSize16, Requires<[Not64BitMode]>;
+def PUSHA16  : I<0x60, RawFrm, (outs), (ins), "pushaw", [], IIC_PUSH_A>,
+               OpSize, Requires<[Not64BitMode]>;
 }
 
 let Constraints = "$src = $dst", SchedRW = [WriteALU] in {
@@ -2143,23 +2147,36 @@ def : MnemonicAlias<"leaveq", "leave", "
 def : MnemonicAlias<"loopz",  "loope",  "att">;
 def : MnemonicAlias<"loopnz", "loopne", "att">;
 
-def : MnemonicAlias<"pop",   "popl",  "att">, Requires<[Not64BitMode]>;
+def : MnemonicAlias<"pop",   "popw",  "att">, Requires<[In16BitMode]>;
+def : MnemonicAlias<"pop",   "popl",  "att">, Requires<[In32BitMode]>;
 def : MnemonicAlias<"pop",   "popq",  "att">, Requires<[In64BitMode]>;
-def : MnemonicAlias<"popf",  "popfl", "att">, Requires<[Not64BitMode]>;
+def : MnemonicAlias<"popf",  "popfw", "att">, Requires<[In16BitMode]>;
+def : MnemonicAlias<"popf",  "popfl", "att">, Requires<[In32BitMode]>;
 def : MnemonicAlias<"popf",  "popfq", "att">, Requires<[In64BitMode]>;
 def : MnemonicAlias<"popfd", "popfl", "att">;
 
 // FIXME: This is wrong for "push reg".  "push %bx" should turn into pushw in
 // all modes.  However: "push (addr)" and "push $42" should default to
 // pushl/pushq depending on the current mode.  Similar for "pop %bx"
-def : MnemonicAlias<"push",   "pushl",  "att">, Requires<[Not64BitMode]>;
+def : MnemonicAlias<"push",   "pushw",  "att">, Requires<[In16BitMode]>;
+def : MnemonicAlias<"push",   "pushl",  "att">, Requires<[In32BitMode]>;
 def : MnemonicAlias<"push",   "pushq",  "att">, Requires<[In64BitMode]>;
-def : MnemonicAlias<"pushf",  "pushfl", "att">, Requires<[Not64BitMode]>;
+def : MnemonicAlias<"pushf",  "pushfw", "att">, Requires<[In16BitMode]>;
+def : MnemonicAlias<"pushf",  "pushfl", "att">, Requires<[In32BitMode]>;
 def : MnemonicAlias<"pushf",  "pushfq", "att">, Requires<[In64BitMode]>;
 def : MnemonicAlias<"pushfd", "pushfl", "att">;
 
-def : MnemonicAlias<"popad",   "popa", "intel">, Requires<[Not64BitMode]>;
-def : MnemonicAlias<"pushad",  "pusha", "intel">, Requires<[Not64BitMode]>;
+def : MnemonicAlias<"popad",  "popal",  "intel">, Requires<[Not64BitMode]>;
+def : MnemonicAlias<"pushad", "pushal", "intel">, Requires<[Not64BitMode]>;
+def : MnemonicAlias<"popa",   "popaw",  "intel">, Requires<[In16BitMode]>;
+def : MnemonicAlias<"pusha",  "pushaw", "intel">, Requires<[In16BitMode]>;
+def : MnemonicAlias<"popa",   "popal",  "intel">, Requires<[In32BitMode]>;
+def : MnemonicAlias<"pusha",  "pushal", "intel">, Requires<[In32BitMode]>;
+
+def : MnemonicAlias<"popa",   "popaw",  "att">, Requires<[In16BitMode]>;
+def : MnemonicAlias<"pusha",  "pushaw", "att">, Requires<[In16BitMode]>;
+def : MnemonicAlias<"popa",   "popal",  "att">, Requires<[In32BitMode]>;
+def : MnemonicAlias<"pusha",  "pushal", "att">, Requires<[In32BitMode]>;
 
 def : MnemonicAlias<"repe",  "rep",   "att">;
 def : MnemonicAlias<"repz",  "rep",   "att">;

Modified: llvm/trunk/test/MC/X86/x86-16.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/x86-16.s?rev=198753&r1=198752&r2=198753&view=diff
==============================================================================
--- llvm/trunk/test/MC/X86/x86-16.s (original)
+++ llvm/trunk/test/MC/X86/x86-16.s Wed Jan  8 06:57:45 2014
@@ -62,8 +62,12 @@ int $255
 // CHECK: int $255
 // CHECK:  encoding: [0xcd,0xff]
 
+// CHECK: pushfw	# encoding: [0x9c]
+        pushf
 // CHECK: pushfl	# encoding: [0x66,0x9c]
         pushfl
+// CHECK: popfw         # encoding: [0x9d]
+        popf
 // CHECK: popfl	        # encoding: [0x66,0x9d]
         popfl
 
@@ -311,6 +315,22 @@ cmovnae	%bx,%bx
 // CHECK:  encoding: [0x9b]
 	fwait
 
+// CHECK: pusha
+// CHECK:  encoding: [0x60]
+        	pusha
+
+// CHECK: popa
+// CHECK:  encoding: [0x61]
+        	popa
+
+// CHECK: pushaw
+// CHECK:  encoding: [0x60]
+        	pushaw
+
+// CHECK: popaw
+// CHECK:  encoding: [0x61]
+        	popaw
+
 // CHECK: pushal
 // CHECK:  encoding: [0x66,0x60]
         	pushal
@@ -341,6 +361,25 @@ testl	-24(%ebp), %ecx
 // CHECK: testl	-24(%ebp), %ecx
 
 
+push %cs
+// CHECK: pushw	%cs
+// CHECK: encoding: [0x0e]
+push %ds
+// CHECK: pushw	%ds
+// CHECK: encoding: [0x1e]
+push %ss
+// CHECK: pushw	%ss
+// CHECK: encoding: [0x16]
+push %es
+// CHECK: pushw	%es
+// CHECK: encoding: [0x06]
+push %fs
+// CHECK: pushw	%fs
+// CHECK: encoding: [0x0f,0xa0]
+push %gs
+// CHECK: pushw	%gs
+// CHECK: encoding: [0x0f,0xa8]
+
 pushw %cs
 // CHECK: pushw	%cs
 // CHECK: encoding: [0x0e]
@@ -379,6 +418,16 @@ pushl %gs
 // CHECK: pushl	%gs
 // CHECK: encoding: [0x66,0x0f,0xa8]
 
+pop %ss
+// CHECK: popw	%ss
+// CHECK: encoding: [0x17]
+pop %ds
+// CHECK: popw	%ds
+// CHECK: encoding: [0x1f]
+pop %es
+// CHECK: popw	%es
+// CHECK: encoding: [0x07]
+
 popl %ss
 // CHECK: popl	%ss
 // CHECK: encoding: [0x66,0x17]

Modified: llvm/trunk/test/MC/X86/x86-32.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/x86-32.s?rev=198753&r1=198752&r2=198753&view=diff
==============================================================================
--- llvm/trunk/test/MC/X86/x86-32.s (original)
+++ llvm/trunk/test/MC/X86/x86-32.s Wed Jan  8 06:57:45 2014
@@ -442,14 +442,22 @@ cmovnae	%bx,%bx
 // FIXME: This is a correct bug poor encoding: Use 65 a1 7c 00 00 00 
         movl	%gs:124, %eax
 
-// CHECK: pusha
+// CHECK: pushal
 // CHECK:  encoding: [0x60]
         	pusha
 
-// CHECK: popa
+// CHECK: popal
 // CHECK:  encoding: [0x61]
         	popa
 
+// CHECK: pushaw
+// CHECK:  encoding: [0x66,0x60]
+        	pushaw
+
+// CHECK: popaw
+// CHECK:  encoding: [0x66,0x61]
+        	popaw
+
 // CHECK: pushal
 // CHECK:  encoding: [0x60]
         	pushal





More information about the llvm-commits mailing list