From patchwork Fri Jun 19 14:55:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiong Wang X-Patchwork-Id: 486751 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C35DB1401DE for ; Sat, 20 Jun 2015 00:59:15 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=rxF/sBOI; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=MbtONxh6wHT9cxVD2k1lA+0uCVezRJOyB/2JaeeAlyXHvk0Jctm9i WcPvQ0U7UHQmrRUEuLJXasAXllZ+O3a/1/pfXlVis1LVF1w8Ff3t9j1LREsJ8Gpm WRBh75vTPZ/v7LRyrn+LhJjw7qqg6esw7bdqS+Irocdl9FiLxXvrJE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=zTsmQJD8gKge4fWyR05bls4NxO0=; b=rxF/sBOIMUQWxJ1gpxRt n66dIrVa7VlUo5AIh3jg6gzoa9wA3UO5dS2PVlUrbuqtsHKFpWpFHPJGcwzksDCi Pfmo4z+7oFF1Q34pOQyEBcOhw5CLuQtNuzc26eabi/zmQOIGTD69pORaF7ylwrgU DKhmY/Bf8ZItGApYseqAhVI= Received: (qmail 23043 invoked by alias); 19 Jun 2015 14:59:07 -0000 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 Received: (qmail 23031 invoked by uid 89); 19 Jun 2015 14:59:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=AWL, BAYES_20, KAM_STOCKGEN, SPF_PASS autolearn=no version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 Jun 2015 14:59:04 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-16-0UBIlMMnSdC5cOvTNAjAeA-1 Received: from e104437-lin ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 19 Jun 2015 15:59:01 +0100 From: Jiong Wang To: gcc-patches Subject: [AArch64][TLSGD Trad][1/2] Generalize TLS Global Dynamic support for all memory mode Date: Fri, 19 Jun 2015 15:55:08 +0100 Message-ID: MIME-Version: 1.0 X-MC-Unique: 0UBIlMMnSdC5cOvTNAjAeA-1 Currently, there is only small model support for TLS GD on AArch64. While TLS Global Dynamic (Traditional) is actually the same for all memory mode. For TLSGD, the code logic is always the following: RegA = GOT descriptor address of tls variable. call __tls_get_addr/ nop Instruction sequences for different memory model differs only for how to addressing the GOT descriptor of that TLS variable, and they should always be packed together for later linker relaxation. Tiny == adr a0, :tlsgd:x Small == adrp a0, :tlsgd:x add a0, a0, #:tlsgd_lo12:x Large == movz a0, #:tlsgd_g1:x movk a0, #:tlsgd_g0_nc:x add a0, gp, a0 This patch generalize TLS GD code for all memory model and remove the duplicated define_expand. Another seperate patch will add GD support for Tiny model. OK for trunk? 2015-06-19 Jiong Wang gcc/ * config/aarch64/aarch64-protos.h (aarch64_symbol_context): Rename SYMBOL_SMALL_TLSGD to SYMBOL_TLSGD. (aarch64_symbol_context): Ditto. * config/aarch64/aarch64.md (tlsgd_small): Deleted. (*tlsgd_small): Renamed into "tlsgd". (UNSPEC_TLSGD): New. * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Rename SYMBOL_SMALL_TLSGD to SYMBOL_TLSGD. Update parameter for gen_tlsgd. (aarch64_expand_mov_immediate): Ditto. (aarch64_print_operand): Ditto. (aarch64_classify_tls_symbol): Ditto. commit c1ed4442a4d81db8a421b74c6a9d65c69e095779 Author: Jiong Wang Date: Mon May 18 16:48:33 2015 +0100 Generalize GD diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index 7b5c86e1..7fad48b 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -61,10 +61,10 @@ enum aarch64_symbol_context This corresponds to the small PIC model of the compiler. - SYMBOL_SMALL_TLSGD SYMBOL_SMALL_TLSDESC SYMBOL_SMALL_GOTTPREL SYMBOL_TINY_TLSIE + SYMBOL_TLSGD SYMBOL_TLSLE Each of of these represents a thread-local symbol, and corresponds to the thread local storage relocation operator for the symbol being referred to. @@ -96,12 +96,12 @@ enum aarch64_symbol_type { SYMBOL_SMALL_ABSOLUTE, SYMBOL_SMALL_GOT, - SYMBOL_SMALL_TLSGD, SYMBOL_SMALL_TLSDESC, SYMBOL_SMALL_GOTTPREL, SYMBOL_TINY_ABSOLUTE, SYMBOL_TINY_GOT, SYMBOL_TINY_TLSIE, + SYMBOL_TLSGD, SYMBOL_TLSLE, SYMBOL_FORCE_TO_MEM }; diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index be1e83d..e724bd4 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -905,13 +905,14 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm, return; } - case SYMBOL_SMALL_TLSGD: + case SYMBOL_TLSGD: { rtx_insn *insns; rtx result = gen_rtx_REG (Pmode, R0_REGNUM); + rtx func = aarch64_tls_get_addr (); start_sequence (); - aarch64_emit_call_insn (gen_tlsgd_small (result, imm)); + aarch64_emit_call_insn (gen_tlsgd (result, imm, func)); insns = get_insns (); end_sequence (); @@ -1547,7 +1548,7 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm) emit_insn (gen_rtx_SET (dest, mem)); return; - case SYMBOL_SMALL_TLSGD: + case SYMBOL_TLSGD: case SYMBOL_SMALL_TLSDESC: case SYMBOL_SMALL_GOTTPREL: case SYMBOL_SMALL_GOT: @@ -4430,7 +4431,7 @@ aarch64_print_operand (FILE *f, rtx x, char code) asm_fprintf (asm_out_file, ":got:"); break; - case SYMBOL_SMALL_TLSGD: + case SYMBOL_TLSGD: asm_fprintf (asm_out_file, ":tlsgd:"); break; @@ -4463,7 +4464,7 @@ aarch64_print_operand (FILE *f, rtx x, char code) asm_fprintf (asm_out_file, ":lo12:"); break; - case SYMBOL_SMALL_TLSGD: + case SYMBOL_TLSGD: asm_fprintf (asm_out_file, ":tlsgd_lo12:"); break; @@ -7272,7 +7273,7 @@ aarch64_classify_tls_symbol (rtx x) { case TLS_MODEL_GLOBAL_DYNAMIC: case TLS_MODEL_LOCAL_DYNAMIC: - return TARGET_TLS_DESC ? SYMBOL_SMALL_TLSDESC : SYMBOL_SMALL_TLSGD; + return TARGET_TLS_DESC ? SYMBOL_SMALL_TLSDESC : SYMBOL_TLSGD; case TLS_MODEL_INITIAL_EXEC: switch (aarch64_cmodel) diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index be9da5b..4fe54c9 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -117,6 +117,7 @@ UNSPEC_ST4_LANE UNSPEC_TLS UNSPEC_TLSDESC + UNSPEC_TLSGD UNSPEC_TLSLE UNSPEC_USHL_2S UNSPEC_VSTRUCTDUMMY @@ -4255,20 +4256,10 @@ ;; The TLS ABI specifically requires that the compiler does not schedule ;; instructions in the TLS stubs, in order to enable linker relaxation. ;; Therefore we treat the stubs as an atomic sequence. -(define_expand "tlsgd_small" - [(parallel [(set (match_operand 0 "register_operand" "") - (call (mem:DI (match_dup 2)) (const_int 1))) - (unspec:DI [(match_operand:DI 1 "aarch64_valid_symref" "")] UNSPEC_GOTSMALLTLS) - (clobber (reg:DI LR_REGNUM))])] - "" -{ - operands[2] = aarch64_tls_get_addr (); -}) - -(define_insn "*tlsgd_small" +(define_insn "tlsgd" [(set (match_operand 0 "register_operand" "") (call (mem:DI (match_operand:DI 2 "" "")) (const_int 1))) - (unspec:DI [(match_operand:DI 1 "aarch64_valid_symref" "S")] UNSPEC_GOTSMALLTLS) + (unspec:DI [(match_operand:DI 1 "aarch64_valid_symref" "S")] UNSPEC_TLSGD) (clobber (reg:DI LR_REGNUM)) ] ""