[x86] Do not relax PUSHi16 to PUSHi32 (PR18414)
authorDavid Woodhouse <dwmw2@infradead.org>
Wed, 8 Jan 2014 12:58:32 +0000 (12:58 +0000)
committerDavid Woodhouse <dwmw2@infradead.org>
Wed, 8 Jan 2014 12:58:32 +0000 (12:58 +0000)
They do *different* things to %esp, so they are not equivalent.

Rename PUSHi8 to PUSH32i8 and add the missing PUSH16i8.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198761 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
lib/Target/X86/X86InstrInfo.td
test/MC/X86/relax-insn.s [new file with mode: 0644]

index 2cf6381198e121e78dfc257aeb9482683da41be0..dfd8a658bd47dddbfebae2a97034846bf59d202c 100644 (file)
@@ -217,9 +217,9 @@ static unsigned getRelaxedOpcodeArith(unsigned Op) {
   case X86::CMP64mi8: return X86::CMP64mi32;
 
     // PUSH
-  case X86::PUSHi8: return X86::PUSHi32;
-  case X86::PUSHi16: return X86::PUSHi32;
-  case X86::PUSH64i8: return X86::PUSH64i32;
+  case X86::PUSH32i8:  return X86::PUSHi32;
+  case X86::PUSH16i8:  return X86::PUSHi16;
+  case X86::PUSH64i8:  return X86::PUSH64i32;
   case X86::PUSH64i16: return X86::PUSH64i32;
   }
 }
index b4955646666790a3c6128af948085fab2ca66844..bfa59ea9dfd1403e5f069e5227e03525159fd307 100644 (file)
@@ -917,7 +917,10 @@ def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[],
 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[],
                  IIC_PUSH_MEM>, OpSize16, Requires<[Not64BitMode]>;
 
-def PUSHi8   : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
+def PUSH16i8 : Ii8<0x6a, RawFrm, (outs), (ins i16i8imm:$imm),
+                   "push{w}\t$imm", [], IIC_PUSH_IMM>, OpSize,
+                   Requires<[Not64BitMode]>;
+def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
                    "push{l}\t$imm", [], IIC_PUSH_IMM>, OpSize16,
                    Requires<[Not64BitMode]>;
 def PUSHi16  : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
diff --git a/test/MC/X86/relax-insn.s b/test/MC/X86/relax-insn.s
new file mode 100644 (file)
index 0000000..510766c
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu %s -o %t
+// RUN: llvm-objdump -d %t | FileCheck %s
+
+.global foo    
+pushw $foo // CHECK: pushw