diff mbox series

[RS6000] Make assembler command line cpu match default for gcc

Message ID 20190727052623.GP3379@bubble.grove.modra.org
State New
Headers show
Series [RS6000] Make assembler command line cpu match default for gcc | expand

Commit Message

Alan Modra July 27, 2019, 5:26 a.m. UTC
When gcc is configured using --with-cpu=<cpu>, the specified cpu
effectively becomes a default -mcpu=<cpu> passed to gcc.  This then
affects the cpu passed to gas via ASM_CPU_SPEC.  If gcc is not
configured using --with-cpu then the cpu passed to gas is that given
by ASM_DEFAULT_SPEC, which currently does not match the default flags
selected in default64.h.  This patch makes ASM_DEFAULT_SPEC agree with
TARGET_DEFAULT flags.

rs6000/default64.h appears in three places in config.gcc, the first
one immediately followed by rs6000/freebsd64.h in $tm_file, and the
other two immediately followed by rs6000/linux64.h.  To be able to
define ASM_DEFAULT_SPEC in rs6000/default64.h we don't want to
redefine in the other two files.  rs6000/freebsd64.h is easy since
that file is always preceded by rs6000/default64.h, but
rs6000/linux64.h can appear without rs6000/default64.h (a
powerpc*-linux config where the default is -m32).  In that case we
will have TARGET_DEFAULT flags of 0 (from rs6000/sysv4.h) and want to
use -mppc without -m64 and -mppc64 with -m64.  This can be done by
using the rs6000/rtems.h ASM_DEFAULT_SPEC in rs6000/sysv4.h, a change
that won't affect sysv4 configurations where -m64 is invalid.

The patch also introduces ASM_DEFAULT_EXTRA for the altivec variant
targets so as to enable -maltivec by default.

Bootstrapped and regression tested powerpc64le-linux, and a number of
powerpc variants built to inspect flags passed to the assembler.  OK
for mainline?

	PR target/91050
	* config/rs6000/sysv4.h (ASM_DEFAULT_SPEC): Modify if -m64.
	* config/rs6000/default64.h (ASM_DEFAULT_SPEC): Define.
	* config/rs6000/freebsd64.h (ASM_DEFAULT_SPEC): Don't define.
	* config/rs6000/linux64.h (ASM_DEFAULT_SPEC): Likewise.
	* config/rs6000/rtems.h (ASM_DEFAULT_SPEC): Likewise.
	* config/rs6000/rs6000.h (ASM_DEFAULT_EXTRA): Define and use
	in asm_default spec.
	* config/rs6000/eabialtivec.h (ASM_DEFAULT_EXTRA): Redefine.
	* config/rs6000/linuxaltivec.h (ASM_DEFAULT_EXTRA): Redefine.

Comments

Segher Boessenkool July 27, 2019, 6:22 p.m. UTC | #1
Hi Alan,

Thank you for doing this!

On Sat, Jul 27, 2019 at 02:56:23PM +0930, Alan Modra wrote:
> The patch also introduces ASM_DEFAULT_EXTRA for the altivec variant
> targets so as to enable -maltivec by default.

That is a behaviour change I think?  I don't know if it is correct...
It doesn't by default use -mabi=altivec as well, for example?

> Bootstrapped and regression tested powerpc64le-linux, and a number of
> powerpc variants built to inspect flags passed to the assembler.  OK
> for mainline?

Did you try with those *altivec targets as well?  Well I guess you did,
or why else did you do this change?

In general it isn't great that we have these target configs that no one
ever tests, or *can* test properly.  Ugh.

The patch is okay for trunk.  Thanks!


Segher
Alan Modra July 28, 2019, 9:31 a.m. UTC | #2
On Sat, Jul 27, 2019 at 01:22:57PM -0500, Segher Boessenkool wrote:
> On Sat, Jul 27, 2019 at 02:56:23PM +0930, Alan Modra wrote:
> > The patch also introduces ASM_DEFAULT_EXTRA for the altivec variant
> > targets so as to enable -maltivec by default.
> 
> That is a behaviour change I think?  I don't know if it is correct...

This -maltivec is the one passed to the assembler, so no real gcc
behaviour change.

> It doesn't by default use -mabi=altivec as well, for example?
> 
> > Bootstrapped and regression tested powerpc64le-linux, and a number of
> > powerpc variants built to inspect flags passed to the assembler.  OK
> > for mainline?
> 
> Did you try with those *altivec targets as well?  Well I guess you did,
> or why else did you do this change?

Actually I spotted the need for a fix by grepping over the sources,
but I did build a powerpc-linuxaltivec target.
Segher Boessenkool July 28, 2019, 10:44 a.m. UTC | #3
On Sun, Jul 28, 2019 at 07:01:32PM +0930, Alan Modra wrote:
> On Sat, Jul 27, 2019 at 01:22:57PM -0500, Segher Boessenkool wrote:
> > On Sat, Jul 27, 2019 at 02:56:23PM +0930, Alan Modra wrote:
> > > The patch also introduces ASM_DEFAULT_EXTRA for the altivec variant
> > > targets so as to enable -maltivec by default.
> > 
> > That is a behaviour change I think?  I don't know if it is correct...
> 
> This -maltivec is the one passed to the assembler, so no real gcc
> behaviour change.

Ah oh right, that is fine then of course, and I need more coffee :-)

Thanks,


Segher
diff mbox series

Patch

diff --git a/gcc/config/rs6000/default64.h b/gcc/config/rs6000/default64.h
index 0cceefefa7b..10743fee796 100644
--- a/gcc/config/rs6000/default64.h
+++ b/gcc/config/rs6000/default64.h
@@ -25,7 +25,11 @@  along with GCC; see the file COPYING3.  If not see
 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT (ISA_2_7_MASKS_SERVER | MASK_POWERPC64 | MASK_64BIT | MASK_LITTLE_ENDIAN)
+#undef ASM_DEFAULT_SPEC
+#define ASM_DEFAULT_SPEC "-mpower8"
 #else
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT (MASK_PPC_GFXOPT | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64 | MASK_64BIT)
+#undef ASM_DEFAULT_SPEC
+#define ASM_DEFAULT_SPEC "-mpower4"
 #endif
diff --git a/gcc/config/rs6000/eabialtivec.h b/gcc/config/rs6000/eabialtivec.h
index 6a95f90bbc4..6daa92264ea 100644
--- a/gcc/config/rs6000/eabialtivec.h
+++ b/gcc/config/rs6000/eabialtivec.h
@@ -23,5 +23,8 @@ 
 #undef  TARGET_DEFAULT
 #define TARGET_DEFAULT (MASK_EABI | MASK_ALTIVEC)
 
+#undef	ASM_DEFAULT_EXTRA
+#define	ASM_DEFAULT_EXTRA " %{!mvsx:%{!maltivec:%{!no-maltivec:-maltivec}}}"
+
 #undef  SUBSUBTARGET_OVERRIDE_OPTIONS
 #define SUBSUBTARGET_OVERRIDE_OPTIONS	rs6000_altivec_abi = 1
diff --git a/gcc/config/rs6000/freebsd64.h b/gcc/config/rs6000/freebsd64.h
index 7e819d102f9..4951275c963 100644
--- a/gcc/config/rs6000/freebsd64.h
+++ b/gcc/config/rs6000/freebsd64.h
@@ -134,11 +134,9 @@  extern int dot_symbols;
     }								\
   while (0)
 
-#undef	ASM_DEFAULT_SPEC
 #undef	ASM_SPEC
 #undef	LINK_OS_FREEBSD_SPEC
 
-#define	ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
 #define	ASM_SPEC	 "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
 #define	LINK_OS_FREEBSD_SPEC "%{m32:%(link_os_freebsd_spec32)}%{!m32:%(link_os_freebsd_spec64)}"
 
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index bd197492cc2..ba5f640efc8 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -181,24 +181,20 @@  extern int dot_symbols;
     }								\
   while (0)
 
-#undef	ASM_DEFAULT_SPEC
 #undef	ASM_SPEC
 #undef	LINK_OS_LINUX_SPEC
 #undef	LINK_SECURE_PLT_SPEC
 
 #ifndef	RS6000_BI_ARCH
-#define	ASM_DEFAULT_SPEC "-mppc64"
 #define	ASM_SPEC	 "%(asm_spec64) %(asm_spec_common)"
 #define	LINK_OS_LINUX_SPEC "%(link_os_linux_spec64)"
 #define	LINK_SECURE_PLT_SPEC ""
 #else
 #if DEFAULT_ARCH64_P
-#define	ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
 #define	ASM_SPEC	 "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
 #define	LINK_OS_LINUX_SPEC "%{m32:%(link_os_linux_spec32)}%{!m32:%(link_os_linux_spec64)}"
 #define	LINK_SECURE_PLT_SPEC "%{m32: " LINK_SECURE_PLT_DEFAULT_SPEC "}"
 #else
-#define	ASM_DEFAULT_SPEC "-mppc%{m64:64}"
 #define	ASM_SPEC	 "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
 #define	LINK_OS_LINUX_SPEC "%{!m64:%(link_os_linux_spec32)}%{m64:%(link_os_linux_spec64)}"
 #define	LINK_SECURE_PLT_SPEC "%{!m64: " LINK_SECURE_PLT_DEFAULT_SPEC "}"
diff --git a/gcc/config/rs6000/linuxaltivec.h b/gcc/config/rs6000/linuxaltivec.h
index 0f3e24f1041..8578f42763a 100644
--- a/gcc/config/rs6000/linuxaltivec.h
+++ b/gcc/config/rs6000/linuxaltivec.h
@@ -28,5 +28,8 @@ 
 #define	TARGET_DEFAULT MASK_ALTIVEC
 #endif
 
+#undef	ASM_DEFAULT_EXTRA
+#define	ASM_DEFAULT_EXTRA " %{!mvsx:%{!maltivec:%{!mno-altivec:-maltivec}}}"
+
 #undef  SUBSUBTARGET_OVERRIDE_OPTIONS
 #define SUBSUBTARGET_OVERRIDE_OPTIONS rs6000_altivec_abi = 1
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 70e0616ee85..6c24b48a9ab 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -157,6 +157,7 @@  ASM_OPT_ANY
 #define CPP_DEFAULT_SPEC ""
 
 #define ASM_DEFAULT_SPEC ""
+#define ASM_DEFAULT_EXTRA ""
 
 /* This macro defines names of additional specifications to put in the specs
    that can be used in various specifications like CC1_SPEC.  Its definition
@@ -174,7 +175,7 @@  ASM_OPT_ANY
   { "cpp_default",		CPP_DEFAULT_SPEC },			\
   { "asm_cpu",			ASM_CPU_SPEC },				\
   { "asm_cpu_native",		ASM_CPU_NATIVE_SPEC },			\
-  { "asm_default",		ASM_DEFAULT_SPEC },			\
+  { "asm_default",		ASM_DEFAULT_SPEC ASM_DEFAULT_EXTRA },	\
   { "cc1_cpu",			CC1_CPU_SPEC },				\
   SUBTARGET_EXTRA_SPECS
 
diff --git a/gcc/config/rs6000/rtems.h b/gcc/config/rs6000/rtems.h
index 401077d8057..0c198020a42 100644
--- a/gcc/config/rs6000/rtems.h
+++ b/gcc/config/rs6000/rtems.h
@@ -254,9 +254,6 @@ 
 %{mcpu=8540: %{!Dppc*: %{!Dmpc*: -Dppc8540}  } } \
 %{mcpu=e6500: -D__PPC_CPU_E6500__}"
 
-#undef	ASM_DEFAULT_SPEC
-#define	ASM_DEFAULT_SPEC "-mppc%{m64:64}"
-
 #undef	ASM_SPEC
 #define	ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
 
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index 17fea80a0a5..4645ef3b21e 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -39,7 +39,7 @@ 
 
 /* Override rs6000.h definition.  */
 #undef	ASM_DEFAULT_SPEC
-#define	ASM_DEFAULT_SPEC "-mppc"
+#define	ASM_DEFAULT_SPEC "-mppc%{m64:64}"
 
 #define	TARGET_HAS_TOC		(TARGET_64BIT				\
 				 || (TARGET_MINIMAL_TOC			\