This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[arm] Rework soft-float flags


The attached patch reworks how the arm backend handles the 
soft-float/hard-float abi commandline options. The main aim is to allow 
subtargets to default to the "softfp" abi (ie. soft-float calling convention 
using hardware fp instructions).

Tested on arm-none-elf and checked that arm-linux still has the correct 
default.
Does this seem an ok way of doing things?

In particular I'm not sure if it's best to use TARGET_OPTIONS or add another 
flag for TARGET_SWITCHES.  I chose TARGET_OPTIONS because then it's obvious 
that it's just a commandline switch, and arm_float_abi should be used to 
determine the ABI in use.

Paul

2004-11-18  Paul Brook  <paul@codesourcery.com>

 * config/arm/arm.c (target_float_switch): New variable..
 (arm_override_options): Use TARGET_DEFAULT_FLOAT_ABI and
 target_float_switch.
 * config/arm/arm.h (target_float_switch): Declare.
 (ARM_FLAG_SOFT_FLOAT): Remove.
 (TARGET_SWITCHES): Remove hard-float and soft-float.
 (TARGET_OPTIONS): Add hard-float and soft-float.
 (TARGET_DEFAULT_FLOAT_ABI): Define.
 * config/arm/coff.h (TARGET_DEFAULT_FLOAT_ABI): Define
 (TARGET_DEFAULT): Don't set ARM_FLAG_SOFT_FLOAT.
 * config/arm/elf.h: Ditto.
 * config/arm/linux-elf.h: Ditto.
 * config/arm/netbsd-elf.h: Ditto.
 * config/arm/netbsd.h: Ditto.
 * config/arm/pe.h: Ditto.
 * config/arm/semi.h: Ditto.
 * config/arm/semiaof.h: Ditto.
 * config/arm/uclinux-elf.h: Ditto.
 * config/arm/unknown-elf.h: Ditto.
 * config/arm/wince-pe.h: Ditto.
Index: config/arm/arm.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.303.2.64
diff -u -p -r1.303.2.64 arm.c
--- config/arm/arm.c	16 Nov 2004 15:48:21 -0000	1.303.2.64
+++ config/arm/arm.c	18 Nov 2004 13:28:34 -0000
@@ -357,6 +357,9 @@ const char * target_fpe_name = NULL;
 /* Set by the -mfloat-abi=... option.  */
 const char * target_float_abi_name = NULL;
 
+/* Set by the legacy -mhard-float and -msoft-float options.  */
+const char * target_float_switch = NULL;
+
 /* Set by the -mabi=... option.  */
 const char * target_abi_name = NULL;
 
@@ -1067,14 +1070,16 @@ arm_override_options (void)
 	error ("invalid floating point abi: -mfloat-abi=%s",
 	       target_float_abi_name);
     }
-  else
+  else if (target_float_switch)
     {
-      /* Use soft-float target flag.  */
-      if (target_flags & ARM_FLAG_SOFT_FLOAT)
-	arm_float_abi = ARM_FLOAT_ABI_SOFT;
-      else
+      /* This is a bit of a hack to avoid needing target flags for these.  */
+      if (target_float_switch[1] == 'h')
 	arm_float_abi = ARM_FLOAT_ABI_HARD;
+      else
+	arm_float_abi = ARM_FLOAT_ABI_SOFT;
     }
+  else
+    arm_float_abi = TARGET_DEFAULT_FLOAT_ABI;
 
   if (arm_float_abi == ARM_FLOAT_ABI_HARD && TARGET_VFP)
     sorry ("-mfloat-abi=hard and VFP");
Index: config/arm/arm.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/arm.h,v
retrieving revision 1.210.2.45
diff -u -p -r1.210.2.45 arm.h
--- config/arm/arm.h	1 Oct 2004 18:20:13 -0000	1.210.2.45
+++ config/arm/arm.h	18 Nov 2004 13:28:34 -0000
@@ -125,6 +125,8 @@ extern const char *target_fpu_name;
 extern const char *target_fpe_name;
 /* Whether to use floating point hardware.  */
 extern const char *target_float_abi_name;
+/* For -m{soft,hard}-float.  */
+extern const char *target_float_switch;
 /* Which ABI to use.  */
 extern const char *target_abi_name;
 /* Define the information needed to generate branch insns.  This is
@@ -211,9 +213,7 @@ extern GTY(()) rtx aof_pic_label;
 #define ARM_FLAG_APCS_REENT	(1 << 6)
 
   /* FLAG 0x0080 now spare (used to be alignment traps).  */
-/* Nonzero if all floating point instructions are missing (and there is no
-   emulator either).  Generate function calls for all ops in this case.  */
-#define ARM_FLAG_SOFT_FLOAT	(1 << 8)
+  /* FLAG (1 << 8) is now spare (used to be soft-float).  */
 
 /* Nonzero if we should compile with BYTES_BIG_ENDIAN set to 1.  */
 #define ARM_FLAG_BIG_END	(1 << 9)
@@ -328,10 +328,6 @@ extern GTY(()) rtx aof_pic_label;
   {"apcs-reentrant",		ARM_FLAG_APCS_REENT,			\
    N_("Generate re-entrant, PIC code") },				\
   {"no-apcs-reentrant",	       -ARM_FLAG_APCS_REENT, "" },		\
-  {"soft-float",		ARM_FLAG_SOFT_FLOAT,			\
-   N_("Use library calls to perform FP operations") },			\
-  {"hard-float",	       -ARM_FLAG_SOFT_FLOAT,			\
-   N_("Use hardware floating point instructions") },			\
   {"big-endian",		ARM_FLAG_BIG_END,			\
    N_("Assume target CPU is configured as big endian") },		\
   {"little-endian",	       -ARM_FLAG_BIG_END,			\
@@ -396,7 +392,11 @@ extern GTY(()) rtx aof_pic_label;
    N_("Specify the minimum bit alignment of structures"), 0},		\
   {"pic-register=", & arm_pic_register_string,				\
    N_("Specify the register to be used for PIC addressing"), 0},	\
-  {"abi=", &target_abi_name, N_("Specify an ABI"), 0}			\
+  {"abi=", &target_abi_name, N_("Specify an ABI"), 0},			\
+  {"soft-float", &target_float_switch,					\
+   N_("Alias for -mfloat-abi=soft"), 0},				\
+  {"hard-float", &target_float_switch,					\
+   N_("Alias for -mfloat-abi=hard"), 0}					\
 }
 
 /* Support for a compile-time default CPU, et cetera.  The rules are:
@@ -480,6 +480,10 @@ enum float_abi_type
 
 extern enum float_abi_type arm_float_abi;
 
+#ifndef TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+#endif
+
 /* Which ABI to use.  */
 enum arm_abi_type
 {
Index: config/arm/coff.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/coff.h,v
retrieving revision 1.32.4.2
diff -u -p -r1.32.4.2 coff.h
--- config/arm/coff.h	15 May 2004 13:02:09 -0000	1.32.4.2
+++ config/arm/coff.h	18 Nov 2004 13:28:34 -0000
@@ -30,8 +30,11 @@
 #undef  TARGET_VERSION
 #define TARGET_VERSION fputs (" (ARM/coff)", stderr)
 
+#undef  TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
+
 #undef  TARGET_DEFAULT
-#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_FRAME)
+#define TARGET_DEFAULT (ARM_FLAG_APCS_FRAME)
 
 #ifndef MULTILIB_DEFAULTS
 #define MULTILIB_DEFAULTS \
Index: config/arm/elf.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/elf.h,v
retrieving revision 1.44.8.7
diff -u -p -r1.44.8.7 elf.h
--- config/arm/elf.h	27 Sep 2004 17:15:15 -0000	1.44.8.7
+++ config/arm/elf.h	18 Nov 2004 13:28:34 -0000
@@ -109,8 +109,12 @@
 #define TARGET_VERSION fputs (" (ARM/elf)", stderr)
 #endif
 
+#ifndef TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
+#endif
+
 #ifndef TARGET_DEFAULT
-#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_FRAME)
+#define TARGET_DEFAULT (ARM_FLAG_APCS_FRAME)
 #endif
 
 #ifndef MULTILIB_DEFAULTS
Index: config/arm/linux-elf.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/linux-elf.h,v
retrieving revision 1.41.4.5
diff -u -p -r1.41.4.5 linux-elf.h
--- config/arm/linux-elf.h	15 May 2004 13:02:09 -0000	1.41.4.5
+++ config/arm/linux-elf.h	18 Nov 2004 13:29:00 -0000
@@ -30,6 +30,9 @@
 /* Do not assume anything about header files.  */
 #define NO_IMPLICIT_EXTERN_C
 
+#undef  TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+
 #undef  TARGET_DEFAULT
 #define TARGET_DEFAULT (0)
 
Index: config/arm/netbsd-elf.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/netbsd-elf.h,v
retrieving revision 1.5.10.4
diff -u -p -r1.5.10.4 netbsd-elf.h
--- config/arm/netbsd-elf.h	15 May 2004 13:02:10 -0000	1.5.10.4
+++ config/arm/netbsd-elf.h	18 Nov 2004 13:28:34 -0000
@@ -33,10 +33,12 @@
 #undef MULTILIB_DEFAULTS
 
 /* Default it to use ATPCS with soft-VFP.  */
+#undef  TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
+
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT			\
-  (ARM_FLAG_SOFT_FLOAT			\
-   | ARM_FLAG_APCS_FRAME		\
+  (ARM_FLAG_APCS_FRAME			\
    | TARGET_ENDIAN_DEFAULT)
 
 #undef ARM_DEFAULT_ABI
Index: config/arm/netbsd.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/netbsd.h,v
retrieving revision 1.26.8.2
diff -u -p -r1.26.8.2 netbsd.h
--- config/arm/netbsd.h	15 May 2004 13:02:10 -0000	1.26.8.2
+++ config/arm/netbsd.h	18 Nov 2004 13:28:34 -0000
@@ -35,8 +35,11 @@
 /* ARM6 family default cpu.  */
 #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
 
+#undef  TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
+
 #undef TARGET_DEFAULT
-#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_FRAME)
+#define TARGET_DEFAULT (ARM_FLAG_APCS_FRAME)
 
 /* Some defines for CPP.
    arm32 is the NetBSD port name, so we always define arm32 and __arm32__.  */
Index: config/arm/pe.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/pe.h,v
retrieving revision 1.22.8.4
diff -u -p -r1.22.8.4 pe.h
--- config/arm/pe.h	17 Aug 2004 19:39:14 -0000	1.22.8.4
+++ config/arm/pe.h	18 Nov 2004 13:28:34 -0000
@@ -58,8 +58,11 @@
   N_("Ignore dllimport attribute for functions") },		\
 { "no-nop-fun-dllimport",	- TARGET_FLAG_NOP_FUN, "" },
 
+#undef  TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
+
 #undef  TARGET_DEFAULT
-#define TARGET_DEFAULT	(ARM_FLAG_SOFT_FLOAT | TARGET_FLAG_NOP_FUN)
+#define TARGET_DEFAULT	(TARGET_FLAG_NOP_FUN)
 
 #undef  MULTILIB_DEFAULTS
 #define MULTILIB_DEFAULTS \
Index: config/arm/semi.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/semi.h,v
retrieving revision 1.12.10.3
diff -u -p -r1.12.10.3 semi.h
--- config/arm/semi.h	15 May 2004 13:02:10 -0000	1.12.10.3
+++ config/arm/semi.h	18 Nov 2004 13:29:55 -0000
@@ -38,6 +38,10 @@
 #define TARGET_VERSION fputs (" (ARM/semi-hosted)", stderr);
 #endif
 
+#ifndef TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+#endif
+
 #ifndef TARGET_DEFAULT
 #define TARGET_DEFAULT (ARM_FLAG_APCS_FRAME)
 #endif
Index: config/arm/semiaof.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/semiaof.h,v
retrieving revision 1.7.14.2
diff -u -p -r1.7.14.2 semiaof.h
--- config/arm/semiaof.h	15 May 2004 13:02:10 -0000	1.7.14.2
+++ config/arm/semiaof.h	18 Nov 2004 13:29:40 -0000
@@ -32,6 +32,8 @@
 
 #define TARGET_VERSION fputs (" (ARM/semi-hosted)", stderr);
 
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+
 #define TARGET_DEFAULT (0)
 
 /* The Norcroft C library defines size_t as "unsigned int".  */
Index: config/arm/uclinux-elf.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/uclinux-elf.h,v
retrieving revision 1.5.14.1
diff -u -p -r1.5.14.1 uclinux-elf.h
--- config/arm/uclinux-elf.h	15 May 2004 13:02:10 -0000	1.5.14.1
+++ config/arm/uclinux-elf.h	18 Nov 2004 13:30:05 -0000
@@ -26,5 +26,8 @@
 #undef  TARGET_VERSION
 #define TARGET_VERSION fputs (" (ARM/ELF ucLinux)", stderr);
 
+#undef  TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+
 #undef  TARGET_DEFAULT
 #define TARGET_DEFAULT (ARM_FLAG_SINGLE_PIC_BASE)
Index: config/arm/unknown-elf.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/unknown-elf.h,v
retrieving revision 1.32.10.2
diff -u -p -r1.32.10.2 unknown-elf.h
--- config/arm/unknown-elf.h	15 May 2004 13:02:10 -0000	1.32.10.2
+++ config/arm/unknown-elf.h	18 Nov 2004 13:28:34 -0000
@@ -29,8 +29,12 @@
 #endif
 
 /* Default to using software floating point.  */
+#ifndef TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
+#endif
+
 #ifndef TARGET_DEFAULT
-#define TARGET_DEFAULT	(ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_FRAME)
+#define TARGET_DEFAULT	(ARM_FLAG_APCS_FRAME)
 #endif
 
 /* Now we define the strings used to build the spec file.  */
Index: config/arm/wince-pe.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/wince-pe.h,v
retrieving revision 1.1.16.2
diff -u -p -r1.1.16.2 wince-pe.h
--- config/arm/wince-pe.h	15 May 2004 13:02:10 -0000	1.1.16.2
+++ config/arm/wince-pe.h	18 Nov 2004 13:28:34 -0000
@@ -19,8 +19,11 @@
    the Free Software Foundation, 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#undef  TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
+
 #undef  TARGET_DEFAULT
-#define TARGET_DEFAULT	(ARM_FLAG_SOFT_FLOAT | TARGET_FLAG_NOP_FUN)
+#define TARGET_DEFAULT	(TARGET_FLAG_NOP_FUN)
 
 #undef  MULTILIB_DEFAULTS
 #define MULTILIB_DEFAULTS \

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]