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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <mips/asm.h>
RCSID("$NetBSD: fpdf.S,v 1.1 2016/07/14 01:59:18 matt Exp $")
/*
* This file provides softfloat compatible routines which use FP instructions
* to do the actual work. This should give near hard-float performance while
* being compatible with soft-float code.
*
* This file implements the double precision floating point routines.
*/
#ifdef MIPS3
#define COP1_SYNC nop
#else
#define COP1_SYNC
#endif
LEAF_NOPROFILE(__adddf3)
dmtc1 a0, $f12
dmtc1 a1, $f14
COP1_SYNC
add.d $f0, $f12, $f14
dmfc1 v0, $f0
jr ra
END(__adddf3)
LEAF_NOPROFILE(__subdf3)
dmtc1 a0, $f12
dmtc1 a1, $f14
COP1_SYNC
sub.d $f0, $f12, $f14
dmfc1 v0, $f0
jr ra
END(__subdf3)
LEAF_NOPROFILE(__muldf3)
dmtc1 a0, $f12
dmtc1 a1, $f14
COP1_SYNC
mul.d $f0, $f12, $f14
dmfc1 v0, $f0
jr ra
END(__muldf3)
LEAF_NOPROFILE(__divdf3)
dmtc1 a0, $f12
dmtc1 a1, $f14
COP1_SYNC
div.d $f0, $f12, $f14
dmfc1 v0, $f0
jr ra
END(__divdf3)
LEAF_NOPROFILE(__negdf2)
dmtc1 a0, $f12
COP1_SYNC
neg.d $f0, $f12
dmfc1 v0, $f0
jr ra
END(__negdf2)
LEAF_NOPROFILE(__extendsfdf2)
dmtc1 a0, $f12
COP1_SYNC
cvt.d.s $f0, $f12
dmfc1 v0, $f0
jr ra
END(__extendsfdf2)
LEAF_NOPROFILE(__fixdfdi)
dmtc1 a0, $f12
COP1_SYNC
trunc.l.d $f0, $f12
dmfc1 v0, $f0
jr ra
END(__fixdfdi)
LEAF_NOPROFILE(__fixdfsi)
dmtc1 a0, $f12
COP1_SYNC
trunc.w.d $f0, $f12
mfc1 v0, $f0
jr ra
END(__fixdfsi)
LEAF_NOPROFILE(__fixunsdfdi)
lui t0, 0x43e0 # 9223372036854775808.0
dsll t0, t0, 32
mtc1 t0, $f0
mtc1 a0, $f12
COP1_SYNC
sub.d $f0, $f12, $f0 # convert to signed
trunc.l.d $f0, $f0
dmfc1 v0, $f0
li v1, 1
dsll v1, v1, 63
add v0, v0, v1 # convert to unsigned
jr ra
END(__fixunsdfdi)
LEAF_NOPROFILE(__fixunsdfsi)
lui t0, 0x41e0 # 2147483648.0
dsll t0, t0, 32
mtc1 t0, $f0
mtc1 a0, $f12
COP1_SYNC
sub.d $f0, $f12, $f0 # convert to signed
trunc.w.d $f0, $f0
lui v1, 0x8000 # 0xffffffff80000000
mfc1 v0, $f0
add v0, v0, v1 # convert to unsigned
jr ra
END(__fixunsdfsi)
LEAF_NOPROFILE(__floatdidf)
dmtc1 a0, $f12
COP1_SYNC
cvt.d.l $f0, $f12
dmfc1 v0, $f0
jr ra
END(__floatdidf)
LEAF_NOPROFILE(__floatsidf)
mtc1 a0, $f12
COP1_SYNC
cvt.d.w $f0, $f12
dmfc1 v0, $f0
jr ra
END(__floatsidf)
LEAF_NOPROFILE(__floatundidf)
li t0, 1
dsll t0, t0, 63
dsub a0, a0, t0
dmtc1 a0, $f12
dmtc1 t0, $f14
COP1_SYNC
cvt.d.l $f0, $f12
cvt.d.l $f2, $f14
add.d $f0, $f0, $f2
dmfc1 v0, $f0
jr ra
END(__floatundidf)
LEAF_NOPROFILE(__floatunsidf)
sll a0, a0, 0
dmtc1 a0, $f12
COP1_SYNC
cvt.d.l $f0, $f12
dmfc1 v0, $f0
jr ra
END(__floatunsidf)
STRONG_ALIAS(__eqdf2, __nedf2)
LEAF_NOPROFILE(__nedf2)
.set push
.set noreorder
dmtc1 a0, $f12
dmtc1 a1, $f14
COP1_SYNC
c.eq.d $f12, $f14
bc1f 2f
li v0, 1
move v0, zero
2: jr ra
nop
.set pop
END(__nedf2)
STRONG_ALIAS(__gedf2, __ltdf2)
LEAF_NOPROFILE(__ltdf2)
.set push
.set noreorder
dmtc1 a0, $f12
dmtc1 a1, $f14
COP1_SYNC
c.olt.d $f12, $f14
bc1t 2f
li v0, -1
move v0, zero
2: jr ra
nop
.set pop
END(__ltdf2)
STRONG_ALIAS(__gtdf2, __ledf2)
LEAF_NOPROFILE(__ledf2)
.set push
.set noreorder
dmtc1 a0, $f12
dmtc1 a1, $f14
COP1_SYNC
c.ole.d $f12, $f14
bc1f 2f
li v0, 1
move v0, zero
2: jr ra
nop
.set pop
END(__ledf2)
LEAF_NOPROFILE(__unorddf2)
.set push
.set noreorder
dmtc1 a0, $f12
dmtc1 a1, $f14
COP1_SYNC
c.un.d $f12, $f14
bc1t 2f
li v0, 1
move v0, zero
2: jr ra
nop
.set pop
END(__unorddf2)
|