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]

[PATCH, MIPS] .gnu.attribute support for sdemtk -mno-float


The mipsisa32r2-sdemtk-elf target supports a -mno-float option, which
disallows any FP operations.  It uses the -msoft-float ABI, and then
links with a library without the soft-float routines.  Since it doesn't
allow any FP operations, it is ABI compatible with all other ABIs with
respect to FP support.

The MIPS port uses .gnu.attribute 4,X to describe the FP ABI being used.
We need to emit 0 for the -mno-float option, to indicate that we can
link with any FP ABI.

I expanded the .gnu.attribute support and added some comments to make it
clearer what was going on.    Then added the SUBTARGET_AS_GNU_ATTRIBUTE
macro so that the sdemtk port can handle -mno-float.

This was tested with a mipsisa32r2-sde-elf build and testsuite run for C
and C++.  There were no regressions.  This was tested by hand on small
testcases to verify that I got the correct correct in all cases for both
the sde and sdemtk toolchains.

OK?

Jim

2010-04-23  James E. Wilson  <wilson@codesourcery.com>

	* config/mips/sdemtk.h: (SUBTARGET_AS_GNU_ATTRIBUTE): New.
	* config/mips/mips.c (mips_file_start): Call it.

Index: sdemtk.h
===================================================================
--- sdemtk.h	(revision 158495)
+++ sdemtk.h	(working copy)
@@ -113,3 +113,9 @@ extern void mips_sync_icache (void *beg,
 /* ...nor does the call sequence preserve $31.  */
 #undef MIPS_SAVE_REG_FOR_PROFILING_P
 #define MIPS_SAVE_REG_FOR_PROFILING_P(REGNO) ((REGNO) == RETURN_ADDR_REGNUM)
+
+/* TARGET_NO_FLOAT code has no float code at all, and hence is compatible with
+   all other float ABIs, so we set the attribute value to 0.  */
+#undef SUBTARGET_AS_GNU_ATTRIBUTE
+#define SUBTARGET_AS_GNU_ATTRIBUTE(ATTR)				\
+  do { if (TARGET_NO_FLOAT) ATTR = 0; } while (0)
Index: mips.c
===================================================================
--- mips.c	(revision 158495)
+++ mips.c	(working copy)
@@ -8185,10 +8185,28 @@ mips_file_start (void)
 		 "\t.previous\n", TARGET_LONG64 ? 64 : 32);
 
 #ifdef HAVE_AS_GNU_ATTRIBUTE
-      fprintf (asm_out_file, "\t.gnu_attribute 4, %d\n",
-	       (TARGET_HARD_FLOAT_ABI
-		? (TARGET_DOUBLE_FLOAT
-		   ? ((!TARGET_64BIT && TARGET_FLOAT64) ? 4 : 1) : 2) : 3));
+      {
+	int attr;
+
+	/* Soft-float code, -msoft-float.  */
+	if (!TARGET_HARD_FLOAT_ABI)
+	  attr = 3;
+	/* Single-float code, -msingle-float.  */
+	else if (!TARGET_DOUBLE_FLOAT)
+	  attr = 2;
+	/* 64-bit FP registers on a 32-bit target, -mips32r2 -mfp64.  */
+	else if (!TARGET_64BIT && TARGET_FLOAT64)
+	  attr = 4;
+	/* Regular FP code, FP regs same size as GP regs, -mdouble-float.  */
+	else
+	  attr = 1;
+
+#ifdef SUBTARGET_AS_GNU_ATTRIBUTE
+	SUBTARGET_AS_GNU_ATTRIBUTE(attr);
+#endif
+
+	fprintf (asm_out_file, "\t.gnu_attribute 4, %d\n", attr);
+      }
 #endif
     }
 

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