public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jiong Wang <jiong.wang@arm.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [AArch64][TLSGD][1/2] Remove unncessary define_expand for TLS GD traditional
Date: Thu, 27 Aug 2015 09:55:00 -0000	[thread overview]
Message-ID: <n994mjl3vmw.fsf@arm.com> (raw)
In-Reply-To: <n99381nsq17.fsf@arm.com>

[-- Attachment #1: Type: text/plain, Size: 3053 bytes --]


Jiong Wang writes:

> 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  <jiong.wang@arm.com>
>
> 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.

Reworked this patch.

The old approach is to generalize the support for global dynamic
traditional on all memory model into one define_insn as them share the
same code logic listed below:

  param_reg = GOT descriptor address for tls variable.
  call __tls_get_addr
  nop

There is one thing bad that we haven't classified GD symbol in the first
place, we was generating different instruction sequences by doing a
final model check in the instruction pattern.

While in the new approach we classify GD symbol into tiny and small
version in the first place, then implement a seperate instruction
pattern for tiny.  The GD code logic is still generalized, because both
tiny and small share the same symbol handling code in aarch64.c.

NOTE: TLS GD for tiny model will utilize the relocation type
BFD_RELOC_AARCH64_TLSGD_ADR_PREL21 which is not available in binutils
2.25 and before, so feature detection is added to make sure GD for tiny
only enabled when there is binutils support, otherwise fall back to GD
for small.

This patch removes the unncessary define_expand "tlsgd_small". It was
there purely because operands[2] need to be generated from another rtx
gen function while it's better to move that to the call site, thus this
redundant expand pattern can be removed.

2015-08-27  Jiong Wang  <jiong.wang@arm.com>

gcc/
  * config/aarch64/aarch64.md (tlsgd_small): Delete this define_expand.
  (*tlsgd_small): Rename this define_insn to "tlsgd_small";

-- 
Regards,
Jiong


[-- Attachment #2: gdt1.patch --]
[-- Type: text/x-diff, Size: 1589 bytes --]

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index c74bf84..988062c 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -1028,9 +1028,10 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm,
       {
 	rtx_insn *insns;
 	rtx result = gen_rtx_REG (Pmode, R0_REGNUM);
+	rtx resolver = aarch64_tls_get_addr ();
 
 	start_sequence ();
-	aarch64_emit_call_insn (gen_tlsgd_small (result, imm));
+	aarch64_emit_call_insn (gen_tlsgd_small (result, imm, resolver));
 	insns = get_insns ();
 	end_sequence ();
 
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 80fd6c4..cf787d8 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -4474,17 +4474,7 @@
 ;; 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_small"
   [(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)

  reply	other threads:[~2015-08-27  9:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-19 14:59 [AArch64][TLSGD Trad][1/2] Generalize TLS Global Dynamic support for all memory mode Jiong Wang
2015-08-27  9:55 ` Jiong Wang [this message]
2015-08-27 10:04   ` [AArch64][TLSGD][2/2] Implement TLS GD traditional for tiny code model Jiong Wang
2015-10-06 13:32     ` Marcus Shawcroft
2015-11-05 14:57       ` Jiong Wang
2015-11-13 15:22         ` Jiong Wang
2015-12-03 10:42           ` [Ping^2][AArch64][TLSGD][2/2] " Jiong Wang
2015-10-06 11:40   ` [AArch64][TLSGD][1/2] Remove unncessary define_expand for TLS GD traditional Marcus Shawcroft

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=n994mjl3vmw.fsf@arm.com \
    --to=jiong.wang@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).