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-2022 Free Software Foundation, Inc.
5! This file is part of the GNU C Library.
6!
7! The GNU C Library is free software; you can redistribute it and/or
8! modify it under the terms of the GNU Lesser General Public
9! License as published by the Free Software Foundation; either
10! version 2.1 of the License, or (at your option) any later version.
11!
12! The GNU C Library 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 GNU
15! Lesser General Public License for more details.
16!
17! You should have received a copy of the GNU Lesser General Public
18! License along with the GNU C Library; if not, see
19! <https://www.gnu.org/licenses/>.
20
21#include <sysdep.h>
22
23#define res_ptr	%o0
24#define s1_ptr	%o1
25#define sz	%o2
26#define s2_limb	%o3
27#define carry	%o5
28#define tmp1	%g1
29#define tmp2	%g2
30#define tmp3	%g3
31#define tmp4	%o4
32
33ENTRY(__mpn_mul_1)
34	srl	sz, 0, sz
35	srl	s2_limb, 0, s2_limb
36	subcc	sz, 1, sz
37	be,pn	%icc, .Lfinal_limb
38	 clr	carry
39
40.Lloop:
41	lduw	[s1_ptr + 0x00], tmp1
42	lduw	[s1_ptr + 0x04], tmp2
43	mulx	tmp1, s2_limb, tmp3
44	add	s1_ptr, 8, s1_ptr
45	mulx	tmp2, s2_limb, tmp4
46	sub	sz, 2, sz
47	add	res_ptr, 8, res_ptr
48	add	carry, tmp3, tmp3
49	stw	tmp3, [res_ptr - 0x08]
50	srlx	tmp3, 32, carry
51	add	carry, tmp4, tmp4
52	stw	tmp4, [res_ptr - 0x04]
53	brgz	sz, .Lloop
54	 srlx	tmp4, 32, carry
55
56	brlz,pt	sz, .Lfinish
57	 nop
58
59.Lfinal_limb:
60	lduw	[s1_ptr + 0x00], tmp1
61	mulx	tmp1, s2_limb, tmp3
62	add	carry, tmp3, tmp3
63	stw	tmp3, [res_ptr + 0x00]
64	srlx	tmp3, 32, carry
65
66.Lfinish:
67	retl
68	 mov	carry, %o0
69END(__mpn_mul_1)
70