public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [AArch64] Simplify TLS pattern by hardcoding relocation modifiers into pattern
@ 2015-09-10 11:46 Jiong Wang
  2015-12-16 15:26 ` [Ping]Re: " Jiong Wang
  2015-12-17 11:44 ` Marcus Shawcroft
  0 siblings, 2 replies; 4+ messages in thread
From: Jiong Wang @ 2015-09-10 11:46 UTC (permalink / raw)
  To: gcc-patches List

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


TLS instruction sequences are always with fixed format, there is no need
to use operand modifier, we can hardcode the relocation modifiers into
instruction pattern, all those redundant checks in aarch64_print_operand
can be removed.

OK for trunk?

2015-09-10  Jiong Wang  <jiong.wang@arm.com>

gcc/
  * config/aarch64/aarch64.md (ldr_got_tiny): Hardcode relocation
  modifers.
  (tlsgd_small): Likewise.
  (tlsgd_tiny): Likewise.
  (tlsie_small_<mode>): Likewise.
  (tlsie_small_sidi): Likewise.
  (tlsie_tiny_<mode>): Likewise.
  (tlsie_tiny_sidi): Likewise.
  (tlsle12_<mode>): Likewise.
  (tlsle24_<mode>): Likewise.
  (tlsdesc_small_<mode>): Likewise.
  (tlsdesc_small_pseudo_<mode>): Likewise.
  (tlsdesc_tiny_<mode>): Likewise.
  (tlsdesc_tiny_pseudo_<mode>): Likewise.
  * config/aarch64/aarch64.c (aarch64_print_operand): Delete useless
  check on 'A', 'L', 'G'.
  
-- 
Regards,
Jiong


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

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 5ba0215..5945d9c 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -4640,23 +4640,6 @@ aarch64_print_operand (FILE *f, rtx x, char code)
 	  asm_fprintf (asm_out_file, ":tlsgd:");
 	  break;

-	case SYMBOL_TINY_TLSDESC:
-	case SYMBOL_SMALL_TLSDESC:
-	  asm_fprintf (asm_out_file, ":tlsdesc:");
-	  break;
-
-	case SYMBOL_SMALL_TLSIE:
-	  asm_fprintf (asm_out_file, ":gottprel:");
-	  break;
-
-	case SYMBOL_TLSLE24:
-	  asm_fprintf (asm_out_file, ":tprel:");
-	  break;
-
-	case SYMBOL_TINY_GOT:
-	  gcc_unreachable ();
-	  break;
-
 	default:
 	  break;
 	}
@@ -4666,38 +4649,9 @@ aarch64_print_operand (FILE *f, rtx x, char code)
     case 'L':
       switch (aarch64_classify_symbolic_expression (x))
 	{
-	case SYMBOL_SMALL_GOT_4G:
-	  asm_fprintf (asm_out_file, ":lo12:");
-	  break;
-
 	case SYMBOL_SMALL_TLSGD:
 	  asm_fprintf (asm_out_file, ":tlsgd_lo12:");
 	  break;
-
-	case SYMBOL_SMALL_TLSDESC:
-	  asm_fprintf (asm_out_file, ":tlsdesc_lo12:");
-	  break;
-
-	case SYMBOL_SMALL_TLSIE:
-	  asm_fprintf (asm_out_file, ":gottprel_lo12:");
-	  break;
-
-	case SYMBOL_TLSLE12:
-	  asm_fprintf (asm_out_file, ":tprel_lo12:");
-	  break;
-
-	case SYMBOL_TLSLE24:
-	  asm_fprintf (asm_out_file, ":tprel_lo12_nc:");
-	  break;
-
-	case SYMBOL_TINY_GOT:
-	  asm_fprintf (asm_out_file, ":got:");
-	  break;
-
-	case SYMBOL_TINY_TLSIE:
-	  asm_fprintf (asm_out_file, ":gottprel:");
-	  break;
-
 	default:
 	  break;
 	}
@@ -4705,15 +4659,6 @@ aarch64_print_operand (FILE *f, rtx x, char code)
       break;

     case 'G':
-
-      switch (aarch64_classify_symbolic_expression (x))
-	{
-	case SYMBOL_TLSLE24:
-	  asm_fprintf (asm_out_file, ":tprel_hi12:");
-	  break;
-	default:
-	  break;
-	}
       output_addr_const (asm_out_file, x);
       break;

diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 4a6bf2d..b808f84 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -4529,7 +4529,7 @@
 	(unspec:DI [(match_operand:DI 1 "aarch64_valid_symref" "S")]
 		   UNSPEC_GOTTINYPIC))]
   ""
-  "ldr\\t%0, %L1"
+  "ldr\\t%0, :got:%1"
   [(set_attr "type" "load1")]
 )

@@ -4571,7 +4571,7 @@
         (unspec:PTR [(match_operand 1 "aarch64_tls_ie_symref" "S")]
 		   UNSPEC_GOTSMALLTLS))]
   ""
-  "adrp\\t%0, %A1\;ldr\\t%<w>0, [%0, #%L1]"
+  "adrp\\t%0, :gottprel:%1\;ldr\\t%<w>0, [%0, #:gottprel_lo12:%1]"
   [(set_attr "type" "load1")
    (set_attr "length" "8")]
 )
@@ -4582,7 +4582,7 @@
           (unspec:SI [(match_operand 1 "aarch64_tls_ie_symref" "S")]
 		      UNSPEC_GOTSMALLTLS)))]
   ""
-  "adrp\\t%0, %A1\;ldr\\t%w0, [%0, #%L1]"
+  "adrp\\t%0, :gottprel:%1\;ldr\\t%w0, [%0, #:gottprel_lo12:%1]"
   [(set_attr "type" "load1")
    (set_attr "length" "8")]
 )
@@ -4593,7 +4593,7 @@
 		     (match_operand:PTR 2 "register_operand" "r")]
 		   UNSPEC_GOTTINYTLS))]
   ""
-  "ldr\\t%<w>0, %L1\;add\\t%<w>0, %<w>0, %<w>2"
+  "ldr\\t%<w>0, :gottprel:%1\;add\\t%<w>0, %<w>0, %<w>2"
   [(set_attr "type" "multiple")
    (set_attr "length" "8")]
 )
@@ -4606,7 +4606,7 @@
 		      ]
 		      UNSPEC_GOTTINYTLS)))]
   ""
-  "ldr\\t%w0, %L1\;add\\t%<w>0, %<w>0, %<w>2"
+  "ldr\\t%w0, :gottprel:%1\;add\\t%<w>0, %<w>0, %<w>2"
   [(set_attr "type" "multiple")
    (set_attr "length" "8")]
 )
@@ -4617,7 +4617,7 @@
 		   (match_operand 2 "aarch64_tls_le_symref" "S")]
 		   UNSPEC_TLSLE12))]
   ""
-  "add\\t%<w>0, %<w>1, #%L2";
+  "add\\t%<w>0, %<w>1, #:tprel_lo12:%2";
   [(set_attr "type" "alu_sreg")
    (set_attr "length" "4")]
 )
@@ -4628,7 +4628,7 @@
 		   (match_operand 2 "aarch64_tls_le_symref" "S")]
 		   UNSPEC_TLSLE24))]
   ""
-  "add\\t%<w>0, %<w>1, #%G2, lsl #12\;add\\t%<w>0, %<w>0, #%L2"
+  "add\\t%<w>0, %<w>1, #:tprel_hi12:%2, lsl #12\;add\\t%<w>0, %<w>0, #:tprel_lo12_nc:%2"
   [(set_attr "type" "multiple")
    (set_attr "length" "8")]
 )
@@ -4661,7 +4661,7 @@
    (clobber (reg:CC CC_REGNUM))
    (clobber (match_scratch:DI 1 "=r"))]
   "TARGET_TLS_DESC"
-  "adrp\\tx0, %A0\;ldr\\t%<w>1, [x0, #%L0]\;add\\t<w>0, <w>0, %L0\;.tlsdesccall\\t%0\;blr\\t%1"
+  "adrp\\tx0, :tlsdesc:%0\;ldr\\t%<w>1, [x0, #:tlsdesc_lo12:%0]\;add\\t<w>0, <w>0, :tlsdesc_lo12:%0\;.tlsdesccall\\t%0\;blr\\t%1"
   [(set_attr "type" "call")
    (set_attr "length" "16")])

@@ -4680,7 +4680,7 @@
    (clobber (reg:CC CC_REGNUM))
    (clobber (match_scratch:DI 2 "=r"))]
   "TARGET_TLS_DESC"
-  "adrp\\t<w>0, %A1\;ldr\\t%<w>2, [%<w>0, #%L1]\;add\\t%<w>0, %<w>0, %L1\;.tlsdesccall\\t%1\;blr\\t%2"
+  "adrp\\t<w>0, :tlsdesc:%1\;ldr\\t%<w>2, [%<w>0, #:tlsdesc_lo12:%1]\;add\\t%<w>0, %<w>0, :tlsdesc_lo12:%1\;.tlsdesccall\\t%1\;blr\\t%2"
   [(set_attr "type" "call")
    (set_attr "length" "16")])

@@ -4692,7 +4692,7 @@
    (clobber (reg:CC CC_REGNUM))
    (clobber (match_scratch:DI 1 "=r"))]
   "TARGET_TLS_DESC"
-  "ldr\t%<w>1, #%A0;adr\t<w>0, %A0;.tlsdesccall\t%0;blr\t%1"
+  "ldr\t%<w>1, #:tlsdesc:%0;adr\t<w>0, :tlsdesc:%0;.tlsdesccall\t%0;blr\t%1"
   [(set_attr "type" "multiple")
    (set_attr "length" "12")])

@@ -4704,7 +4704,7 @@
    (clobber (reg:CC CC_REGNUM))
    (clobber (match_scratch:DI 2 "=r"))]
   "TARGET_TLS_DESC"
-  "ldr\t%<w>2, #%A1;adr\t%<w>0, %A1;.tlsdesccall\t%1;blr\t%2"
+  "ldr\t%<w>2, #:tlsdesc:%1;adr\t%<w>0, :tlsdesc:%1;.tlsdesccall\t%1;blr\t%2"
   [(set_attr "type" "multiple")
    (set_attr "length" "16")])


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Ping]Re: [AArch64] Simplify TLS pattern by hardcoding relocation modifiers into pattern
  2015-09-10 11:46 [AArch64] Simplify TLS pattern by hardcoding relocation modifiers into pattern Jiong Wang
@ 2015-12-16 15:26 ` Jiong Wang
  2015-12-17 11:44 ` Marcus Shawcroft
  1 sibling, 0 replies; 4+ messages in thread
From: Jiong Wang @ 2015-12-16 15:26 UTC (permalink / raw)
  To: gcc-patches List



On 10/09/15 12:28, Jiong Wang wrote:
> TLS instruction sequences are always with fixed format, there is no need
> to use operand modifier, we can hardcode the relocation modifiers into
> instruction pattern, all those redundant checks in aarch64_print_operand
> can be removed.
>
> OK for trunk?
>
> 2015-09-10  Jiong Wang  <jiong.wang@arm.com>
>
> gcc/
>    * config/aarch64/aarch64.md (ldr_got_tiny): Hardcode relocation
>    modifers.
>    (tlsgd_small): Likewise.
>    (tlsgd_tiny): Likewise.
>    (tlsie_small_<mode>): Likewise.
>    (tlsie_small_sidi): Likewise.
>    (tlsie_tiny_<mode>): Likewise.
>    (tlsie_tiny_sidi): Likewise.
>    (tlsle12_<mode>): Likewise.
>    (tlsle24_<mode>): Likewise.
>    (tlsdesc_small_<mode>): Likewise.
>    (tlsdesc_small_pseudo_<mode>): Likewise.
>    (tlsdesc_tiny_<mode>): Likewise.
>    (tlsdesc_tiny_pseudo_<mode>): Likewise.
>    * config/aarch64/aarch64.c (aarch64_print_operand): Delete useless
>    check on 'A', 'L', 'G'.
>    

Ping ~

There is no functional change by this patch, but just cleanup of those
unnecessary use of output modifiers.

All these instruction sequences are always with fixed format, we can just
hardcode the relocation modifiers into instruction patterns, then all those
redundant checks in aarch64_print_operand can be removed.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [AArch64] Simplify TLS pattern by hardcoding relocation modifiers into pattern
  2015-09-10 11:46 [AArch64] Simplify TLS pattern by hardcoding relocation modifiers into pattern Jiong Wang
  2015-12-16 15:26 ` [Ping]Re: " Jiong Wang
@ 2015-12-17 11:44 ` Marcus Shawcroft
  2015-12-18  9:45   ` Jiong Wang
  1 sibling, 1 reply; 4+ messages in thread
From: Marcus Shawcroft @ 2015-12-17 11:44 UTC (permalink / raw)
  To: Jiong Wang; +Cc: gcc-patches List

On 10 September 2015 at 12:28, Jiong Wang <jiong.wang@arm.com> wrote:
>
> TLS instruction sequences are always with fixed format, there is no need
> to use operand modifier, we can hardcode the relocation modifiers into
> instruction pattern, all those redundant checks in aarch64_print_operand
> can be removed.
>
> OK for trunk?
>
> 2015-09-10  Jiong Wang  <jiong.wang@arm.com>
>
> gcc/
>   * config/aarch64/aarch64.md (ldr_got_tiny): Hardcode relocation
>   modifers.
>   (tlsgd_small): Likewise.
>   (tlsgd_tiny): Likewise.
>   (tlsie_small_<mode>): Likewise.
>   (tlsie_small_sidi): Likewise.
>   (tlsie_tiny_<mode>): Likewise.
>   (tlsie_tiny_sidi): Likewise.
>   (tlsle12_<mode>): Likewise.
>   (tlsle24_<mode>): Likewise.
>   (tlsdesc_small_<mode>): Likewise.
>   (tlsdesc_small_pseudo_<mode>): Likewise.
>   (tlsdesc_tiny_<mode>): Likewise.
>   (tlsdesc_tiny_pseudo_<mode>): Likewise.
>   * config/aarch64/aarch64.c (aarch64_print_operand): Delete useless
>   check on 'A', 'L', 'G'.

Hi, Is there a particular reason for wanting to change this?

Cheers
/Marcus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [AArch64] Simplify TLS pattern by hardcoding relocation modifiers into pattern
  2015-12-17 11:44 ` Marcus Shawcroft
@ 2015-12-18  9:45   ` Jiong Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Jiong Wang @ 2015-12-18  9:45 UTC (permalink / raw)
  To: Marcus Shawcroft; +Cc: gcc-patches List



On 17/12/15 11:44, Marcus Shawcroft wrote:
> On 10 September 2015 at 12:28, Jiong Wang <jiong.wang@arm.com> wrote:
>> TLS instruction sequences are always with fixed format, there is no need
>> to use operand modifier, we can hardcode the relocation modifiers into
>> instruction pattern, all those redundant checks in aarch64_print_operand
>> can be removed.
>>
>> OK for trunk?
>>
>> 2015-09-10  Jiong Wang  <jiong.wang@arm.com>
>>
>> gcc/
>>    * config/aarch64/aarch64.md (ldr_got_tiny): Hardcode relocation
>>    modifers.
>>    (tlsgd_small): Likewise.
>>    (tlsgd_tiny): Likewise.
>>    (tlsie_small_<mode>): Likewise.
>>    (tlsie_small_sidi): Likewise.
>>    (tlsie_tiny_<mode>): Likewise.
>>    (tlsie_tiny_sidi): Likewise.
>>    (tlsle12_<mode>): Likewise.
>>    (tlsle24_<mode>): Likewise.
>>    (tlsdesc_small_<mode>): Likewise.
>>    (tlsdesc_small_pseudo_<mode>): Likewise.
>>    (tlsdesc_tiny_<mode>): Likewise.
>>    (tlsdesc_tiny_pseudo_<mode>): Likewise.
>>    * config/aarch64/aarch64.c (aarch64_print_operand): Delete useless
>>    check on 'A', 'L', 'G'.
> Hi, Is there a particular reason for wanting to change this?

It's because operand modifier is only need if

   "different variants of the assembler require different syntax."

These TLS RTL patterns have fixed assembler string, we just need to
output them literally.

If we don't do this cleanup, we will end up doing redundant checking in
aarch64_print_operand.

For example, the 'L' operand modifier is used by various TLS patterns,
if it's for "tlsie_tiny_sidi"  then we should output ":gottprel:", if
it's for tlsie_small_sidi, we should output ":gottprel_lo12:", and
similar for quite a few others.

We have classified those symbols into different types, so different TLS
unspec patterns generated for each one. The use of operand modifer 'L'
is purely revert the classification we have done, and re-do the
classification in aarch64_print_operand uncessarily.

    case 'L':
       switch (aarch64_classify_symbolic_expression (x))
         {
         case SYMBOL_SMALL_GOT_4G:
           ...
         case SYMBOL_SMALL_TLSGD:
           ...
         case SYMBOL_SMALL_TLSDESC:
           ...
         case SYMBOL_SMALL_TLSIE:
           ...
     }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-18  9:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-10 11:46 [AArch64] Simplify TLS pattern by hardcoding relocation modifiers into pattern Jiong Wang
2015-12-16 15:26 ` [Ping]Re: " Jiong Wang
2015-12-17 11:44 ` Marcus Shawcroft
2015-12-18  9:45   ` Jiong Wang

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).