Marcus Shawcroft writes: > On 21 May 2015 at 17:44, Jiong Wang <jiong.w...@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.w...@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.w...@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
From 4a244a1d4b32b1e10e5ba07c0c568f135648912e Mon Sep 17 00:00:00 2001 From: Jiong Wang <jiong.w...@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