aboutsummaryrefslogtreecommitdiff
path: root/fpu/softfloat-specialize.h
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2011-02-10 11:28:58 +0000
committerAurelien Jarno <aurelien@aurel32.net>2011-02-10 18:28:21 +0100
commit600e30d2b293bd19b0d0cdb7e8a517cecf482d12 (patch)
tree265f184644fcc33b1e1877d49edf3189695245e7 /fpu/softfloat-specialize.h
parentbcd4d9afd411494f9e1cb2a3b4a65dcf4207857e (diff)
downloadqemu-arm-600e30d2b293bd19b0d0cdb7e8a517cecf482d12.tar.gz
softfloat: Fix single-to-half precision float conversions
Fix various bugs in the single-to-half-precision conversion code: * input NaNs not correctly converted in IEEE mode (fixed by defining and using a commonNaNToFloat16()) * wrong values returned when converting NaN/Inf into non-IEEE half precision value * wrong values returned for conversion of values which are on the boundary between denormal and zero for the half precision format * zeroes not correctly identified * excessively large results in non-IEEE mode should generate InvalidOp, not Overflow Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'fpu/softfloat-specialize.h')
-rw-r--r--fpu/softfloat-specialize.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h
index 1b7521f8e6..1c0b12b573 100644
--- a/fpu/softfloat-specialize.h
+++ b/fpu/softfloat-specialize.h
@@ -120,6 +120,27 @@ float16 float16_maybe_silence_nan(float16 a_)
}
/*----------------------------------------------------------------------------
+| Returns the result of converting the canonical NaN `a' to the half-
+| precision floating-point format.
+*----------------------------------------------------------------------------*/
+
+static float16 commonNaNToFloat16(commonNaNT a STATUS_PARAM)
+{
+ uint16_t mantissa = a.high>>54;
+
+ if (STATUS(default_nan_mode)) {
+ return float16_default_nan;
+ }
+
+ if (mantissa) {
+ return make_float16(((((uint16_t) a.sign) << 15)
+ | (0x1F << 10) | mantissa));
+ } else {
+ return float16_default_nan;
+ }
+}
+
+/*----------------------------------------------------------------------------
| The pattern for a default generated single-precision NaN.
*----------------------------------------------------------------------------*/
#if defined(TARGET_SPARC)