aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/sparc/sparc32/udiv_qrnnd.S
blob: 2fbb8a5f54ee0d0de1872669da4ad38a57ff1695 (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
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
! SPARC  __udiv_qrnnd division support, used from longlong.h.
!
! Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc.
!
! This file is part of the GNU MP Library.
!
! The GNU MP Library is free software; you can redistribute it and/or modify
! it under the terms of the GNU Library General Public License as published by
! the Free Software Foundation; either version 2 of the License, or (at your
! option) any later version.
!
! The GNU MP Library is distributed in the hope that it will be useful, but
! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
! License for more details.
!
! You should have received a copy of the GNU Library General Public License
! along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
! the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
! Added PIC support - May/96, Miguel de Icaza
!
! INPUT PARAMETERS
! rem_ptr	i0
! n1		i1
! n0		i2
! d		i3

#include <sysdep.h>
#undef ret	/* Kludge for glibc */

#ifdef PIC
	.text
#else
	.section .rodata,#alloc
#endif
	.align	8

	.type two_to_32,@object
	.size two_to_32,8
two_to_32:
	.double	0r4294967296

	.type two_to_31,@object
	.size two_to_31,8
two_to_31:
	.double	0r2147483648

	.text
ENTRY(__udiv_qrnnd)
	!#PROLOGUE# 0
	save	%sp,-104,%sp
	!#PROLOGUE# 1
	st	%i1,[%fp-8]
	ld	[%fp-8],%f10
#ifdef PIC
LOC(base):
	call	1f
	fitod	%f10,%f4
1:	ldd	[%o7-(LOC(base)-two_to_32)],%f8
#else
	sethi	%hi(two_to_32),%o7
	fitod	%f10,%f4
	ldd	[%o7+%lo(two_to_32)],%f8
#endif
	cmp	%i1,0
	bge	LOC(248)
	mov	%i0,%i5
	faddd	%f4,%f8,%f4
LOC(248):
	st	%i2,[%fp-8]
	ld	[%fp-8],%f10
	fmuld	%f4,%f8,%f6
	cmp	%i2,0
	bge	LOC(249)
	fitod	%f10,%f2
	faddd	%f2,%f8,%f2
LOC(249):
	st	%i3,[%fp-8]
	faddd	%f6,%f2,%f2
	ld	[%fp-8],%f10
	cmp	%i3,0
	bge	LOC(250)
	fitod	%f10,%f4
	faddd	%f4,%f8,%f4
LOC(250):
	fdivd	%f2,%f4,%f2
#ifdef PIC
	ldd	[%o7-(LOC(base)-two_to_31)],%f4
#else
	sethi	%hi(two_to_31),%o7
	ldd	[%o7+%lo(two_to_31)],%f4
#endif
	fcmped	%f2,%f4
	nop
	fbge,a	LOC(251)
	fsubd	%f2,%f4,%f2
	fdtoi	%f2,%f2
	st	%f2,[%fp-8]
	b	LOC(252)
	ld	[%fp-8],%i4
LOC(251):
	fdtoi	%f2,%f2
	st	%f2,[%fp-8]
	ld	[%fp-8],%i4
	sethi	%hi(-2147483648),%g2
	xor	%i4,%g2,%i4
LOC(252):
	wr	%g0,%i4,%y
	sra	%i3,31,%g2
	and	%i4,%g2,%g2
	andcc	%g0,0,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,%i3,%g1
	mulscc	%g1,0,%g1
	add	%g1,%g2,%i0
	rd	%y,%g3
	subcc	%i2,%g3,%o7
	subxcc	%i1,%i0,%g0
	be	LOC(253)
	cmp	%o7,%i3

	add	%i4,-1,%i0
	add	%o7,%i3,%o7
	st	%o7,[%i5]
	ret
	restore
LOC(253):
	blu	LOC(246)
	mov	%i4,%i0
	add	%i4,1,%i0
	sub	%o7,%i3,%o7
LOC(246):
	st	%o7,[%i5]
	ret
	restore

END(__udiv_qrnnd)