+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
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"
#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
#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[] =
{
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
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
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
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
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
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
__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; \
#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); \