Replace MIPS_MARCH_CONTROLS_SOFT_FLOAT with driver specs

Richard Sandiford richard@codesourcery.com
Mon Sep 10 16:05:00 GMT 2007


The mips64vr*-elf and mips*-sde-elf configurations define a macro called
MIPS_MARCH_CONTROLS_SOFT_FLOAT.  As its name suggests, the macro uses
the -march setting to choose between -mhard-float and -msoft-float when
neither option is explicitly given.  However, the effect of the macro is
local to the compiler proper, so:

    mipsisa32-sde-elf -march=4kc

generates soft-float code but links against hard-float multilibs.

With ABI-sensitive options like -mhard-float and -msoft-float, it seems
better to work out the default in DRIVER_SELF_SPECS instead.  Then every
tool that cares can see what the float setting is, and the driver can use
it to pick the right multilibs.  The only drawback I can think of is that
these specs don't work when more than one -march option is specified on
the command line.  However, several other things also fall down in that
situation, including multilib selection, and the assembler actually warns
when two -march options are used.  So it's not a new restriction.

Regression-tested on mipsisa32r2-sde-elf.  Also tested by building
mips64vrel-elf and making sure that the -march options added the
right -m*-float option.  Applied to mainline.

Richard


gcc/
	* config/mips/mips.h (MIPS_ARCH_FLOAT_SPEC): New macro.
	* config/mips/mips.c (mips_cpu_info_table): Mention it in the
	the introductory comment.
	(MIPS_MARCH_CONTROLS_SOFT_FLOAT): Delete.
	(override_options): Don't test for it.
	* config/mips/sde.h (MIPS_MARCH_CONTROLS_SOFT_FLOAT): Delete.
	(DRIVER_SELF_SPECS): Add MIPS_ARCH_FLOAT_SPEC.
	* config/mips/vr.h: As for config/mips/sde.h.

Index: gcc/config/mips/mips.h
===================================================================
--- gcc/config/mips/mips.h	2007-09-08 06:55:31.000000000 -0700
+++ gcc/config/mips/mips.h	2007-09-10 07:33:34.000000000 -0700
@@ -658,6 +658,16 @@ #define MIPS_ISA_LEVEL_SPEC \
      %{march=mips64|march=5k*|march=20k*|march=sb1*|march=sr71000: -mips64} \
      %{!march=*: -" MULTILIB_ISA_DEFAULT "}}"
 
+/* A spec that infers a -mhard-float or -msoft-float setting from an
+   -march argument.  It should only be used for configurations that
+   have hard- and soft-float multilibs.  */
+
+#define MIPS_ARCH_FLOAT_SPEC \
+  "%{mhard-float|msoft-float|march=mips*:; \
+     march=vr41*|march=m4k|march=4k*|march=24kc|march=24kec \
+     |march=34kc|march=74kc|march=5kc: -msoft-float; \
+     march=*: -mhard-float}"
+
 /* A spec condition that matches 32-bit options.  It only works if
    MIPS_ISA_LEVEL_SPEC has been applied.  */
 
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2007-09-08 06:55:33.000000000 -0700
+++ gcc/config/mips/mips.c	2007-09-08 06:55:33.000000000 -0700
@@ -740,9 +740,10 @@ const struct attribute_spec mips_attribu
    matched in the order listed.  The first mention of an ISA level is
    taken as the canonical name for that ISA.
 
-   To ease comparison, please keep this table in the same order as
-   gas's mips_cpu_info_table[].  Please also make sure that
-   MIPS_ISA_LEVEL_SPEC handles all -march options correctly.  */
+   To ease comparison, please keep this table in the same order
+   as gas's mips_cpu_info_table[].  Please also make sure that
+   MIPS_ISA_LEVEL_SPEC and MIPS_ARCH_FLOAT_SPEC handle all -march
+   options correctly.  */
 const struct mips_cpu_info mips_cpu_info_table[] = {
   /* Entries for generic ISAs */
   { "mips1", PROCESSOR_R3000, 1 },
@@ -1216,12 +1217,6 @@ static const unsigned char mips16e_save_
   31, 30, 23, 22, 21, 20, 19, 18, 17, 16, 7, 6, 5, 4
 };
 
-/* Nonzero if -march should decide the default value of
-   MASK_SOFT_FLOAT_ABI.  */
-#ifndef MIPS_MARCH_CONTROLS_SOFT_FLOAT
-#define MIPS_MARCH_CONTROLS_SOFT_FLOAT 0
-#endif
-
 /* Initialize the GCC target structure.  */
 #undef TARGET_ASM_ALIGNED_HI_OP
 #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
@@ -5858,26 +5853,6 @@ override_options (void)
 	target_flags &= ~MASK_LONG64;
     }
 
-  if (MIPS_MARCH_CONTROLS_SOFT_FLOAT
-      && (target_flags_explicit & MASK_SOFT_FLOAT_ABI) == 0)
-    {
-      /* For some configurations, it is useful to have -march control
-	 the default setting of MASK_SOFT_FLOAT_ABI.  */
-      switch ((int) mips_arch)
-	{
-	case PROCESSOR_R4100:
-	case PROCESSOR_R4111:
-	case PROCESSOR_R4120:
-	case PROCESSOR_R4130:
-	  target_flags |= MASK_SOFT_FLOAT_ABI;
-	  break;
-
-	default:
-	  target_flags &= ~MASK_SOFT_FLOAT_ABI;
-	  break;
-	}
-    }
-
   if (!TARGET_OLDABI)
     flag_pcc_struct_return = 0;
 
Index: gcc/config/mips/sde.h
===================================================================
--- gcc/config/mips/sde.h	2007-09-08 01:48:10.000000000 -0700
+++ gcc/config/mips/sde.h	2007-09-08 06:55:33.000000000 -0700
@@ -20,15 +20,15 @@ the Free Software Foundation; either ver
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Let the -march option set soft-float.  */
-#define MIPS_MARCH_CONTROLS_SOFT_FLOAT 1
-
 #define DRIVER_SELF_SPECS						\
   /* Make sure a -mips option is present.  This helps us to pick	\
      the right multilib, and also makes the later specs easier		\
      to write.  */							\
   MIPS_ISA_LEVEL_SPEC,							\
 									\
+  /* Infer the default float setting from -march.  */			\
+  MIPS_ARCH_FLOAT_SPEC,							\
+									\
   /* If no ABI option is specified, infer one from the ISA level	\
      or -mgp setting.  */						\
   "%{!mabi=*: %{" MIPS_32BIT_OPTION_SPEC ": -mabi=32;: -mabi=n32}}",	\
Index: gcc/config/mips/vr.h
===================================================================
--- gcc/config/mips/vr.h	2007-09-08 01:48:10.000000000 -0700
+++ gcc/config/mips/vr.h	2007-09-10 07:35:20.000000000 -0700
@@ -21,7 +21,6 @@ the Free Software Foundation; either ver
 
 #define DEFAULT_VR_ARCH "mfix-vr4130"
 #define MIPS_ABI_DEFAULT ABI_EABI
-#define MIPS_MARCH_CONTROLS_SOFT_FLOAT 1
 #define MULTILIB_DEFAULTS \
 	{ MULTILIB_ENDIAN_DEFAULT,		\
 	  MULTILIB_ABI_DEFAULT,			\
@@ -41,6 +40,9 @@ #define DRIVER_SELF_SPECS \
 	/* Same idea for -mfix-vr4130.  */				\
 	"%{mfix-vr4130:%{!march=*:-march=vr4130}}",			\
 									\
+	/* Infer the default float setting from -march.  */		\
+	MIPS_ARCH_FLOAT_SPEC,						\
+									\
 	/* Make -mabi=eabi -mlong32 the default.  */			\
 	"%{!mabi=*:-mabi=eabi %{!mlong*:-mlong32}}",			\
 									\



More information about the Gcc-patches mailing list