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]

Re: [patch] add softfp to sparc-*-linux*


Joseph S. Myers wrote:
> It looks like this sfp-machine.h file is specific to 32-bit mode, but 
> sparc-*-linux* can also build biarch configurations with both 32-bit and 
> 64-bit multilibs.  

I'm not aware of any 64 bit sparc's with no fpu, so disabling soft-fp for
arch64 seems fine to me. I verified the t-* file order so this should take 
effect.

> Unless you really need the functions in libgcc for hard-float you should 
> define softfp_wrap_start anyway in such a way as to ensure they only 
> appear in soft-float libgcc.

Tried to do that as well. Seem OK?

> Strictly you should arrange for the symbol versions for these functions to 
> reflect that they are new in 4.5 for this platform.  

I also took a stab at putting these in, but I have no idea if this is the
correct way to do it.

-Austin


2009-04-14  Austin Foxley   <austinf@cetoncorp.com>

        * config.gcc (sparc-*-linux*) : Add softfp rules to sparc linux target
        * config/sparc/sfp-machine.h : softfp machine header, based on glibc
        * config/sparc/t-fprules-softfp : softfp config rules for sparc
        * config/sparc/libgcc-sparc-glibc.ver : Add GCC_4.5.0 versions of fp functions
        * config/libgcc-std.ver : Add empty GCC_4.5.0 stub

Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 146132)
+++ gcc/config.gcc	(working copy)
@@ -2175,7 +2175,7 @@
 	else
 		tm_file="${tm_file} sparc/linux.h"
 	fi
-	tmake_file="${tmake_file} sparc/t-crtfm"
+ 	tmake_file="${tmake_file} sparc/t-crtfm sparc/t-fprules-softfp soft-fp/t-softfp"
 	;;
 sparc-*-rtems*)
 	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sp-elf.h sparc/rtemself.h rtems.h newlib-stdint.h"
Index: gcc/config/sparc/libgcc-sparc-glibc.ver
===================================================================
--- gcc/config/sparc/libgcc-sparc-glibc.ver	(revision 146132)
+++ gcc/config/sparc/libgcc-sparc-glibc.ver	(working copy)
@@ -73,3 +73,78 @@
 }
 
 %endif
+
+%if defined(_SOFT_FLOAT) && !defined(__arch64__)
+%exclude {
+  __addtf3
+  __divtc3
+  __divtf3
+  __eqtf2
+  __extenddftf2
+  __extendsftf2
+  __extendxftf2
+  __fixtfdi
+  __fixtfsi
+  __fixtfti
+  __fixunstfdi
+  __fixunstfsi
+  __fixunstfti
+  __floatditf
+  __floatsitf
+  __floattitf
+  __floatunditf
+  __floatunsitf
+  __floatuntitf
+  __getf2
+  __gttf2
+  __letf2
+  __lttf2
+  __multc3
+  __multf3
+  __negtf2
+  __netf2
+  __powitf2
+  __subtf3
+  __trunctfdf2
+  __trunctfsf2
+  __trunctfxf2
+  __unordtf2
+}
+
+GCC_4.5.0 {
+  __addtf3
+  __divtc3
+  __divtf3
+  __eqtf2
+  __extenddftf2
+  __extendsftf2
+  __extendxftf2
+  __fixtfdi
+  __fixtfsi
+  __fixtfti
+  __fixunstfdi
+  __fixunstfsi
+  __fixunstfti
+  __floatditf
+  __floatsitf
+  __floattitf
+  __floatunditf
+  __floatunsitf
+  __floatuntitf
+  __getf2
+  __gttf2
+  __letf2
+  __lttf2
+  __multc3
+  __multf3
+  __negtf2
+  __netf2
+  __powitf2
+  __subtf3
+  __trunctfdf2
+  __trunctfsf2
+  __trunctfxf2
+  __unordtf2
+}
+%endif
+
Index: gcc/config/sparc/t-fprules-softfp
===================================================================
--- gcc/config/sparc/t-fprules-softfp	(revision 0)
+++ gcc/config/sparc/t-fprules-softfp	(revision 0)
@@ -0,0 +1,10 @@
+softfp_float_modes := sf df
+softfp_int_modes := si di
+softfp_extensions := sfdf
+softfp_truncations := dfsf
+softfp_machine_header := sparc/sfp-machine.h
+softfp_exclude_libgcc2 := y
+
+softfp_wrap_start := '\#if defined(_SOFT_FLOAT) && !defined(__arch64__)'
+softfp_wrap_end := '\#endif'
+
Index: gcc/config/sparc/sfp-machine.h
===================================================================
--- gcc/config/sparc/sfp-machine.h	(revision 0)
+++ gcc/config/sparc/sfp-machine.h	(revision 0)
@@ -0,0 +1,139 @@
+#define _FP_W_TYPE_SIZE     32
+#define _FP_W_TYPE          unsigned long
+#define _FP_WS_TYPE         signed long
+#define _FP_I_TYPE          long
+
+/* The type of the result of a floating point comparison.  This must
+   match `__libgcc_cmp_return__' in GCC for the target.  */
+typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
+#define CMPtype __gcc_CMPtype
+
+#define _FP_MUL_MEAT_S(R,X,Y)				\
+  _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_D(R,X,Y)				\
+  _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_Q(R,X,Y)				\
+  _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
+#define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_udiv(S,R,X,Y)
+#define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_2_udiv(D,R,X,Y)
+#define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_4_udiv(Q,R,X,Y)
+
+#define _FP_NANFRAC_S		((_FP_QNANBIT_S << 1) - 1)
+#define _FP_NANFRAC_D		((_FP_QNANBIT_D << 1) - 1), -1
+#define _FP_NANFRAC_Q		((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
+#define _FP_NANSIGN_S		0
+#define _FP_NANSIGN_D		0
+#define _FP_NANSIGN_Q		0
+
+#define _FP_KEEPNANFRACP 1
+
+/* If one NaN is signaling and the other is not,
+ * we choose that one, otherwise we choose X.
+ */
+/* For _Qp_* and _Q_*, this should prefer X, for
+ * CPU instruction emulation this should prefer Y.
+ * (see SPAMv9 B.2.2 section).
+ */
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)			\
+  do {								\
+    if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)		\
+	&& !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs))	\
+      {								\
+	R##_s = Y##_s;						\
+	_FP_FRAC_COPY_##wc(R,Y);				\
+      }								\
+    else							\
+      {								\
+	R##_s = X##_s;						\
+	_FP_FRAC_COPY_##wc(R,X);				\
+      }								\
+    R##_c = FP_CLS_NAN;						\
+  } while (0)
+
+/* Some assembly to speed things up. */
+#define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0)			\
+  __asm__ ("addcc %r7,%8,%2\n\
+	    addxcc %r5,%6,%1\n\
+	    addx %r3,%4,%0"						\
+	   : "=r" ((USItype)(r2)),					\
+	     "=&r" ((USItype)(r1)),					\
+	     "=&r" ((USItype)(r0))					\
+	   : "%rJ" ((USItype)(x2)),					\
+	     "rI" ((USItype)(y2)),					\
+	     "%rJ" ((USItype)(x1)),					\
+	     "rI" ((USItype)(y1)),					\
+	     "%rJ" ((USItype)(x0)),					\
+	     "rI" ((USItype)(y0))					\
+	   : "cc")
+
+#define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0)			\
+  __asm__ ("subcc %r7,%8,%2\n\
+	    subxcc %r5,%6,%1\n\
+	    subx %r3,%4,%0"						\
+	   : "=r" ((USItype)(r2)),					\
+	     "=&r" ((USItype)(r1)),					\
+	     "=&r" ((USItype)(r0))					\
+	   : "%rJ" ((USItype)(x2)),					\
+	     "rI" ((USItype)(y2)),					\
+	     "%rJ" ((USItype)(x1)),					\
+	     "rI" ((USItype)(y1)),					\
+	     "%rJ" ((USItype)(x0)),					\
+	     "rI" ((USItype)(y0))					\
+	   : "cc")
+
+#define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)		\
+  do {									\
+    __asm__ __volatile__ ("\
+	    addcc %10,%11,%3\n\
+	    addxcc %8,%9,%2\n\
+	    addxcc %6,%7,%1\n\
+	    addx %4,%5,%0"	      					\
+	   : "=r" ((USItype)(r3)),					\
+	     "=&r" ((USItype)(r2))					\
+	     "=&r" ((USItype)(r1))					\
+	     "=&r" ((USItype)(r0))					\
+	   : "%rJ" ((USItype)(x3)),					\
+	     "rI" ((USItype)(y3)),					\
+	     "%rJ" ((USItype)(x2)),					\
+	     "rI" ((USItype)(y2)),					\
+	     "%rJ" ((USItype)(x1)),					\
+	     "rI" ((USItype)(y1)),					\
+	     "%rJ" ((USItype)(x0)),					\
+	     "rI" ((USItype)(y0))					\
+	   : "cc");	            					\
+  } while (0)
+
+#define __FP_FRAC_SUB_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)		\
+  do {									\
+    __asm__ __volatile__ ("\
+	    subcc %10,%11,%3\n\
+	    subxcc %8,%9,%2\n\
+	    subxcc %6,%7,%1\n\
+	    subx %4,%5,%0"		    				\
+	   : "=r" ((USItype)(r3)),					\
+	     "=&r" ((USItype)(r2))					\
+	     "=&r" ((USItype)(r1))					\
+	     "=&r" ((USItype)(r0))					\
+	   : "%rJ" ((USItype)(x3)),					\
+	     "rI" ((USItype)(y3)),					\
+	     "%rJ" ((USItype)(x2)),					\
+	     "rI" ((USItype)(y2)),					\
+	     "%rJ" ((USItype)(x1)),					\
+	     "rI" ((USItype)(y1)),					\
+	     "%rJ" ((USItype)(x0)),					\
+	     "rI" ((USItype)(y0))					\
+	   : "cc");						\
+  } while (0)
+
+#define __FP_FRAC_DEC_3(x2,x1,x0,y2,y1,y0) __FP_FRAC_SUB_3(x2,x1,x0,x2,x1,x0,y2,y1,y0)
+
+#define __FP_FRAC_DEC_4(x3,x2,x1,x0,y3,y2,y1,y0) __FP_FRAC_SUB_4(x3,x2,x1,x0,x3,x2,x1,x0,y3,y2,y1,y0)
+
+#define __BIG_ENDIAN 4321
+#define __BYTE_ORDER __BIG_ENDIAN
+
+/* Define ALIASNAME as a strong alias for NAME.  */
+#define strong_alias(name, aliasname) _strong_alias(name, aliasname)
+#define _strong_alias(name, aliasname) \
+extern __typeof (name) aliasname __attribute__ ((alias (#name)));
Index: gcc/libgcc-std.ver
===================================================================
--- gcc/libgcc-std.ver	(revision 146132)
+++ gcc/libgcc-std.ver	(working copy)
@@ -1885,3 +1885,8 @@
 
   __sync_synchronize
 }
+
+%inherit GCC_4.5.0 GCC_4.4.0
+GCC_4.5.0 {
+}
+


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