1 /* ===-- muldi3.c - Implement __muldi3 -------------------------------------===
3 * The LLVM Compiler Infrastructure
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
8 * ===----------------------------------------------------------------------===
10 * This file implements __muldi3 for the compiler_rt library.
12 * ===----------------------------------------------------------------------===
21 __muldsi3(su_int a
, su_int b
)
24 const int bits_in_word_2
= (int)(sizeof(si_int
) * CHAR_BIT
) / 2;
25 const su_int lower_mask
= (su_int
)~0 >> bits_in_word_2
;
26 r
.s
.low
= (a
& lower_mask
) * (b
& lower_mask
);
27 su_int t
= r
.s
.low
>> bits_in_word_2
;
28 r
.s
.low
&= lower_mask
;
29 t
+= (a
>> bits_in_word_2
) * (b
& lower_mask
);
30 r
.s
.low
+= (t
& lower_mask
) << bits_in_word_2
;
31 r
.s
.high
= t
>> bits_in_word_2
;
32 t
= r
.s
.low
>> bits_in_word_2
;
33 r
.s
.low
&= lower_mask
;
34 t
+= (b
>> bits_in_word_2
) * (a
& lower_mask
);
35 r
.s
.low
+= (t
& lower_mask
) << bits_in_word_2
;
36 r
.s
.high
+= t
>> bits_in_word_2
;
37 r
.s
.high
+= (a
>> bits_in_word_2
) * (b
>> bits_in_word_2
);
43 ARM_EABI_FNALIAS(lmul
, muldi3
)
45 COMPILER_RT_ABI di_int
46 __muldi3(di_int a
, di_int b
)
53 r
.all
= __muldsi3(x
.s
.low
, y
.s
.low
);
54 r
.s
.high
+= x
.s
.high
* y
.s
.low
+ x
.s
.low
* y
.s
.high
;