]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/sparc/sparc32/sparcv9/mul_1.S
992d61b0528da3b01356e43ec58db0005930bb35
[thirdparty/glibc.git] / sysdeps / sparc / sparc32 / sparcv9 / mul_1.S
1 ! SPARC v9 32-bit __mpn_mul_1 -- Multiply a limb vector with a single
2 ! limb and store the product in a second limb vector.
3 !
4 ! Copyright (C) 2013-2014 Free Software Foundation, Inc.
5 ! This file is part of the GNU C Library.
6 ! Contributed by David S. Miller <davem@davemloft.net>
7 !
8 ! The GNU C Library is free software; you can redistribute it and/or
9 ! modify it under the terms of the GNU Lesser General Public
10 ! License as published by the Free Software Foundation; either
11 ! version 2.1 of the License, or (at your option) any later version.
12 !
13 ! The GNU C Library is distributed in the hope that it will be useful,
14 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ! Lesser General Public License for more details.
17 !
18 ! You should have received a copy of the GNU Lesser General Public
19 ! License along with the GNU C Library; if not, see
20 ! <http://www.gnu.org/licenses/>.
21
22 #include <sysdep.h>
23
24 #define res_ptr %o0
25 #define s1_ptr %o1
26 #define sz %o2
27 #define s2_limb %o3
28 #define carry %o5
29 #define tmp1 %g1
30 #define tmp2 %g2
31 #define tmp3 %g3
32 #define tmp4 %o4
33
34 ENTRY(__mpn_mul_1)
35 srl sz, 0, sz
36 srl s2_limb, 0, s2_limb
37 subcc sz, 1, sz
38 be,pn %icc, .Lfinal_limb
39 clr carry
40
41 .Lloop:
42 lduw [s1_ptr + 0x00], tmp1
43 lduw [s1_ptr + 0x04], tmp2
44 mulx tmp1, s2_limb, tmp3
45 add s1_ptr, 8, s1_ptr
46 mulx tmp2, s2_limb, tmp4
47 sub sz, 2, sz
48 add res_ptr, 8, res_ptr
49 add carry, tmp3, tmp3
50 stw tmp3, [res_ptr - 0x08]
51 srlx tmp3, 32, carry
52 add carry, tmp4, tmp4
53 stw tmp4, [res_ptr - 0x04]
54 brgz sz, .Lloop
55 srlx tmp4, 32, carry
56
57 brlz,pt sz, .Lfinish
58 nop
59
60 .Lfinal_limb:
61 lduw [s1_ptr + 0x00], tmp1
62 mulx tmp1, s2_limb, tmp3
63 add carry, tmp3, tmp3
64 stw tmp3, [res_ptr + 0x00]
65 srlx tmp3, 32, carry
66
67 .Lfinish:
68 retl
69 mov carry, %o0
70 END(__mpn_mul_1)