diff mbox

RFA: M32C: Add __clrsbhi2 to libgcc

Message ID 87obmwuufj.fsf@redhat.com
State New
Headers show

Commit Message

Nick Clifton July 31, 2012, 9:54 a.m. UTC
Hi DJ,

  The patch below adds an implementation of the __clrsbhi2 function to
  libgcc for the M32C port.  Implementing this function resolves several
  gcc testsuite failures that rely upon the function being present.

  Ok to apply ?

Cheers
  Nick

libgcc/ChangeLog
2012-07-31  Nick Clifton  <nickc@redhat.com>

	* config/m32c/lib2funcs.c (__clrsbhi2): New function.

Comments

DJ Delorie July 31, 2012, 7:16 p.m. UTC | #1
Ok.
diff mbox

Patch

Index: libgcc/config/m32c/lib2funcs.c
===================================================================
--- libgcc/config/m32c/lib2funcs.c	(revision 189996)
+++ libgcc/config/m32c/lib2funcs.c	(working copy)
@@ -132,3 +132,17 @@ 
 {
   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;
+}