beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / sparc32 / udiv.asm
blob23ab3de1dbb7f7cc5a09e99266751038c190887e
1 dnl SPARC v7 __udiv_qrnnd division support, used from longlong.h.
2 dnl This is for v7 CPUs with a floating-point unit.
4 dnl Copyright 1993, 1994, 1996, 2000 Free Software Foundation, Inc.
6 dnl This file is part of the GNU MP Library.
7 dnl
8 dnl The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl it under the terms of either:
10 dnl
11 dnl * the GNU Lesser General Public License as published by the Free
12 dnl Software Foundation; either version 3 of the License, or (at your
13 dnl option) any later version.
14 dnl
15 dnl or
16 dnl
17 dnl * the GNU General Public License as published by the Free Software
18 dnl Foundation; either version 2 of the License, or (at your option) any
19 dnl later version.
20 dnl
21 dnl or both in parallel, as here.
22 dnl
23 dnl The GNU MP Library is distributed in the hope that it will be useful, but
24 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 dnl for more details.
27 dnl
28 dnl You should have received copies of the GNU General Public License and the
29 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
30 dnl see https://www.gnu.org/licenses/.
33 include(`../config.m4')
35 C INPUT PARAMETERS
36 C rem_ptr i0
37 C n1 i1
38 C n0 i2
39 C d i3
41 ASM_START()
43 ifdef(`PIC',
44 ` TEXT
45 L(getpc):
46 retl
47 nop')
49 TEXT
50 ALIGN(8)
51 L(C0): .double 0r4294967296
52 L(C1): .double 0r2147483648
54 PROLOGUE(mpn_udiv_qrnnd)
55 save %sp,-104,%sp
56 st %i1,[%fp-8]
57 ld [%fp-8],%f10
59 ifdef(`PIC',
60 `L(pc): call L(getpc) C put address of this insn in %o7
61 ldd [%o7+L(C0)-L(pc)],%f8',
62 ` sethi %hi(L(C0)),%o7
63 ldd [%o7+%lo(L(C0))],%f8')
65 fitod %f10,%f4
66 cmp %i1,0
67 bge L(248)
68 mov %i0,%i5
69 faddd %f4,%f8,%f4
70 L(248):
71 st %i2,[%fp-8]
72 ld [%fp-8],%f10
73 fmuld %f4,%f8,%f6
74 cmp %i2,0
75 bge L(249)
76 fitod %f10,%f2
77 faddd %f2,%f8,%f2
78 L(249):
79 st %i3,[%fp-8]
80 faddd %f6,%f2,%f2
81 ld [%fp-8],%f10
82 cmp %i3,0
83 bge L(250)
84 fitod %f10,%f4
85 faddd %f4,%f8,%f4
86 L(250):
87 fdivd %f2,%f4,%f2
89 ifdef(`PIC',
90 ` ldd [%o7+L(C1)-L(pc)],%f4',
91 ` sethi %hi(L(C1)),%o7
92 ldd [%o7+%lo(L(C1))],%f4')
94 fcmped %f2,%f4
95 nop
96 fbge,a L(251)
97 fsubd %f2,%f4,%f2
98 fdtoi %f2,%f2
99 st %f2,[%fp-8]
100 b L(252)
101 ld [%fp-8],%i4
102 L(251):
103 fdtoi %f2,%f2
104 st %f2,[%fp-8]
105 ld [%fp-8],%i4
106 sethi %hi(-2147483648),%g2
107 xor %i4,%g2,%i4
108 L(252):
109 wr %g0,%i4,%y
110 sra %i3,31,%g2
111 and %i4,%g2,%g2
112 andcc %g0,0,%g1
113 mulscc %g1,%i3,%g1
114 mulscc %g1,%i3,%g1
115 mulscc %g1,%i3,%g1
116 mulscc %g1,%i3,%g1
117 mulscc %g1,%i3,%g1
118 mulscc %g1,%i3,%g1
119 mulscc %g1,%i3,%g1
120 mulscc %g1,%i3,%g1
121 mulscc %g1,%i3,%g1
122 mulscc %g1,%i3,%g1
123 mulscc %g1,%i3,%g1
124 mulscc %g1,%i3,%g1
125 mulscc %g1,%i3,%g1
126 mulscc %g1,%i3,%g1
127 mulscc %g1,%i3,%g1
128 mulscc %g1,%i3,%g1
129 mulscc %g1,%i3,%g1
130 mulscc %g1,%i3,%g1
131 mulscc %g1,%i3,%g1
132 mulscc %g1,%i3,%g1
133 mulscc %g1,%i3,%g1
134 mulscc %g1,%i3,%g1
135 mulscc %g1,%i3,%g1
136 mulscc %g1,%i3,%g1
137 mulscc %g1,%i3,%g1
138 mulscc %g1,%i3,%g1
139 mulscc %g1,%i3,%g1
140 mulscc %g1,%i3,%g1
141 mulscc %g1,%i3,%g1
142 mulscc %g1,%i3,%g1
143 mulscc %g1,%i3,%g1
144 mulscc %g1,%i3,%g1
145 mulscc %g1,0,%g1
146 add %g1,%g2,%i0
147 rd %y,%g3
148 subcc %i2,%g3,%o7
149 subxcc %i1,%i0,%g0
150 be L(253)
151 cmp %o7,%i3
153 add %i4,-1,%i0
154 add %o7,%i3,%o7
155 st %o7,[%i5]
157 restore
158 L(253):
159 blu L(246)
160 mov %i4,%i0
161 add %i4,1,%i0
162 sub %o7,%i3,%o7
163 L(246):
164 st %o7,[%i5]
166 restore
167 EPILOGUE(mpn_udiv_qrnnd)