aboutsummaryrefslogtreecommitdiff
path: root/fpu
diff options
context:
space:
mode:
authorLIU Zhiwei <zhiwei_liu@c-sky.com>2020-08-13 15:14:21 +0800
committerRichard Henderson <richard.henderson@linaro.org>2020-08-28 10:48:07 -0700
commit5ebf5f4be66c378fd5f3dee85f54dd4942171d57 (patch)
tree02ac552319514abe55960e34a116489f4b5f1955 /fpu
parent34f0c0a98a5f3bb6706088c0384f937f7a294d3e (diff)
downloadqemu-5ebf5f4be66c378fd5f3dee85f54dd4942171d57.zip
qemu-5ebf5f4be66c378fd5f3dee85f54dd4942171d57.tar.gz
qemu-5ebf5f4be66c378fd5f3dee85f54dd4942171d57.tar.bz2
softfloat: Define misc operations for bfloat16
Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20200813071421.2509-4-zhiwei_liu@c-sky.com> [rth: Fix merge conflict with NO_SIGNALING_NANS; use bool for predicates.] Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'fpu')
-rw-r--r--fpu/softfloat-specialize.c.inc38
1 files changed, 38 insertions, 0 deletions
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index dc4ea33..c2f87ad 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -266,6 +266,25 @@ bool float16_is_quiet_nan(float16 a_, float_status *status)
}
/*----------------------------------------------------------------------------
+| Returns 1 if the bfloat16 value `a' is a quiet
+| NaN; otherwise returns 0.
+*----------------------------------------------------------------------------*/
+
+bool bfloat16_is_quiet_nan(bfloat16 a_, float_status *status)
+{
+ if (no_signaling_nans(status)) {
+ return bfloat16_is_any_nan(a_);
+ } else {
+ uint16_t a = a_;
+ if (snan_bit_is_one(status)) {
+ return (((a >> 6) & 0x1FF) == 0x1FE) && (a & 0x3F);
+ } else {
+ return ((a >> 6) & 0x1FF) == 0x1FF;
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------
| Returns 1 if the half-precision floating-point value `a' is a signaling
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/
@@ -285,6 +304,25 @@ bool float16_is_signaling_nan(float16 a_, float_status *status)
}
/*----------------------------------------------------------------------------
+| Returns 1 if the bfloat16 value `a' is a signaling
+| NaN; otherwise returns 0.
+*----------------------------------------------------------------------------*/
+
+bool bfloat16_is_signaling_nan(bfloat16 a_, float_status *status)
+{
+ if (no_signaling_nans(status)) {
+ return 0;
+ } else {
+ uint16_t a = a_;
+ if (snan_bit_is_one(status)) {
+ return ((a >> 6) & 0x1FF) == 0x1FF;
+ } else {
+ return (((a >> 6) & 0x1FF) == 0x1FE) && (a & 0x3F);
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------
| Returns 1 if the single-precision floating-point value `a' is a quiet
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/