Revisión | 377ed92679a2a5f838bc0a095112ea5020720fff (tree) |
---|---|
Tiempo | 2018-05-18 07:27:15 |
Autor | Richard Henderson <richard.henderson@lina...> |
Commiter | Richard Henderson |
fpu/softfloat: Define floatN_silence_nan in terms of parts_silence_nan
Isolate the target-specific choice to 3 functions instead of 6.
The code in floatx80_default_nan tried to be over-general. There are
only two targets that support this format: x86 and m68k. Thus there
is no point in inventing a mechanism for snan_bit_is_one.
Move routines that no longer have ifdefs out of softfloat-specialize.h.
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
@@ -279,24 +279,6 @@ int float16_is_signaling_nan(float16 a_, float_status *status) | ||
279 | 279 | } |
280 | 280 | |
281 | 281 | /*---------------------------------------------------------------------------- |
282 | -| Returns a quiet NaN from a signalling NaN for the half-precision | |
283 | -| floating point value `a'. | |
284 | -*----------------------------------------------------------------------------*/ | |
285 | - | |
286 | -float16 float16_silence_nan(float16 a, float_status *status) | |
287 | -{ | |
288 | -#ifdef NO_SIGNALING_NANS | |
289 | - g_assert_not_reached(); | |
290 | -#else | |
291 | - if (snan_bit_is_one(status)) { | |
292 | - return float16_default_nan(status); | |
293 | - } else { | |
294 | - return a | (1 << 9); | |
295 | - } | |
296 | -#endif | |
297 | -} | |
298 | - | |
299 | -/*---------------------------------------------------------------------------- | |
300 | 282 | | Returns 1 if the single-precision floating-point value `a' is a quiet |
301 | 283 | | NaN; otherwise returns 0. |
302 | 284 | *----------------------------------------------------------------------------*/ |
@@ -335,30 +317,6 @@ int float32_is_signaling_nan(float32 a_, float_status *status) | ||
335 | 317 | } |
336 | 318 | |
337 | 319 | /*---------------------------------------------------------------------------- |
338 | -| Returns a quiet NaN from a signalling NaN for the single-precision | |
339 | -| floating point value `a'. | |
340 | -*----------------------------------------------------------------------------*/ | |
341 | - | |
342 | -float32 float32_silence_nan(float32 a, float_status *status) | |
343 | -{ | |
344 | -#ifdef NO_SIGNALING_NANS | |
345 | - g_assert_not_reached(); | |
346 | -#else | |
347 | - if (snan_bit_is_one(status)) { | |
348 | -# ifdef TARGET_HPPA | |
349 | - a &= ~0x00400000; | |
350 | - a |= 0x00200000; | |
351 | - return a; | |
352 | -# else | |
353 | - return float32_default_nan(status); | |
354 | -# endif | |
355 | - } else { | |
356 | - return a | (1 << 22); | |
357 | - } | |
358 | -#endif | |
359 | -} | |
360 | - | |
361 | -/*---------------------------------------------------------------------------- | |
362 | 320 | | Returns the result of converting the single-precision floating-point NaN |
363 | 321 | | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid |
364 | 322 | | exception is raised. |
@@ -707,31 +665,6 @@ int float64_is_signaling_nan(float64 a_, float_status *status) | ||
707 | 665 | } |
708 | 666 | |
709 | 667 | /*---------------------------------------------------------------------------- |
710 | -| Returns a quiet NaN from a signalling NaN for the double-precision | |
711 | -| floating point value `a'. | |
712 | -*----------------------------------------------------------------------------*/ | |
713 | - | |
714 | -float64 float64_silence_nan(float64 a, float_status *status) | |
715 | -{ | |
716 | -#ifdef NO_SIGNALING_NANS | |
717 | - g_assert_not_reached(); | |
718 | -#else | |
719 | - if (snan_bit_is_one(status)) { | |
720 | -# ifdef TARGET_HPPA | |
721 | - a &= ~0x0008000000000000ULL; | |
722 | - a |= 0x0004000000000000ULL; | |
723 | - return a; | |
724 | -# else | |
725 | - return float64_default_nan(status); | |
726 | -# endif | |
727 | - } else { | |
728 | - return a | LIT64(0x0008000000000000); | |
729 | - } | |
730 | -#endif | |
731 | -} | |
732 | - | |
733 | - | |
734 | -/*---------------------------------------------------------------------------- | |
735 | 668 | | Returns the result of converting the double-precision floating-point NaN |
736 | 669 | | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid |
737 | 670 | | exception is raised. |
@@ -886,16 +819,10 @@ int floatx80_is_signaling_nan(floatx80 a, float_status *status) | ||
886 | 819 | |
887 | 820 | floatx80 floatx80_silence_nan(floatx80 a, float_status *status) |
888 | 821 | { |
889 | -#ifdef NO_SIGNALING_NANS | |
890 | - g_assert_not_reached(); | |
891 | -#else | |
892 | - if (snan_bit_is_one(status)) { | |
893 | - return floatx80_default_nan(status); | |
894 | - } else { | |
895 | - a.low |= LIT64(0xC000000000000000); | |
896 | - return a; | |
897 | - } | |
898 | -#endif | |
822 | + /* None of the targets that have snan_bit_is_one use floatx80. */ | |
823 | + assert(!snan_bit_is_one(status)); | |
824 | + a.low |= LIT64(0xC000000000000000); | |
825 | + return a; | |
899 | 826 | } |
900 | 827 | |
901 | 828 | /*---------------------------------------------------------------------------- |
@@ -2135,6 +2135,37 @@ float128 float128_default_nan(float_status *status) | ||
2135 | 2135 | } |
2136 | 2136 | |
2137 | 2137 | /*---------------------------------------------------------------------------- |
2138 | +| Returns a quiet NaN from a signalling NaN for the floating point value `a'. | |
2139 | +*----------------------------------------------------------------------------*/ | |
2140 | + | |
2141 | +float16 float16_silence_nan(float16 a, float_status *status) | |
2142 | +{ | |
2143 | + FloatParts p = float16_unpack_raw(a); | |
2144 | + p.frac <<= float16_params.frac_shift; | |
2145 | + p = parts_silence_nan(p, status); | |
2146 | + p.frac >>= float16_params.frac_shift; | |
2147 | + return float16_pack_raw(p); | |
2148 | +} | |
2149 | + | |
2150 | +float32 float32_silence_nan(float32 a, float_status *status) | |
2151 | +{ | |
2152 | + FloatParts p = float32_unpack_raw(a); | |
2153 | + p.frac <<= float32_params.frac_shift; | |
2154 | + p = parts_silence_nan(p, status); | |
2155 | + p.frac >>= float32_params.frac_shift; | |
2156 | + return float32_pack_raw(p); | |
2157 | +} | |
2158 | + | |
2159 | +float64 float64_silence_nan(float64 a, float_status *status) | |
2160 | +{ | |
2161 | + FloatParts p = float64_unpack_raw(a); | |
2162 | + p.frac <<= float64_params.frac_shift; | |
2163 | + p = parts_silence_nan(p, status); | |
2164 | + p.frac >>= float64_params.frac_shift; | |
2165 | + return float64_pack_raw(p); | |
2166 | +} | |
2167 | + | |
2168 | +/*---------------------------------------------------------------------------- | |
2138 | 2169 | | Takes a 64-bit fixed-point value `absZ' with binary point between bits 6 |
2139 | 2170 | | and 7, and returns the properly rounded 32-bit integer corresponding to the |
2140 | 2171 | | input. If `zSign' is 1, the input is negated before being converted to an |