libgcc-std.ver (__clztf2): New.
authorRichard Henderson <rth@redhat.com>
Sun, 9 Feb 2003 18:35:22 +0000 (10:35 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Sun, 9 Feb 2003 18:35:22 +0000 (10:35 -0800)
        * libgcc-std.ver (__clztf2): New.
        (__ctztf2, __popcounttf2, __paritytf2): New.
        * libgcc2.c (__clzSI2, __clzDI2, __ctzSI2, __ctzDI2, __popcountSI2,
        __popcountDI2, __paritySI2, __parityDI2): Use UWmode and UDWmode;
        adjust code to match the different type sizes.
        * libgcc2.h (__clzSI2, __ctzSI2, __popcountSI2, __paritySI2,
        __clzDI2, __ctzDI2, __popcountDI2, __parityDI2): New macros.

        * optabs.c (init_integral_libfuncs): Don't hard-code SImode and
        TImode; select word_mode and twice that.
        (init_floating_libfuncs): Don't hard-code SFmode and TFmode;
        select the modes from float, double, and long double.
        (init_optabs): Remove duplicate initializations.

From-SVN: r62606

gcc/ChangeLog
gcc/libgcc-std.ver
gcc/libgcc2.c
gcc/libgcc2.h
gcc/optabs.c

index 0085476bdcce2d52bccdbb7ee754e2bb7d12f6d9..7188c9fe0aad3a8002dc01d58ce7c10dd9be823e 100644 (file)
@@ -1,3 +1,19 @@
+2003-02-09  Richard Henderson  <rth@redhat.com>
+
+       * libgcc-std.ver (__clztf2): New.
+       (__ctztf2, __popcounttf2, __paritytf2): New.
+       * libgcc2.c (__clzSI2, __clzDI2, __ctzSI2, __ctzDI2, __popcountSI2,
+       __popcountDI2, __paritySI2, __parityDI2): Use UWmode and UDWmode;
+       adjust code to match the different type sizes.
+       * libgcc2.h (__clzSI2, __ctzSI2, __popcountSI2, __paritySI2,
+       __clzDI2, __ctzDI2, __popcountDI2, __parityDI2): New macros.
+
+       * optabs.c (init_integral_libfuncs): Don't hard-code SImode and
+       TImode; select word_mode and twice that.
+       (init_floating_libfuncs): Don't hard-code SFmode and TFmode;
+       select the modes from float, double, and long double.
+       (init_optabs): Remove duplicate initializations.
+
 2003-02-09  Wolfgang Bangerth  <bangerth@ticam.utexas.edu>
 
        * doc/install.texi: Squeeze and streamline section on
index 360e528ba0139265479673063b8f715935db8c97..21847be6b92eb07b6551a7c538111996805434f2 100644 (file)
@@ -186,10 +186,14 @@ GCC_3.4 {
   # bit scanning and counting built-ins
   __clzsi2
   __clzdi2
+  __clzti2
   __ctzsi2
   __ctzdi2
+  __ctzti2
   __popcountsi2
   __popcountdi2
-  __paritysi2  
-  __paritydi2  
+  __popcountti2
+  __paritysi2
+  __paritydi2
+  __parityti2
 }
index 3736b2c61ca61830f570968f6c49517d97a8aedd..069aedb14c1d88d669c8d9a86f1dd7bd5c93f7a5 100644 (file)
@@ -539,15 +539,13 @@ const UQItype __clz_tab[] =
 \f
 #ifdef L_clzsi2
 #undef int
-extern int __clzsi2 (USItype x);
+extern int __clzSI2 (UWtype x);
 int
-__clzsi2 (USItype x)
+__clzSI2 (UWtype x)
 {
-  UWtype w = x;
   Wtype ret;
 
-  count_leading_zeros (ret, w);
-  ret -= (sizeof(w) - sizeof(x)) * BITS_PER_UNIT;
+  count_leading_zeros (ret, x);
 
   return ret;
 }
@@ -555,25 +553,19 @@ __clzsi2 (USItype x)
 \f
 #ifdef L_clzdi2
 #undef int
-extern int __clzdi2 (UDItype x);
+extern int __clzDI2 (UDWtype x);
 int
-__clzdi2 (UDItype x)
+__clzDI2 (UDWtype x)
 {
+  DWunion uu;
   UWtype word;
   Wtype ret, add;
 
-  if (sizeof(x) > sizeof(word))
-    {
-      DWunion uu;
-
-      uu.ll = x;
-      if (uu.s.high)
-       word = uu.s.high, add = 0;
-      else
-       word = uu.s.low, add = W_TYPE_SIZE;
-    }
+  uu.ll = x;
+  if (uu.s.high)
+    word = uu.s.high, add = 0;
   else
-    word = x, add = (Wtype)(sizeof(x) - sizeof(word)) * BITS_PER_UNIT;
+    word = uu.s.low, add = W_TYPE_SIZE;
 
   count_leading_zeros (ret, word);
   return ret + add;
@@ -582,9 +574,9 @@ __clzdi2 (UDItype x)
 \f
 #ifdef L_ctzsi2
 #undef int
-extern int __ctzsi2 (USItype x);
+extern int __ctzSI2 (UWtype x);
 int
-__ctzsi2 (USItype x)
+__ctzSI2 (UWtype x)
 {
   Wtype ret;
 
@@ -596,25 +588,19 @@ __ctzsi2 (USItype x)
 \f
 #ifdef L_ctzdi2
 #undef int
-extern int __ctzdi2 (UDItype x);
+extern int __ctzDI2 (UDWtype x);
 int
-__ctzdi2 (UDItype x)
+__ctzDI2 (UDWtype x)
 {
+  DWunion uu;
   UWtype word;
   Wtype ret, add;
 
-  if (sizeof(x) > sizeof(word))
-    {
-      DWunion uu;
-
-      uu.ll = x;
-      if (uu.s.low)
-       word = uu.s.low, add = 0;
-      else
-       word = uu.s.high, add = W_TYPE_SIZE;
-    }
+  uu.ll = x;
+  if (uu.s.low)
+    word = uu.s.low, add = 0;
   else
-    word = x, add = 0;
+    word = uu.s.high, add = W_TYPE_SIZE;
 
   count_trailing_zeros (ret, word);
   return ret + add;
@@ -642,57 +628,77 @@ const UQItype __popcount_tab[] =
 \f
 #ifdef L_popcountsi2
 #undef int
-extern int __popcountsi2 (USItype x);
+extern int __popcountSI2 (UWtype x);
 int
-__popcountsi2 (USItype x)
+__popcountSI2 (UWtype x)
 {
-  return __popcount_tab[(x >>  0) & 0xff]
-       + __popcount_tab[(x >>  8) & 0xff]
-       + __popcount_tab[(x >> 16) & 0xff]
-       + __popcount_tab[(x >> 24) & 0xff];
+  UWtype i, ret = 0;
+
+  for (i = 0; i < W_TYPE_SIZE; i += 8)
+    ret += __popcount_tab[(x >> i) & 0xff];
+
+  return ret;
 }
 #endif
 \f
 #ifdef L_popcountdi2
 #undef int
-extern int __popcountdi2 (UDItype x);
+extern int __popcountDI2 (UDWtype x);
 int
-__popcountdi2 (UDItype x)
+__popcountDI2 (UDWtype x)
 {
-  return __popcount_tab[(x >>  0) & 0xff]
-       + __popcount_tab[(x >>  8) & 0xff]
-       + __popcount_tab[(x >> 16) & 0xff]
-       + __popcount_tab[(x >> 24) & 0xff]
-       + __popcount_tab[(x >> 32) & 0xff]
-       + __popcount_tab[(x >> 40) & 0xff]
-       + __popcount_tab[(x >> 48) & 0xff]
-       + __popcount_tab[(x >> 56) & 0xff];
+  UWtype i, ret = 0;
+
+  for (i = 0; i < 2*W_TYPE_SIZE; i += 8)
+    ret += __popcount_tab[(x >> i) & 0xff];
+
+  return ret;
 }
 #endif
 \f
 #ifdef L_paritysi2
 #undef int
-extern int __paritysi2 (USItype x);
+extern int __paritySI2 (UWtype x);
 int
-__paritysi2 (USItype x)
+__paritySI2 (UWtype x)
 {
-  UWtype nx = x;
-  nx ^= nx >> 16;
-  nx ^= nx >> 8;
-  nx ^= nx >> 4;
-  nx &= 0xf;
-  return (0x6996 >> nx) & 1;
+#if W_TYPE_SIZE > 64
+# error "fill out the table"
+#endif
+#if W_TYPE_SIZE > 32
+  x ^= x >> 32;
+#endif
+#if W_TYPE_SIZE > 16
+  x ^= x >> 16;
+#endif
+  x ^= x >> 8;
+  x ^= x >> 4;
+  x &= 0xf;
+  return (0x6996 >> x) & 1;
 }
 #endif
 \f
 #ifdef L_paritydi2
 #undef int
-extern int __paritydi2 (UDItype x);
+extern int __parityDI2 (UDWtype x);
 int
-__paritydi2 (UDItype x)
+__parityDI2 (UDWtype x)
 {
-  UWtype nx = x ^ (x >> 32);
+  DWunion uu;
+  UWtype nx;
+
+  uu.ll = x;
+  nx = uu.s.low ^ uu.s.high;
+
+#if W_TYPE_SIZE > 64
+# error "fill out the table"
+#endif
+#if W_TYPE_SIZE > 32
+  nx ^= nx >> 32;
+#endif
+#if W_TYPE_SIZE > 16
   nx ^= nx >> 16;
+#endif
   nx ^= nx >> 8;
   nx ^= nx >> 4;
   nx &= 0xf;
index 876e1d56c821628682732c2bb72acc20bf6ab6db..09c1b0810207d11a1fcaa398c3c85529b314994a 100644 (file)
@@ -203,7 +203,15 @@ typedef int word_type __attribute__ ((mode (__word__)));
 #define __fixunssfSI   __NW(fixunssf,)
 
 #define __ffsSI2       __NW(ffs,2)
+#define __clzSI2       __NW(clz,2)
+#define __ctzSI2       __NW(ctz,2)
+#define __popcountSI2  __NW(popcount,2)
+#define __paritySI2    __NW(parity,2)
 #define __ffsDI2       __NDW(ffs,2)
+#define __clzDI2       __NDW(clz,2)
+#define __ctzDI2       __NDW(ctz,2)
+#define __popcountDI2  __NDW(popcount,2)
+#define __parityDI2    __NDW(parity,2)
 
 extern DWtype __muldi3 (DWtype, DWtype);
 extern DWtype __divdi3 (DWtype, DWtype);
@@ -226,20 +234,6 @@ extern DWtype __lshrdi3 (DWtype, word_type);
 extern DWtype __ashldi3 (DWtype, word_type);
 extern DWtype __ashrdi3 (DWtype, word_type);
 
-/* ??? Ought to get these named properly for DSPs.  */
-#if BITS_PER_UNIT != 8 || MIN_UNITS_PER_WORD < 4
-# undef L_clzsi2
-# undef L_ctzsi2
-# undef L_popcountsi2
-# undef L_paritysi2
-# if LONG_LONG_TYPE_SIZE <= 32
-#  undef L_clzdi2
-#  undef L_ctzdi2
-#  undef L_popcountdi2
-#  undef L_paritydi2
-# endif
-#endif
-
 /* __udiv_w_sdiv is static inline when building other libgcc2 portions.  */
 #if (!defined(L_udivdi3) && !defined(L_divdi3) && \
      !defined(L_umoddi3) && !defined(L_moddi3))
index 226b199daa0a23f380ada018bca05b2c326b0895..fbd7bdf43a186c0d578e6c9fdb2c2b592bcd8947 100644 (file)
@@ -5396,7 +5396,9 @@ init_integral_libfuncs (optable, opname, suffix)
      const char *opname;
      int suffix;
 {
-  init_libfuncs (optable, SImode, TImode, opname, suffix);
+  init_libfuncs (optable, word_mode,
+                mode_for_size (2*BITS_PER_WORD, MODE_INT, 0),
+                opname, suffix);
 }
 
 /* Initialize the libfunc fields of an entire group of entries in some
@@ -5410,7 +5412,18 @@ init_floating_libfuncs (optable, opname, suffix)
      const char *opname;
      int suffix;
 {
-  init_libfuncs (optable, SFmode, TFmode, opname, suffix);
+  enum machine_mode fmode, dmode, lmode;
+
+  fmode = float_type_node ? TYPE_MODE (float_type_node) : VOIDmode;
+  dmode = double_type_node ? TYPE_MODE (double_type_node) : VOIDmode;
+  lmode = long_double_type_node ? TYPE_MODE (long_double_type_node) : VOIDmode;
+
+  if (fmode != VOIDmode)
+    init_libfuncs (optable, fmode, fmode, opname, suffix);
+  if (dmode != fmode && dmode != VOIDmode)
+    init_libfuncs (optable, dmode, dmode, opname, suffix);
+  if (lmode != dmode && lmode != VOIDmode)
+    init_libfuncs (optable, lmode, lmode, opname, suffix);
 }
 
 rtx
@@ -5659,17 +5672,6 @@ init_optabs ()
   /* The ffs function operates on `int'.  */
   ffs_optab->handlers[(int) mode_for_size (INT_TYPE_SIZE, MODE_INT, 0)].libfunc
     = init_one_libfunc ("ffs");
-  ffs_optab->handlers[(int) DImode].libfunc = init_one_libfunc ("__ffsdi2");
-  clz_optab->handlers[(int) SImode].libfunc = init_one_libfunc ("__clzsi2");
-  clz_optab->handlers[(int) DImode].libfunc = init_one_libfunc ("__clzdi2");
-  ctz_optab->handlers[(int) SImode].libfunc = init_one_libfunc ("__ctzsi2");
-  ctz_optab->handlers[(int) DImode].libfunc = init_one_libfunc ("__ctzdi2");
-  popcount_optab->handlers[(int) SImode].libfunc
-      = init_one_libfunc ("__popcountsi2");
-  popcount_optab->handlers[(int) DImode].libfunc
-      = init_one_libfunc ("__popcountdi2");
-  parity_optab->handlers[(int) SImode].libfunc = init_one_libfunc ("__paritysi2");
-  parity_optab->handlers[(int) DImode].libfunc = init_one_libfunc ("__paritydi2");
 
   extendsfdf2_libfunc = init_one_libfunc ("__extendsfdf2");
   extendsfxf2_libfunc = init_one_libfunc ("__extendsfxf2");