diff mbox

[27/28] mn10300: Add support in longlong.h.

Message ID 1294691517-19580-28-git-send-email-rth@redhat.com
State New
Headers show

Commit Message

Richard Henderson Jan. 10, 2011, 8:31 p.m. UTC
From: Richard Henderson <rth@twiddle.net>

This greatly helps out the DImode division, and to a lesser
extent the DImode multiplication routines in libgcc2.c.
---
 gcc/longlong.h |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

Comments

Jeff Law Jan. 12, 2011, 2:06 p.m. UTC | #1
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/10/11 13:31, Richard Henderson wrote:
> From: Richard Henderson <rth@twiddle.net>
> 
> This greatly helps out the DImode division, and to a lesser
> extent the DImode multiplication routines in libgcc2.c.
OK.
jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNLbV1AAoJEBRtltQi2kC7csoH/0Sngi+AhO/FG/+Cyf095wg2
yqA24oL+6Qp15+4ce4CVcj2GDWwA7DytIf0GHg9BdI7qRhznnj1yEKC6hbkxy3yD
YpHW87UK6D5xMbgM9uhIpx1rwsn5xGCOQjIzjqJ1d3Zd0FOuhTFeMYnlqKVe3kmo
/AAk7v+tXhDDc2zXZ5qQ99Za/x28fucPzJwcYKv27JCmkAH4leP/ES62HvEo27O2
P/VIOI0MpNCphyoC01dielNdZ8UJsl5Tyi1SreNT3V/FQOTDtNQX4O5897FCmbLW
pulamCH2xpqjtrQIiMPuZ3hRd1ksBHTP8SGeV7sER0eZA5ahdjuMB9MtzaQyZzo=
=kCWq
-----END PGP SIGNATURE-----
Richard Henderson Jan. 12, 2011, 6:02 p.m. UTC | #2
On 01/12/2011 06:06 AM, Jeff Law wrote:
>> This greatly helps out the DImode division, and to a lesser
>> extent the DImode multiplication routines in libgcc2.c.
> OK.

Thanks.  Blocked on [16/28] Expose MDR register, and to a
lesser extent [24/28] Implement adddi3.


r~
diff mbox

Patch

diff --git a/gcc/longlong.h b/gcc/longlong.h
index bb916ae..5937a48 100644
--- a/gcc/longlong.h
+++ b/gcc/longlong.h
@@ -718,6 +718,43 @@  UDItype __umulsidi3 (USItype, USItype);
 #endif /* __mc88110__ */
 #endif /* __m88000__ */
 
+#if defined (__mn10300__)
+# if defined (__AM33__)
+#  define count_leading_zeros(COUNT,X)	((COUNT) = __builtin_clz (X))
+#  define umul_ppmm(w1, w0, u, v)		\
+    asm("mulu %3,%2,%1,%0" : "=r"(w0), "=r"(w1) : "r"(u), "r"(v))
+#  define smul_ppmm(w1, w0, u, v)		\
+    asm("mul %3,%2,%1,%0" : "=r"(w0), "=r"(w1) : "r"(u), "r"(v))
+# else
+#  define umul_ppmm(w1, w0, u, v)		\
+    asm("nop; nop; mulu %3,%0" : "=d"(w0), "=z"(w1) : "%0"(u), "d"(v))
+#  define smul_ppmm(w1, w0, u, v)		\
+    asm("nop; nop; mul %3,%0" : "=d"(w0), "=z"(w1) : "%0"(u), "d"(v))
+# endif
+# define add_ssaaaa(sh, sl, ah, al, bh, bl)	\
+  do {						\
+    DWunion __s, __a, __b;			\
+    __a.s.low = (al); __a.s.high = (ah);	\
+    __b.s.low = (bl); __b.s.high = (bh);	\
+    __s.ll = __a.ll + __b.ll;			\
+    (sl) = __s.s.low; (sh) = __s.s.high;	\
+  } while (0)
+# define sub_ddmmss(sh, sl, ah, al, bh, bl)	\
+  do {						\
+    DWunion __s, __a, __b;			\
+    __a.s.low = (al); __a.s.high = (ah);	\
+    __b.s.low = (bl); __b.s.high = (bh);	\
+    __s.ll = __a.ll - __b.ll;			\
+    (sl) = __s.s.low; (sh) = __s.s.high;	\
+  } while (0)
+# define udiv_qrnnd(q, r, nh, nl, d)		\
+  asm("divu %2,%0" : "=D"(q), "=z"(r) : "D"(d), "0"(nl), "1"(nh))
+# define sdiv_qrnnd(q, r, nh, nl, d)		\
+  asm("div %2,%0" : "=D"(q), "=z"(r) : "D"(d), "0"(nl), "1"(nh))
+# define UMUL_TIME 3
+# define UDIV_TIME 38
+#endif
+
 #if defined (__mips__) && W_TYPE_SIZE == 32
 #define umul_ppmm(w1, w0, u, v)						\
   do {									\