[project @ 2000-08-21 14:16:57 by simonmar]
[ghc-hetmet.git] / ghc / rts / gmp / mpn / sparc32 / udiv_fp.S
1 ! SPARC v7 __udiv_qrnnd division support, used from longlong.h.
2 ! This is for v7 CPUs with a floating-point unit.
3
4 ! Copyright (C) 1993, 1994, 1996 Free Software Foundation, Inc.
5
6 ! This file is part of the GNU MP Library.
7
8 ! The GNU MP Library is free software; you can redistribute it and/or modify
9 ! it under the terms of the GNU Library General Public License as published by
10 ! the Free Software Foundation; either version 2 of the License, or (at your
11 ! option) any later version.
12
13 ! The GNU MP Library is distributed in the hope that it will be useful, but
14 ! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ! or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
16 ! License for more details.
17
18 ! You should have received a copy of the GNU Library General Public License
19 ! along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
20 ! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 ! MA 02111-1307, USA.
22
23
24 ! INPUT PARAMETERS
25 ! rem_ptr       i0
26 ! n1            i1
27 ! n0            i2
28 ! d             i3
29
30 #include "sysdep.h"
31 #undef ret      /* Kludge for glibc */
32
33         .text
34         .align  8
35 LC0:    .double 0r4294967296
36 LC1:    .double 0r2147483648
37
38         .align  4
39         .global C_SYMBOL_NAME(__udiv_qrnnd)
40 C_SYMBOL_NAME(__udiv_qrnnd):
41         !#PROLOGUE# 0
42         save    %sp,-104,%sp
43         !#PROLOGUE# 1
44         st      %i1,[%fp-8]
45         ld      [%fp-8],%f10
46         sethi   %hi(LC0),%o7
47         fitod   %f10,%f4
48         ldd     [%o7+%lo(LC0)],%f8
49         cmp     %i1,0
50         bge     L248
51         mov     %i0,%i5
52         faddd   %f4,%f8,%f4
53 L248:
54         st      %i2,[%fp-8]
55         ld      [%fp-8],%f10
56         fmuld   %f4,%f8,%f6
57         cmp     %i2,0
58         bge     L249
59         fitod   %f10,%f2
60         faddd   %f2,%f8,%f2
61 L249:
62         st      %i3,[%fp-8]
63         faddd   %f6,%f2,%f2
64         ld      [%fp-8],%f10
65         cmp     %i3,0
66         bge     L250
67         fitod   %f10,%f4
68         faddd   %f4,%f8,%f4
69 L250:
70         fdivd   %f2,%f4,%f2
71         sethi   %hi(LC1),%o7
72         ldd     [%o7+%lo(LC1)],%f4
73         fcmped  %f2,%f4
74         nop
75         fbge,a  L251
76         fsubd   %f2,%f4,%f2
77         fdtoi   %f2,%f2
78         st      %f2,[%fp-8]
79         b       L252
80         ld      [%fp-8],%i4
81 L251:
82         fdtoi   %f2,%f2
83         st      %f2,[%fp-8]
84         ld      [%fp-8],%i4
85         sethi   %hi(-2147483648),%g2
86         xor     %i4,%g2,%i4
87 L252:
88         wr      %g0,%i4,%y
89         sra     %i3,31,%g2
90         and     %i4,%g2,%g2
91         andcc   %g0,0,%g1
92         mulscc  %g1,%i3,%g1
93         mulscc  %g1,%i3,%g1
94         mulscc  %g1,%i3,%g1
95         mulscc  %g1,%i3,%g1
96         mulscc  %g1,%i3,%g1
97         mulscc  %g1,%i3,%g1
98         mulscc  %g1,%i3,%g1
99         mulscc  %g1,%i3,%g1
100         mulscc  %g1,%i3,%g1
101         mulscc  %g1,%i3,%g1
102         mulscc  %g1,%i3,%g1
103         mulscc  %g1,%i3,%g1
104         mulscc  %g1,%i3,%g1
105         mulscc  %g1,%i3,%g1
106         mulscc  %g1,%i3,%g1
107         mulscc  %g1,%i3,%g1
108         mulscc  %g1,%i3,%g1
109         mulscc  %g1,%i3,%g1
110         mulscc  %g1,%i3,%g1
111         mulscc  %g1,%i3,%g1
112         mulscc  %g1,%i3,%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,0,%g1
125         add     %g1,%g2,%i0
126         rd      %y,%g3
127         subcc   %i2,%g3,%o7
128         subxcc  %i1,%i0,%g0
129         be      L253
130         cmp     %o7,%i3
131
132         add     %i4,-1,%i0
133         add     %o7,%i3,%o7
134         st      %o7,[%i5]
135         ret
136         restore
137 L253:
138         blu     L246
139         mov     %i4,%i0
140         add     %i4,1,%i0
141         sub     %o7,%i3,%o7
142 L246:
143         st      %o7,[%i5]
144         ret
145         restore