Browse Source

Move powerpc specific optimizations (courtesy of apple) to powerpc
subdir. Put together a theoretical framework for adding arch specific
optimizations. Havn't tried this yet but it looks correct...
-Erik

Eric Andersen 22 years ago
parent
commit
26d7ea9112

+ 23 - 6
libm/Makefile

@@ -22,6 +22,14 @@
 TOPDIR=../
 include $(TOPDIR)Rules.mak
 
+ifeq ($(TARGET_ARCH),$(wildcard $(TARGET_ARCH)))
+DIRS = $(TARGET_ARCH)
+else
+DIRS = 
+endif
+ALL_SUBDIRS = powerpc
+
+
 LIBM=libm.a
 LIBM_SHARED=libm.so
 LIBM_SHARED_FULLNAME=libm-$(MAJOR_VERSION).$(MINOR_VERSION).so
@@ -43,8 +51,7 @@ CSRC =   e_acos.c e_acosh.c e_asin.c e_atan2.c e_atanh.c e_cosh.c\
          w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c w_gamma_r.c\
          w_hypot.c w_j0.c w_j1.c w_jn.c w_lgamma.c w_lgamma_r.c\
          w_log.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c\
-         w_sqrt.c ceilfloor.c fpmacros.c frexpldexp.c logb.c rndint.c\
-         scalb.c sign.c
+         w_sqrt.c fpmacros.c
 else
 CSRC =   w_acos.c w_asin.c s_atan.c w_atan2.c s_ceil.c s_cos.c \
 	 w_cosh.c w_exp.c s_expm1.c s_fabs.c s_floor.c w_fmod.c \
@@ -59,9 +66,9 @@ OBJS=$(COBJS)
 
 
 ifneq ($(strip $(HAS_FLOATING_POINT)),true)
-all:  clean
+all:  clean subdirs
 else
-all: $(OBJS) $(COBJS1) $(LIBM)
+all: $(OBJS) $(LIBM) subdirs
 endif
 
 $(LIBM): ar-target
@@ -90,11 +97,21 @@ $(COBJS): %.o : %.c
 	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 $(OBJ): Makefile
-$(COBJS1): Makefile
 
 tags:
 	ctags -R
 
-clean: 
+clean: subdirs_clean
 	rm -f *.[oa] *~ core $(LIBM_SHARED)* $(LIBM_SHARED_FULLNAME)*
 
+subdirs: $(patsubst %, _dir_%, $(DIRS))
+subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
+
+$(patsubst %, _dir_%, $(DIRS)) : dummy
+	$(MAKE) -C $(patsubst _dir_%, %, $@)
+
+$(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy
+	$(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
+
+.PHONY: dummy
+

+ 60 - 0
libm/powerpc/Makefile

@@ -0,0 +1,60 @@
+# Makefile for uClibc's math library
+# Copyright (C) 2001 by Lineo, inc.
+#
+# This math library is derived primarily from the Cephes Math Library,
+# copyright by Stephen L. Moshier <moshier@world.std.com>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+TOPDIR=../../
+include $(TOPDIR)Rules.mak
+
+LIBM=../libm.a
+TARGET_CC= $(TOPDIR)extra/gcc-uClibc/$(TARGET_ARCH)-uclibc-gcc
+TARGET_CFLAGS+=-D_IEEE_LIBM -D_ISOC99_SOURCE -D_SVID_SOURCE
+
+ifeq ($(strip $(DO_C99_MATH)),true)
+CSRC =   ceilfloor.c  frexpldexp.c  logb.c  rndint.c  scalb.c  sign.c
+else
+CSRC =
+endif
+COBJS=$(patsubst %.c,%.o, $(CSRC))
+OBJS=$(COBJS)
+
+
+ifneq ($(strip $(HAS_FLOATING_POINT)),true)
+all:  clean
+else
+all: $(OBJS) $(LIBM)
+endif
+
+$(LIBM): ar-target
+
+ar-target: $(OBJS)
+	$(AR) $(ARFLAGS) $(LIBM) $(OBJS)
+
+$(COBJS): %.o : %.c
+	$(TARGET_CC) $(TARGET_CFLAGS) -c $< -o $@
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
+
+$(OBJ): Makefile
+
+tags:
+	ctags -R
+
+clean: 
+	rm -f *.[oa] *~ core $(LIBM_SHARED)* $(LIBM_SHARED_FULLNAME)*
+

+ 1 - 6
libm/ceilfloor.c → libm/powerpc/ceilfloor.c

@@ -1,4 +1,3 @@
-#if defined(__ppc__)
 /*******************************************************************************
 *                                                                              *
 *      File ceilfloor.c,                                                       *
@@ -22,10 +21,6 @@
 *                                                                              *
 *******************************************************************************/
 
-#if !defined(__ppc__)
-#define asm(x)
-#endif
-
 static const double        twoTo52  = 4503599627370496.0;
 static const unsigned long signMask = 0x80000000ul;
 
@@ -176,4 +171,4 @@ double floor ( double x )
 *******************************************************************************/
 	return ( x );
 	}
-#endif /* __ppc__ */
+

+ 1 - 2
libm/frexpldexp.c → libm/powerpc/frexpldexp.c

@@ -1,4 +1,3 @@
-#if defined(__ppc__)
 /*******************************************************************************
 *                                                                              *
 *      File frexpldexp.c,                                                      *
@@ -70,4 +69,4 @@ double frexp ( double value, int *eptr )
 	argument.words.hi = ( argument.words.hi & 0x800fffff ) | 0x3fe00000;
 	return argument.dbl;
 	}
-#endif /* __ppc__ */
+

+ 1 - 2
libm/logb.c → libm/powerpc/logb.c

@@ -1,4 +1,3 @@
-#if defined(__ppc__)
 /*******************************************************************************
 *                                                                              *
 *      File logb.c,                                                            *
@@ -101,4 +100,4 @@ double logb (  double x  )
             return ( xInHex.dbl - klTod );
             }
       }
-#endif /* __ppc__ */
+

+ 0 - 12
libm/rndint.c → libm/powerpc/rndint.c

@@ -47,10 +47,6 @@
 #include <limits.h>
 #include <math.h>
 
-#if !defined(__ppc__)
-#define asm(x)
-#endif
-
 #define      SET_INVALID      0x01000000UL
 
 typedef union
@@ -108,7 +104,6 @@ static const DblInHex TOWARDZERO = {{ 0x00000000, 0x00000001 }};
 *     Now a bit twidling version that is about %30 faster.                     *
 *******************************************************************************/
 
-#if defined(__ppc__)
 double rint ( double x )
       {
       DblInHex argument;
@@ -159,7 +154,6 @@ double rint ( double x )
 *******************************************************************************/
       return ( x );
       }
-#endif /* __ppc__ */
 
 /*******************************************************************************
 *                                                                              *
@@ -176,9 +170,7 @@ double rint ( double x )
 double nearbyint ( double x )
       {
 	double y;
-#if defined(__ppc__)
 	double OldEnvironment;
-#endif /* __ppc__ */
       
 	y = twoTo52;
 	
@@ -400,10 +392,8 @@ long int roundtol ( double x )
 	DblInHex argument, OldEnvironment;
 	register unsigned long int xhi;
 	register long int target;
-#if defined(__ppc__)
 	const DblInHex kTZ = {{ 0x0, 0x1 }};
 	const DblInHex kUP = {{ 0x0, 0x2 }};
-#endif /* __ppc__ */
 	
 	argument.dbl = x;
 	xhi = argument.words.hi & 0x7ffffffful;	        	// high 32 bits of x
@@ -568,7 +558,6 @@ double trunc ( double x )
 *     modf is the double implementation.                                       *                             
 *******************************************************************************/
 
-#if defined(__ppc__)
 double modf ( double x, double *iptr )
       {
       register double OldEnvironment, xtrunc;
@@ -629,4 +618,3 @@ double modf ( double x, double *iptr )
             return ( argument.dbl );
             }
       }
-#endif /* __ppc__ */

+ 0 - 2
libm/scalb.c → libm/powerpc/scalb.c

@@ -1,4 +1,3 @@
-#if defined(__ppc__)
 /***********************************************************************
 **      File:    scalb.c
 **      
@@ -84,4 +83,3 @@ double scalb ( double x, int n  )
       xInHex.words.hi = ( ( unsigned long ) ( n + 1023 ) ) << 20;
       return ( x * xInHex.dbl );
       }
-#endif /* __ppc__ */

+ 0 - 2
libm/sign.c → libm/powerpc/sign.c

@@ -1,4 +1,3 @@
-#if defined(__ppc__)
 /*******************************************************************************
 *                                                                              *
 *      File sign.c,                                                            *
@@ -55,4 +54,3 @@ double copysign ( double arg2, double arg1 )
       
       return y.dbl;
       }
-#endif /* __ppc__ */

+ 1 - 2
libm/s_ceil.c

@@ -1,4 +1,3 @@
-#if !defined(__ppc__)
 /* @(#)s_ceil.c 5.1 93/09/24 */
 /*
  * ====================================================
@@ -79,4 +78,4 @@ static double huge = 1.0e300;
 	INSERT_WORDS(x,i0,i1);
 	return x;
 }
-#endif /* !__ppc__ */
+

+ 1 - 2
libm/s_copysign.c

@@ -1,4 +1,3 @@
-#if !defined(__ppc__)
 /* @(#)s_copysign.c 5.1 93/09/24 */
 /*
  * ====================================================
@@ -37,4 +36,4 @@ static char rcsid[] = "$NetBSD: s_copysign.c,v 1.8 1995/05/10 20:46:57 jtc Exp $
 	SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
         return x;
 }
-#endif
+

+ 0 - 2
libm/s_floor.c

@@ -1,4 +1,3 @@
-#if !defined(__ppc__)
 /* @(#)s_floor.c 5.1 93/09/24 */
 /*
  * ====================================================
@@ -80,4 +79,3 @@ static double huge = 1.0e300;
 	INSERT_WORDS(x,i0,i1);
 	return x;
 }
-#endif /* !__ppc__ */

+ 0 - 2
libm/s_frexp.c

@@ -1,4 +1,3 @@
-#if !defined(__ppc__)
 /* @(#)s_frexp.c 5.1 93/09/24 */
 /*
  * ====================================================
@@ -58,4 +57,3 @@ two54 =  1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
 	SET_HIGH_WORD(x,hx);
 	return x;
 }
-#endif /* !__ppc__ */

+ 0 - 2
libm/s_ldexp.c

@@ -1,4 +1,3 @@
-#if !defined(__ppc__)
 /* @(#)s_ldexp.c 5.1 93/09/24 */
 /*
  * ====================================================
@@ -31,4 +30,3 @@ static char rcsid[] = "$NetBSD: s_ldexp.c,v 1.6 1995/05/10 20:47:40 jtc Exp $";
 	if(!finite(value)||value==0.0) errno = ERANGE;
 	return value;
 }
-#endif /* !__ppc__ */

+ 0 - 2
libm/s_logb.c

@@ -1,4 +1,3 @@
-#if !defined(__ppc__)
 /* @(#)s_logb.c 5.1 93/09/24 */
 /*
  * ====================================================
@@ -41,4 +40,3 @@ static char rcsid[] = "$NetBSD: s_logb.c,v 1.8 1995/05/10 20:47:50 jtc Exp $";
 	else
 		return (double) (ix-1023); 
 }
-#endif /* !__ppc__ */

+ 0 - 2
libm/s_modf.c

@@ -1,4 +1,3 @@
-#if !defined(__ppc__)
 /* @(#)s_modf.c 5.1 93/09/24 */
 /*
  * ====================================================
@@ -82,4 +81,3 @@ static double one = 1.0;
 	    }
 	}
 }
-#endif /* !__ppc__ */

+ 0 - 2
libm/s_rint.c

@@ -1,4 +1,3 @@
-#if !defined(__ppc__)
 /* @(#)s_rint.c 5.1 93/09/24 */
 /*
  * ====================================================
@@ -85,4 +84,3 @@ TWO52[2]={
 	w = TWO52[sx]+x;
 	return w-TWO52[sx];
 }
-#endif /* !__ppc__ */

+ 0 - 2
libm/w_scalb.c

@@ -1,4 +1,3 @@
-#if !defined(__ppc__)
 /* @(#)w_scalb.c 5.1 93/09/24 */
 /*
  * ====================================================
@@ -59,4 +58,3 @@ static char rcsid[] = "$NetBSD: w_scalb.c,v 1.6 1995/05/10 20:49:48 jtc Exp $";
 	return z;
 #endif 
 }
-#endif /* !__ppc__ */