From a23c12a627e8224e337cd641381579190e178404 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Mon, 22 Oct 2018 20:38:13 +0000 Subject: [PATCH] X86: add alias for pushfw/popfw in Intel mode A while ago we changed pushf and popf in Intel mode to generate pushfq and popfq. Unfortunately that left us with no way to get the 16-bit encoding in Intel mode so this patch adds pushfw and popfw as aliases there. llvm-svn: 344949 --- llvm/lib/Target/X86/X86InstrInfo.td | 4 ++++ llvm/test/MC/X86/intel-syntax-encoding.s | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/llvm/lib/Target/X86/X86InstrInfo.td b/llvm/lib/Target/X86/X86InstrInfo.td index 39c3bbfd90e3..a12c9e81b053 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.td +++ b/llvm/lib/Target/X86/X86InstrInfo.td @@ -2966,6 +2966,8 @@ def : MnemonicAlias<"popf", "popfl", "att">, Requires<[In32BitMode]>; def : MnemonicAlias<"popf", "popfq", "att">, Requires<[In64BitMode]>; def : MnemonicAlias<"popf", "popfq", "intel">, Requires<[In64BitMode]>; def : MnemonicAlias<"popfd", "popfl", "att">; +def : MnemonicAlias<"popfw", "popf", "intel">, Requires<[In32BitMode]>; +def : MnemonicAlias<"popfw", "popf", "intel">, Requires<[In64BitMode]>; // 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 @@ -2978,6 +2980,8 @@ def : MnemonicAlias<"pushf", "pushfl", "att">, Requires<[In32BitMode]>; def : MnemonicAlias<"pushf", "pushfq", "att">, Requires<[In64BitMode]>; def : MnemonicAlias<"pushf", "pushfq", "intel">, Requires<[In64BitMode]>; def : MnemonicAlias<"pushfd", "pushfl", "att">; +def : MnemonicAlias<"pushfw", "pushf", "intel">, Requires<[In32BitMode]>; +def : MnemonicAlias<"pushfw", "pushf", "intel">, Requires<[In64BitMode]>; def : MnemonicAlias<"popad", "popal", "intel">, Requires<[Not64BitMode]>; def : MnemonicAlias<"pushad", "pushal", "intel">, Requires<[Not64BitMode]>; diff --git a/llvm/test/MC/X86/intel-syntax-encoding.s b/llvm/test/MC/X86/intel-syntax-encoding.s index aedd74447d65..cf1b403e967e 100644 --- a/llvm/test/MC/X86/intel-syntax-encoding.s +++ b/llvm/test/MC/X86/intel-syntax-encoding.s @@ -64,6 +64,11 @@ pushf popf +// CHECK: encoding: [0x66,0x9c] +// CHECK: encoding: [0x66,0x9d] +pushfw +popfw + LBB0_3: // CHECK: encoding: [0xeb,A] jmp LBB0_3