public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [AArch64][TLSLE][5/N] Recognize -mtls-size
@ 2015-05-21 16:53 Jiong Wang
  2015-05-21 18:14 ` [AArch64][TLSLE][4/N] " Jiong Wang
  2015-06-26 15:25 ` [AArch64][TLSLE][5/N] " Marcus Shawcroft
  0 siblings, 2 replies; 10+ messages in thread
From: Jiong Wang @ 2015-05-21 16:53 UTC (permalink / raw)
  To: gcc-patches

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


This patch add -mtls-size option for AArch64. This option let user to do
finer control on code generation for various TLS model on AArch64.

For example, for TLS LE, user can specify smaller tls-size, for example
4K which is quite usual, to let AArch64 backend generate more efficient
instruction sequences.

Currently, -mtls-size accept all integer, then will translate it into
12(4K), 24(16M), 32(4G), 48(256TB) based on the value.

no functional change.

ok for trunk?

2015-05-20  Jiong Wang  <jiong.wang@arm.com>

gcc/
  * config/aarch64/aarch64.opt (mtls-size): New entry.
  * config/aarch64/aarch64.c (initialize_aarch64_tls_size): New function.
  * doc/invoke.texi (AArch64 Options): Document -mtls-size.
  
-- 
Regards,
Jiong


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

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 55b166c..e6aa0e1 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -6835,6 +6835,7 @@ aarch64_add_stmt_cost (void *data, int count, enum vect_cost_for_stmt kind,
 }
 
 static void initialize_aarch64_code_model (void);
+static void initialize_aarch64_tls_size (void);
 
 /* Parse the architecture extension string.  */
 
@@ -7068,6 +7069,7 @@ aarch64_override_options (void)
 #endif
 
   initialize_aarch64_code_model ();
+  initialize_aarch64_tls_size ();
 
   aarch64_build_bitmask_table ();
 
@@ -7173,6 +7175,36 @@ initialize_aarch64_code_model (void)
      aarch64_cmodel = aarch64_cmodel_var;
 }
 
+/* A checking mechanism for the implementation of the tls size.  */
+
+static void
+initialize_aarch64_tls_size (void)
+{
+  switch (aarch64_cmodel_var)
+    {
+    case AARCH64_CMODEL_TINY:
+      /* The maximum TLS size allowed under tiny is 1M.  */
+      if (aarch64_tls_size > 20)
+	aarch64_tls_size = 20;
+      break;
+    case AARCH64_CMODEL_SMALL:
+      /* The maximum TLS size allowed under small is 4G.  */
+      if (aarch64_tls_size > 32)
+	aarch64_tls_size = 32;
+      break;
+    case AARCH64_CMODEL_LARGE:
+      /* The maximum TLS size allowed under large is 16E.
+	 FIXME: 16E should be 64bit, we only support 48bit offset now.  */
+      if (aarch64_tls_size > 48)
+	aarch64_tls_size = 48;
+      break;
+    default:
+      gcc_unreachable ();
+    }
+
+  return;
+}
+
 /* Return true if SYMBOL_REF X binds locally.  */
 
 static bool
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 6d72ac2..e87a1f5 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -95,6 +95,11 @@ mtls-dialect=
 Target RejectNegative Joined Enum(tls_type) Var(aarch64_tls_dialect) Init(TLS_DESCRIPTORS)
 Specify TLS dialect
 
+mtls-size=
+Target RejectNegative Joined UInteger Var(aarch64_tls_size) Init(24)
+Specifies size of the TLS data area, default size is 16M. Accept any integer, but the value
+will be transformed into 12(4K), 24(16M), 32(4G), 48(256TB)
+
 march=
 Target RejectNegative ToLower Joined Var(aarch64_arch_string)
 -march=ARCH	Use features of architecture ARCH
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 117b5d9..1f96a4f 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -513,6 +513,7 @@ Objective-C and Objective-C++ Dialects}.
 -mstrict-align @gol
 -momit-leaf-frame-pointer  -mno-omit-leaf-frame-pointer @gol
 -mtls-dialect=desc  -mtls-dialect=traditional @gol
+-mtls-size=@var{size} @gol
 -mfix-cortex-a53-835769  -mno-fix-cortex-a53-835769 @gol
 -mfix-cortex-a53-843419  -mno-fix-cortex-a53-843419 @gol
 -march=@var{name}  -mcpu=@var{name}  -mtune=@var{name}}
@@ -12390,6 +12391,13 @@ of TLS variables.  This is the default.
 Use traditional TLS as the thread-local storage mechanism for dynamic accesses
 of TLS variables.
 
+@item -mtls-size=@var{size}
+@opindex mtls-size
+Specify the size of TLS area. You can specify smaller value to get better code
+generation for TLS variable access. Currently, we accept any integer, but will
+turn them into 12(4K), 24(16M), 32(4G), 48(256TB) according to the integer
+value.
+
 @item -mfix-cortex-a53-835769
 @itemx -mno-fix-cortex-a53-835769
 @opindex mfix-cortex-a53-835769

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

* Re: [AArch64][TLSLE][4/N] Recognize -mtls-size
  2015-05-21 16:53 [AArch64][TLSLE][5/N] Recognize -mtls-size Jiong Wang
@ 2015-05-21 18:14 ` Jiong Wang
  2015-06-26 15:25 ` [AArch64][TLSLE][5/N] " Marcus Shawcroft
  1 sibling, 0 replies; 10+ messages in thread
From: Jiong Wang @ 2015-05-21 18:14 UTC (permalink / raw)
  To: gcc-patches


Jiong Wang writes:

> This patch add -mtls-size option for AArch64. This option let user to do
> finer control on code generation for various TLS model on AArch64.
>
> For example, for TLS LE, user can specify smaller tls-size, for example
> 4K which is quite usual, to let AArch64 backend generate more efficient
> instruction sequences.
>
> Currently, -mtls-size accept all integer, then will translate it into
> 12(4K), 24(16M), 32(4G), 48(256TB) based on the value.
>
> no functional change.
>
> ok for trunk?
>
> 2015-05-20  Jiong Wang  <jiong.wang@arm.com>
>
> gcc/
>   * config/aarch64/aarch64.opt (mtls-size): New entry.
>   * config/aarch64/aarch64.c (initialize_aarch64_tls_size): New function.
>   * doc/invoke.texi (AArch64 Options): Document -mtls-size.

Rename summary from "5/N" to "4/N".

The fourth patch was a binutils patch at:
  https://sourceware.org/ml/binutils/2015-05/msg00181.html
  
-- 
Regards,
Jiong

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

* Re: [AArch64][TLSLE][5/N] Recognize -mtls-size
  2015-05-21 16:53 [AArch64][TLSLE][5/N] Recognize -mtls-size Jiong Wang
  2015-05-21 18:14 ` [AArch64][TLSLE][4/N] " Jiong Wang
@ 2015-06-26 15:25 ` Marcus Shawcroft
  2015-08-19 14:30   ` [AArch64][TLSLE][1/3] Add the option "-mtls-size" for AArch64 Jiong Wang
  1 sibling, 1 reply; 10+ messages in thread
From: Marcus Shawcroft @ 2015-06-26 15:25 UTC (permalink / raw)
  To: Jiong Wang; +Cc: gcc-patches

On 21 May 2015 at 17:44, Jiong Wang <jiong.wang@arm.com> wrote:
>
> This patch add -mtls-size option for AArch64. This option let user to do
> finer control on code generation for various TLS model on AArch64.
>
> For example, for TLS LE, user can specify smaller tls-size, for example
> 4K which is quite usual, to let AArch64 backend generate more efficient
> instruction sequences.
>
> Currently, -mtls-size accept all integer, then will translate it into
> 12(4K), 24(16M), 32(4G), 48(256TB) based on the value.
>
> no functional change.
>
> ok for trunk?
>
> 2015-05-20  Jiong Wang  <jiong.wang@arm.com>
>
> gcc/
>   * config/aarch64/aarch64.opt (mtls-size): New entry.
>   * config/aarch64/aarch64.c (initialize_aarch64_tls_size): New function.
>   * doc/invoke.texi (AArch64 Options): Document -mtls-size.

+mtls-size=
+Target RejectNegative Joined UInteger Var(aarch64_tls_size) Init(24)
+Specifies size of the TLS data area, default size is 16M. Accept any
integer, but the value
+will be transformed into 12(4K), 24(16M), 32(4G), 48(256TB)
+

Can we follow the mechanism used by rs6000 and limit the accepted
values here using an Enum to just the valid values: 12, 24, 32, 48?

+@item -mtls-size=@var{size}
+@opindex mtls-size
+Specify the size of TLS area. You can specify smaller value to get better code
+generation for TLS variable access. Currently, we accept any integer, but will
+turn them into 12(4K), 24(16M), 32(4G), 48(256TB) according to the integer
+value.
+

How about:
"Specify bit size of immediate TLS offsets.  Valid values are 12, 24, 32, 48."

Thanks
/Marcus

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

* [AArch64][TLSLE][1/3] Add the option "-mtls-size" for AArch64
  2015-06-26 15:25 ` [AArch64][TLSLE][5/N] " Marcus Shawcroft
@ 2015-08-19 14:30   ` Jiong Wang
  2015-08-19 14:37     ` [AArch64][TLSLE][2/3] " Jiong Wang
  2015-08-25 10:26     ` [AArch64][TLSLE][1/3] " Marcus Shawcroft
  0 siblings, 2 replies; 10+ messages in thread
From: Jiong Wang @ 2015-08-19 14:30 UTC (permalink / raw)
  To: Marcus Shawcroft; +Cc: GCC Patches

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


Marcus Shawcroft writes:

> On 21 May 2015 at 17:44, Jiong Wang <jiong.wang@arm.com> wrote:
>>
>> This patch add -mtls-size option for AArch64. This option let user to do
>> finer control on code generation for various TLS model on AArch64.
>>
>> For example, for TLS LE, user can specify smaller tls-size, for example
>> 4K which is quite usual, to let AArch64 backend generate more efficient
>> instruction sequences.
>>
>> Currently, -mtls-size accept all integer, then will translate it into
>> 12(4K), 24(16M), 32(4G), 48(256TB) based on the value.
>>
>> no functional change.
>>
>> ok for trunk?
>>
>> 2015-05-20  Jiong Wang  <jiong.wang@arm.com>
>>
>> gcc/
>>   * config/aarch64/aarch64.opt (mtls-size): New entry.
>>   * config/aarch64/aarch64.c (initialize_aarch64_tls_size): New function.
>>   * doc/invoke.texi (AArch64 Options): Document -mtls-size.
>
> +mtls-size=
> +Target RejectNegative Joined UInteger Var(aarch64_tls_size) Init(24)
> +Specifies size of the TLS data area, default size is 16M. Accept any
> integer, but the value
> +will be transformed into 12(4K), 24(16M), 32(4G), 48(256TB)
> +
>
> Can we follow the mechanism used by rs6000 and limit the accepted
> values here using an Enum to just the valid values: 12, 24, 32, 48?

Done.

>
> +@item -mtls-size=@var{size}
> +@opindex mtls-size
> +Specify the size of TLS area. You can specify smaller value to get better code
> +generation for TLS variable access. Currently, we accept any integer, but will
> +turn them into 12(4K), 24(16M), 32(4G), 48(256TB) according to the integer
> +value.
> +
>
> How about:
> "Specify bit size of immediate TLS offsets.  Valid values are 12, 24,
> 32, 48."

Done.

Patch updated, please review, thanks.

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

gcc/
  * config/aarch64/aarch64.opt (mtls-size): New entry.
  * config/aarch64/aarch64.c (initialize_aarch64_tls_size): New function.
  (aarch64_override_options_internal): Call initialize_aarch64_tls_size.
  * doc/invoke.texi (AArch64 Options): Document -mtls-size.

-- 
Regards,
Jiong


[-- Attachment #2: 0001-1.patch --]
[-- Type: text/x-diff, Size: 3756 bytes --]

From 4a244a1d4b32b1e10e5ba07c0c568f135648912e Mon Sep 17 00:00:00 2001
From: Jiong Wang <jiong.wang@arm.com>
Date: Wed, 19 Aug 2015 14:10:37 +0100
Subject: [PATCH 1/3] 1

---
 gcc/config/aarch64/aarch64.c   | 31 +++++++++++++++++++++++++++++++
 gcc/config/aarch64/aarch64.opt | 19 +++++++++++++++++++
 gcc/doc/invoke.texi            |  5 +++++
 3 files changed, 55 insertions(+)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 0f3be3c..f55cc38 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -7506,6 +7506,36 @@ aarch64_parse_one_override_token (const char* token,
   return;
 }
 
+/* A checking mechanism for the implementation of the tls size.  */
+
+static void
+initialize_aarch64_tls_size (struct gcc_options *opts)
+{
+  switch (opts->x_aarch64_cmodel_var)
+    {
+    case AARCH64_CMODEL_TINY:
+      /* The maximum TLS size allowed under tiny is 1M.  */
+      if (aarch64_tls_size > 20)
+	aarch64_tls_size = 20;
+      break;
+    case AARCH64_CMODEL_SMALL:
+      /* The maximum TLS size allowed under small is 4G.  */
+      if (aarch64_tls_size > 32)
+	aarch64_tls_size = 32;
+      break;
+    case AARCH64_CMODEL_LARGE:
+      /* The maximum TLS size allowed under large is 16E.
+	 FIXME: 16E should be 64bit, we only support 48bit offset now.  */
+      if (aarch64_tls_size > 48)
+	aarch64_tls_size = 48;
+      break;
+    default:
+      gcc_unreachable ();
+    }
+
+  return;
+}
+
 /* Parse STRING looking for options in the format:
      string	:: option:string
      option	:: name=substring
@@ -7598,6 +7628,7 @@ aarch64_override_options_internal (struct gcc_options *opts)
     }
 
   initialize_aarch64_code_model (opts);
+  initialize_aarch64_tls_size (opts);
 
   aarch64_override_options_after_change_1 (opts);
 }
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 37c2c50..8642bdb 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -96,6 +96,25 @@ mtls-dialect=
 Target RejectNegative Joined Enum(tls_type) Var(aarch64_tls_dialect) Init(TLS_DESCRIPTORS) Save
 Specify TLS dialect
 
+mtls-size=
+Target RejectNegative Joined Var(aarch64_tls_size) Enum(aarch64_tls_size)
+Specifies bit size of immediate TLS offsets.  Valid values are 12, 24, 32, 48.
+
+Enum
+Name(aarch64_tls_size) Type(int)
+
+EnumValue
+Enum(aarch64_tls_size) String(12) Value(12)
+
+EnumValue
+Enum(aarch64_tls_size) String(24) Value(24)
+
+EnumValue
+Enum(aarch64_tls_size) String(32) Value(32)
+
+EnumValue
+Enum(aarch64_tls_size) String(48) Value(48)
+
 march=
 Target RejectNegative ToLower Joined Var(aarch64_arch_string)
 -march=ARCH	Use features of architecture ARCH
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 27be317..c9f332c 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -514,6 +514,7 @@ Objective-C and Objective-C++ Dialects}.
 -mstrict-align @gol
 -momit-leaf-frame-pointer  -mno-omit-leaf-frame-pointer @gol
 -mtls-dialect=desc  -mtls-dialect=traditional @gol
+-mtls-size=@var{size} @gol
 -mfix-cortex-a53-835769  -mno-fix-cortex-a53-835769 @gol
 -mfix-cortex-a53-843419  -mno-fix-cortex-a53-843419 @gol
 -march=@var{name}  -mcpu=@var{name}  -mtune=@var{name}}
@@ -12409,6 +12410,10 @@ of TLS variables.  This is the default.
 Use traditional TLS as the thread-local storage mechanism for dynamic accesses
 of TLS variables.
 
+@item -mtls-size=@var{size}
+@opindex mtls-size
+Specify bit size of immediate TLS offsets.  Valid values are 12, 24, 32, 48.
+
 @item -mfix-cortex-a53-835769
 @itemx -mno-fix-cortex-a53-835769
 @opindex mfix-cortex-a53-835769
-- 
1.9.1


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

* [AArch64][TLSLE][2/3] Add the option "-mtls-size" for AArch64
  2015-08-19 14:30   ` [AArch64][TLSLE][1/3] Add the option "-mtls-size" for AArch64 Jiong Wang
@ 2015-08-19 14:37     ` Jiong Wang
  2015-08-19 16:34       ` [AArch64][TLSLE][2/3] Rename SYMBOL_TLSLE to SYMBOL_TLSLE24 Jiong Wang
  2015-08-25  9:46       ` [AArch64][TLSLE][2/3] Add the option "-mtls-size" for AArch64 Marcus Shawcroft
  2015-08-25 10:26     ` [AArch64][TLSLE][1/3] " Marcus Shawcroft
  1 sibling, 2 replies; 10+ messages in thread
From: Jiong Wang @ 2015-08-19 14:37 UTC (permalink / raw)
  To: GCC Patches; +Cc: Marcus Shawcroft

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


As we have added -mtls-size support, there should be four types TLSLE
symbols:

  SYMBOL_TLSLE12
  SYMBOL_TLSLE24
  SYMBOL_TLSLE32
  SYMBOL_TLSLE48

which reflect the maximum address bits needed to address this symbol.

This patch rename SYMBOL_TLSLE to SYMBOL_TLSLE24. Patch [3/3] will add
support for other symbol types.

OK for trunk?

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

gcc/
  * config/aarch64/aarch64-protos.h (aarch64_symbol_type): Rename
  SYMBOL_TLSLE to SYMBOL_TLSLE24.
  * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Likewise
  (aarch64_expand_mov_immediate): Likewise
  (aarch64_print_operand): Likewise
  (aarch64_classify_symbol): Likewise


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

From 676fc22d51432b037a2c77ae9de01f934cc77985 Mon Sep 17 00:00:00 2001
From: Jiong Wang <jiong.wang@arm.com>
Date: Wed, 19 Aug 2015 14:12:57 +0100
Subject: [PATCH 2/3] 2

---
 gcc/config/aarch64/aarch64-protos.h |  4 ++--
 gcc/config/aarch64/aarch64.c        | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 0b09d49..daa45bf 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -74,7 +74,7 @@ enum aarch64_symbol_context
    SYMBOL_SMALL_TLSGD
    SYMBOL_SMALL_TLSDESC
    SYMBOL_SMALL_GOTTPREL
-   SYMBOL_TLSLE
+   SYMBOL_TLSLE24
    Each of these represents a thread-local symbol, and corresponds to the
    thread local storage relocation operator for the symbol being referred to.
 
@@ -111,7 +111,7 @@ enum aarch64_symbol_type
   SYMBOL_SMALL_GOTTPREL,
   SYMBOL_TINY_ABSOLUTE,
   SYMBOL_TINY_GOT,
-  SYMBOL_TLSLE,
+  SYMBOL_TLSLE24,
   SYMBOL_FORCE_TO_MEM
 };
 
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index f55cc38..87f8d96 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -1115,7 +1115,7 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm,
 	return;
       }
 
-    case SYMBOL_TLSLE:
+    case SYMBOL_TLSLE24:
       {
 	rtx tp = aarch64_load_tp (NULL);
 
@@ -1677,7 +1677,7 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm)
 
 	case SYMBOL_SMALL_ABSOLUTE:
 	case SYMBOL_TINY_ABSOLUTE:
-	case SYMBOL_TLSLE:
+	case SYMBOL_TLSLE24:
 	  aarch64_load_symref_appropriately (dest, imm, sty);
 	  return;
 
@@ -4560,7 +4560,7 @@ aarch64_print_operand (FILE *f, rtx x, char code)
 	  asm_fprintf (asm_out_file, ":gottprel:");
 	  break;
 
-	case SYMBOL_TLSLE:
+	case SYMBOL_TLSLE24:
 	  asm_fprintf (asm_out_file, ":tprel:");
 	  break;
 
@@ -4593,7 +4593,7 @@ aarch64_print_operand (FILE *f, rtx x, char code)
 	  asm_fprintf (asm_out_file, ":gottprel_lo12:");
 	  break;
 
-	case SYMBOL_TLSLE:
+	case SYMBOL_TLSLE24:
 	  asm_fprintf (asm_out_file, ":tprel_lo12_nc:");
 	  break;
 
@@ -4611,7 +4611,7 @@ aarch64_print_operand (FILE *f, rtx x, char code)
 
       switch (aarch64_classify_symbolic_expression (x, SYMBOL_CONTEXT_ADR))
 	{
-	case SYMBOL_TLSLE:
+	case SYMBOL_TLSLE24:
 	  asm_fprintf (asm_out_file, ":tprel_hi12:");
 	  break;
 	default:
@@ -8717,7 +8717,7 @@ aarch64_classify_tls_symbol (rtx x)
       return SYMBOL_SMALL_GOTTPREL;
 
     case TLS_MODEL_LOCAL_EXEC:
-      return SYMBOL_TLSLE;
+      return SYMBOL_TLSLE24;
 
     case TLS_MODEL_EMULATED:
     case TLS_MODEL_NONE:
-- 
1.9.1


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

* [AArch64][TLSLE][2/3] Rename SYMBOL_TLSLE to SYMBOL_TLSLE24
  2015-08-19 14:37     ` [AArch64][TLSLE][2/3] " Jiong Wang
@ 2015-08-19 16:34       ` Jiong Wang
  2015-08-25  9:46       ` [AArch64][TLSLE][2/3] Add the option "-mtls-size" for AArch64 Marcus Shawcroft
  1 sibling, 0 replies; 10+ messages in thread
From: Jiong Wang @ 2015-08-19 16:34 UTC (permalink / raw)
  To: GCC Patches; +Cc: Marcus Shawcroft


Jiong Wang writes:

> As we have added -mtls-size support, there should be four types TLSLE
> symbols:
>
>   SYMBOL_TLSLE12
>   SYMBOL_TLSLE24
>   SYMBOL_TLSLE32
>   SYMBOL_TLSLE48
>
> which reflect the maximum address bits needed to address this symbol.
>
> This patch rename SYMBOL_TLSLE to SYMBOL_TLSLE24. Patch [3/3] will add
> support for other symbol types.
>
> OK for trunk?
>
> 2015-08-19  Jiong Wang  <jiong.wang@arm.com>
>
> gcc/
>   * config/aarch64/aarch64-protos.h (aarch64_symbol_type): Rename
>   SYMBOL_TLSLE to SYMBOL_TLSLE24.
>   * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Likewise
>   (aarch64_expand_mov_immediate): Likewise
>   (aarch64_print_operand): Likewise
>   (aarch64_classify_symbol): Likewise

Sorry, the patch name should be

  [AArch64][TLSLE][2/3] Rename SYMBOL_TLSLE to SYMBOL_TLSLE24

instead of

  [AArch64][TLSLE][2/3] Add the option "-mtls-size" for AArch64

-- 
Regards,
Jiong

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

* Re: [AArch64][TLSLE][2/3] Add the option "-mtls-size" for AArch64
  2015-08-19 14:37     ` [AArch64][TLSLE][2/3] " Jiong Wang
  2015-08-19 16:34       ` [AArch64][TLSLE][2/3] Rename SYMBOL_TLSLE to SYMBOL_TLSLE24 Jiong Wang
@ 2015-08-25  9:46       ` Marcus Shawcroft
  1 sibling, 0 replies; 10+ messages in thread
From: Marcus Shawcroft @ 2015-08-25  9:46 UTC (permalink / raw)
  To: Jiong Wang; +Cc: GCC Patches

> 2015-08-19  Jiong Wang  <jiong.wang@arm.com>
>
> gcc/
>   * config/aarch64/aarch64-protos.h (aarch64_symbol_type): Rename
>   SYMBOL_TLSLE to SYMBOL_TLSLE24.
>   * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Likewise
>   (aarch64_expand_mov_immediate): Likewise
>   (aarch64_print_operand): Likewise
>   (aarch64_classify_symbol): Likewise
>

OK /Marcus

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

* Re: [AArch64][TLSLE][1/3] Add the option "-mtls-size" for AArch64
  2015-08-19 14:30   ` [AArch64][TLSLE][1/3] Add the option "-mtls-size" for AArch64 Jiong Wang
  2015-08-19 14:37     ` [AArch64][TLSLE][2/3] " Jiong Wang
@ 2015-08-25 10:26     ` Marcus Shawcroft
  2015-08-25 14:19       ` Jiong Wang
  1 sibling, 1 reply; 10+ messages in thread
From: Marcus Shawcroft @ 2015-08-25 10:26 UTC (permalink / raw)
  To: Jiong Wang; +Cc: GCC Patches

On 19 August 2015 at 15:26, Jiong Wang <jiong.wang@arm.com> wrote:

> 2015-08-19  Jiong Wang  <jiong.wang@arm.com>
>
> gcc/
>   * config/aarch64/aarch64.opt (mtls-size): New entry.
>   * config/aarch64/aarch64.c (initialize_aarch64_tls_size): New function.
>   (aarch64_override_options_internal): Call initialize_aarch64_tls_size.
>   * doc/invoke.texi (AArch64 Options): Document -mtls-size.
>
> --
> Regards,
> Jiong
>

+    case AARCH64_CMODEL_TINY:
+      /* The maximum TLS size allowed under tiny is 1M.  */
+      if (aarch64_tls_size > 20)
+ aarch64_tls_size = 20;

The only valid values of aarch64_tls_size handled/expected by the
remainder of the patch set is 12,24,32,48 so setting the value to 20
here doesn;t make sense.

/Marcus

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

* Re: [AArch64][TLSLE][1/3] Add the option "-mtls-size" for AArch64
  2015-08-25 10:26     ` [AArch64][TLSLE][1/3] " Marcus Shawcroft
@ 2015-08-25 14:19       ` Jiong Wang
  2015-08-26 12:39         ` Marcus Shawcroft
  0 siblings, 1 reply; 10+ messages in thread
From: Jiong Wang @ 2015-08-25 14:19 UTC (permalink / raw)
  To: Marcus Shawcroft; +Cc: GCC Patches

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


Marcus Shawcroft writes:

> On 19 August 2015 at 15:26, Jiong Wang <jiong.wang@arm.com> wrote:
>
>> 2015-08-19  Jiong Wang  <jiong.wang@arm.com>
>>
>> gcc/
>>   * config/aarch64/aarch64.opt (mtls-size): New entry.
>>   * config/aarch64/aarch64.c (initialize_aarch64_tls_size): New function.
>>   (aarch64_override_options_internal): Call initialize_aarch64_tls_size.
>>   * doc/invoke.texi (AArch64 Options): Document -mtls-size.
>>
>> --
>> Regards,
>> Jiong
>>
>
> +    case AARCH64_CMODEL_TINY:
> +      /* The maximum TLS size allowed under tiny is 1M.  */
> +      if (aarch64_tls_size > 20)
> + aarch64_tls_size = 20;
>
> The only valid values of aarch64_tls_size handled/expected by the
> remainder of the patch set is 12,24,32,48 so setting the value to 20
> here doesn;t make sense.

Thanks for pointing this out, how about the new patch attached?

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

gcc/
  * config/aarch64/aarch64.opt (mtls-size): New entry.
  * config/aarch64/aarch64.c (initialize_aarch64_tls_size): New function.
  (aarch64_override_options_internal): Call initialize_aarch64_tls_size.
  * doc/invoke.texi (AArch64 Options): Document -mtls-size.


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

commit 36736a1a2133ffc949d3e00efdced8ef2c53cddd
Author: Jiong Wang <jiong.wang@arm.com>
Date:   Tue Aug 25 11:13:44 2015 +0100

    1

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 382be2c..318b852 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -7492,6 +7492,40 @@ aarch64_parse_one_override_token (const char* token,
   return;
 }
 
+/* A checking mechanism for the implementation of the tls size.  */
+
+static void
+initialize_aarch64_tls_size (struct gcc_options *opts)
+{
+  if (aarch64_tls_size == 0)
+    aarch64_tls_size = 24;
+
+  switch (opts->x_aarch64_cmodel_var)
+    {
+    case AARCH64_CMODEL_TINY:
+      /* Both the default and maximum TLS size allowed under tiny is 1M which
+	 needs two instructions to address, so we clamp the size to 24.  */
+      if (aarch64_tls_size > 24)
+	aarch64_tls_size = 24;
+      break;
+    case AARCH64_CMODEL_SMALL:
+      /* The maximum TLS size allowed under small is 4G.  */
+      if (aarch64_tls_size > 32)
+	aarch64_tls_size = 32;
+      break;
+    case AARCH64_CMODEL_LARGE:
+      /* The maximum TLS size allowed under large is 16E.
+	 FIXME: 16E should be 64bit, we only support 48bit offset now.  */
+      if (aarch64_tls_size > 48)
+	aarch64_tls_size = 48;
+      break;
+    default:
+      gcc_unreachable ();
+    }
+
+  return;
+}
+
 /* Parse STRING looking for options in the format:
      string	:: option:string
      option	:: name=substring
@@ -7584,6 +7618,7 @@ aarch64_override_options_internal (struct gcc_options *opts)
     }
 
   initialize_aarch64_code_model (opts);
+  initialize_aarch64_tls_size (opts);
 
   aarch64_override_options_after_change_1 (opts);
 }
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 37c2c50..8642bdb 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -96,6 +96,25 @@ mtls-dialect=
 Target RejectNegative Joined Enum(tls_type) Var(aarch64_tls_dialect) Init(TLS_DESCRIPTORS) Save
 Specify TLS dialect
 
+mtls-size=
+Target RejectNegative Joined Var(aarch64_tls_size) Enum(aarch64_tls_size)
+Specifies bit size of immediate TLS offsets.  Valid values are 12, 24, 32, 48.
+
+Enum
+Name(aarch64_tls_size) Type(int)
+
+EnumValue
+Enum(aarch64_tls_size) String(12) Value(12)
+
+EnumValue
+Enum(aarch64_tls_size) String(24) Value(24)
+
+EnumValue
+Enum(aarch64_tls_size) String(32) Value(32)
+
+EnumValue
+Enum(aarch64_tls_size) String(48) Value(48)
+
 march=
 Target RejectNegative ToLower Joined Var(aarch64_arch_string)
 -march=ARCH	Use features of architecture ARCH
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 27be317..f990bef 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -514,6 +514,7 @@ Objective-C and Objective-C++ Dialects}.
 -mstrict-align @gol
 -momit-leaf-frame-pointer  -mno-omit-leaf-frame-pointer @gol
 -mtls-dialect=desc  -mtls-dialect=traditional @gol
+-mtls-size=@var{size} @gol
 -mfix-cortex-a53-835769  -mno-fix-cortex-a53-835769 @gol
 -mfix-cortex-a53-843419  -mno-fix-cortex-a53-843419 @gol
 -march=@var{name}  -mcpu=@var{name}  -mtune=@var{name}}
@@ -12409,6 +12410,11 @@ of TLS variables.  This is the default.
 Use traditional TLS as the thread-local storage mechanism for dynamic accesses
 of TLS variables.
 
+@item -mtls-size=@var{size}
+@opindex mtls-size
+Specify bit size of immediate TLS offsets.  Valid values are 12, 24, 32, 48.
+This option depends on binutils higher than 2.25.
+
 @item -mfix-cortex-a53-835769
 @itemx -mno-fix-cortex-a53-835769
 @opindex mfix-cortex-a53-835769

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

* Re: [AArch64][TLSLE][1/3] Add the option "-mtls-size" for AArch64
  2015-08-25 14:19       ` Jiong Wang
@ 2015-08-26 12:39         ` Marcus Shawcroft
  0 siblings, 0 replies; 10+ messages in thread
From: Marcus Shawcroft @ 2015-08-26 12:39 UTC (permalink / raw)
  To: Jiong Wang; +Cc: GCC Patches

On 25 August 2015 at 15:15, Jiong Wang <jiong.wang@arm.com> wrote:

> 2015-08-25  Jiong Wang  <jiong.wang@arm.com>
>
> gcc/
>   * config/aarch64/aarch64.opt (mtls-size): New entry.
>   * config/aarch64/aarch64.c (initialize_aarch64_tls_size): New function.
>   (aarch64_override_options_internal): Call initialize_aarch64_tls_size.
>   * doc/invoke.texi (AArch64 Options): Document -mtls-size.
>

OK Thanks /Marcus

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

end of thread, other threads:[~2015-08-26 12:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-21 16:53 [AArch64][TLSLE][5/N] Recognize -mtls-size Jiong Wang
2015-05-21 18:14 ` [AArch64][TLSLE][4/N] " Jiong Wang
2015-06-26 15:25 ` [AArch64][TLSLE][5/N] " Marcus Shawcroft
2015-08-19 14:30   ` [AArch64][TLSLE][1/3] Add the option "-mtls-size" for AArch64 Jiong Wang
2015-08-19 14:37     ` [AArch64][TLSLE][2/3] " Jiong Wang
2015-08-19 16:34       ` [AArch64][TLSLE][2/3] Rename SYMBOL_TLSLE to SYMBOL_TLSLE24 Jiong Wang
2015-08-25  9:46       ` [AArch64][TLSLE][2/3] Add the option "-mtls-size" for AArch64 Marcus Shawcroft
2015-08-25 10:26     ` [AArch64][TLSLE][1/3] " Marcus Shawcroft
2015-08-25 14:19       ` Jiong Wang
2015-08-26 12:39         ` Marcus Shawcroft

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