1 // SPDX-License-Identifier: GPL-2.0
4 #define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
5 #define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
6 #define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
8 #define umul_ppmm(w1, w0, u, v) \
10 UWtype __x0, __x1, __x2, __x3; \
11 UHWtype __ul, __vl, __uh, __vh; \
12 __ul = __ll_lowpart(u); \
13 __uh = __ll_highpart(u); \
14 __vl = __ll_lowpart(v); \
15 __vh = __ll_highpart(v); \
16 __x0 = (UWtype) __ul * __vl; \
17 __x1 = (UWtype) __ul * __vh; \
18 __x2 = (UWtype) __uh * __vl; \
19 __x3 = (UWtype) __uh * __vh; \
20 __x1 += __ll_highpart(__x0); \
24 (w1) = __x3 + __ll_highpart(__x1); \
25 (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0); \
28 #define __umulsidi3(u, v) ( \
31 umul_ppmm(__w.s.high, __w.s.low, u, v); \
35 DWtype
__muldi3(DWtype u
, DWtype v
)
37 const DWunion uu
= {.ll
= u
};
38 const DWunion vv
= {.ll
= v
};
39 DWunion w
= {.ll
= __umulsidi3(uu
.s
.low
, vv
.s
.low
)};
41 w
.s
.high
+= ((UWtype
) uu
.s
.low
* (UWtype
) vv
.s
.high
42 + (UWtype
) uu
.s
.high
* (UWtype
) vv
.s
.low
);