summaryrefslogtreecommitdiff
path: root/gcc/config/stormy16/stormy16-lib2.c
diff options
context:
space:
mode:
authornickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-02 14:17:36 +0000
committernickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-02 14:17:36 +0000
commit72a6151bdf47d02fad580dceed43db197277e127 (patch)
tree68d8f0a4e38bd0957da4573d0051e7dc8e89be12 /gcc/config/stormy16/stormy16-lib2.c
parentda6b28c3ce91578d3b8fe0ce85ccdb175fbad541 (diff)
downloadgcc-72a6151bdf47d02fad580dceed43db197277e127.tar.gz
* 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
Diffstat (limited to 'gcc/config/stormy16/stormy16-lib2.c')
-rw-r--r--gcc/config/stormy16/stormy16-lib2.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/config/stormy16/stormy16-lib2.c b/gcc/config/stormy16/stormy16-lib2.c
index 7038624be0e..8ca9484dc94 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;
+}