mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-19 10:10:39 +08:00
Makefile.in (LIBGCC_DEPS): Add libgcc2.h.
* Makefile.in (LIBGCC_DEPS): Add libgcc2.h. * libgcc2.c (__clz_tab[], __popcount_tab[]): Set the fixed dimension of these arrays. * libgcc2.h (__clz_tab[], __popcount_tab[]): Add exports of these arrays. * longlong.h: Only provide a prototype for the __clz_tab[] array if this header has not been included from libgcc2.h. * config/stormy16/stormy16-lib2.c: Include libgcc2.h rather than defining own types. Provide prototypes for exported functions. Use the __clz_tab[] and __popcount_tab[] arrays provided by libgcc2.c. From-SVN: r104081
This commit is contained in:
parent
a174b2f8ec
commit
dcfae47c5e
@ -1,3 +1,18 @@
|
||||
2005-09-09 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
* Makefile.in (LIBGCC_DEPS): Add libgcc2.h.
|
||||
* libgcc2.c (__clz_tab[], __popcount_tab[]): Set the fixed
|
||||
dimension of these arrays.
|
||||
* libgcc2.h (__clz_tab[], __popcount_tab[]): Add exports of
|
||||
these arrays.
|
||||
* longlong.h: Only provide a prototype for the __clz_tab[] array
|
||||
if this header has not been included from libgcc2.h.
|
||||
* config/stormy16/stormy16-lib2.c: Include libgcc2.h rather than
|
||||
defining own types.
|
||||
Provide prototypes for exported functions.
|
||||
Use the __clz_tab[] and __popcount_tab[] arrays provided by
|
||||
libgcc2.c.
|
||||
|
||||
2005-09-08 Josh Conner <jconner@apple.com>
|
||||
|
||||
PR c++/23180
|
||||
|
@ -1350,7 +1350,7 @@ libgcc.mk: config.status Makefile mklibgcc $(LIB2ADD) $(LIB2ADD_ST) specs \
|
||||
# All the things that might cause us to want to recompile bits of libgcc.
|
||||
LIBGCC_DEPS = $(GCC_PASSES) $(LANGUAGES) stmp-int-hdrs $(STMP_FIXPROTO) \
|
||||
libgcc.mk $(srcdir)/libgcc2.c $(srcdir)/libgcov.c $(TCONFIG_H) \
|
||||
$(MACHMODE_H) longlong.h gbl-ctors.h config.status \
|
||||
$(MACHMODE_H) longlong.h gbl-ctors.h config.status $(srcdir)/libgcc2.h \
|
||||
tsystem.h $(FPBIT) $(DPBIT) $(TPBIT) $(LIB2ADD) \
|
||||
$(LIB2ADD_ST) $(LIB2ADDEH) $(LIB2ADDEHDEP) $(EXTRA_PARTS) \
|
||||
$(srcdir)/config/$(LIB1ASMSRC) \
|
||||
|
@ -1,19 +1,79 @@
|
||||
typedef int HItype __attribute__ ((mode (HI)));
|
||||
typedef int SItype __attribute__ ((mode (SI)));
|
||||
typedef unsigned int USItype __attribute__ ((mode (SI)));
|
||||
/* This file contains 16-bit versions of some of the functions found in
|
||||
libgcc2.c. Really libgcc ought to be moved out of the gcc directory
|
||||
and into its own top level directory, and then split up into multiple
|
||||
files. On this glorious day maybe this code can be integrated into
|
||||
it too. */
|
||||
|
||||
/* Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 2, or (at your option) any later
|
||||
version.
|
||||
|
||||
In addition to the permissions in the GNU General Public License, the
|
||||
Free Software Foundation gives you unlimited permission to link the
|
||||
compiled version of this file into combinations with other programs,
|
||||
and to distribute those combinations without any restriction coming
|
||||
from the use of this file. (The General Public License restrictions
|
||||
do apply in other respects; for example, they cover modification of
|
||||
the file, and distribution when not linked into a combine
|
||||
executable.)
|
||||
|
||||
GCC 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301, USA. */
|
||||
|
||||
#include "tconfig.h"
|
||||
#include "tsystem.h"
|
||||
#include "coretypes.h"
|
||||
#include "tm.h"
|
||||
|
||||
#ifdef HAVE_GAS_HIDDEN
|
||||
#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
|
||||
#else
|
||||
#define ATTRIBUTE_HIDDEN
|
||||
#endif
|
||||
|
||||
#include "libgcc2.h"
|
||||
#undef int
|
||||
|
||||
/* These prototypes would normally live in libgcc2.h, but this can
|
||||
only happen once the code below is integrated into libgcc2.c. */
|
||||
|
||||
extern USItype udivmodsi4 (USItype, USItype, word_type);
|
||||
extern SItype __divsi3 (SItype, SItype);
|
||||
extern SItype __modsi3 (SItype, SItype);
|
||||
extern SItype __udivsi3 (SItype, SItype);
|
||||
extern SItype __umodsi3 (SItype, SItype);
|
||||
extern SItype __ashlsi3 (SItype, SItype);
|
||||
extern SItype __ashrsi3 (SItype, SItype);
|
||||
extern USItype __lshrsi3 (USItype, USItype);
|
||||
extern int __popcounthi2 (UHWtype);
|
||||
extern int __parityhi2 (UHWtype);
|
||||
extern int __clzhi2 (UHWtype);
|
||||
extern int __ctzhi2 (UHWtype);
|
||||
|
||||
|
||||
typedef int word_type __attribute__ ((mode (__word__)));
|
||||
|
||||
USItype
|
||||
udivmodsi4(USItype num, USItype den, word_type modwanted)
|
||||
udivmodsi4 (USItype num, USItype den, word_type modwanted)
|
||||
{
|
||||
USItype bit = 1;
|
||||
USItype res = 0;
|
||||
|
||||
while (den < num && bit && !(den & (1L<<31)))
|
||||
while (den < num && bit && !(den & (1L << 31)))
|
||||
{
|
||||
den <<=1;
|
||||
bit <<=1;
|
||||
den <<= 1;
|
||||
bit <<= 1;
|
||||
}
|
||||
while (bit)
|
||||
{
|
||||
@ -22,15 +82,15 @@ udivmodsi4(USItype num, USItype den, word_type modwanted)
|
||||
num -= den;
|
||||
res |= bit;
|
||||
}
|
||||
bit >>=1;
|
||||
den >>=1;
|
||||
bit >>= 1;
|
||||
den >>= 1;
|
||||
}
|
||||
if (modwanted) return num;
|
||||
|
||||
if (modwanted)
|
||||
return num;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SItype
|
||||
__divsi3 (SItype a, SItype b)
|
||||
{
|
||||
@ -57,8 +117,6 @@ __divsi3 (SItype a, SItype b)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SItype
|
||||
__modsi3 (SItype a, SItype b)
|
||||
{
|
||||
@ -82,17 +140,12 @@ __modsi3 (SItype a, SItype b)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
SItype
|
||||
__udivsi3 (SItype a, SItype b)
|
||||
{
|
||||
return udivmodsi4 (a, b, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SItype
|
||||
__umodsi3 (SItype a, SItype b)
|
||||
{
|
||||
@ -141,22 +194,13 @@ __lshrsi3 (USItype a, USItype b)
|
||||
return a;
|
||||
}
|
||||
|
||||
static const unsigned char __popcount_tab[] =
|
||||
{
|
||||
0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
|
||||
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
|
||||
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
|
||||
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
|
||||
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
|
||||
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
|
||||
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
|
||||
3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,
|
||||
};
|
||||
|
||||
/* Returns the number of set bits in X.
|
||||
FIXME: The return type really should be unsigned,
|
||||
but this is not how the builtin is prototyped. */
|
||||
int
|
||||
__popcounthi2 (unsigned int x)
|
||||
__popcounthi2 (UHWtype x)
|
||||
{
|
||||
unsigned int ret;
|
||||
int ret;
|
||||
|
||||
ret = __popcount_tab [x & 0xff];
|
||||
ret += __popcount_tab [(x >> 8) & 0xff];
|
||||
@ -164,8 +208,12 @@ __popcounthi2 (unsigned int x)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Returns the number of set bits in X, modulo 2.
|
||||
FIXME: The return type really should be unsigned,
|
||||
but this is not how the builtin is prototyped. */
|
||||
|
||||
int
|
||||
__parityhi2 (unsigned int x)
|
||||
__parityhi2 (UHWtype x)
|
||||
{
|
||||
x ^= x >> 8;
|
||||
x ^= x >> 4;
|
||||
@ -173,19 +221,31 @@ __parityhi2 (unsigned int x)
|
||||
return (0x6996 >> x) & 1;
|
||||
}
|
||||
|
||||
int
|
||||
__ctzhi2 (unsigned int x)
|
||||
{
|
||||
extern int __ctzsi2 (unsigned long);
|
||||
unsigned long y = x;
|
||||
|
||||
return __ctzsi2 (y << 16) - 16;
|
||||
}
|
||||
/* Returns the number of leading zero bits in X.
|
||||
FIXME: The return type really should be unsigned,
|
||||
but this is not how the builtin is prototyped. */
|
||||
|
||||
int
|
||||
__clzhi2 (unsigned int x)
|
||||
__clzhi2 (UHWtype x)
|
||||
{
|
||||
extern int __clzsi2 (unsigned long);
|
||||
|
||||
return __clzsi2 (x) - 16;
|
||||
if (x > 0xff)
|
||||
return 8 - __clz_tab[x >> 8];
|
||||
return 16 - __clz_tab[x];
|
||||
}
|
||||
|
||||
/* Returns the number of trailing zero bits in X.
|
||||
FIXME: The return type really should be unsigned,
|
||||
but this is not how the builtin is prototyped. */
|
||||
|
||||
int
|
||||
__ctzhi2 (UHWtype x)
|
||||
{
|
||||
/* This is cunning. It converts X into a number with only the one bit
|
||||
set, the bit was the least significant bit in X. From this we can
|
||||
use the __clz_tab[] array to compute the number of trailing bits. */
|
||||
x &= - x;
|
||||
|
||||
if (x > 0xff)
|
||||
return __clz_tab[x >> 8] + 7;
|
||||
return __clz_tab[x] - 1;
|
||||
}
|
||||
|
@ -648,7 +648,7 @@ __udiv_w_sdiv (UWtype *rp __attribute__ ((__unused__)),
|
||||
#endif
|
||||
|
||||
#ifdef L_clz
|
||||
const UQItype __clz_tab[] =
|
||||
const UQItype __clz_tab[256] =
|
||||
{
|
||||
0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
@ -657,7 +657,7 @@ const UQItype __clz_tab[] =
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -731,7 +731,7 @@ extern const UQItype __popcount_tab[] ATTRIBUTE_HIDDEN;
|
||||
#endif
|
||||
|
||||
#ifdef L_popcount_tab
|
||||
const UQItype __popcount_tab[] =
|
||||
const UQItype __popcount_tab[256] =
|
||||
{
|
||||
0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
|
||||
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
|
||||
@ -740,7 +740,7 @@ const UQItype __popcount_tab[] =
|
||||
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
|
||||
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
|
||||
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
|
||||
3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,
|
||||
3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -373,6 +373,16 @@ typedef union
|
||||
DWtype ll;
|
||||
} DWunion;
|
||||
|
||||
/* Defined for L_popcount_tab. Exported here because some targets may
|
||||
want to use it for their own versions of the __popcount builtins. */
|
||||
extern const UQItype __popcount_tab[256];
|
||||
|
||||
/* Defined for L_clz. Exported here because some targets may want to use
|
||||
it for their own versions of the __clz builtins. It contains the bit
|
||||
position of the first set bit for the numbers 0 - 255. This avoids the
|
||||
need for a seperate table for the __ctz builtins. */
|
||||
extern const UQItype __clz_tab[256];
|
||||
|
||||
#include "longlong.h"
|
||||
|
||||
#undef int
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
|
||||
Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2004
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2004,
|
||||
2005 Free Software Foundation, Inc.
|
||||
|
||||
This definition file is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public
|
||||
@ -29,8 +29,7 @@
|
||||
DItype, UDItype -- Signed and unsigned 64 bit types.
|
||||
|
||||
On a 32 bit machine UWtype should typically be USItype;
|
||||
on a 64 bit machine, UWtype should typically be UDItype.
|
||||
*/
|
||||
on a 64 bit machine, UWtype should typically be UDItype. */
|
||||
|
||||
#define __BITS4 (W_TYPE_SIZE / 4)
|
||||
#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
|
||||
@ -42,6 +41,7 @@
|
||||
#define UWtype USItype
|
||||
#define UHWtype USItype
|
||||
#define UDWtype UDItype
|
||||
extern const UQItype __clz_tab[256] ATTRIBUTE_HIDDEN;
|
||||
#endif
|
||||
|
||||
/* Define auxiliary asm macros.
|
||||
@ -129,7 +129,6 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
|
||||
#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzl (X))
|
||||
#define COUNT_LEADING_ZEROS_0 64
|
||||
#else
|
||||
extern const UQItype __clz_tab[] ATTRIBUTE_HIDDEN;
|
||||
#define count_leading_zeros(COUNT,X) \
|
||||
do { \
|
||||
UDItype __xr = (X), __t, __a; \
|
||||
@ -1312,7 +1311,6 @@ UDItype __umulsidi3 (USItype, USItype);
|
||||
#endif
|
||||
|
||||
#if !defined (count_leading_zeros)
|
||||
extern const UQItype __clz_tab[] ATTRIBUTE_HIDDEN;
|
||||
#define count_leading_zeros(count, x) \
|
||||
do { \
|
||||
UWtype __xr = (x); \
|
||||
|
Loading…
x
Reference in New Issue
Block a user