Commit ba964383 by Nick Clifton Committed by Nick Clifton

stormy16-lib2.c: Arrange for separate compilation of each function.

        * config/stormy16/stormy16-lib2.c: Arrange for separate
        compilation of each function.
        (__ffshi2): New function.
        (__stormy16_count_leading_zeros): New function.
        * config/stormy16/t-stormy16 (LIB2FUNCS_EXTRA): Use stub files to
        compile each function into its own object file.
        (stormy16-lib2-ashlsi3.c): New stub file.
        (stormy16-lib2-ashrsi3.c): New stub file.
        (stormy16-lib2-clzhi2.c): New stub file.
        (stormy16-lib2-count-leading-zeros.c): New stub file.
        (stormy16-lib2-ctzhi2.c): New stub file.
        (stormy16-lib2-divsi3.c): New stub file.
        (stormy16-lib2-ffshi2.c): New stub file.
        (stormy16-lib2-lshrsi3.c): New stub file.
        (stormy16-lib2-modsi3.c): New stub file.
        (stormy16-lib2-parityhi2.c): New stub file.
        (stormy16-lib2-popcounthi2.c): New stub file.
        (stormy16-lib2-udivmodsi4.c): New stub file.
        (stormy16-lib2-udivsi3.c): New stub file.
        (stormy16-lib2-umodsi3.c): New stub file.
        * longlong.h (count_leading_zeros): Define macro for stormy16
        target.
        (COUNT_LEADING_ZEROS_0): Likewise.

From-SVN: r154713
parent c7f06e13
2009-11-27 Nick Clifton <nickc@redhat.com>
* longlong.h (count_leading_zeros): Define macro for stormy16
target.
(COUNT_LEADING_ZEROS_0): Likewise.
* config/stormy16/stormy16-lib2.c: Arrange for separate
compilation of each function.
(__ffshi2): New function.
(__stormy16_count_leading_zeros): New function.
* config/stormy16/t-stormy16 (LIB2FUNCS_EXTRA): Use stub files to
compile each function into its own object file.
(stormy16-lib2-ashlsi3.c): New stub file.
(stormy16-lib2-ashrsi3.c): New stub file.
(stormy16-lib2-clzhi2.c): New stub file.
(stormy16-lib2-count-leading-zeros.c): New stub file.
(stormy16-lib2-ctzhi2.c): New stub file.
(stormy16-lib2-divsi3.c): New stub file.
(stormy16-lib2-ffshi2.c): New stub file.
(stormy16-lib2-lshrsi3.c): New stub file.
(stormy16-lib2-modsi3.c): New stub file.
(stormy16-lib2-parityhi2.c): New stub file.
(stormy16-lib2-popcounthi2.c): New stub file.
(stormy16-lib2-udivmodsi4.c): New stub file.
(stormy16-lib2-udivsi3.c): New stub file.
(stormy16-lib2-umodsi3.c): New stub file.
2009-11-27 Richard Henderson <rth@redhat.com> 2009-11-27 Richard Henderson <rth@redhat.com>
* config/i386/sse.md (vec_interleave_highv16qi, * config/i386/sse.md (vec_interleave_highv16qi,
#define XSTORMY16_ASHLSI3
#include "stormy16-lib2.c"
#define XSTORMY16_ASHRSI3
#include "stormy16-lib2.c"
#define XSTORMY16_CLZHI2
#include "stormy16-lib2.c"
#define XSTORMY16_COUNT_LEADING_ZEROS
#include "stormy16-lib2.c"
#define XSTORMY16_CTZHI2
#include "stormy16-lib2.c"
#define XSTORMY16_DIVSI3
#include "stormy16-lib2.c"
#define XSTORMY16_FFSHI2
#include "stormy16-lib2.c"
#define XSTORMY16_LSHRSI3
#include "stormy16-lib2.c"
#define XSTORMY16_MODSI3
#include "stormy16-lib2.c"
#define XSTORMY16_PARITYHI2
#include "stormy16-lib2.c"
#define XSTORMY16_POPCOUNTHI2
#include "stormy16-lib2.c"
#define XSTORMY16_UDIVMODSI4
#include "stormy16-lib2.c"
#define XSTORMY16_UDIVSI3
#include "stormy16-lib2.c"
#define XSTORMY16_UMODSI3
#include "stormy16-lib2.c"
...@@ -75,7 +75,7 @@ extern int __clzhi2 (UHWtype); ...@@ -75,7 +75,7 @@ extern int __clzhi2 (UHWtype);
extern int __ctzhi2 (UHWtype); extern int __ctzhi2 (UHWtype);
#ifdef XSTORMY16_UDIVMODSI4
USItype USItype
udivmodsi4 (USItype num, USItype den, word_type modwanted) udivmodsi4 (USItype num, USItype den, word_type modwanted)
{ {
...@@ -102,7 +102,9 @@ udivmodsi4 (USItype num, USItype den, word_type modwanted) ...@@ -102,7 +102,9 @@ udivmodsi4 (USItype num, USItype den, word_type modwanted)
return num; return num;
return res; return res;
} }
#endif
#ifdef XSTORMY16_DIVSI3
SItype SItype
__divsi3 (SItype a, SItype b) __divsi3 (SItype a, SItype b)
{ {
...@@ -128,7 +130,9 @@ __divsi3 (SItype a, SItype b) ...@@ -128,7 +130,9 @@ __divsi3 (SItype a, SItype b)
return res; return res;
} }
#endif
#ifdef XSTORMY16_MODSI3
SItype SItype
__modsi3 (SItype a, SItype b) __modsi3 (SItype a, SItype b)
{ {
...@@ -151,19 +155,25 @@ __modsi3 (SItype a, SItype b) ...@@ -151,19 +155,25 @@ __modsi3 (SItype a, SItype b)
return res; return res;
} }
#endif
#ifdef XSTORMY16_UDIVSI3
SItype SItype
__udivsi3 (SItype a, SItype b) __udivsi3 (SItype a, SItype b)
{ {
return udivmodsi4 (a, b, 0); return udivmodsi4 (a, b, 0);
} }
#endif
#ifdef XSTORMY16_UMODSI3
SItype SItype
__umodsi3 (SItype a, SItype b) __umodsi3 (SItype a, SItype b)
{ {
return udivmodsi4 (a, b, 1); return udivmodsi4 (a, b, 1);
} }
#endif
#ifdef XSTORMY16_ASHLSI3
SItype SItype
__ashlsi3 (SItype a, SItype b) __ashlsi3 (SItype a, SItype b)
{ {
...@@ -177,7 +187,9 @@ __ashlsi3 (SItype a, SItype b) ...@@ -177,7 +187,9 @@ __ashlsi3 (SItype a, SItype b)
a <<= 1; a <<= 1;
return a; return a;
} }
#endif
#ifdef XSTORMY16_ASHRSI3
SItype SItype
__ashrsi3 (SItype a, SItype b) __ashrsi3 (SItype a, SItype b)
{ {
...@@ -191,7 +203,9 @@ __ashrsi3 (SItype a, SItype b) ...@@ -191,7 +203,9 @@ __ashrsi3 (SItype a, SItype b)
a >>= 1; a >>= 1;
return a; return a;
} }
#endif
#ifdef XSTORMY16_LSHRSI3
USItype USItype
__lshrsi3 (USItype a, USItype b) __lshrsi3 (USItype a, USItype b)
{ {
...@@ -205,9 +219,11 @@ __lshrsi3 (USItype a, USItype b) ...@@ -205,9 +219,11 @@ __lshrsi3 (USItype a, USItype b)
a >>= 1; a >>= 1;
return a; return a;
} }
#endif
#ifdef XSTORMY16_POPCOUNTHI2
/* Returns the number of set bits in X. /* Returns the number of set bits in X.
FIXME: The return type really should be unsigned, FIXME: The return type really should be "unsigned int"
but this is not how the builtin is prototyped. */ but this is not how the builtin is prototyped. */
int int
__popcounthi2 (UHWtype x) __popcounthi2 (UHWtype x)
...@@ -219,9 +235,11 @@ __popcounthi2 (UHWtype x) ...@@ -219,9 +235,11 @@ __popcounthi2 (UHWtype x)
return ret; return ret;
} }
#endif
#ifdef XSTORMY16_PARITYHI2
/* Returns the number of set bits in X, modulo 2. /* Returns the number of set bits in X, modulo 2.
FIXME: The return type really should be unsigned, FIXME: The return type really should be "unsigned int"
but this is not how the builtin is prototyped. */ but this is not how the builtin is prototyped. */
int int
...@@ -232,32 +250,72 @@ __parityhi2 (UHWtype x) ...@@ -232,32 +250,72 @@ __parityhi2 (UHWtype x)
x &= 0xf; x &= 0xf;
return (0x6996 >> x) & 1; return (0x6996 >> x) & 1;
} }
#endif
#ifdef XSTORMY16_CLZHI2
/* Returns the number of leading zero bits in X. /* Returns the number of leading zero bits in X.
FIXME: The return type really should be unsigned, FIXME: The return type really should be "unsigned int"
but this is not how the builtin is prototyped. */ but this is not how the builtin is prototyped. */
int int
__clzhi2 (UHWtype x) __clzhi2 (UHWtype x)
{ {
if (x > 0xff) return __stormy16_count_leading_zeros (x);
return 8 - __clz_tab[x >> 8];
return 16 - __clz_tab[x];
} }
#endif
#ifdef XSTORMY16_CTZHI2
/* Returns the number of trailing zero bits in X. /* Returns the number of trailing zero bits in X.
FIXME: The return type really should be unsigned, FIXME: The return type really should be "signed int" since
but this is not how the builtin is prototyped. */ ctz(0) returns -1, but this is not how the builtin is prototyped. */
int int
__ctzhi2 (UHWtype x) __ctzhi2 (UHWtype x)
{ {
/* This is cunning. It converts X into a number with only the one bit /* 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 set, the bit that was the least significant bit in X. From this we
use the __clz_tab[] array to compute the number of trailing bits. */ can use the count_leading_zeros to compute the number of trailing
bits. */
x &= - x; x &= - x;
if (x > 0xff) return 15 - __stormy16_count_leading_zeros (x);
return __clz_tab[x >> 8] + 7; }
return __clz_tab[x] - 1; #endif
#ifdef XSTORMY16_FFSHI2
/* Returns one plus the index of the least significant 1-bit of X,
or if X is zero, returns zero. FIXME: The return type really
should be "unsigned int" but this is not how the builtin is
prototyped. */
int
__ffshi2 (UHWtype u)
{
UHWtype count;
if (u == 0)
return 0;
return 16 - __stormy16_count_leading_zeros (u & - u);
}
#endif
#ifdef XSTORMY16_COUNT_LEADING_ZEROS
#undef unsigned
/* Count the number of zero-bits from the most significant bit to the
first nonzero bit in VALUE. Returns 16 for VALUE == 0. Implemented
as a simple for loop in order to save space by removing the need for
the __clz_tab array. */
unsigned int
__stormy16_count_leading_zeros (unsigned int value)
{
unsigned int i;
unsigned int c;
for (c = 0, i = 1 << 15; i; i >>= 1, c++)
if (i & value)
break;
return c;
} }
#endif /* XSTORMY16_COUNT_LEADING_ZEROS */
...@@ -21,7 +21,21 @@ ...@@ -21,7 +21,21 @@
# SImode routines # SImode routines
LIB2FUNCS_EXTRA = \ LIB2FUNCS_EXTRA = \
$(srcdir)/config/stormy16/stormy16-lib2.c $(srcdir)/config/stormy16/stormy16-lib2-udivmodsi4.c \
$(srcdir)/config/stormy16/stormy16-lib2-divsi3.c \
$(srcdir)/config/stormy16/stormy16-lib2-modsi3.c \
$(srcdir)/config/stormy16/stormy16-lib2-udivsi3.c \
$(srcdir)/config/stormy16/stormy16-lib2-umodsi3.c \
$(srcdir)/config/stormy16/stormy16-lib2-ashlsi3.c \
$(srcdir)/config/stormy16/stormy16-lib2-ashrsi3.c \
$(srcdir)/config/stormy16/stormy16-lib2-lshrsi3.c \
$(srcdir)/config/stormy16/stormy16-lib2-popcounthi2.c \
$(srcdir)/config/stormy16/stormy16-lib2-parityhi2.c \
$(srcdir)/config/stormy16/stormy16-lib2-clzhi2.c \
$(srcdir)/config/stormy16/stormy16-lib2-ctzhi2.c \
$(srcdir)/config/stormy16/stormy16-lib2-ffshi2.c \
$(srcdir)/config/stormy16/stormy16-lib2-count-leading-zeros.c
# floating point emulation libraries # floating point emulation libraries
......
...@@ -1324,6 +1324,28 @@ UDItype __umulsidi3 (USItype, USItype); ...@@ -1324,6 +1324,28 @@ UDItype __umulsidi3 (USItype, USItype);
#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X)) #define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X))
#endif /* __xtensa__ */ #endif /* __xtensa__ */
#if defined xstormy16
extern UHItype __stormy16_count_leading_zeros (UHItype);
#define count_leading_zeros(count, x) \
do \
{ \
UHItype size; \
\
/* We assume that W_TYPE_SIZE is a multiple of 16... */ \
for ((count) = 0, size = W_TYPE_SIZE; size; size -= 16) \
{ \
UHItype c; \
\
c = __stormy16_count_leading_zeros ((x) >> (size - 16)); \
(count) += c; \
if (c != 16) \
break; \
} \
} \
while (0)
#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
#endif
#if defined (__z8000__) && W_TYPE_SIZE == 16 #if defined (__z8000__) && W_TYPE_SIZE == 16
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add %H1,%H5\n\tadc %H0,%H3" \ __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \
......
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