From 6c2f0f83a5c02bf30aebbba56d78687023ab0ea0 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Tue, 13 Mar 2012 08:06:51 +0100 Subject: [PATCH] i386.h (TARGET_TLS_INDIRECT_SEG_REFS): New. * 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 | 8 ++++++++ gcc/config/i386/i386.c | 20 ++++++++++++-------- gcc/config/i386/i386.h | 3 +++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 477aa77210f..7ae846459c5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2012-03-13 Uros Bizjak + + * 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 * config/i386/i386.md (*tls_global_dynamic_64_): Remove :P diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index dbcf5a9ab49..e3668927cb6 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -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); diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index c77070bc10a..c7d645eef65 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -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;