From patchwork Thu Jul 28 14:42:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 107393 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5231BB6F62 for ; Fri, 29 Jul 2011 23:12:15 +1000 (EST) Received: (qmail 10324 invoked by alias); 29 Jul 2011 13:12:13 -0000 Received: (qmail 9946 invoked by uid 22791); 29 Jul 2011 13:12:11 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, DATE_IN_PAST_12_24, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-gw0-f47.google.com (HELO mail-gw0-f47.google.com) (74.125.83.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Jul 2011 13:11:57 +0000 Received: by gwb11 with SMTP id 11so3023918gwb.20 for ; Fri, 29 Jul 2011 06:11:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.51.6 with SMTP id y6mr38556wfy.356.1311864124351; Thu, 28 Jul 2011 07:42:04 -0700 (PDT) Received: by 10.143.34.2 with HTTP; Thu, 28 Jul 2011 07:42:04 -0700 (PDT) In-Reply-To: References: <20110728025508.GA9511@intel.com> Date: Thu, 28 Jul 2011 16:42:04 +0200 Message-ID: Subject: Re: PATCH: PR target/47715: [x32] TLS doesn't work From: Uros Bizjak To: "H.J. Lu" Cc: gcc-patches@gcc.gnu.org Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Thu, Jul 28, 2011 at 3:47 PM, H.J. Lu wrote: >>>> TLS on X32 is almost identical to TLS on x86-64.  The only difference is >>>> x32 address space is 32bit.  That means TLS symbols can be in either >>>> SImode or DImode with upper 32bit zero.  This patch updates >>>> tls_global_dynamic_64 to support x32.  OK for trunk? >> >> Please also change 64bit GNU2_TLS patterns, so -mtls-dialect=gnu2 will >> also work.  Please see attached patch. >> > > Yes, it works.  Can you apply it? This is what I have committed: 2011-07-28 Uros Bizjak PR target/47715 * config/i386/i386.md (*tls_global_dynamic_64): Remove mode from tls_symbolic_operand check. Update code sequence for TARGET_X32. (tls_global_dynamic_64): Remove mode from tls_symbolic_operand check. (tls_dynamic_gnu2_64): Ditto. (*tls_dynamic_gnu2_lea_64): Ditto. (*tls_dynamic_gnu2_call_64): Ditto. (*tls_dynamic_gnu2_combine_64): Ditto. Uros. Index: i386.md =================================================================== --- i386.md (revision 176870) +++ i386.md (working copy) @@ -12327,11 +12327,12 @@ (call:DI (mem:QI (match_operand:DI 2 "constant_call_address_operand" "z")) (match_operand:DI 3 "" ""))) - (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")] + (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")] UNSPEC_TLS_GD)] "TARGET_64BIT" { - fputs (ASM_BYTE "0x66\n", asm_out_file); + if (!TARGET_X32) + fputs (ASM_BYTE "0x66\n", asm_out_file); output_asm_insn ("lea{q}\t{%a1@tlsgd(%%rip), %%rdi|rdi, %a1@tlsgd[rip]}", operands); fputs (ASM_SHORT "0x6666\n", asm_out_file); @@ -12349,7 +12350,7 @@ (call:DI (mem:QI (match_operand:DI 2 "constant_call_address_operand" "")) (const_int 0))) - (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")] + (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")] UNSPEC_TLS_GD)])]) (define_insn "*tls_local_dynamic_base_32_gnu" @@ -12553,7 +12554,7 @@ (define_expand "tls_dynamic_gnu2_64" [(set (match_dup 2) - (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")] + (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")] UNSPEC_TLSDESC)) (parallel [(set (match_operand:DI 0 "register_operand" "") @@ -12568,7 +12569,7 @@ (define_insn "*tls_dynamic_lea_64" [(set (match_operand:DI 0 "register_operand" "=r") - (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")] + (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")] UNSPEC_TLSDESC))] "TARGET_64BIT && TARGET_GNU2_TLS" "lea{q}\t{%a1@TLSDESC(%%rip), %0|%0, %a1@TLSDESC[rip]}" @@ -12579,7 +12580,7 @@ (define_insn "*tls_dynamic_call_64" [(set (match_operand:DI 0 "register_operand" "=a") - (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "") + (unspec:DI [(match_operand 1 "tls_symbolic_operand" "") (match_operand:DI 2 "register_operand" "0") (reg:DI SP_REG)] UNSPEC_TLSDESC)) @@ -12598,7 +12599,7 @@ (reg:DI SP_REG)] UNSPEC_TLSDESC) (const:DI (unspec:DI - [(match_operand:DI 1 "tls_symbolic_operand" "")] + [(match_operand 1 "tls_symbolic_operand" "")] UNSPEC_DTPOFF)))) (clobber (reg:CC FLAGS_REG))] "TARGET_64BIT && TARGET_GNU2_TLS"