aboutsummaryrefslogtreecommitdiff
path: root/vendor/gmp-6.3.0/mpn/sparc64/ultrasparct3/mul_1.asm
blob: af05d627bcfd804c0e7e5e9ca86de28451e6d1f0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
dnl  SPARC v9 mpn_mul_1 for T3/T4/T5.

dnl  Contributed to the GNU project by David Miller and Torbjörn Granlund.

dnl  Copyright 2013 Free Software Foundation, Inc.

dnl  This file is part of the GNU MP Library.
dnl
dnl  The GNU MP Library is free software; you can redistribute it and/or modify
dnl  it under the terms of either:
dnl
dnl    * the GNU Lesser General Public License as published by the Free
dnl      Software Foundation; either version 3 of the License, or (at your
dnl      option) any later version.
dnl
dnl  or
dnl
dnl    * the GNU General Public License as published by the Free Software
dnl      Foundation; either version 2 of the License, or (at your option) any
dnl      later version.
dnl
dnl  or both in parallel, as here.
dnl
dnl  The GNU MP Library is distributed in the hope that it will be useful, but
dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dnl  for more details.
dnl
dnl  You should have received copies of the GNU General Public License and the
dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
dnl  see https://www.gnu.org/licenses/.

include(`../config.m4')

C		   cycles/limb
C UltraSPARC T3:	23
C UltraSPARC T4:	 3

C INPUT PARAMETERS
define(`rp', `%i0')
define(`up', `%i1')
define(`n',  `%i2')
define(`v0', `%i3')

ASM_START()
	REGISTER(%g2,#scratch)
	REGISTER(%g3,#scratch)
PROLOGUE(mpn_mul_1)
	save	%sp, -176, %sp

	and	n, 3, %g5
	add	n, -4, n
	brz	%g5, L(b0)
	 cmp	%g5, 2
	bcs	%xcc, L(b1)
	 nop
	be	%xcc, L(b2)
	 nop

L(b3):	addcc	%g0, %g0, %i5
	ldx	[up+0], %l0
	ldx	[up+8], %l1
	ldx	[up+16], %l2
	mulx	%l0, v0, %o0
	umulxhi(%l0, v0, %o1)
	brgz	n, L(gt3)
	 add	rp, -8, rp
	mulx	%l1, v0, %o2
	umulxhi(%l1, v0, %o3)
	b	L(wd3)
	 nop
L(gt3):	ldx	[up+24], %l3
	mulx	%l1, v0, %o2
	umulxhi(%l1, v0, %o3)
	add	up, 24, up
	b	L(lo3)
	 add	n, -3, n

L(b2):	addcc	%g0, %g0, %o1
	ldx	[up+0], %l1
	ldx	[up+8], %l2
	brgz	n, L(gt2)
	 add	rp, -16, rp
	mulx	%l1, v0, %o2
	umulxhi(%l1, v0, %o3)
	mulx	%l2, v0, %o4
	umulxhi(%l2, v0, %o5)
	b	L(wd2)
	 nop
L(gt2):	ldx	[up+16], %l3
	mulx	%l1, v0, %o2
	umulxhi(%l1, v0, %o3)
	ldx	[up+24], %l0
	mulx	%l2, v0, %o4
	umulxhi(%l2, v0, %o5)
	add	up, 16, up
	b	L(lo2)
	 add	n, -2, n

L(b1):	addcc	%g0, %g0, %o3
	ldx	[up+0], %l2
	brgz	n, L(gt1)
	nop
	mulx	%l2, v0, %o4
	stx	%o4, [rp+0]
	umulxhi(%l2, v0, %i0)
	ret
	 restore
L(gt1):	ldx	[up+8], %l3
	ldx	[up+16], %l0
	mulx	%l2, v0, %o4
	umulxhi(%l2, v0, %o5)
	ldx	[up+24], %l1
	mulx	%l3, v0, %i4
	umulxhi(%l3, v0, %i5)
	add	rp, -24, rp
	add	up, 8, up
	b	L(lo1)
	 add	n, -1, n

L(b0):	addcc	%g0, %g0, %o5
	ldx	[up+0], %l3
	ldx	[up+8], %l0
	ldx	[up+16], %l1
	mulx	%l3, v0, %i4
	umulxhi(%l3, v0, %i5)
	ldx	[up+24], %l2
	mulx	%l0, v0, %o0
	umulxhi(%l0, v0, %o1)
	b	L(lo0)
	 nop

	ALIGN(16)
L(top):	ldx	[up+0], %l3	C 0
	addxccc(%i4, %o5, %i4)	C 0
	mulx	%l1, v0, %o2	C 1
	stx	%i4, [rp+0]	C 1
	umulxhi(%l1, v0, %o3)	C 2
L(lo3):	ldx	[up+8], %l0	C 2
	addxccc(%o0, %i5, %o0)	C 3
	mulx	%l2, v0, %o4	C 3
	stx	%o0, [rp+8]	C 4
	umulxhi(%l2, v0, %o5)	C 4
L(lo2):	ldx	[up+16], %l1	C 5
	addxccc(%o2, %o1, %o2)	C 5
	mulx	%l3, v0, %i4	C 6
	stx	%o2, [rp+16]	C 6
	umulxhi(%l3, v0, %i5)	C 7
L(lo1):	ldx	[up+24], %l2	C 7
	addxccc(%o4, %o3, %o4)	C 8
	mulx	%l0, v0, %o0	C 8
	stx	%o4, [rp+24]	C 9
	umulxhi(%l0, v0, %o1)	C 9
	add	rp, 32, rp	C 10
L(lo0):	add	up, 32, up	C 10
	brgz	n, L(top)	C 11
	 add	n, -4, n	C 11

L(end):	addxccc(%i4, %o5, %i4)
	mulx	%l1, v0, %o2
	stx	%i4, [rp+0]
	umulxhi(%l1, v0, %o3)
	addxccc(%o0, %i5, %o0)
L(wd3):	mulx	%l2, v0, %o4
	stx	%o0, [rp+8]
	umulxhi(%l2, v0, %o5)
	addxccc(%o2, %o1, %o2)
L(wd2):	stx	%o2, [rp+16]
	addxccc(%o4, %o3, %o4)
	stx	%o4, [rp+24]
	addxc(	%g0, %o5, %i0)
	ret
	 restore
EPILOGUE()