1dnl  mpopt.sparcv8.m4
2dnl
3dnl  Copyright (c) 2003 Bob Deblier
4dnl
5dnl  Author: Bob Deblier <bob.deblier@telenet.be>
6dnl
7dnl  This library is free software; you can redistribute it and/or
8dnl  modify it under the terms of the GNU Lesser General Public
9dnl  License as published by the Free Software Foundation; either
10dnl  version 2.1 of the License, or (at your option) any later version.
11dnl
12dnl  This library is distributed in the hope that it will be useful,
13dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
14dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15dnl  Lesser General Public License for more details.
16dnl
17dnl  You should have received a copy of the GNU Lesser General Public
18dnl  License along with this library; if not, write to the Free Software
19dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21include(config.m4)
22include(ASM_SRCDIR/asmdefs.m4)
23include(ASM_SRCDIR/sparc.m4)
24
25
26C_FUNCTION_BEGIN(mpsetmul)
27	sll %o0,2,%g1
28	dec 4,%o2
29	clr %o0
30LOCAL(mpsetmul_loop):
31	ld [%o2+%g1],%g2
32	umul %o3,%g2,%g2
33	rd %y,%g3
34	addcc %o0,%g2,%g2
35	addx %g0,%g3,%o0
36	deccc 4,%g1
37	bnz LOCAL(mpsetmul_loop)
38	st %g2,[%o1+%g1]
39	retl
40	nop
41C_FUNCTION_END(mpsetmul)
42
43
44C_FUNCTION_BEGIN(mpaddmul)
45	sll %o0,2,%g1
46	mov %o1,%o4
47	dec 4,%o1
48	dec 4,%o2
49	clr %o0
50LOCAL(mpaddmul_loop):
51	ld [%o2+%g1],%g2
52	ld [%o1+%g1],%g3
53	umul %o3,%g2,%g2
54	rd %y,%g4
55	addcc %o0,%g2,%g2
56	addx %g0,%g4,%g4
57	addcc %g2,%g3,%g2
58	addx %g0,%g4,%o0
59	deccc 4,%g1
60	bnz LOCAL(mpaddmul_loop)
61	st %g2,[%o4+%g1]
62	retl
63	nop
64C_FUNCTION_END(mpaddmul)
65
66
67C_FUNCTION_BEGIN(mpaddsqrtrc)
68	sll %o0,2,%g1
69	add %o1,%g1,%o1
70	dec 4,%o2
71	add %o1,%g1,%o1
72	dec 8,%o1
73	clr %o0
74LOCAL(mpaddsqrtrc_loop):
75	ld [%o2+%g1],%g2
76	ldd [%o1],%o4
77	umul %g2,%g2,%g3
78	rd %y,%g2
79	addcc %o5,%g3,%o5
80	addxcc %o4,%g2,%o4
81	addx %g0,%g0,%o3
82	addcc %o5,%o0,%o5
83	addxcc %o4,%g0,%o4
84	addx %o3,%g0,%o0
85	std %o4,[%o1]
86	deccc 4,%g1
87	bnz LOCAL(mpaddsqrtrc_loop)
88	sub %o1,8,%o1
89	retl
90	nop
91C_FUNCTION_END(mpaddsqrtrc)
92