xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/sparc32/mul_1.asm (revision cef8759bd76c1b621f8eab8faa6f208faabc2e15)
1dnl  SPARC mpn_mul_1 -- Multiply a limb vector with a limb and store
2dnl  the result in a second limb vector.
3
4dnl  Copyright 1992-1994, 2000 Free Software Foundation, Inc.
5
6dnl  This file is part of the GNU MP Library.
7dnl
8dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9dnl  it under the terms of either:
10dnl
11dnl    * the GNU Lesser General Public License as published by the Free
12dnl      Software Foundation; either version 3 of the License, or (at your
13dnl      option) any later version.
14dnl
15dnl  or
16dnl
17dnl    * the GNU General Public License as published by the Free Software
18dnl      Foundation; either version 2 of the License, or (at your option) any
19dnl      later version.
20dnl
21dnl  or both in parallel, as here.
22dnl
23dnl  The GNU MP Library is distributed in the hope that it will be useful, but
24dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26dnl  for more details.
27dnl
28dnl  You should have received copies of the GNU General Public License and the
29dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
30dnl  see https://www.gnu.org/licenses/.
31
32
33include(`../config.m4')
34
35C INPUT PARAMETERS
36C res_ptr	o0
37C s1_ptr	o1
38C size		o2
39C s2_limb	o3
40
41ASM_START()
42PROLOGUE(mpn_mul_1)
43	C Make S1_PTR and RES_PTR point at the end of their blocks
44	C and put (- 4 x SIZE) in index/loop counter.
45	sll	%o2,2,%o2
46	add	%o0,%o2,%o4	C RES_PTR in o4 since o0 is retval
47	add	%o1,%o2,%o1
48	sub	%g0,%o2,%o2
49
50	cmp	%o3,0xfff
51	bgu	L(large)
52	nop
53
54	ld	[%o1+%o2],%o5
55	mov	0,%o0
56	b	L(0)
57	 add	%o4,-4,%o4
58L(loop0):
59	st	%g1,[%o4+%o2]
60L(0):	wr	%g0,%o3,%y
61	sra	%o5,31,%g2
62	and	%o3,%g2,%g2
63	andcc	%g1,0,%g1
64	mulscc	%g1,%o5,%g1
65	mulscc	%g1,%o5,%g1
66	mulscc	%g1,%o5,%g1
67	mulscc	%g1,%o5,%g1
68	mulscc	%g1,%o5,%g1
69	mulscc	%g1,%o5,%g1
70	mulscc	%g1,%o5,%g1
71	mulscc	%g1,%o5,%g1
72	mulscc	%g1,%o5,%g1
73	mulscc	%g1,%o5,%g1
74	mulscc	%g1,%o5,%g1
75	mulscc	%g1,%o5,%g1
76	mulscc	%g1,0,%g1
77	sra	%g1,20,%g4
78	sll	%g1,12,%g1
79	rd	%y,%g3
80	srl	%g3,20,%g3
81	or	%g1,%g3,%g1
82
83	addcc	%g1,%o0,%g1
84	addx	%g2,%g4,%o0	C add sign-compensation and cy to hi limb
85	addcc	%o2,4,%o2	C loop counter
86	bne,a	L(loop0)
87	 ld	[%o1+%o2],%o5
88
89	retl
90	st	%g1,[%o4+%o2]
91
92
93L(large):
94	ld	[%o1+%o2],%o5
95	mov	0,%o0
96	sra	%o3,31,%g4	C g4 = mask of ones iff S2_LIMB < 0
97	b	L(1)
98	 add	%o4,-4,%o4
99L(loop):
100	st	%g3,[%o4+%o2]
101L(1):	wr	%g0,%o5,%y
102	and	%o5,%g4,%g2	C g2 = S1_LIMB iff S2_LIMB < 0, else 0
103	andcc	%g0,%g0,%g1
104	mulscc	%g1,%o3,%g1
105	mulscc	%g1,%o3,%g1
106	mulscc	%g1,%o3,%g1
107	mulscc	%g1,%o3,%g1
108	mulscc	%g1,%o3,%g1
109	mulscc	%g1,%o3,%g1
110	mulscc	%g1,%o3,%g1
111	mulscc	%g1,%o3,%g1
112	mulscc	%g1,%o3,%g1
113	mulscc	%g1,%o3,%g1
114	mulscc	%g1,%o3,%g1
115	mulscc	%g1,%o3,%g1
116	mulscc	%g1,%o3,%g1
117	mulscc	%g1,%o3,%g1
118	mulscc	%g1,%o3,%g1
119	mulscc	%g1,%o3,%g1
120	mulscc	%g1,%o3,%g1
121	mulscc	%g1,%o3,%g1
122	mulscc	%g1,%o3,%g1
123	mulscc	%g1,%o3,%g1
124	mulscc	%g1,%o3,%g1
125	mulscc	%g1,%o3,%g1
126	mulscc	%g1,%o3,%g1
127	mulscc	%g1,%o3,%g1
128	mulscc	%g1,%o3,%g1
129	mulscc	%g1,%o3,%g1
130	mulscc	%g1,%o3,%g1
131	mulscc	%g1,%o3,%g1
132	mulscc	%g1,%o3,%g1
133	mulscc	%g1,%o3,%g1
134	mulscc	%g1,%o3,%g1
135	mulscc	%g1,%o3,%g1
136	mulscc	%g1,%g0,%g1
137	rd	%y,%g3
138	addcc	%g3,%o0,%g3
139	addx	%g2,%g1,%o0	C add sign-compensation and cy to hi limb
140	addcc	%o2,4,%o2	C loop counter
141	bne,a	L(loop)
142	 ld	[%o1+%o2],%o5
143
144	retl
145	st	%g3,[%o4+%o2]
146EPILOGUE(mpn_mul_1)
147