Patchwork RFA: M32C: Add __clrsbhi2 to libgcc

login
register
mail settings
Submitter Nick Clifton
Date July 31, 2012, 9:54 a.m.
Message ID <87obmwuufj.fsf@redhat.com>
Download mbox | patch
Permalink /patch/174213/
State New
Headers show

Comments

Nick Clifton - July 31, 2012, 9:54 a.m.
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.
DJ Delorie - July 31, 2012, 7:16 p.m.
Ok.

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;
+}