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]

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


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(-)

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" "")
-- 
1.7.4


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