Skip to contentSkip to conversation

[6106] Implement default-NaN mode.

Qemu-devel Paul Brook 3 participants 3 messages Dec 19, 2008

lore
Share & tools
lore

Paul Brook

author
#0 lore raw

Revision: 6106

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6106
Author:   pbrook
Date:     2008-12-19 13:53:37 +0000 (Fri, 19 Dec 2008)

Log Message:
-----------
Implement default-NaN mode.

Modified Paths:
--------------
trunk/fpu/softfloat-specialize.h
trunk/fpu/softfloat.h
trunk/target-arm/helper.c

Modified: trunk/fpu/softfloat-specialize.h
===================================================================

fpu/softfloat-specialize.h +18 -0
@@ -144,6 +144,9 @@
     flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
     bits32 av, bv, res;
 
+    if ( STATUS(default_nan_mode) )
+        return float32_default_nan;
+
     aIsNaN = float32_is_nan( a );
     aIsSignalingNaN = float32_is_signaling_nan( a );
     bIsNaN = float32_is_nan( b );
@@ -276,6 +279,9 @@
     flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
     bits64 av, bv, res;
 
+    if ( STATUS(default_nan_mode) )
+        return float64_default_nan;
+
     aIsNaN = float64_is_nan( a );
     aIsSignalingNaN = float64_is_signaling_nan( a );
     bIsNaN = float64_is_nan( b );
@@ -412,6 +418,12 @@
 {
     flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
 
+    if ( STATUS(default_nan_mode) ) {
+        a.low = floatx80_default_nan_low;
+        a.high = floatx80_default_nan_high;
+        return a;
+    }
+
     aIsNaN = floatx80_is_nan( a );
     aIsSignalingNaN = floatx80_is_signaling_nan( a );
     bIsNaN = floatx80_is_nan( b );
@@ -532,6 +544,12 @@
 {
     flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
 
+    if ( STATUS(default_nan_mode) ) {
+        a.low = float128_default_nan_low;
+        a.high = float128_default_nan_high;
+        return a;
+    }
+
     aIsNaN = float128_is_nan( a );
     aIsSignalingNaN = float128_is_signaling_nan( a );
     bIsNaN = float128_is_nan( b );

Modified: trunk/fpu/softfloat.h
===================================================================

fpu/softfloat.h +5 -0
@@ -190,10 +190,15 @@
 #ifdef FLOATX80
     signed char floatx80_rounding_precision;
 #endif
+    flag default_nan_mode;
 } float_status;
 
 void set_float_rounding_mode(int val STATUS_PARAM);
 void set_float_exception_flags(int val STATUS_PARAM);
+INLINE void set_default_nan_mode(flag val STATUS_PARAM)
+{
+    STATUS(default_nan_mode) = val;
+}
 INLINE int get_float_exception_flags(float_status *status)
 {
     return STATUS(float_exception_flags);

Modified: trunk/target-arm/helper.c
===================================================================

target-arm/helper.c +2 -0
@@ -2334,6 +2334,8 @@
         }
         set_float_rounding_mode(i, &env->vfp.fp_status);
     }
+    if (changed & (1 << 25))
+        set_default_nan_mode((val & (1 << 25)) != 0, &env->vfp.fp_status);
 
     i = vfp_exceptbits_to_host((val >> 8) & 0x1f);
     set_float_exception_flags(i, &env->vfp.fp_status);
#1 lore raw
Quoted 16 lines · Paul Brook

Revision: 6106

         http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6106
Author:   pbrook
Date:     2008-12-19 13:53:37 +0000 (Fri, 19 Dec 2008)

Log Message:
-----------
Implement default-NaN mode.

Modified Paths:
--------------
trunk/fpu/softfloat-specialize.h
trunk/fpu/softfloat.h
trunk/target-arm/helper.c

[...]

target-arm/helper.c 2008-12-19 13:53:37 UTC (rev 6106) line 2341

Quoted 13 lines

Modified: trunk/target-arm/helper.c
===================================================================

target-arm/helper.c 2008-12-19 13:53:37 UTC (rev 6106) renamed from target-arm/helper.c 2008-12-19 13:37:53 UTC (rev 6105) +2 -0
@@ -2334,6 +2334,8 @@
        }
        set_float_rounding_mode(i, &env->vfp.fp_status);
    }
+    if (changed & (1 << 25))
+        set_default_nan_mode((val & (1 << 25)) != 0, &env->vfp.fp_status);
 
    i = vfp_exceptbits_to_host((val >> 8) & 0x1f);
    set_float_exception_flags(i, &env->vfp.fp_status);

Doesn't this require an update to the way flags are computed in target-arm/cpu.h/cpu_get_tb_cpu_state?

Also I guess the comment at end of vfp_set_fpscr needs some update to reflect the handling of DN :-)

Laurent

#2 lore raw
Quoted 2 lines

Doesn't this require an update to the way flags are computed in target-arm/cpu.h/cpu_get_tb_cpu_state?

No. These are all runtime checks.

In theory this patch (and the flush-to-zero patch) introduce some runtime overhead. However it should only effect the exceptional cases of denormals and NaNs, normal numbers should be unaffected.

Quoted 2 lines

Also I guess the comment at end of vfp_set_fpscr needs some update to reflect the handling of DN :-)

Keep reading :-)

Paul