Commit 53585c36 by Richard Henderson Committed by Richard Henderson

libgcc2.c: Include auto-host.h.

        * 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
parent bc8a6d63
2003-02-01 Richard Henderson <rth@redhat.com> 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 * config/i386/i386.md (addsi_1_zext splitter): Add TARGET_64BIT
to the conditional. to the conditional.
(ashlsi3_1_zext splitter): Likewise. (ashlsi3_1_zext splitter): Likewise.
......
...@@ -29,10 +29,14 @@ along with GCC; see the file COPYING. If not, write to the Free ...@@ -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 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */ 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 /* It is incorrect to include config.h here, because this file is being
compiled for the target, and hence definitions concerning only the host compiled for the target, and hence definitions concerning only the host
do not apply. */ do not apply. */
#include "tconfig.h" #include "tconfig.h"
#include "tsystem.h" #include "tsystem.h"
#include "coretypes.h" #include "coretypes.h"
...@@ -43,6 +47,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -43,6 +47,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#undef abort #undef abort
#endif #endif
#ifdef HAVE_GAS_HIDDEN
#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
#else
#define ATTRIBUTE_HIDDEN
#endif
#include "libgcc2.h" #include "libgcc2.h"
#ifdef DECLARE_LIBRARY_RENAMES #ifdef DECLARE_LIBRARY_RENAMES
...@@ -495,11 +505,6 @@ __udiv_w_sdiv (UWtype *rp __attribute__ ((__unused__)), ...@@ -495,11 +505,6 @@ __udiv_w_sdiv (UWtype *rp __attribute__ ((__unused__)),
#define L_udivmoddi4 #define L_udivmoddi4
#endif #endif
#if (defined (L_clzsi2) || defined (L_clzdi2) || \
defined (L_ctzsi2) || defined (L_ctzdi2))
extern const UQItype __clz_tab[];
#endif
#ifdef L_clz #ifdef L_clz
const UQItype __clz_tab[] = const UQItype __clz_tab[] =
{ {
...@@ -518,22 +523,13 @@ const UQItype __clz_tab[] = ...@@ -518,22 +523,13 @@ const UQItype __clz_tab[] =
Wtype Wtype
__clzsi2 (USItype x) __clzsi2 (USItype x)
{ {
Wtype a; UWtype w = x;
Wtype ret;
/* 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 32 - (__clz_tab[x >> a] + a); count_leading_zeros (ret, w);
ret -= (sizeof(w) - sizeof(x)) * BITS_PER_UNIT;
return ret;
} }
#endif #endif
...@@ -541,15 +537,24 @@ __clzsi2 (USItype x) ...@@ -541,15 +537,24 @@ __clzsi2 (USItype x)
Wtype Wtype
__clzdi2 (UDItype x) __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 uu.ll = x;
thus DItype is 64 bits wide. */ if (uu.s.high)
for (a = 64 - 8; a > 0; a -= 8) word = uu.s.high, add = 0;
if (((x >> a) & 0xff) != 0) else
break; 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 #endif
...@@ -557,24 +562,11 @@ __clzdi2 (UDItype x) ...@@ -557,24 +562,11 @@ __clzdi2 (UDItype x)
Wtype Wtype
__ctzsi2 (USItype x) __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 return ret;
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;
} }
#endif #endif
...@@ -582,20 +574,30 @@ __ctzsi2 (USItype x) ...@@ -582,20 +574,30 @@ __ctzsi2 (USItype x)
Wtype Wtype
__ctzdi2 (UDItype x) __ctzdi2 (UDItype x)
{ {
Wtype a; UWtype word;
Wtype ret, add;
if (sizeof(x) > sizeof(word))
{
DWunion uu;
x = x & -x; uu.ll = x;
for (a = 64 - 8; a > 0; a -= 8) if (uu.s.low)
if (((x >> a) & 0xff) != 0) word = uu.s.low, add = 0;
break; 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 #endif
#if (defined (L_popcountsi2) || defined (L_popcountdi2) || \ #if (defined (L_popcountsi2) || defined (L_popcountdi2) \
defined (L_paritysi2) || defined (L_paritydi2)) || defined (L_popcount_tab))
extern const UQItype __popcount_tab[]; extern const UQItype __popcount_tab[] ATTRIBUTE_HIDDEN;
#endif #endif
#ifdef L_popcount_tab #ifdef L_popcount_tab
...@@ -642,9 +644,13 @@ __popcountdi2 (UDItype x) ...@@ -642,9 +644,13 @@ __popcountdi2 (UDItype x)
Wtype Wtype
__paritysi2 (USItype x) __paritysi2 (USItype x)
{ {
x ^= x >> 16; UWtype nx = x;
x ^= x >> 8; nx ^= nx >> 16;
return __popcount_tab[x & 0xff] & 1; nx ^= nx >> 8;
nx ^= nx >> 4;
nx ^= nx >> 2;
nx ^= nx >> 1;
return nx & 1;
} }
#endif #endif
...@@ -652,10 +658,13 @@ __paritysi2 (USItype x) ...@@ -652,10 +658,13 @@ __paritysi2 (USItype x)
Wtype Wtype
__paritydi2 (UDItype x) __paritydi2 (UDItype x)
{ {
Wtype nx = x ^ (x >> 32); UWtype nx = x ^ (x >> 32);
nx ^= nx >> 16; nx ^= nx >> 16;
nx ^= nx >> 8; nx ^= nx >> 8;
return __popcount_tab[nx & 0xff] & 1; nx ^= nx >> 4;
nx ^= nx >> 2;
nx ^= nx >> 1;
return nx & 1;
} }
#endif #endif
......
...@@ -134,7 +134,7 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype); ...@@ -134,7 +134,7 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
__asm__("cttz %1,%0" : "=r"(COUNT) : "r"(X)) __asm__("cttz %1,%0" : "=r"(COUNT) : "r"(X))
#define COUNT_LEADING_ZEROS_0 64 #define COUNT_LEADING_ZEROS_0 64
#else #else
extern const UQItype __clz_tab[]; extern const UQItype __clz_tab[] ATTRIBUTE_HIDDEN;
#define count_leading_zeros(COUNT,X) \ #define count_leading_zeros(COUNT,X) \
do { \ do { \
UDItype __xr = (X), __t, __a; \ UDItype __xr = (X), __t, __a; \
...@@ -1287,7 +1287,7 @@ UDItype __umulsidi3 (USItype, USItype); ...@@ -1287,7 +1287,7 @@ UDItype __umulsidi3 (USItype, USItype);
#endif #endif
#if !defined (count_leading_zeros) #if !defined (count_leading_zeros)
extern const UQItype __clz_tab[]; extern const UQItype __clz_tab[] ATTRIBUTE_HIDDEN;
#define count_leading_zeros(count, x) \ #define count_leading_zeros(count, x) \
do { \ do { \
UWtype __xr = (x); \ UWtype __xr = (x); \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment