Commit message: Enable -mpcrel for -mcpu=future if it is allowed by the ABI.
2020-04-06 Michael Meissner <meiss...@linux.ibm.com> * config/rs6000/linux64.h (PCREL_SUPPORTED_BY_OS): Enable prefixed PC-relative addressing if the ABI supports it. * config/rs6000/rs6000-cpus.def (ISA_FUTURE_MASKS_SERVER): Do not set OPTION_MASK_PREFIXED here. * config/rs6000/rs6000.c (rs6000_option_override_internal): Enable OPTION_MASK_PREFIXED and OPTION_MASK_PCREL on -mcpu=future by default if the current ABI allows the options. I tested this on a little endian PowerPC power8 system, doing bootstrap and make check. There were no regressions. I tested by hand the various conditions where -mpcrel is not enabled, and they all used the normal power9 TOC references. -mcpu=power9 generates TOC; -mcpu=future -mcmodel=large generates TOC; -mcpu=future -mcmode=small generates TOC; -mcpu=future -mno-prefixed generates TOC; -mcpu=future -mno-pcrel generates TOC; -mcpu=future generates PC-relative. --- /tmp/apbaWN_linux64.h 2020-04-03 17:15:05.059677000 -0400 +++ gcc/config/rs6000/linux64.h 2020-04-03 17:01:05.580426937 -0400 @@ -640,3 +640,10 @@ extern int dot_symbols; enabling the __float128 keyword. */ #undef TARGET_FLOAT128_ENABLE_TYPE #define TARGET_FLOAT128_ENABLE_TYPE 1 + +/* Enable using prefixed PC-relative addressing on the 'future' machine if the + ABI supports it. The ELF v2 ABI only supports PC-relative relocations for + the medium code model. */ +#define PCREL_SUPPORTED_BY_OS (TARGET_FUTURE && TARGET_PREFIXED \ + && ELFv2_ABI_CHECK \ + && (TARGET_CMODEL == CMODEL_MEDIUM)) --- /tmp/XzRKno_rs6000-cpus.def 2020-04-03 17:15:05.068676928 -0400 +++ gcc/config/rs6000/rs6000-cpus.def 2020-04-03 17:00:50.115550614 -0400 @@ -75,10 +75,14 @@ | OPTION_MASK_P8_VECTOR \ | OPTION_MASK_P9_VECTOR) -/* Support for a future processor's features. Do not enable -mpcrel until it - is fully functional. */ +/* Support for a future processor's features. Do not set OPTION_MASK_PREFIXED + or OPTION_MASK_PCREL here. Those options are enabled in the function + rs6000_option_override if the ABI supports them. */ #define ISA_FUTURE_MASKS_SERVER (ISA_3_0_MASKS_SERVER \ - | OPTION_MASK_FUTURE \ + | OPTION_MASK_FUTURE) + +/* Flags that need to be turned off if -mno-future. */ +#define OTHER_FUTURE_MASKS (OPTION_MASK_PCREL \ | OPTION_MASK_PREFIXED) /* Flags that need to be turned off if -mno-future. */ --- /tmp/nyxSRY_rs6000.c 2020-04-03 17:15:05.081676823 -0400 +++ gcc/config/rs6000/rs6000.c 2020-04-03 17:03:19.846353197 -0400 @@ -4020,6 +4020,12 @@ rs6000_option_override_internal (bool gl rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW; } + /* Enable -mprefixed by default on 64-bit 'future' systems. */ + if (TARGET_FUTURE && TARGET_POWERPC64 + && (rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) == 0) + rs6000_isa_flags |= OPTION_MASK_PREFIXED; + + /* -mprefixed (and hence -mpcrel) requires -mcpu=future. */ if (TARGET_PREFIXED && !TARGET_FUTURE) { @@ -4171,6 +4177,14 @@ rs6000_option_override_internal (bool gl SUB3TARGET_OVERRIDE_OPTIONS; #endif +#ifdef PCREL_SUPPORTED_BY_OS + /* If the ABI has support for PC-relative relocations, enable it by + default. */ + if (PCREL_SUPPORTED_BY_OS + && (rs6000_isa_flags_explicit & OPTION_MASK_PCREL) == 0) + rs6000_isa_flags |= OPTION_MASK_PCREL; +#endif + /* -mpcrel requires -mcmodel=medium, but we can't check TARGET_CMODEL until after the subtarget override options are done. */ if (TARGET_PCREL && TARGET_CMODEL != CMODEL_MEDIUM) -- Michael Meissner, IBM IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797