diff options
author | Michael Meissner <2019-02-12 Michael Meissner meissner@linux.ibm.com> | 2020-04-25 02:43:10 -0400 |
---|---|---|
committer | Michael Meissner <2019-02-12 Michael Meissner meissner@linux.ibm.com> | 2020-04-25 02:43:10 -0400 |
commit | da4aae6e16f2755161b148d110edbf8ed8589acc (patch) | |
tree | 79f3974cc50dba7ad4fb082d3b21d80225f5ee3d | |
parent | 352811870d7d7edcca109ef50822e26ca7ef2b36 (diff) | |
download | gcc-da4aae6e16f2755161b148d110edbf8ed8589acc.zip gcc-da4aae6e16f2755161b148d110edbf8ed8589acc.tar.gz gcc-da4aae6e16f2755161b148d110edbf8ed8589acc.tar.bz2 |
Turn on -mpcrel by default for -mcpu=future
2020-04-25 Michael Meissner <meissner@linux.ibm.com>
* config/rs6000/linux64.h (PCREL_SUPPORTED_BY_OS): Define to
enable PC-relative addressing for -mcpu=future.
* config/rs6000/rs6000-cpus.def (ISA_FUTURE_MASKS_SERVER): Move
after OTHER_FUTURE_MASKS. Use OTHER_FUTURE_MASKS.
* config/rs6000/rs6000.c (PCREL_SUPPORTED_BY_OS): If not defined,
suppress PC-relative addressing.
(rs6000_option_override_internal): Split up error messages
checking for -mprefixed and -mpcrel. Enable -mpcrel if the target
system supports it.
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/config/rs6000/linux64.h | 7 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000-cpus.def | 11 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 28 |
4 files changed, 45 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3c0d67b..3d91fcd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2020-04-25 Michael Meissner <meissner@linux.ibm.com> + + * config/rs6000/linux64.h (PCREL_SUPPORTED_BY_OS): Define to + enable PC-relative addressing for -mcpu=future. + * config/rs6000/rs6000-cpus.def (ISA_FUTURE_MASKS_SERVER): Move + after OTHER_FUTURE_MASKS. Use OTHER_FUTURE_MASKS. + * config/rs6000/rs6000.c (PCREL_SUPPORTED_BY_OS): If not defined, + suppress PC-relative addressing. + (rs6000_option_override_internal): Split up error messages + checking for -mprefixed and -mpcrel. Enable -mpcrel if the target + system supports it. + 2020-04-25 Jakub Jelinek <jakub@redhat.com> Richard Biener <rguenther@suse.de> diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 11911c4..34776c8 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -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) diff --git a/gcc/config/rs6000/rs6000-cpus.def b/gcc/config/rs6000/rs6000-cpus.def index ff1db60..83362e0 100644 --- a/gcc/config/rs6000/rs6000-cpus.def +++ b/gcc/config/rs6000/rs6000-cpus.def @@ -75,16 +75,15 @@ | OPTION_MASK_P8_VECTOR \ | OPTION_MASK_P9_VECTOR) -/* Support for a future processor's features. Do not enable -mpcrel until it - is fully functional. */ -#define ISA_FUTURE_MASKS_SERVER (ISA_3_0_MASKS_SERVER \ - | OPTION_MASK_FUTURE \ - | OPTION_MASK_PREFIXED) - /* Flags that need to be turned off if -mno-future. */ #define OTHER_FUTURE_MASKS (OPTION_MASK_PCREL \ | OPTION_MASK_PREFIXED) +/* Support for a future processor's features. */ +#define ISA_FUTURE_MASKS_SERVER (ISA_3_0_MASKS_SERVER \ + | OPTION_MASK_FUTURE \ + | OTHER_FUTURE_MASKS) + /* Flags that need to be turned off if -mno-power9-vector. */ #define OTHER_P9_VECTOR_MASKS (OPTION_MASK_FLOAT128_HW \ | OPTION_MASK_P9_MINMAX) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index a2992e6..aa632ea 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -98,6 +98,11 @@ #endif #endif +/* Don't enable PC-relative addressing if the target does not support it. */ +#ifndef PCREL_SUPPORTED_BY_OS +#define PCREL_SUPPORTED_BY_OS 0 +#endif + /* Support targetm.vectorize.builtin_mask_for_load. */ tree altivec_builtin_mask_for_load; @@ -4024,15 +4029,17 @@ rs6000_option_override_internal (bool global_init_p) rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW; } - /* -mprefixed (and hence -mpcrel) requires -mcpu=future. */ - if (TARGET_PREFIXED && !TARGET_FUTURE) + /* Enable -mprefixed by default on 'future' systems. */ + if (TARGET_FUTURE && (rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) == 0) + rs6000_isa_flags |= OPTION_MASK_PREFIXED; + + /* -mprefixed requires -mcpu=future. */ + else if (TARGET_PREFIXED && !TARGET_FUTURE) { - if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0) - error ("%qs requires %qs", "-mpcrel", "-mcpu=future"); - else if ((rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) != 0) + if ((rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) != 0) error ("%qs requires %qs", "-mprefixed", "-mcpu=future"); - rs6000_isa_flags &= ~(OPTION_MASK_PCREL | OPTION_MASK_PREFIXED); + rs6000_isa_flags &= ~OPTION_MASK_PREFIXED; } /* -mpcrel requires prefixed load/store addressing. */ @@ -4175,9 +4182,16 @@ rs6000_option_override_internal (bool global_init_p) SUB3TARGET_OVERRIDE_OPTIONS; #endif + /* If the ABI has support for PC-relative relocations, enable it by default. + This test depends on the sub-target tests above setting the code model to + medium for ELF v2 systems. */ + if (PCREL_SUPPORTED_BY_OS + && (rs6000_isa_flags_explicit & OPTION_MASK_PCREL) == 0) + rs6000_isa_flags |= OPTION_MASK_PCREL; + /* -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) + else if (TARGET_PCREL && TARGET_CMODEL != CMODEL_MEDIUM) { if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0) error ("%qs requires %qs", "-mpcrel", "-mcmodel=medium"); |