OSDN Git Service

Move powerpc specific optimizations (courtesy of apple) to powerpc
authorEric Andersen <andersen@codepoet.org>
Sat, 24 Nov 2001 03:46:25 +0000 (03:46 -0000)
committerEric Andersen <andersen@codepoet.org>
Sat, 24 Nov 2001 03:46:25 +0000 (03:46 -0000)
subdir.  Put together a theoretical framework for adding arch specific
optimizations.  Havn't tried this yet but it looks correct...
 -Erik

17 files changed:
libm/Makefile
libm/powerpc/Makefile [new file with mode: 0644]
libm/powerpc/ceilfloor.c [moved from libm/ceilfloor.c with 98% similarity]
libm/powerpc/frexpldexp.c [moved from libm/frexpldexp.c with 98% similarity]
libm/powerpc/logb.c [moved from libm/logb.c with 99% similarity]
libm/powerpc/rndint.c [moved from libm/rndint.c with 99% similarity]
libm/powerpc/scalb.c [moved from libm/scalb.c with 98% similarity]
libm/powerpc/sign.c [moved from libm/sign.c with 98% similarity]
libm/s_ceil.c
libm/s_copysign.c
libm/s_floor.c
libm/s_frexp.c
libm/s_ldexp.c
libm/s_logb.c
libm/s_modf.c
libm/s_rint.c
libm/w_scalb.c

index c82ca3f..e9c7c80 100644 (file)
 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
+
diff --git a/libm/powerpc/Makefile b/libm/powerpc/Makefile
new file mode 100644 (file)
index 0000000..7464ee0
--- /dev/null
@@ -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)*
+
similarity index 98%
rename from libm/ceilfloor.c
rename to libm/powerpc/ceilfloor.c
index 9607435..d5947ab 100644 (file)
@@ -1,4 +1,3 @@
-#if defined(__ppc__)
 /*******************************************************************************
 *                                                                              *
 *      File ceilfloor.c,                                                       *
 *                                                                              *
 *******************************************************************************/
 
-#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__ */
+
similarity index 98%
rename from libm/frexpldexp.c
rename to libm/powerpc/frexpldexp.c
index dbb6fcc..6b759f9 100644 (file)
@@ -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__ */
+
similarity index 99%
rename from libm/logb.c
rename to libm/powerpc/logb.c
index da2a27d..3a410ba 100644 (file)
@@ -1,4 +1,3 @@
-#if defined(__ppc__)
 /*******************************************************************************
 *                                                                              *
 *      File logb.c,                                                            *
@@ -101,4 +100,4 @@ double logb (  double x  )
             return ( xInHex.dbl - klTod );
             }
       }
-#endif /* __ppc__ */
+
similarity index 99%
rename from libm/rndint.c
rename to libm/powerpc/rndint.c
index 7f8c183..1b7a9ec 100644 (file)
 #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__ */
similarity index 98%
rename from libm/scalb.c
rename to libm/powerpc/scalb.c
index 03d2de9..98a2b7d 100644 (file)
@@ -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__ */
similarity index 98%
rename from libm/sign.c
rename to libm/powerpc/sign.c
index 524d6af..0bf2f38 100644 (file)
@@ -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__ */
index f17b314..8616d0f 100644 (file)
@@ -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__ */
+
index 666c34a..63261fc 100644 (file)
@@ -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
+
index 375dc5a..5a36b2d 100644 (file)
@@ -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__ */
index f187d84..bfc9dba 100644 (file)
@@ -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__ */
index 5e7313e..085823a 100644 (file)
@@ -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__ */
index 7ec1c36..02bb99f 100644 (file)
@@ -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__ */
index 2d3e537..9d71c01 100644 (file)
@@ -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__ */
index b2d9c0e..8808857 100644 (file)
@@ -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__ */
index bde5f70..50026be 100644 (file)
@@ -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__ */