xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/sparc64/ultrasparct3/add_n.asm (revision 7863ba460b0a05b553c754e5dbc29247dddec322)
1dnl  SPARC v9 mpn_add_n for T3/T4.
2
3dnl  Contributed to the GNU project by David Miller.
4
5dnl  Copyright 2013 Free Software Foundation, Inc.
6
7dnl  This file is part of the GNU MP Library.
8dnl
9dnl  The GNU MP Library is free software; you can redistribute it and/or modify
10dnl  it under the terms of either:
11dnl
12dnl    * the GNU Lesser General Public License as published by the Free
13dnl      Software Foundation; either version 3 of the License, or (at your
14dnl      option) any later version.
15dnl
16dnl  or
17dnl
18dnl    * the GNU General Public License as published by the Free Software
19dnl      Foundation; either version 2 of the License, or (at your option) any
20dnl      later version.
21dnl
22dnl  or both in parallel, as here.
23dnl
24dnl  The GNU MP Library is distributed in the hope that it will be useful, but
25dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27dnl  for more details.
28dnl
29dnl  You should have received copies of the GNU General Public License and the
30dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
31dnl  see https://www.gnu.org/licenses/.
32
33include(`../config.m4')
34
35C		   cycles/limb
36C UltraSPARC T3:	 8
37C UltraSPARC T4:	 3
38
39C INPUT PARAMETERS
40define(`rp', `%i0')
41define(`up', `%i1')
42define(`vp', `%i2')
43define(`n',  `%i3')
44define(`cy', `%i4')
45
46define(`u0_off', `%l2')
47define(`u1_off', `%l3')
48define(`loop_n', `%l6')
49define(`tmp', `%l7')
50
51ASM_START()
52	REGISTER(%g2,#scratch)
53	REGISTER(%g3,#scratch)
54PROLOGUE(mpn_add_nc)
55	save	%sp, -176, %sp
56	b,a	L(ent)
57EPILOGUE()
58PROLOGUE(mpn_add_n)
59	save	%sp, -176, %sp
60
61	mov	0, cy
62L(ent):
63	subcc	n, 1, n
64	be	L(final_one)
65	 cmp	%g0, cy
66
67	ldx	[up + 0], %o4
68	sllx	n, 3, tmp
69
70	ldx	[vp + 0], %o5
71	add	up, tmp, u0_off
72
73	ldx	[up + 8], %g5
74	neg	tmp, loop_n
75
76	ldx	[vp + 8], %g1
77	add	u0_off, 8, u1_off
78
79	sub	loop_n, -(2 * 8), loop_n
80
81	brgez,pn loop_n, L(loop_tail)
82	 add	vp, (2 * 8), vp
83
84	b,a	L(top)
85	ALIGN(16)
86L(top):
87	addxccc(%o4, %o5, tmp)
88	ldx	[vp + 0], %o5
89
90	add	rp, (2 * 8), rp
91	ldx	[loop_n + u0_off], %o4
92
93	add	vp, (2 * 8), vp
94	stx	tmp, [rp - 16]
95
96	addxccc(%g1, %g5, tmp)
97	ldx	[vp - 8], %g1
98
99	ldx	[loop_n + u1_off], %g5
100	sub	loop_n, -(2 * 8), loop_n
101
102	brlz	loop_n, L(top)
103	 stx	tmp, [rp - 8]
104
105L(loop_tail):
106	addxccc(%o4, %o5, %g3)
107	add	loop_n, u0_off, up
108
109	addxccc(%g1, %g5, %g5)
110	stx	%g3, [rp + 0]
111
112	brgz,pt	loop_n, L(done)
113	 stx	%g5, [rp + 8]
114
115	add	rp, (2 * 8), rp
116L(final_one):
117	ldx	[up+0], %o4
118	ldx	[vp+0], %o5
119	addxccc(%o4, %o5, %g3)
120	stx	%g3, [rp+0]
121
122L(done):
123	addxc(%g0, %g0, %i0)
124	ret
125	 restore
126EPILOGUE()
127