[OpenBIOS] r62 - openbios-devel/libgcc

svn@openbios.org svn at openbios.org
Sun Jun 11 12:50:32 CEST 2006


Author: stepan
Date: 2006-06-11 12:50:31 +0200 (Sun, 11 Jun 2006)
New Revision: 62

Added:
   openbios-devel/libgcc/__divti3.c
   openbios-devel/libgcc/__udivmodti4.c
   openbios-devel/libgcc/__udivti3.c
   openbios-devel/libgcc/__umodti3.c
   openbios-devel/libgcc/multi3.c
Modified:
   openbios-devel/libgcc/build.xml
Log:
add 128bit functions. 


Added: openbios-devel/libgcc/__divti3.c
===================================================================
--- openbios-devel/libgcc/__divti3.c	                        (rev 0)
+++ openbios-devel/libgcc/__divti3.c	2006-06-11 10:50:31 UTC (rev 62)
@@ -0,0 +1,29 @@
+/*
+ * arch/i386/libgcc/__divti3.c
+ */
+
+#include "asm/types.h"
+#define NULL ((void *)0)
+
+extern __uint128_t __udivmodti4(__uint128_t num, __uint128_t den, __uint128_t *rem);
+
+__int128_t __divti3(__int128_t num, __int128_t den)
+{
+  int minus = 0;
+  __int128_t v;
+
+  if ( num < 0 ) {
+    num = -num;
+    minus = 1;
+  }
+  if ( den < 0 ) {
+    den = -den;
+    minus ^= 1;
+  }
+
+  v = __udivmodti4(num, den, NULL);
+  if ( minus )
+    v = -v;
+
+  return v;
+}

Added: openbios-devel/libgcc/__udivmodti4.c
===================================================================
--- openbios-devel/libgcc/__udivmodti4.c	                        (rev 0)
+++ openbios-devel/libgcc/__udivmodti4.c	2006-06-11 10:50:31 UTC (rev 62)
@@ -0,0 +1,34 @@
+#include "asm/types.h"
+
+extern void __divide_error();
+
+__uint128_t __udivmodti4(__uint128_t num, __uint128_t den, __uint128_t *rem_p)
+{
+  __uint128_t quot = 0, qbit = 1;
+
+  if ( den == 0 ) {
+    __divide_error();
+    return 0;			/* If trap returns... */
+  }
+
+  /* Left-justify denominator and count shift */
+  while ( (__int128_t)den >= 0 ) {
+    den <<= 1;
+    qbit <<= 1;
+  }
+
+  while ( qbit ) {
+    if ( den <= num ) {
+      num -= den;
+      quot += qbit;
+    }
+    den >>= 1;
+    qbit >>= 1;
+  }
+
+  if ( rem_p )
+    *rem_p = num;
+
+  return quot;
+}
+

Added: openbios-devel/libgcc/__udivti3.c
===================================================================
--- openbios-devel/libgcc/__udivti3.c	                        (rev 0)
+++ openbios-devel/libgcc/__udivti3.c	2006-06-11 10:50:31 UTC (rev 62)
@@ -0,0 +1,13 @@
+/*
+ * arch/i386/libgcc/__divdi3.c
+ */
+
+#include "asm/types.h"
+#define NULL ((void *)0)
+
+extern __uint128_t __udivmodti4(__uint128_t num, __uint128_t den, __uint128_t *rem);
+
+__uint128_t __udivti3(__uint128_t num, __uint128_t den)
+{
+  return __udivmodti4(num, den, NULL);
+}

Added: openbios-devel/libgcc/__umodti3.c
===================================================================
--- openbios-devel/libgcc/__umodti3.c	                        (rev 0)
+++ openbios-devel/libgcc/__umodti3.c	2006-06-11 10:50:31 UTC (rev 62)
@@ -0,0 +1,15 @@
+/*
+ * arch/i386/libgcc/__umoddi3.c
+ */
+
+#include "asm/types.h"
+
+extern __uint128_t __udivmodti4(__uint128_t num, __uint128_t den, __uint128_t *rem);
+
+__uint128_t __umodti3(__uint128_t num, __uint128_t den)
+{
+  __uint128_t v;
+
+  (void) __udivmodti4(num, den, &v);
+  return v;
+}

Modified: openbios-devel/libgcc/build.xml
===================================================================
--- openbios-devel/libgcc/build.xml	2006-06-10 02:22:45 UTC (rev 61)
+++ openbios-devel/libgcc/build.xml	2006-06-11 10:50:31 UTC (rev 62)
@@ -3,11 +3,19 @@
  <library name="gcc" type="static" target="target">
   <object source="ashldi3.c"/>
   <object source="ashrdi3.c"/>
+  <object source="__lshrdi3.c"/>
+
   <object source="__divdi3.c"/>
   <object source="__udivdi3.c"/>
   <object source="__udivmoddi4.c"/>
   <object source="__umoddi3.c"/>
-  <object source="__lshrdi3.c"/>
+  <object source="__divti3.c"/>
+  <object source="__udivti3.c"/>
+  <object source="__udivmodti4.c"/>
+  <object source="__umodti3.c"/>
+
+  <object source="multi3.c"/>
+
  </library>
 
 </build>

Added: openbios-devel/libgcc/multi3.c
===================================================================
--- openbios-devel/libgcc/multi3.c	                        (rev 0)
+++ openbios-devel/libgcc/multi3.c	2006-06-11 10:50:31 UTC (rev 62)
@@ -0,0 +1,86 @@
+/* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and 
+			   gcc-2.7.2.3/longlong.h which is: */
+/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+#define BITS_PER_UNIT 8
+#define DI_TYPE_SIZE 64
+
+#define __BITS4 (DI_TYPE_SIZE / 4)
+#define __ll_B (1L << (DI_TYPE_SIZE / 2))
+#define __ll_lowpart(t) ((UDItype) (t) % __ll_B)
+#define __ll_highpart(t) ((UDItype) (t) / __ll_B)
+
+#define umul_ppmm(w1, w0, u, v)						\
+  do {									\
+    UDItype __x0, __x1, __x2, __x3;					\
+    UDItype __ul, __vl, __uh, __vh;					\
+									\
+    __ul = __ll_lowpart (u);						\
+    __uh = __ll_highpart (u);						\
+    __vl = __ll_lowpart (v);						\
+    __vh = __ll_highpart (v);						\
+									\
+    __x0 = (UDItype) __ul * __vl;					\
+    __x1 = (UDItype) __ul * __vh;					\
+    __x2 = (UDItype) __uh * __vl;					\
+    __x3 = (UDItype) __uh * __vh;					\
+									\
+    __x1 += __ll_highpart (__x0);/* this can't give carry */		\
+    __x1 += __x2;		/* but this indeed can */		\
+    if (__x1 < __x2)		/* did we get it? */			\
+      __x3 += __ll_B;		/* yes, add it in the proper pos. */	\
+									\
+    (w1) = __x3 + __ll_highpart (__x1);					\
+    (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0);		\
+  } while (0)
+
+#define __umulsidi3(u, v) \
+  ({TIunion __w;							\
+    umul_ppmm (__w.s.high, __w.s.low, u, v);				\
+    __w.ll; })
+
+typedef 	 int DItype	__attribute__ ((mode (DI)));
+typedef unsigned int UDItype	__attribute__ ((mode (DI)));
+typedef		 int TItype	__attribute__ ((mode (TI)));
+typedef int word_type __attribute__ ((mode (__word__)));
+
+struct TIstruct {DItype high, low;};
+
+typedef union
+{
+  struct TIstruct s;
+  TItype ll;
+} TIunion;
+
+TItype
+__multi3 (TItype u, TItype v)
+{
+  TIunion w;
+  TIunion uu, vv;
+
+  uu.ll = u,
+  vv.ll = v;
+
+  w.ll = __umulsidi3 (uu.s.low, vv.s.low);
+  w.s.high += ((UDItype) uu.s.low * (UDItype) vv.s.high
+	       + (UDItype) uu.s.high * (UDItype) vv.s.low);
+
+  return w.ll;
+}




More information about the OpenBIOS mailing list