aboutsummaryrefslogtreecommitdiff
path: root/fpu/softfloat-specialize.h
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2010-12-07 15:37:34 +0000
committerPeter Maydell <peter.maydell@linaro.org>2010-12-07 15:37:34 +0000
commitb408dbdec3d3220b7e2da2b0fd768048f43a2e39 (patch)
tree790b550113eeaa93bcc7cc28d4ce133ce8f5db08 /fpu/softfloat-specialize.h
parent09d9487fbb5c17226762e73c2b7d84170f5bd092 (diff)
softfloat: Add float*_maybe_silence_nan() functions
Add functions float*_maybe_silence_nan() which ensure that a value is not a signaling NaN by turning it into a quiet NaN. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Nathan Froyd <froydnj@codesourcery.com>
Diffstat (limited to 'fpu/softfloat-specialize.h')
-rw-r--r--fpu/softfloat-specialize.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h
index 8e6aceb552..07468786f9 100644
--- a/fpu/softfloat-specialize.h
+++ b/fpu/softfloat-specialize.h
@@ -102,6 +102,25 @@ int float32_is_signaling_nan( float32 a_ )
}
/*----------------------------------------------------------------------------
+| Returns a quiet NaN if the single-precision floating point value `a' is a
+| signaling NaN; otherwise returns `a'.
+*----------------------------------------------------------------------------*/
+
+float32 float32_maybe_silence_nan( float32 a_ )
+{
+ if (float32_is_signaling_nan(a_)) {
+ uint32_t a = float32_val(a_);
+#if SNAN_BIT_IS_ONE
+ a &= ~(1 << 22);
+#else
+ a |= (1 << 22);
+#endif
+ return make_float32(a);
+ }
+ return a_;
+}
+
+/*----------------------------------------------------------------------------
| Returns the result of converting the single-precision floating-point NaN
| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid
| exception is raised.
@@ -234,6 +253,25 @@ int float64_is_signaling_nan( float64 a_ )
}
/*----------------------------------------------------------------------------
+| Returns a quiet NaN if the double-precision floating point value `a' is a
+| signaling NaN; otherwise returns `a'.
+*----------------------------------------------------------------------------*/
+
+float64 float64_maybe_silence_nan( float64 a_ )
+{
+ if (float64_is_signaling_nan(a_)) {
+ bits64 a = float64_val(a_);
+#if SNAN_BIT_IS_ONE
+ a &= ~LIT64( 0x0008000000000000 );
+#else
+ a |= LIT64( 0x0008000000000000 );
+#endif
+ return make_float64(a);
+ }
+ return a_;
+}
+
+/*----------------------------------------------------------------------------
| Returns the result of converting the double-precision floating-point NaN
| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid
| exception is raised.