Skip to contentSkip to conversation

soft-float fixes for target-s390x

PATCH Superseded Richard Henderson 3 participants 9 messages Dec 7, 2012 – Dec 8, 2012

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover soft-float fixes for target-s390x

... or for upcoming s390x changes.

The s390x isa has insns for both signed and unsigned conversions to all three (binary) floating point types. One of these was missing and the other producing incorrect results.

Tested with the s390x rewrite on the gcc testsuite.

Changes v1-v2:
Incorporating feedback from Peter Maydell (previously missed in the 140+ message thread).

r~

Richard Henderson (2):
softfloat: Fix uint64_to_float64
softfloat: Implement uint64_to_float128

 fpu/softfloat.c | 17 +++++++++++++++--
 fpu/softfloat.h |  3 +++
 2 files changed, 18 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH v2 1/2 softfloat: Fix uint64_to_float64

The interface to normalizeRoundAndPackFloat64 requires that the high bit be clear. Perform one shift-right-and-jam if needed.

---
 fpu/softfloat.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
fpu/softfloat.c +7 -2
index 8413146..62830d7 100644
@@ -1273,9 +1273,14 @@ float64 int64_to_float64( int64 a STATUS_PARAM )
 
 float64 uint64_to_float64( uint64 a STATUS_PARAM )
 {
-    if ( a == 0 ) return float64_zero;
-    return normalizeRoundAndPackFloat64( 0, 0x43C, a STATUS_VAR );
+    int exp =  0x43C;
 
+    if ( a == 0 ) return float64_zero;
+    if ( (int64_t)a < 0 ) {
+        shift64RightJamming(a, 1, &a);
+        exp += 1;
+    }
+    return normalizeRoundAndPackFloat64( 0, exp, a STATUS_VAR );
 }
 
 /*----------------------------------------------------------------------------
Signature · 1 line
1.7.11.7
#3 lore raw

Re: [Qemu-devel] [PATCH 1/2] softfloat: Fix uint64_to_float64

In reply to Richard Henderson

Am 07.12.2012 22:52, schrieb Richard Henderson:

Quoted 13 lines

The interface to normalizeRoundAndPackFloat64 requires that the high bit be clear. Perform one shift-right-and-jam if needed.

---
 fpu/softfloat.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
fpu/softfloat.c +0 -0
index 8413146..62830d7 100644

fpu/softfloat.c float64 int64_to_float64( int64 a STATUS_PARAM ) · line 1276

Quoted 6 lines
fpu/softfloat.c +1 -2
@@ -1273,9 +1273,14 @@ float64 int64_to_float64( int64 a STATUS_PARAM )
 
 float64 uint64_to_float64( uint64 a STATUS_PARAM )
 {
-    if ( a == 0 ) return float64_zero;
-    return normalizeRoundAndPackFloat64( 0, 0x43C, a STATUS_VAR );
+    int exp =  0x43C;

Extra space before number.

fpu/softfloat.c float64 int64_to_float64( int64 a STATUS_PARAM ) · line 1286

Quoted 10 lines
fpu/softfloat.c +6 -0
+    if ( a == 0 ) return float64_zero;
+    if ( (int64_t)a < 0 ) {
+        shift64RightJamming(a, 1, &a);
+        exp += 1;
+    }
+    return normalizeRoundAndPackFloat64( 0, exp, a STATUS_VAR );
 }
 
 /*----------------------------------------------------------------------------

Shouldn't we be updating the Coding Style on all lines we touch? The shift line matches it but the normalize and ifs don't.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#4 lore raw

Re: [Qemu-devel] [PATCH 1/2] softfloat: Fix uint64_to_float64

Quoted 2 lines · Andreas Färber

Shouldn't we be updating the Coding Style on all lines we touch? The shift line matches it but the normalize and ifs don't.

fpu/ is a special case because the softfloat library has such a bonkers coding style. I tend to update to qemu standard when I touch bits of it, but following the existing practice is also OK in my opinion.

-- PMM

#5 lore raw

Re: [Qemu-devel] [PATCH 1/2] softfloat: Fix uint64_to_float64

Am 08.12.2012 17:08, schrieb Peter Maydell:

Quoted 8 lines · Andreas Färber
Quoted 2 lines

Shouldn't we be updating the Coding Style on all lines we touch? The shift line matches it but the normalize and ifs don't.

fpu/ is a special case because the softfloat library has such a bonkers coding style. I tend to update to qemu standard when I touch bits of it, but following the existing practice is also OK in my opinion.

The same applies to linux-user and much of ppc code (spaces before parenthesis, no braces). The only agreed-on way to address this is by fixing the parts we touch - no veto here, but seems trivial enough to fix. Otherwise the situation won't ever improve.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#6 lore raw

PATCH v2 2/2 softfloat: Implement uint64_to_float128

In reply to Richard Henderson
---
 fpu/softfloat.c | 8 ++++++++
 fpu/softfloat.h | 3 +++
 2 files changed, 11 insertions(+)
fpu/softfloat.c +8 -0
index 62830d7..d3290d8 100644
@@ -1337,6 +1337,14 @@ float128 int64_to_float128( int64 a STATUS_PARAM )
 
 }
 
+float128 uint64_to_float128( uint64 a STATUS_PARAM )
+{
+    if (a == 0) {
+        return float128_zero;
+    }
+    return normalizeRoundAndPackFloat128(0, 0x406E, a, 0 STATUS_VAR);
+}
+
 /*----------------------------------------------------------------------------
 | Returns the result of converting the single-precision floating-point value
 | `a' to the 32-bit two's complement integer format.  The conversion is
fpu/softfloat.h +3 -0
index d8999b3..c1ea196 100644
@@ -237,6 +237,7 @@ float64 int64_to_float64( int64 STATUS_PARAM );
 float64 uint64_to_float64( uint64 STATUS_PARAM );
 floatx80 int64_to_floatx80( int64 STATUS_PARAM );
 float128 int64_to_float128( int64 STATUS_PARAM );
+float128 uint64_to_float128( uint64 STATUS_PARAM );
 
 /*----------------------------------------------------------------------------
 | Software half-precision conversion routines.
@@ -630,6 +631,8 @@ INLINE int float128_is_any_nan(float128 a)
         ((a.low != 0) || ((a.high & 0xffffffffffffLL) != 0));
 }
 
+#define float128_zero make_float128(0, 0)
+
 /*----------------------------------------------------------------------------
 | The pattern for a default generated quadruple-precision NaN.
 *----------------------------------------------------------------------------*/
Signature · 1 line
1.7.11.7
#8 lore raw

Re: [Qemu-devel] [PATCH 2/2] softfloat: Implement uint64_to_float128

In reply to Richard Henderson

Am 07.12.2012 22:52, schrieb Richard Henderson:

Quoted 11 lines
---
 fpu/softfloat.c | 8 ++++++++
 fpu/softfloat.h | 3 +++
 2 files changed, 11 insertions(+)
fpu/softfloat.c +0 -0
index 62830d7..d3290d8 100644

fpu/softfloat.c float128 int64_to_float128( int64 a STATUS_PARAM ) · line 1340

Quoted 4 lines
fpu/softfloat.c +1 -0
@@ -1337,6 +1337,14 @@ float128 int64_to_float128( int64 a STATUS_PARAM )
 
 }
 
+float128 uint64_to_float128( uint64 a STATUS_PARAM )

Update the parenthesis style as well? You adopted QEMU's style below.

Quoted 15 lines
fpu/softfloat.c +7 -0
+{
+    if (a == 0) {
+        return float128_zero;
+    }
+    return normalizeRoundAndPackFloat128(0, 0x406E, a, 0 STATUS_VAR);
+}
+
 /*----------------------------------------------------------------------------
 | Returns the result of converting the single-precision floating-point value
 | `a' to the 32-bit two's complement integer format.  The conversion is
fpu/softfloat.h +0 -0
index d8999b3..c1ea196 100644

fpu/softfloat.h float64 int64_to_float64( int64 STATUS_PARAM ); · line 240

Quoted 4 lines
fpu/softfloat.h +1 -0
@@ -237,6 +237,7 @@ float64 int64_to_float64( int64 STATUS_PARAM );
 float64 uint64_to_float64( uint64 STATUS_PARAM );
 floatx80 int64_to_floatx80( int64 STATUS_PARAM );
 float128 int64_to_float128( int64 STATUS_PARAM );
+float128 uint64_to_float128( uint64 STATUS_PARAM );

Ditto? I would've expected checkpatch.pl complaints...

Andreas

Quoted 13 lines
fpu/softfloat.h +2 -0
 /*----------------------------------------------------------------------------
 | Software half-precision conversion routines.
@@ -630,6 +631,8 @@ INLINE int float128_is_any_nan(float128 a)
         ((a.low != 0) || ((a.high & 0xffffffffffffLL) != 0));
 }
 
+#define float128_zero make_float128(0, 0)
+
 /*----------------------------------------------------------------------------
 | The pattern for a default generated quadruple-precision NaN.
 *----------------------------------------------------------------------------*/
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg