Patchwork XStormy16: Add __cmpsi2 function

login
register
mail settings
Submitter Nick Clifton
Date Aug. 11, 2010, 11:58 a.m.
Message ID <m34of1tl6v.fsf@redhat.com>
Download mbox | patch
Permalink /patch/61472/
State New
Headers show

Comments

Nick Clifton - Aug. 11, 2010, 11:58 a.m.
Hi Guys,

  I am checking in the patch below to add an implementation of the
  __cmpsi2 function to xstormy's libgcc.  I had thought that it would
  never be needed, but this turned out to be untrue.

  I am also changing the build optimization for libgcc (for the xstormy)
  from -Os to -O2 as this provides a better compromise between speed and
  size.

Cheers
  Nick

gcc/ChangeLog
2010-08-11  Nick Clifton  <nickc@redhat.com>

	* config/stormy16/stormy16-lib2.c (__cmpsi2): New function.
	* config/stormy16/stormy16-lib2-cmpsi2.c: New file.
	* config/stormy16/t-stormy16 (LIB2FUNCS_EXTRA): Add
	stormy16-lib2-cmpsi.c.

	* config/stormy16/t-stormy16 (TARGET_LIBGCC2_CFLAGS): Change to
	-O2.

Patch

Index: gcc/config/stormy16/t-stormy16
===================================================================
--- gcc/config/stormy16/t-stormy16	(revision 163096)
+++ gcc/config/stormy16/t-stormy16	(working copy)
@@ -33,6 +33,7 @@ 
 	$(srcdir)/config/stormy16/stormy16-lib2-clzhi2.c \
 	$(srcdir)/config/stormy16/stormy16-lib2-ctzhi2.c \
 	$(srcdir)/config/stormy16/stormy16-lib2-ffshi2.c \
+	$(srcdir)/config/stormy16/stormy16-lib2-cmpsi2.c \
 	$(srcdir)/config/stormy16/stormy16-lib2-ucmpsi2.c
 
 # Floating point emulation libraries.
@@ -46,4 +47,4 @@ 
 dp-bit.c: $(srcdir)/config/fp-bit.c
 	cat $(srcdir)/config/fp-bit.c > dp-bit.c
 
-TARGET_LIBGCC2_CFLAGS = -Os
+TARGET_LIBGCC2_CFLAGS = -O2
Index: gcc/config/stormy16/stormy16-lib2-cmpsi2.c
===================================================================
--- gcc/config/stormy16/stormy16-lib2-cmpsi2.c	(revision 0)
+++ gcc/config/stormy16/stormy16-lib2-cmpsi2.c	(revision 0)
@@ -0,0 +1,2 @@ 
+#define XSTORMY16_CMPSI2
+#include "stormy16-lib2.c"
Index: gcc/config/stormy16/stormy16-lib2.c
===================================================================
--- gcc/config/stormy16/stormy16-lib2.c	(revision 163096)
+++ gcc/config/stormy16/stormy16-lib2.c	(working copy)
@@ -332,3 +332,26 @@ 
   return hi_a < hi_b ? 0 : 2;
 }
 #endif
+
+#ifdef XSTORMY16_CMPSI2
+/* Performs an signed comparison of two 32-bit values: A and B.
+   If A is less than B, then 0 is returned.  If A is greater than B,
+   then 2 is returned.  Otherwise A and B are equal and 1 is returned.  */
+
+word_type
+__cmpsi2 (SItype a, SItype b)
+{
+  word_type hi_a = (a >> 16);
+  word_type hi_b = (b >> 16);
+
+  if (hi_a == hi_b)
+    {
+      word_type low_a = (a & 0xffff);
+      word_type low_b = (b & 0xffff);
+
+      return low_a < low_b ? 0 : (low_a > low_b ? 2 : 1);
+    }
+
+  return hi_a < hi_b ? 0 : 2;
+}
+#endif