[PATCH 03/10] target/i386: Avoid using floatx80_infinity global const

Peter Maydell posted 10 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH 03/10] target/i386: Avoid using floatx80_infinity global const
Posted by Peter Maydell 1 month, 3 weeks ago
The global const floatx80_infinity is (unlike all the other
float*_infinity values) target-specific, because whether the explicit
Integer bit is set or not varies between m68k and i386.  We want to
be able to compile softfloat once for multiple targets, so we can't
continue to use a single global whose value needs to be different
between targets.

Replace the direct uses of floatx80_infinity in target/i386 with
calls to the new floatx80_default_inf() function.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target/i386/tcg/fpu_helper.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
index f112c6c6737..741af09f908 100644
--- a/target/i386/tcg/fpu_helper.c
+++ b/target/i386/tcg/fpu_helper.c
@@ -1832,7 +1832,7 @@ void helper_fxtract(CPUX86State *env)
     } else if (floatx80_is_infinity(ST0)) {
         fpush(env);
         ST0 = ST1;
-        ST1 = floatx80_infinity;
+        ST1 = floatx80_default_inf(0, &env->fp_status);
     } else {
         int expdif;
 
@@ -2358,9 +2358,8 @@ void helper_fscale(CPUX86State *env)
                 float_raise(float_flag_invalid, &env->fp_status);
                 ST0 = floatx80_default_nan(&env->fp_status);
             } else {
-                ST0 = (floatx80_is_neg(ST0) ?
-                       floatx80_chs(floatx80_infinity) :
-                       floatx80_infinity);
+                ST0 = floatx80_default_inf(floatx80_is_neg(ST0),
+                                           &env->fp_status);
             }
         }
     } else {
-- 
2.43.0
Re: [PATCH 03/10] target/i386: Avoid using floatx80_infinity global const
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
On 17/2/25 13:50, Peter Maydell wrote:
> The global const floatx80_infinity is (unlike all the other
> float*_infinity values) target-specific, because whether the explicit
> Integer bit is set or not varies between m68k and i386.  We want to
> be able to compile softfloat once for multiple targets, so we can't
> continue to use a single global whose value needs to be different
> between targets.
> 
> Replace the direct uses of floatx80_infinity in target/i386 with
> calls to the new floatx80_default_inf() function.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   target/i386/tcg/fpu_helper.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)


> @@ -2358,9 +2358,8 @@ void helper_fscale(CPUX86State *env)
>                   float_raise(float_flag_invalid, &env->fp_status);
>                   ST0 = floatx80_default_nan(&env->fp_status);
>               } else {
> -                ST0 = (floatx80_is_neg(ST0) ?
> -                       floatx80_chs(floatx80_infinity) :
> -                       floatx80_infinity);
> +                ST0 = floatx80_default_inf(floatx80_is_neg(ST0),
> +                                           &env->fp_status);

Which expand to:

{
   .low = floatx80_default_inf_int_bit_is_zero ? 0 : (1ULL << 63),
   .high = (((uint16_t)zSign) << 15) + 0x7fff
}

Effectively equivalent of toggling the sign with floatx80_chs
(the floatx80_chs removal was not obvious, worth mentioning?).

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Review note, as softfloat API methods names are verbose,
float*_chs() could be renamed as _change_sign().

Regards,

Phil.

Re: [PATCH 03/10] target/i386: Avoid using floatx80_infinity global const
Posted by Richard Henderson 1 month, 3 weeks ago
On 2/17/25 04:50, Peter Maydell wrote:
> The global const floatx80_infinity is (unlike all the other
> float*_infinity values) target-specific, because whether the explicit
> Integer bit is set or not varies between m68k and i386.  We want to
> be able to compile softfloat once for multiple targets, so we can't
> continue to use a single global whose value needs to be different
> between targets.
> 
> Replace the direct uses of floatx80_infinity in target/i386 with
> calls to the new floatx80_default_inf() function.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   target/i386/tcg/fpu_helper.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~