summaryrefslogtreecommitdiff
path: root/libgcc/config/m32c/lib2funcs.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2012-08-01 09:36:01 +0000
committerNick Clifton <nickc@gcc.gnu.org>2012-08-01 09:36:01 +0000
commitd04aacfc87503addc886a6a0ee9e69d73ffc280f (patch)
tree74fcf3af710e09b1234961cf95516e4a23b7acdc /libgcc/config/m32c/lib2funcs.c
parentcecd512351699ce0a43ae82c12b7f78c30ea78af (diff)
downloadgcc-d04aacfc87503addc886a6a0ee9e69d73ffc280f.tar.gz
lib2funcs.c (__clrsbhi2): New function.
* config/m32c/lib2funcs.c (__clrsbhi2): New function. Implements __clrsb for an HImode argument. From-SVN: r190032
Diffstat (limited to 'libgcc/config/m32c/lib2funcs.c')
-rw-r--r--libgcc/config/m32c/lib2funcs.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libgcc/config/m32c/lib2funcs.c b/libgcc/config/m32c/lib2funcs.c
index 274affc4ab0..76b237cdf26 100644
--- a/libgcc/config/m32c/lib2funcs.c
+++ b/libgcc/config/m32c/lib2funcs.c
@@ -1,5 +1,5 @@
/* libgcc routines for R8C/M16C/M32C
- Copyright (C) 2005, 2009
+ Copyright (C) 2005, 2009, 2012
Free Software Foundation, Inc.
Contributed by Red Hat.
@@ -132,3 +132,17 @@ __umoddi3 (uint32_type a, uint32_type b)
{
return udivmodsi4 (a, b, 1);
}
+
+/* Returns the number of leading redundant sign bits in X.
+ I.e. the number of bits following the most significant bit which are
+ identical to it. There are no special cases for 0 or other values. */
+
+int
+__clrsbhi2 (word_type x)
+{
+ if (x < 0)
+ x = ~x;
+ if (x == 0)
+ return 15;
+ return __builtin_clz (x) - 1;
+}