[PATCH v3 05/11] [x86] Add PUSHA16, POPA16 instructions, and fix aliases for 16-bit mode
David Woodhouse
dwmw2 at infradead.org
Fri Dec 20 06:58:02 PST 2013
From: David Woodhouse <David.Woodhouse at intel.com>
---
lib/Target/X86/X86InstrInfo.td | 33 +++++++++++++++++++++-------
test/MC/X86/x86-16.s | 49 ++++++++++++++++++++++++++++++++++++++++++
test/MC/X86/x86-32.s | 12 +++++++++--
3 files changed, 84 insertions(+), 10 deletions(-)
diff --git a/lib/Target/X86/X86InstrInfo.td b/lib/Target/X86/X86InstrInfo.td
index 2a4c8f3..b37660e 100644
--- a/lib/Target/X86/X86InstrInfo.td
+++ b/lib/Target/X86/X86InstrInfo.td
@@ -967,13 +967,17 @@ def PUSHF64 : I<0x9C, RawFrm, (outs), (ins), "pushfq", [], IIC_PUSH_F>,
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 {
@@ -2134,23 +2138,36 @@ def : MnemonicAlias<"leaveq", "leave", "att">, Requires<[In64BitMode]>;
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">;
diff --git a/test/MC/X86/x86-16.s b/test/MC/X86/x86-16.s
index d160d46..75611bf 100644
--- a/test/MC/X86/x86-16.s
+++ b/test/MC/X86/x86-16.s
@@ -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]
diff --git a/test/MC/X86/x86-32.s b/test/MC/X86/x86-32.s
index 99136bd..fa88f28 100644
--- a/test/MC/X86/x86-32.s
+++ b/test/MC/X86/x86-32.s
@@ -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
--
1.8.3.1
More information about the llvm-commits
mailing list