aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/loader/SparcMulDiv.S
blob: 11139d192d8f70334e44ef8ba8655dafd4720699 (plain)
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
/*
 * Hardware integer division and multiplication routines for SPARC v8 and higher.
 *
 * Copyright (C) 1996 David S. Miller (davem@redhat.com)
 * Copyright (C) 1999 Jakub Jelinek (jj@ultra.linux.cz)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * JAKUB JELINEK OR DAVID MILLER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/SparcMulDiv.S,v 1.1 1999/07/10 07:24:51 dawes Exp $ */

	.globl	urem_sparcv89, umul_sparcv89, udiv_sparcv89
	.globl	rem_sparcv89, mul_sparcv89, div_sparcv89

	.align	32
urem_sparcv89:
	wr	%g0, 0x0, %y
	nop
	nop
	nop
	udiv	%o0, %o1, %o2
	umul	%o2, %o1, %o2
	retl
	 sub	%o0, %o2, %o0

	.align	32
umul_sparcv89:
	umul	%o0, %o1, %o0
	retl
	 rd	%y, %o1

	.align	32
udiv_sparcv89:
	wr	%g0, 0x0, %y
	nop
	nop
	retl
	 udiv	%o0, %o1, %o0

	.align	32
rem_sparcv89:
	sra	%o0, 0x1f, %o4
	wr	%o4, 0x0, %y
	nop
	nop
	nop
	sdivcc	%o0, %o1, %o2
	bvs,a	1f
	 xnor	%o2, %g0, %o2
1:	smul	%o2, %o1, %o2
	retl
	 sub	%o0, %o2, %o0

	.align	32
mul_sparcv89:
	smul	%o0, %o1, %o0
	retl
	 rd	%y, %o1
	nop

	.align	32
div_sparcv89:
	sra	%o0, 0x1f, %o2
	wr	%o2, 0x0, %y
	nop
	nop
	nop
	sdivcc	%o0, %o1, %o0
	bvs,a	1f
	 xnor	%o0, %g0, %o0
1:	retl
	 nop