This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH [5/n] X32: Fix x32 trampoline


Hi,

X32 uses movl instead of movabs for trampoline.  OK for trunk?

Thanks.

H.J.
---
2011-07-09  H.J. Lu  <hongjiu.lu@intel.com>

	* config/i386/i386.c (ix86_trampoline_init): Use movl instead
	of movabs for x32.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 04cb07d..c852719 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -22721,13 +23030,14 @@ ix86_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
     }
   else
     {
-      int offset = 0;
+      int offset = 0, size;
 
       /* Load the function address to r11.  Try to load address using
 	 the shorter movl instead of movabs.  We may want to support
 	 movq for kernel mode, but kernel does not use trampolines at
 	 the moment.  */
-      if (x86_64_zext_immediate_operand (fnaddr, VOIDmode))
+      if (TARGET_X32
+	  || x86_64_zext_immediate_operand (fnaddr, VOIDmode))
 	{
 	  fnaddr = copy_to_mode_reg (DImode, fnaddr);
 
@@ -22750,11 +23060,21 @@ ix86_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
 
       /* Load static chain using movabs to r10.  */
       mem = adjust_address (m_tramp, HImode, offset);
-      emit_move_insn (mem, gen_int_mode (0xba49, HImode));
+      /* Use the shorter movl instead of movabs for x32.  */
+      if (TARGET_X32)
+	{
+	  size = 6;
+	  emit_move_insn (mem, gen_int_mode (0xba41, HImode));
+	}
+      else
+	{
+	  size = 10;
+	  emit_move_insn (mem, gen_int_mode (0xba49, HImode));
+	}
 
-      mem = adjust_address (m_tramp, DImode, offset + 2);
+      mem = adjust_address (m_tramp, ptr_mode, offset + 2);
       emit_move_insn (mem, chain_value);
-      offset += 10;
+      offset += size;
 
       /* Jump to r11; the last (unused) byte is a nop, only there to
 	 pad the write out to a single 32-bit store.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]