ppc64: Don't set Kp bit on SLB
[openbios.git] / libgcc / multi3.c
blobe7186be2a67d4874ba431daf8a684b57014ba7e5
1 /* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and
2 gcc-2.7.2.3/longlong.h which is: */
3 /* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 51 Franklin St, Fifth Floor, Boston,
20 MA 02110-1301, USA. */
22 #include "libgcc.h"
24 #define BITS_PER_UNIT 8
25 #define DI_TYPE_SIZE 64
27 #define __BITS4 (DI_TYPE_SIZE / 4)
28 #define __ll_B (1L << (DI_TYPE_SIZE / 2))
29 #define __ll_lowpart(t) ((UDItype) (t) % __ll_B)
30 #define __ll_highpart(t) ((UDItype) (t) / __ll_B)
32 #define umul_ppmm(w1, w0, u, v) \
33 do { \
34 UDItype __x0, __x1, __x2, __x3; \
35 UDItype __ul, __vl, __uh, __vh; \
37 __ul = __ll_lowpart (u); \
38 __uh = __ll_highpart (u); \
39 __vl = __ll_lowpart (v); \
40 __vh = __ll_highpart (v); \
42 __x0 = (UDItype) __ul * __vl; \
43 __x1 = (UDItype) __ul * __vh; \
44 __x2 = (UDItype) __uh * __vl; \
45 __x3 = (UDItype) __uh * __vh; \
47 __x1 += __ll_highpart (__x0);/* this can't give carry */ \
48 __x1 += __x2; /* but this indeed can */ \
49 if (__x1 < __x2) /* did we get it? */ \
50 __x3 += __ll_B; /* yes, add it in the proper pos. */ \
52 (w1) = __x3 + __ll_highpart (__x1); \
53 (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
54 } while (0)
56 #define __umulsidi3(u, v) \
57 ({TIunion __w; \
58 umul_ppmm (__w.s.high, __w.s.low, u, v); \
59 __w.ll; })
61 struct TIstruct {DItype high, low;};
63 typedef union
65 struct TIstruct s;
66 TItype ll;
67 } TIunion;
69 TItype
70 __multi3 (TItype u, TItype v)
72 TIunion w;
73 TIunion uu, vv;
75 uu.ll = u,
76 vv.ll = v;
78 w.ll = __umulsidi3 (uu.s.low, vv.s.low);
79 w.s.high += ((UDItype) uu.s.low * (UDItype) vv.s.high
80 + (UDItype) uu.s.high * (UDItype) vv.s.low);
82 return w.ll;