diff mbox

PATCH: Check ptr_mode and use Pmode in ix86_trampoline_init

Message ID 20120311011847.GA11408@intel.com
State New
Headers show

Commit Message

H.J. Lu March 11, 2012, 1:18 a.m. UTC
Hi,

x86 trampoline depends on ptr_mode.  This patch checks ptr_mode, instead
of TARGET_X32.  Also we should use Pmode for address mode.  Tested on
Linux/x86-64.  OK for trunk?

Thanks.


H.J.
---
2012-03-10  H.J. Lu  <hongjiu.lu@intel.com>

	* config/i386/i386.c (ix86_trampoline_init): Use movl for 64bit if
	ptr_mode == SImode.  Replace DImode with Pmode or ptr_mode.

Comments

Uros Bizjak March 11, 2012, 2:54 p.m. UTC | #1
On Sun, Mar 11, 2012 at 2:18 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Hi,
>
> x86 trampoline depends on ptr_mode.  This patch checks ptr_mode, instead
> of TARGET_X32.  Also we should use Pmode for address mode.  Tested on
> Linux/x86-64.  OK for trunk?

Why we are looking at ptr_mode here?

Uros.
H.J. Lu March 11, 2012, 3:52 p.m. UTC | #2
On Sun, Mar 11, 2012 at 7:54 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Sun, Mar 11, 2012 at 2:18 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>> Hi,
>>
>> x86 trampoline depends on ptr_mode.  This patch checks ptr_mode, instead
>> of TARGET_X32.  Also we should use Pmode for address mode.  Tested on
>> Linux/x86-64.  OK for trunk?
>
> Why we are looking at ptr_mode here?
>

If ptr_mode is SImode, we can always use movl to reach our target.
We don't need to check anything else.
Uros Bizjak March 11, 2012, 4:20 p.m. UTC | #3
On Sun, Mar 11, 2012 at 4:52 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

>>> x86 trampoline depends on ptr_mode.  This patch checks ptr_mode, instead
>>> of TARGET_X32.  Also we should use Pmode for address mode.  Tested on
>>> Linux/x86-64.  OK for trunk?
>>
>> Why we are looking at ptr_mode here?
>>
>
> If ptr_mode is SImode, we can always use movl to reach our target.
> We don't need to check anything else.

Under this assumption, the patch is OK.

Thanks,
Uros.
diff mbox

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index bc144a9..bfa3cdc 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -24309,10 +24313,13 @@  ix86_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
       /* 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))
+	 the moment.  FNADDR is a 32bit address and may not be in
+	 DImode when ptr_mode == SImode.  Always use movl in this
+	 case.  */
+      if (ptr_mode == SImode
+	  || x86_64_zext_immediate_operand (fnaddr, VOIDmode))
 	{
-	  fnaddr = copy_to_mode_reg (DImode, fnaddr);
+	  fnaddr = copy_to_mode_reg (Pmode, fnaddr);
 
 	  mem = adjust_address (m_tramp, HImode, offset);
 	  emit_move_insn (mem, gen_int_mode (0xbb41, HImode));
@@ -24331,9 +24338,9 @@  ix86_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
 	  offset += 10;
 	}
 
-      /* Load static chain using movabs to r10.  Use the
-	 shorter movl instead of movabs for x32.  */
-      if (TARGET_X32)
+      /* Load static chain using movabs to r10.  Use the shorter movl
+         instead of movabs when ptr_mode == SImode.  */
+      if (ptr_mode == SImode)
 	{
 	  opcode = 0xba41;
 	  size = 6;