Commit b109f9f867a793b66217d43ede10c7a47242e270
1 parent
1d6bda35
more native FPU comparison functions - native FPU remainder
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1339 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
110 additions
and
4 deletions
fpu/softfloat-native.c
... | ... | @@ -120,10 +120,39 @@ float32 float32_round_to_int( float32 a STATUS_PARAM) |
120 | 120 | return rintf(a); |
121 | 121 | } |
122 | 122 | |
123 | +float32 float32_rem( float32 a, float32 b STATUS_PARAM) | |
124 | +{ | |
125 | + return remainderf(a, b); | |
126 | +} | |
127 | + | |
123 | 128 | float32 float32_sqrt( float32 a STATUS_PARAM) |
124 | 129 | { |
125 | 130 | return sqrtf(a); |
126 | 131 | } |
132 | +char float32_compare( float32 a, float32 b STATUS_PARAM ) | |
133 | +{ | |
134 | + if (a < b) { | |
135 | + return -1; | |
136 | + } else if (a == b) { | |
137 | + return 0; | |
138 | + } else if (a > b) { | |
139 | + return 1; | |
140 | + } else { | |
141 | + return 2; | |
142 | + } | |
143 | +} | |
144 | +char float32_compare_quiet( float32 a, float32 b STATUS_PARAM ) | |
145 | +{ | |
146 | + if (isless(a, b)) { | |
147 | + return -1; | |
148 | + } else if (a == b) { | |
149 | + return 0; | |
150 | + } else if (isgreater(a, b)) { | |
151 | + return 1; | |
152 | + } else { | |
153 | + return 2; | |
154 | + } | |
155 | +} | |
127 | 156 | char float32_is_signaling_nan( float32 a1) |
128 | 157 | { |
129 | 158 | float32u u; |
... | ... | @@ -195,10 +224,39 @@ float64 float64_round_to_int( float64 a STATUS_PARAM ) |
195 | 224 | #endif |
196 | 225 | } |
197 | 226 | |
227 | +float64 float64_rem( float64 a, float64 b STATUS_PARAM) | |
228 | +{ | |
229 | + return remainder(a, b); | |
230 | +} | |
231 | + | |
198 | 232 | float64 float64_sqrt( float64 a STATUS_PARAM) |
199 | 233 | { |
200 | 234 | return sqrt(a); |
201 | 235 | } |
236 | +char float64_compare( float64 a, float64 b STATUS_PARAM ) | |
237 | +{ | |
238 | + if (a < b) { | |
239 | + return -1; | |
240 | + } else if (a == b) { | |
241 | + return 0; | |
242 | + } else if (a > b) { | |
243 | + return 1; | |
244 | + } else { | |
245 | + return 2; | |
246 | + } | |
247 | +} | |
248 | +char float64_compare_quiet( float64 a, float64 b STATUS_PARAM ) | |
249 | +{ | |
250 | + if (isless(a, b)) { | |
251 | + return -1; | |
252 | + } else if (a == b) { | |
253 | + return 0; | |
254 | + } else if (isgreater(a, b)) { | |
255 | + return 1; | |
256 | + } else { | |
257 | + return 2; | |
258 | + } | |
259 | +} | |
202 | 260 | char float64_is_signaling_nan( float64 a1) |
203 | 261 | { |
204 | 262 | float64u u; |
... | ... | @@ -248,10 +306,38 @@ floatx80 floatx80_round_to_int( floatx80 a STATUS_PARAM) |
248 | 306 | { |
249 | 307 | return rintl(a); |
250 | 308 | } |
309 | +floatx80 floatx80_rem( floatx80 a, floatx80 b STATUS_PARAM) | |
310 | +{ | |
311 | + return remainderl(a, b); | |
312 | +} | |
251 | 313 | floatx80 floatx80_sqrt( floatx80 a STATUS_PARAM) |
252 | 314 | { |
253 | 315 | return sqrtl(a); |
254 | 316 | } |
317 | +char floatx80_compare( floatx80 a, floatx80 b STATUS_PARAM ) | |
318 | +{ | |
319 | + if (a < b) { | |
320 | + return -1; | |
321 | + } else if (a == b) { | |
322 | + return 0; | |
323 | + } else if (a > b) { | |
324 | + return 1; | |
325 | + } else { | |
326 | + return 2; | |
327 | + } | |
328 | +} | |
329 | +char floatx80_compare_quiet( floatx80 a, floatx80 b STATUS_PARAM ) | |
330 | +{ | |
331 | + if (isless(a, b)) { | |
332 | + return -1; | |
333 | + } else if (a == b) { | |
334 | + return 0; | |
335 | + } else if (isgreater(a, b)) { | |
336 | + return 1; | |
337 | + } else { | |
338 | + return 2; | |
339 | + } | |
340 | +} | |
255 | 341 | char floatx80_is_signaling_nan( floatx80 a1) |
256 | 342 | { |
257 | 343 | floatx80u u; | ... | ... |
fpu/softfloat-native.h
... | ... | @@ -127,7 +127,6 @@ float32 float32_rem( float32, float32 STATUS_PARAM); |
127 | 127 | float32 float32_sqrt( float32 STATUS_PARAM); |
128 | 128 | INLINE char float32_eq( float32 a, float32 b STATUS_PARAM) |
129 | 129 | { |
130 | - /* XXX: incorrect because it can raise an exception */ | |
131 | 130 | return a == b; |
132 | 131 | } |
133 | 132 | INLINE char float32_le( float32 a, float32 b STATUS_PARAM) |
... | ... | @@ -140,7 +139,7 @@ INLINE char float32_lt( float32 a, float32 b STATUS_PARAM) |
140 | 139 | } |
141 | 140 | INLINE char float32_eq_signaling( float32 a, float32 b STATUS_PARAM) |
142 | 141 | { |
143 | - return a == b; | |
142 | + return a <= b && a >= b; | |
144 | 143 | } |
145 | 144 | INLINE char float32_le_quiet( float32 a, float32 b STATUS_PARAM) |
146 | 145 | { |
... | ... | @@ -150,6 +149,13 @@ INLINE char float32_lt_quiet( float32 a, float32 b STATUS_PARAM) |
150 | 149 | { |
151 | 150 | return isless(a, b); |
152 | 151 | } |
152 | +INLINE char float32_unordered( float32 a, float32 b STATUS_PARAM) | |
153 | +{ | |
154 | + return isunordered(a, b); | |
155 | + | |
156 | +} | |
157 | +char float32_compare( float32, float32 STATUS_PARAM ); | |
158 | +char float32_compare_quiet( float32, float32 STATUS_PARAM ); | |
153 | 159 | char float32_is_signaling_nan( float32 ); |
154 | 160 | |
155 | 161 | INLINE float32 float32_abs(float32 a) |
... | ... | @@ -213,7 +219,7 @@ INLINE char float64_lt( float64 a, float64 b STATUS_PARAM) |
213 | 219 | } |
214 | 220 | INLINE char float64_eq_signaling( float64 a, float64 b STATUS_PARAM) |
215 | 221 | { |
216 | - return a == b; | |
222 | + return a <= b && a >= b; | |
217 | 223 | } |
218 | 224 | INLINE char float64_le_quiet( float64 a, float64 b STATUS_PARAM) |
219 | 225 | { |
... | ... | @@ -224,6 +230,13 @@ INLINE char float64_lt_quiet( float64 a, float64 b STATUS_PARAM) |
224 | 230 | return isless(a, b); |
225 | 231 | |
226 | 232 | } |
233 | +INLINE char float64_unordered( float64 a, float64 b STATUS_PARAM) | |
234 | +{ | |
235 | + return isunordered(a, b); | |
236 | + | |
237 | +} | |
238 | +char float64_compare( float64, float64 STATUS_PARAM ); | |
239 | +char float64_compare_quiet( float64, float64 STATUS_PARAM ); | |
227 | 240 | char float64_is_signaling_nan( float64 ); |
228 | 241 | |
229 | 242 | INLINE float64 float64_abs(float64 a) |
... | ... | @@ -287,7 +300,7 @@ INLINE char floatx80_lt( floatx80 a, floatx80 b STATUS_PARAM) |
287 | 300 | } |
288 | 301 | INLINE char floatx80_eq_signaling( floatx80 a, floatx80 b STATUS_PARAM) |
289 | 302 | { |
290 | - return a == b; | |
303 | + return a <= b && a >= b; | |
291 | 304 | } |
292 | 305 | INLINE char floatx80_le_quiet( floatx80 a, floatx80 b STATUS_PARAM) |
293 | 306 | { |
... | ... | @@ -298,6 +311,13 @@ INLINE char floatx80_lt_quiet( floatx80 a, floatx80 b STATUS_PARAM) |
298 | 311 | return isless(a, b); |
299 | 312 | |
300 | 313 | } |
314 | +INLINE char floatx80_unordered( floatx80 a, floatx80 b STATUS_PARAM) | |
315 | +{ | |
316 | + return isunordered(a, b); | |
317 | + | |
318 | +} | |
319 | +char floatx80_compare( floatx80, floatx80 STATUS_PARAM ); | |
320 | +char floatx80_compare_quiet( floatx80, floatx80 STATUS_PARAM ); | |
301 | 321 | char floatx80_is_signaling_nan( floatx80 ); |
302 | 322 | |
303 | 323 | INLINE floatx80 floatx80_abs(floatx80 a) | ... | ... |