This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [SPARC] Support for --with-{cpu,tune}-{32,64} in sparc*-* targets
- From: jose dot marchesi at oracle dot com (Jose E. Marchesi)
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 25 May 2016 20:44:04 +0200
- Subject: Re: [SPARC] Support for --with-{cpu,tune}-{32,64} in sparc*-* targets
- Authentication-results: sourceware.org; auth=none
- References: <8760uwwd7v dot fsf at oracle dot com> <2152793 dot aoeKpf2VKk at polaris>
> This patch adds support for the --with-{cpu,tune}-{32,64} configure
> options to sparc*-* targets. This allows to separately select cpus and
> tune options for -m32 and -m64 modes in multilib compilers.
SPARC/Linux is not the only SPARC target though. :-)
Nope :)
> Tested in sparc64-*-* and sparcv9-*-* targets.
>
> 2016-04-28 Jose E. Marchesi <jose.marchesi@oracle.com>
>
> * config.gcc (sparc*-*-*): Support cpu_32, cpu_64, tune_32 and
> tune_64.
> * doc/install.texi (--with-cpu-32, --with-cpu-64): Document
> support on SPARC.
> * config/sparc/linux64.h (OPTION_DEFAULT_SPECS): Add entries for
> cpu_32, cpu_64, tune_32 and tune_64.
Thanks, but we need at least the same change in config/sparc/sol2.h (and
possibly other files which cloned sol2.h like linux64.h).
The patch below has been extended to cover targets using
config/sparc/sol2.h.
Now --with-{cpu,tune}-{32,64} are honored in all the biarch targets
(sparc64-*-linux-gnu, sparcv9-*-linux-gnu, sparc*-sun-solaris2*)
targets.
The options are however ignored in the targets not supporting biarch,
such as sparc, sparclite or leon.
Tested in sparc64-linux-gnu, sparcv9-linux-gnu and sparc-sun-solaris2.11.
2016-05-25 Jose E. Marchesi <jose.marchesi@oracle.com>
* config.gcc (sparc*-*-*): Support cpu_32, cpu_64, tune_32 and
tune_64.
* doc/install.texi (--with-cpu-32, --with-cpu-64): Document
support on SPARC.
* config/sparc/linux64.h (OPTION_DEFAULT_SPECS): Add entries for
cpu_32, cpu_64, tune_32 and tune_64.
* config/sparc/sol2.h (OPTION_DEFAULT_SPECS): Likewise.
diff --git a/gcc/config.gcc b/gcc/config.gcc
index f66e48c..e4bf17a 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4280,9 +4280,9 @@ case "${target}" in
esac
;;
sparc*-*-*)
- supported_defaults="cpu float tune"
+ supported_defaults="cpu cpu_32 cpu_64 float tune tune_32 tune_64"
- for which in cpu tune; do
+ for which in cpu cpu_32 cpu_64 tune tune_32 tune_64; do
eval "val=\$with_$which"
case ${val} in
"" | sparc | sparcv9 | sparc64 \
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index a1ef325..9d53c29 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -164,22 +164,42 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
#endif
/* Support for a compile-time default CPU, et cetera. The rules are:
- --with-cpu is ignored if -mcpu is specified.
- --with-tune is ignored if -mtune is specified.
+ --with-cpu is ignored if -mcpu is specified; likewise --with-cpu-32
+ and --with-cpu-64.
+ --with-tune is ignored if -mtune is specified; likewise --with-tune-32
+ and --with-tune-64.
--with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
are specified.
In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
here, otherwise say -mcpu=v7 would be passed even when -m64.
- CC1_SPEC above takes care of this instead. */
+ CC1_SPEC above takes care of this instead.
+
+ Note that the order of the cpu* and tune* options matters: the
+ config.gcc file always sets with_cpu to some value, even if the
+ user didn't use --with-cpu when invoking the configure script.
+ This value is based on the target name. Therefore we have to make
+ sure that --with-cpu-32 takes precedence to --with-cpu in < v9
+ systems, and that --with-cpu-64 takes precedence to --with-cpu in
+ >= v9 systems. As for the tune* options, in some platforms
+ config.gcc also sets a default value for it if the user didn't use
+ --with-tune when invoking the configure script. */
#undef OPTION_DEFAULT_SPECS
#if DEFAULT_ARCH32_P
#define OPTION_DEFAULT_SPECS \
+ {"cpu_32", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
+ {"cpu_64", "%{m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
{"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
+ {"tune_32", "%{!m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
+ {"tune_64", "%{m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
{"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
{"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
#else
#define OPTION_DEFAULT_SPECS \
+ {"cpu_32", "%{m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
+ {"cpu_64", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
{"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
+ {"tune_32", "%{m32:%{!mtune=*:-mtune=%(VALUE)}}" }, \
+ {"tune_64", "%{!m32:%{!mtune=*:-mtune=%(VALUE)}}" }, \
{"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
{"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
#endif
diff --git a/gcc/config/sparc/sol2.h b/gcc/config/sparc/sol2.h
index 07e6368..a54e1ec 100644
--- a/gcc/config/sparc/sol2.h
+++ b/gcc/config/sparc/sol2.h
@@ -231,22 +231,42 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
#endif
/* Support for a compile-time default CPU, et cetera. The rules are:
- --with-cpu is ignored if -mcpu is specified.
- --with-tune is ignored if -mtune is specified.
+ --with-cpu is ignored if -mcpu is specified; likewise --with-cpu-32
+ and --with-cpu-64.
+ --with-tune is ignored if -mtune is specified; likewise --with-tune-32
+ and --with-tune-64.
--with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
are specified.
In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
here, otherwise say -mcpu=v7 would be passed even when -m64.
- CC1_SPEC above takes care of this instead. */
+ CC1_SPEC above takes care of this instead.
+
+ Note that the order of the cpu* and tune* options matters: the
+ config.gcc file always sets with_cpu to some value, even if the
+ user didn't use --with-cpu when invoking the configure script.
+ This value is based on the target name. Therefore we have to make
+ sure that --with-cpu-32 takes precedence to --with-cpu in < v9
+ systems, and that --with-cpu-64 takes precedence to --with-cpu in
+ >= v9 systems. As for the tune* options, in some platforms
+ config.gcc also sets a default value for it if the user didn't use
+ --with-tune when invoking the configure script. */
#undef OPTION_DEFAULT_SPECS
#if DEFAULT_ARCH32_P
#define OPTION_DEFAULT_SPECS \
+ {"cpu_32", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
+ {"cpu_64", "%{m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
{"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
+ {"tune_32", "%{!m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
+ {"tune_64", "%{m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
{"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
{"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
#else
#define OPTION_DEFAULT_SPECS \
+ {"cpu_32", "%{m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
+ {"cpu_64", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
{"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
+ {"tune_32", "%{m32:%{!mtune=*:-mtune=%(VALUE)}}" }, \
+ {"tune_64", "%{!m32:%{!mtune=*:-mtune=%(VALUE)}}" }, \
{"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
{"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
#endif
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index e1ca26c..ee2494e 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1241,7 +1241,7 @@ This option is only supported on some targets, including ARC, ARM, i386, M68k,
PowerPC, and SPARC@. It is mandatory for ARC@. The @option{--with-cpu-32} and
@option{--with-cpu-64} options specify separate default CPUs for
32-bit and 64-bit modes; these options are only supported for i386,
-x86-64 and PowerPC.
+x86-64, PowerPC, and SPARC@.
@item --with-schedule=@var{cpu}
@itemx --with-arch=@var{cpu}