rs6000: Rework option -mpowerpc64 handling [PR106680]
authorKewen Lin <linkw@linux.ibm.com>
Tue, 27 Dec 2022 10:13:07 +0000 (04:13 -0600)
committerKewen Lin <linkw@linux.ibm.com>
Tue, 27 Dec 2022 10:13:07 +0000 (04:13 -0600)
commitacc727cf02a1446dc00f8772f3f479fa3a508f8e
tree056d1cf5537f0950e84218fee25be122c05117c7
parente2acff49fb2962b921bf8b73984b89878b61492c
rs6000: Rework option -mpowerpc64 handling [PR106680]

PR106680 shows that -m32 -mpowerpc64 is different from
-mpowerpc64 -m32, this is determined by the way how we
handle option powerpc64 in rs6000_handle_option.

Segher pointed out this difference should be taken as
a bug and we should ensure that option powerpc64 is
independent of -m32/-m64.  So this patch removes the
handlings in rs6000_handle_option and add some necessary
supports in rs6000_option_override_internal instead.

With this patch, if users specify -m{no-,}powerpc64, the
specified value is honoured, otherwise, for 64bit it
always enables OPTION_MASK_POWERPC64; while for 32bit
and TARGET_POWERPC64 and OS_MISSING_POWERPC64, it disables
OPTION_MASK_POWERPC64.

btw, following Segher's suggestion, I did some tries to warn
when OPTION_MASK_POWERPC64 is set for OS_MISSING_POWERPC64.
If warn for the case that powerpc64 is specified explicitly,
there are some TCs using -m32 -mpowerpc64 on ppc64-linux,
they need some updates, meanwhile the artificial run
with "--target_board=unix'{-m32/-mpowerpc64}'" will have
noisy warnings on ppc64-linux.  If warn for the case that
it's specified implicitly, they can just be initialized by
TARGET_DEFAULT (like -m32 on ppc64-linux) or set from the
given cpu mask, we have to special case them and not to warn.
As Segher's latest comment, I decide not to warn them and
keep it consistent with before.

Bootstrapped and regress-tested on:
  - powerpc64-linux-gnu P7 and P8 {-m64,-m32}
  - powerpc64le-linux-gnu P9 and P10
  - powerpc-ibm-aix7.2.0.0 {-maix64,-maix32}
  - powerpc-darwin9 (with Iain's help)

PR target/106680

gcc/ChangeLog:

* common/config/rs6000/rs6000-common.cc (rs6000_handle_option): Remove
the adjustment for option powerpc64 in -m64 handling, and remove the
whole -m32 handling.
* config/rs6000/rs6000.cc (rs6000_option_override_internal): When no
explicit powerpc64 option is provided, enable it for -m64.  For 32 bit
and OS_MISSING_POWERPC64, disable powerpc64 if it's enabled but not
specified explicitly.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr106680-1.c: New test.
* gcc.target/powerpc/pr106680-2.c: New test.
* gcc.target/powerpc/pr106680-3.c: New test.
* gcc.target/powerpc/pr106680-4.c: New test.

2022-12-27  Kewen Lin  <linkw@linux.ibm.com>
    Iain Sandoe  <iain@sandoe.co.uk>
gcc/common/config/rs6000/rs6000-common.cc
gcc/config/rs6000/rs6000.cc
gcc/testsuite/gcc.target/powerpc/pr106680-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/pr106680-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/pr106680-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/pr106680-4.c [new file with mode: 0644]