From 72a6151bdf47d02fad580dceed43db197277e127 Mon Sep 17 00:00:00 2001 From: nickc Date: Fri, 2 Sep 2005 14:17:36 +0000 Subject: [PATCH] * config/stormy16/stormy16-lib2.c (__popcounthi2, __parityhi2, __ctzhi2, __clzhi2): New functions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@103779 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 ++++ gcc/config/stormy16/stormy16-lib2.c | 49 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8c31315..a89a70f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +005-09-02 Nick Clifton + + * config/stormy16/stormy16-lib2.c (__popcounthi2, __parityhi2, + __ctzhi2, __clzhi2): New functions. + 2005-09-02 Andrew Pinski PR middle-end/23547 diff --git a/gcc/config/stormy16/stormy16-lib2.c b/gcc/config/stormy16/stormy16-lib2.c index 7038624..8ca9484 100644 --- a/gcc/config/stormy16/stormy16-lib2.c +++ b/gcc/config/stormy16/stormy16-lib2.c @@ -140,3 +140,52 @@ __lshrsi3 (USItype a, USItype b) a >>= 1; 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, +}; + +int +__popcounthi2 (unsigned int x) +{ + unsigned int ret; + + ret = __popcount_tab [x & 0xff]; + ret += __popcount_tab [(x >> 8) & 0xff]; + + return ret; +} + +int +__parityhi2 (unsigned int x) +{ + x ^= x >> 8; + x ^= x >> 4; + x &= 0xf; + return (0x6996 >> x) & 1; +} + +int +__ctzhi2 (unsigned int x) +{ + extern int __ctzsi2 (unsigned long); + unsigned long y = x; + + return __ctzsi2 (y << 16) - 16; +} + +int +__clzhi2 (unsigned int x) +{ + extern int __clzsi2 (unsigned long); + + return __clzsi2 (x) - 16; +} -- 2.7.4