Patchwork [x32] PATCH: Don't generate byte 0x66 in TLS GD for TARGET_X32

login
register
mail settings
Submitter H.J. Lu
Date March 12, 2011, 3:45 p.m.
Message ID <20110312154536.GA4034@intel.com>
Download mbox | patch
Permalink /patch/86523/
State New
Headers show

Comments

H.J. Lu - March 12, 2011, 3:45 p.m.
Hi,

For x32, pointers are 32bit.  It uses

movl %fs:0, %eax

instead of

movq %fs:0, %rax

to load TCB pointer.  I checked in this patch to avoid byte 0x66 in TLS
GD for TARGET_X32.

H.J.
---
From 8c92f0d4860fd2693af864d87804aaee843f2680 Mon Sep 17 00:00:00 2001
From: H.J. Lu <hjl.tools@gmail.com>
Date: Sat, 12 Mar 2011 05:53:03 -0800
Subject: [PATCH 5/5] Don't generate byte 0x66 in TLS GD for TARGET_X32.

---
 gcc/ChangeLog.x32       |    5 +++++
 gcc/config/i386/i386.md |   10 ++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

Patch

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 5ecea15..b85956c 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,8 @@ 
+2011-03-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* config/i386/i386.md (*tls_global_dynamic_64): Don't generate
+	byte 0x66 before lea for TARGET_X32.
+
 2011-03-11  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/48084
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 8208491..89c0455 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -12595,9 +12595,15 @@ 
    (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
 	      UNSPEC_TLS_GD)]
   "TARGET_64BIT"
-  { return ASM_BYTE "0x66\n\tlea{q}\t{%a1@tlsgd(%%rip), %%rdi|rdi, %a1@tlsgd[rip]}\n" ASM_SHORT "0x6666\n\trex64\n\tcall\t%P2"; }
+{
+  if (TARGET_X32)
+    return "lea{q}\t{%a1@tlsgd(%%rip), %%rdi|rdi, %a1@tlsgd[rip]}\n" ASM_SHORT "0x6666\n\trex64\n\tcall\t%P2";
+  else
+    return ASM_BYTE "0x66\n\tlea{q}\t{%a1@tlsgd(%%rip), %%rdi|rdi, %a1@tlsgd[rip]}\n" ASM_SHORT "0x6666\n\trex64\n\tcall\t%P2";
+}
   [(set_attr "type" "multi")
-   (set_attr "length" "16")])
+   (set (attr "length")
+	(symbol_ref "TARGET_X32 ? 15 : 16"))])
 
 (define_expand "tls_global_dynamic_64"
   [(parallel [(set (match_operand:DI 0 "register_operand" "")