libgcc2.c: Include auto-host.h.
authorRichard Henderson <rth@redhat.com>
Sat, 1 Feb 2003 20:58:35 +0000 (12:58 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Sat, 1 Feb 2003 20:58:35 +0000 (12:58 -0800)
        * libgcc2.c: Include auto-host.h.
        (ATTRIBUTE_HIDDEN): New.
        (__clz_tab): Don't declare here for clz and ctz.
        (__clzsi2, __clzdi2): Use count_leading_zeros.
        (__ctzsi2, __ctzdi2): Use count_trailing_zeros.
        (__popcount_tab): Mark ATTRIBUTE_HIDDEN.
        (__paritysi2, __paritydi2): Use shifts instead of __popcount_tab.
        * longlong.h (__clz_tab): Mark ATTRIBUTE_HIDDEN.

From-SVN: r62256

gcc/ChangeLog
gcc/libgcc2.c
gcc/longlong.h

index 796ddb06f1b5395a3495a1d9196798ac90a8f633..fef7792022975bdaf99238ef57cf2feaf703be3b 100644 (file)
@@ -1,3 +1,14 @@
+2003-02-01  Richard Henderson  <rth@redhat.com>
+
+       * libgcc2.c: Include auto-host.h.
+       (ATTRIBUTE_HIDDEN): New.
+       (__clz_tab): Don't declare here for clz and ctz.
+       (__clzsi2, __clzdi2): Use count_leading_zeros.
+       (__ctzsi2, __ctzdi2): Use count_trailing_zeros.
+       (__popcount_tab): Mark ATTRIBUTE_HIDDEN.
+       (__paritysi2, __paritydi2): Use shifts instead of __popcount_tab.
+       * longlong.h (__clz_tab): Mark ATTRIBUTE_HIDDEN.
+
 2003-02-01  Richard Henderson  <rth@redhat.com>
 
        * config/i386/i386.md (addsi_1_zext splitter): Add TARGET_64BIT
index 5de1edecd8cc97b2818d0c80237d8c621ec5bbcc..4260e25d66cecf0de34d6cb302e2aa412c54f192 100644 (file)
@@ -29,10 +29,14 @@ along with GCC; see the file COPYING.  If not, write to the Free
 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+
+/* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
+   supposedly valid even though this is a "target" file.  */
+#include "auto-host.h"
+
 /* It is incorrect to include config.h here, because this file is being
    compiled for the target, and hence definitions concerning only the host
    do not apply.  */
-
 #include "tconfig.h"
 #include "tsystem.h"
 #include "coretypes.h"
@@ -43,6 +47,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #undef abort
 #endif
 
+#ifdef HAVE_GAS_HIDDEN
+#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
+#else
+#define ATTRIBUTE_HIDDEN
+#endif
+
 #include "libgcc2.h"
 \f
 #ifdef DECLARE_LIBRARY_RENAMES
@@ -495,11 +505,6 @@ __udiv_w_sdiv (UWtype *rp __attribute__ ((__unused__)),
 #define L_udivmoddi4
 #endif
 
-#if (defined (L_clzsi2) || defined (L_clzdi2) || \
-     defined (L_ctzsi2) || defined (L_ctzdi2))
-extern const UQItype __clz_tab[];
-#endif
-
 #ifdef L_clz
 const UQItype __clz_tab[] =
 {
@@ -518,22 +523,13 @@ const UQItype __clz_tab[] =
 Wtype
 __clzsi2 (USItype x)
 {
-  Wtype a;
-
-  /* Note that we've already verified that BITS_PER_UNIT == 8, and
-     thus SItype is 32 bits wide.  */
-  if (x < (1 << 2 * 8))
-    if (x < (1 << 1 * 8))
-      a = 0 * 8;
-    else
-      a = 1 * 8;
-  else
-    if (x < (1 << 3 * 8))
-      a = 2 * 8;
-    else
-      a = 3 * 8;
+  UWtype w = x;
+  Wtype ret;
 
-  return 32 - (__clz_tab[x >> a] + a);
+  count_leading_zeros (ret, w);
+  ret -= (sizeof(w) - sizeof(x)) * BITS_PER_UNIT;
+
+  return ret;
 }
 #endif
 \f
@@ -541,15 +537,24 @@ __clzsi2 (USItype x)
 Wtype
 __clzdi2 (UDItype x)
 {
-  Wtype a;
+  UWtype word;
+  Wtype ret, add;
+
+  if (sizeof(x) > sizeof(word))
+    {
+      DWunion uu;
 
-  /* Note that we've already verified that BITS_PER_UNIT == 8, and
-     thus DItype is 64 bits wide.  */
-  for (a = 64 - 8; a > 0; a -= 8)
-    if (((x >> a) & 0xff) != 0)
-      break;
+      uu.ll = x;
+      if (uu.s.high)
+       word = uu.s.high, add = 0;
+      else
+       word = uu.s.low, add = W_TYPE_SIZE;
+    }
+  else
+    word = x, add = (Wtype)(sizeof(x) - sizeof(word)) * BITS_PER_UNIT;
 
-  return 64 - (__clz_tab[x >> a] + a);
+  count_leading_zeros (ret, word);
+  return ret + add;
 }
 #endif
 \f
@@ -557,24 +562,11 @@ __clzdi2 (UDItype x)
 Wtype
 __ctzsi2 (USItype x)
 {
-  Wtype a;
+  Wtype ret;
 
-  x = x & -x;
+  count_trailing_zeros (ret, x);
 
-  /* Note that we've already verified that BITS_PER_UNIT == 8, and
-     thus SItype is 32 bits wide.  */
-  if (x < (1 << 2 * 8))
-    if (x < (1 << 1 * 8))
-      a = 0 * 8;
-    else
-      a = 1 * 8;
-  else
-    if (x < (1 << 3 * 8))
-      a = 2 * 8;
-    else
-      a = 3 * 8;
-
-  return __clz_tab[x >> a] + a - 1;
+  return ret;
 }
 #endif
 \f
@@ -582,20 +574,30 @@ __ctzsi2 (USItype x)
 Wtype
 __ctzdi2 (UDItype x)
 {
-  Wtype a;
+  UWtype word;
+  Wtype ret, add;
+
+  if (sizeof(x) > sizeof(word))
+    {
+      DWunion uu;
 
-  x = x & -x;
-  for (a = 64 - 8; a > 0; a -= 8)
-    if (((x >> a) & 0xff) != 0)
-      break;
+      uu.ll = x;
+      if (uu.s.low)
+       word = uu.s.low, add = 0;
+      else
+       word = uu.s.high, add = W_TYPE_SIZE;
+    }
+  else
+    word = x, add = 0;
 
-  return __clz_tab[x >> a] + a - 1;
+  count_trailing_zeros (ret, word);
+  return ret + add;
 }
 #endif
 
-#if (defined (L_popcountsi2) || defined (L_popcountdi2) || \
-     defined (L_paritysi2) || defined (L_paritydi2))
-extern const UQItype __popcount_tab[];
+#if (defined (L_popcountsi2) || defined (L_popcountdi2)        \
+     || defined (L_popcount_tab))
+extern const UQItype __popcount_tab[] ATTRIBUTE_HIDDEN;
 #endif
 
 #ifdef L_popcount_tab
@@ -642,9 +644,13 @@ __popcountdi2 (UDItype x)
 Wtype
 __paritysi2 (USItype x)
 {
-  x ^= x >> 16;
-  x ^= x >> 8;
-  return __popcount_tab[x & 0xff] & 1;
+  UWtype nx = x;
+  nx ^= nx >> 16;
+  nx ^= nx >> 8;
+  nx ^= nx >> 4;
+  nx ^= nx >> 2;
+  nx ^= nx >> 1;
+  return nx & 1;
 }
 #endif
 \f
@@ -652,10 +658,13 @@ __paritysi2 (USItype x)
 Wtype
 __paritydi2 (UDItype x)
 {
-  Wtype nx = x ^ (x >> 32);
+  UWtype nx = x ^ (x >> 32);
   nx ^= nx >> 16;
   nx ^= nx >> 8;
-  return __popcount_tab[nx & 0xff] & 1;
+  nx ^= nx >> 4;
+  nx ^= nx >> 2;
+  nx ^= nx >> 1;
+  return nx & 1;
 }
 #endif
 
index b886f2bdc8d3759ef6c58b55ee29f30a5aa4bdf4..c1fee2d25893ca20d72be23bd6bfc267fc1a1c55 100644 (file)
@@ -134,7 +134,7 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
   __asm__("cttz %1,%0" : "=r"(COUNT) : "r"(X))
 #define COUNT_LEADING_ZEROS_0 64
 #else
-extern const UQItype __clz_tab[];
+extern const UQItype __clz_tab[] ATTRIBUTE_HIDDEN;
 #define count_leading_zeros(COUNT,X) \
   do {                                                                 \
     UDItype __xr = (X), __t, __a;                                      \
@@ -1287,7 +1287,7 @@ UDItype __umulsidi3 (USItype, USItype);
 #endif
 
 #if !defined (count_leading_zeros)
-extern const UQItype __clz_tab[];
+extern const UQItype __clz_tab[] ATTRIBUTE_HIDDEN;
 #define count_leading_zeros(count, x) \
   do {                                                                 \
     UWtype __xr = (x);                                                 \