aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2005-09-02 14:17:36 +0000
committerNick Clifton <nickc@gcc.gnu.org>2005-09-02 14:17:36 +0000
commitebf178cd33b328d2d47c4845e5711edd4492b85d (patch)
tree68d8f0a4e38bd0957da4573d0051e7dc8e89be12 /gcc
parente55a7487cae2538bb61e30978ade1ecc96a6997c (diff)
downloadgcc-ebf178cd33b328d2d47c4845e5711edd4492b85d.zip
gcc-ebf178cd33b328d2d47c4845e5711edd4492b85d.tar.gz
gcc-ebf178cd33b328d2d47c4845e5711edd4492b85d.tar.bz2
stormy16-lib2.c (__popcounthi2, [...]): New functions.
* config/stormy16/stormy16-lib2.c (__popcounthi2, __parityhi2, __ctzhi2, __clzhi2): New functions. From-SVN: r103779
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/stormy16/stormy16-lib2.c49
2 files changed, 54 insertions, 0 deletions
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 <nickc@redhat.com>
+
+ * config/stormy16/stormy16-lib2.c (__popcounthi2, __parityhi2,
+ __ctzhi2, __clzhi2): New functions.
+
2005-09-02 Andrew Pinski <pinskia@physics.uc.edu>
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;
+}