i386.h (TARGET_TLS_INDIRECT_SEG_REFS): New.
authorUros Bizjak <ubizjak@gmail.com>
Tue, 13 Mar 2012 07:06:51 +0000 (08:06 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Tue, 13 Mar 2012 07:06:51 +0000 (08:06 +0100)
* config/i386/i386.h (TARGET_TLS_INDIRECT_SEG_REFS): New.
* config/i386/i386.c (ix86_decompose_address): Use
TARGET_TLS_INDIRECT_SEG_REFS to prevent %fs:(%reg) addresses.
(legitimize_tls_address): Use TARGET_TLS_INDIRECT_SEG_REFS to load
thread pointer to a register.

From-SVN: r185278

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/i386.h

index 477aa77210fd2e05fef9f5bcf66bede2f7ccd9c2..7ae846459c5310cc66533e3ea39da4333af17906 100644 (file)
@@ -1,3 +1,11 @@
+2012-03-13  Uros Bizjak  <ubizjak@gmail.com>
+
+       * config/i386/i386.h (TARGET_TLS_INDIRECT_SEG_REFS): New.
+       * config/i386/i386.c (ix86_decompose_address): Use
+       TARGET_TLS_INDIRECT_SEG_REFS to prevent %fs:(%reg) addresses.
+       (legitimize_tls_address): Use TARGET_TLS_INDIRECT_SEG_REFS to load
+       thread pointer to a register.
+
 2012-03-12  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config/i386/i386.md (*tls_global_dynamic_64_<mode>): Remove :P
index dbcf5a9ab499843b4121a579762deac4f0117d05..e3668927cb6d76536ffd363082ea90b852bf6106 100644 (file)
@@ -11552,11 +11552,6 @@ ix86_decompose_address (rtx addr, struct ix86_address *out)
   else
     disp = addr;                       /* displacement */
 
-  /* Since address override works only on the (reg32) part in fs:(reg32),
-     we can't use it as memory operand.  */
-  if (Pmode != word_mode && seg == SEG_FS && (base || index))
-    return 0;
-
   if (index)
     {
       if (REG_P (index))
@@ -11568,6 +11563,10 @@ ix86_decompose_address (rtx addr, struct ix86_address *out)
        return 0;
     }
 
+  if (seg != SEG_DEFAULT && (base || index)
+      && !TARGET_TLS_INDIRECT_SEG_REFS)
+    return 0;
+
   /* Extract the integral value of scale.  */
   if (scale_rtx)
     {
@@ -12696,7 +12695,9 @@ legitimize_tls_address (rtx x, enum tls_model model, bool for_mov)
 
       if (TARGET_64BIT || TARGET_ANY_GNU_TLS)
        {
-          base = get_thread_pointer (for_mov || !TARGET_TLS_DIRECT_SEG_REFS);
+          base = get_thread_pointer (for_mov
+                                    || !(TARGET_TLS_DIRECT_SEG_REFS
+                                         && TARGET_TLS_INDIRECT_SEG_REFS));
          off = force_reg (Pmode, off);
          return gen_rtx_PLUS (Pmode, base, off);
        }
@@ -12716,7 +12717,9 @@ legitimize_tls_address (rtx x, enum tls_model model, bool for_mov)
 
       if (TARGET_64BIT || TARGET_ANY_GNU_TLS)
        {
-         base = get_thread_pointer (for_mov || !TARGET_TLS_DIRECT_SEG_REFS);
+         base = get_thread_pointer (for_mov
+                                    || !(TARGET_TLS_DIRECT_SEG_REFS
+                                         && TARGET_TLS_INDIRECT_SEG_REFS));
          return gen_rtx_PLUS (Pmode, base, off);
        }
       else
@@ -13249,7 +13252,8 @@ ix86_delegitimize_tls_address (rtx orig_x)
   rtx x = orig_x, unspec;
   struct ix86_address addr;
 
-  if (!TARGET_TLS_DIRECT_SEG_REFS)
+  if (!(TARGET_TLS_DIRECT_SEG_REFS
+       && TARGET_TLS_INDIRECT_SEG_REFS))
     return orig_x;
   if (MEM_P (x))
     x = XEXP (x, 0);
index c77070bc10a2a1ef635932509f0cda6189328644..c7d645eef65aa22b07415aacb5d603ae33b381e3 100644 (file)
@@ -467,6 +467,9 @@ extern int x86_prefetch_sse;
 #define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT 0
 #endif
 
+/* Address override works only on the (%reg) part of %fs:(%reg).  */
+#define TARGET_TLS_INDIRECT_SEG_REFS (Pmode == word_mode)
+
 /* Fence to use after loop using storent.  */
 
 extern tree x86_mfence;