OSDN Git Service

* config/stormy16/stormy16-lib2.c (__popcounthi2, __parityhi2, __ctzhi2,
authornickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Sep 2005 14:17:36 +0000 (14:17 +0000)
committernickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Sep 2005 14:17:36 +0000 (14:17 +0000)
__clzhi2): New functions.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@103779 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/stormy16/stormy16-lib2.c

index 8c31315..a89a70f 100644 (file)
@@ -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
index 7038624..8ca9484 100644 (file)
@@ -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;
+}