Mercurial > hg > CbC > CbC_gcc
diff gcc/config/stormy16/stormy16-lib2.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
line wrap: on
line diff
--- a/gcc/config/stormy16/stormy16-lib2.c Sun Feb 07 18:28:00 2010 +0900 +++ b/gcc/config/stormy16/stormy16-lib2.c Fri Feb 12 23:39:51 2010 +0900 @@ -75,7 +75,7 @@ extern int __ctzhi2 (UHWtype); - +#ifdef XSTORMY16_UDIVMODSI4 USItype udivmodsi4 (USItype num, USItype den, word_type modwanted) { @@ -102,7 +102,9 @@ return num; return res; } +#endif +#ifdef XSTORMY16_DIVSI3 SItype __divsi3 (SItype a, SItype b) { @@ -128,7 +130,9 @@ return res; } +#endif +#ifdef XSTORMY16_MODSI3 SItype __modsi3 (SItype a, SItype b) { @@ -151,19 +155,25 @@ return res; } +#endif +#ifdef XSTORMY16_UDIVSI3 SItype __udivsi3 (SItype a, SItype b) { return udivmodsi4 (a, b, 0); } +#endif +#ifdef XSTORMY16_UMODSI3 SItype __umodsi3 (SItype a, SItype b) { return udivmodsi4 (a, b, 1); } +#endif +#ifdef XSTORMY16_ASHLSI3 SItype __ashlsi3 (SItype a, SItype b) { @@ -177,7 +187,9 @@ a <<= 1; return a; } +#endif +#ifdef XSTORMY16_ASHRSI3 SItype __ashrsi3 (SItype a, SItype b) { @@ -191,7 +203,9 @@ a >>= 1; return a; } +#endif +#ifdef XSTORMY16_LSHRSI3 USItype __lshrsi3 (USItype a, USItype b) { @@ -205,9 +219,11 @@ a >>= 1; return a; } +#endif +#ifdef XSTORMY16_POPCOUNTHI2 /* 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. */ int __popcounthi2 (UHWtype x) @@ -219,9 +235,11 @@ return ret; } +#endif +#ifdef XSTORMY16_PARITYHI2 /* 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. */ int @@ -232,32 +250,62 @@ x &= 0xf; return (0x6996 >> x) & 1; } +#endif -/* 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. */ - +#ifdef XSTORMY16_CLZHI2 +/* Returns the number of zero-bits from the most significant bit to the + first nonzero bit in X. Returns 16 for X == 0. Implemented as a + simple for loop in order to save space by removing the need for + the __clz_tab array. + FIXME: The return type really should be "unsigned int" but this is + not how the builtin is prototyped. */ +#undef unsigned int __clzhi2 (UHWtype x) { - if (x > 0xff) - return 8 - __clz_tab[x >> 8]; - return 16 - __clz_tab[x]; + unsigned int i; + unsigned int c; + unsigned int value = x; + + for (c = 0, i = 1 << 15; i; i >>= 1, c++) + if (i & value) + break; + return c; } +#endif +#ifdef XSTORMY16_CTZHI2 /* 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. */ + FIXME: The return type really should be "signed int" since + ctz(0) returns -1, 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. */ + set, the bit that was the least significant bit in X. From this we + can use the count_leading_zeros to compute the number of trailing + bits. */ x &= - x; - if (x > 0xff) - return __clz_tab[x >> 8] + 7; - return __clz_tab[x] - 1; + return 15 - __builtin_clz (x); } +#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 - __builtin_clz (u & - u); +} +#endif