diff options
Diffstat (limited to 'arch/m68k/lib/muldi3.c')
-rw-r--r-- | arch/m68k/lib/muldi3.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/arch/m68k/lib/muldi3.c b/arch/m68k/lib/muldi3.c index be4f275649e3..79e928a525d0 100644 --- a/arch/m68k/lib/muldi3.c +++ b/arch/m68k/lib/muldi3.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and | 1 | /* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and |
2 | gcc-2.7.2.3/longlong.h which is: */ | 2 | gcc-2.7.2.3/longlong.h which is: */ |
3 | /* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | 3 | /* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. |
4 | 4 | ||
@@ -19,7 +19,39 @@ along with GNU CC; see the file COPYING. If not, write to | |||
19 | the Free Software Foundation, 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | 20 | Boston, MA 02111-1307, USA. */ |
21 | 21 | ||
22 | #define BITS_PER_UNIT 8 | 22 | #if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE) |
23 | |||
24 | #define SI_TYPE_SIZE 32 | ||
25 | #define __BITS4 (SI_TYPE_SIZE / 4) | ||
26 | #define __ll_B (1L << (SI_TYPE_SIZE / 2)) | ||
27 | #define __ll_lowpart(t) ((USItype) (t) % __ll_B) | ||
28 | #define __ll_highpart(t) ((USItype) (t) / __ll_B) | ||
29 | |||
30 | #define umul_ppmm(w1, w0, u, v) \ | ||
31 | do { \ | ||
32 | USItype __x0, __x1, __x2, __x3; \ | ||
33 | USItype __ul, __vl, __uh, __vh; \ | ||
34 | \ | ||
35 | __ul = __ll_lowpart (u); \ | ||
36 | __uh = __ll_highpart (u); \ | ||
37 | __vl = __ll_lowpart (v); \ | ||
38 | __vh = __ll_highpart (v); \ | ||
39 | \ | ||
40 | __x0 = (USItype) __ul * __vl; \ | ||
41 | __x1 = (USItype) __ul * __vh; \ | ||
42 | __x2 = (USItype) __uh * __vl; \ | ||
43 | __x3 = (USItype) __uh * __vh; \ | ||
44 | \ | ||
45 | __x1 += __ll_highpart (__x0);/* this can't give carry */ \ | ||
46 | __x1 += __x2; /* but this indeed can */ \ | ||
47 | if (__x1 < __x2) /* did we get it? */ \ | ||
48 | __x3 += __ll_B; /* yes, add it in the proper pos. */ \ | ||
49 | \ | ||
50 | (w1) = __x3 + __ll_highpart (__x1); \ | ||
51 | (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \ | ||
52 | } while (0) | ||
53 | |||
54 | #else | ||
23 | 55 | ||
24 | #define umul_ppmm(w1, w0, u, v) \ | 56 | #define umul_ppmm(w1, w0, u, v) \ |
25 | __asm__ ("mulu%.l %3,%1:%0" \ | 57 | __asm__ ("mulu%.l %3,%1:%0" \ |
@@ -28,12 +60,14 @@ Boston, MA 02111-1307, USA. */ | |||
28 | : "%0" ((USItype)(u)), \ | 60 | : "%0" ((USItype)(u)), \ |
29 | "dmi" ((USItype)(v))) | 61 | "dmi" ((USItype)(v))) |
30 | 62 | ||
63 | #endif | ||
64 | |||
31 | #define __umulsidi3(u, v) \ | 65 | #define __umulsidi3(u, v) \ |
32 | ({DIunion __w; \ | 66 | ({DIunion __w; \ |
33 | umul_ppmm (__w.s.high, __w.s.low, u, v); \ | 67 | umul_ppmm (__w.s.high, __w.s.low, u, v); \ |
34 | __w.ll; }) | 68 | __w.ll; }) |
35 | 69 | ||
36 | typedef int SItype __attribute__ ((mode (SI))); | 70 | typedef int SItype __attribute__ ((mode (SI))); |
37 | typedef unsigned int USItype __attribute__ ((mode (SI))); | 71 | typedef unsigned int USItype __attribute__ ((mode (SI))); |
38 | typedef int DItype __attribute__ ((mode (DI))); | 72 | typedef int DItype __attribute__ ((mode (DI))); |
39 | typedef int word_type __attribute__ ((mode (__word__))); | 73 | typedef int word_type __attribute__ ((mode (__word__))); |