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. -- Regards, Jiong
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