[PATCH] softfloat,m68k: disable floatx80_invalid_encoding() for m68k

Laurent Vivier posted 1 patch 3 years, 10 months ago
Test docker-mingw@fedora passed
Test checkpatch passed
Test asan passed
Test docker-quick@centos7 passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200612140400.2130118-1-laurent@vivier.eu
include/fpu/softfloat.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
[PATCH] softfloat,m68k: disable floatx80_invalid_encoding() for m68k
Posted by Laurent Vivier 3 years, 10 months ago
According to the comment, this definition of invalid encoding is given
by intel developer's manual, and doesn't comply with 680x0 FPU.

With m68k, the explicit integer bit can be zero in the case of:
 - zeros                (exp == 0, mantissa == 0)
 - denormalized numbers (exp == 0, mantissa != 0)
 - unnormalized numbers (exp != 0, exp < 0x7FFF)
 - infinities           (exp == 0x7FFF, mantissa == 0)
 - not-a-numbers        (exp == 0x7FFF, mantissa != 0)

For infinities and NaNs, the explicit integer bit can be either one or
zero.

The IEEE 754 standard does not define a zero integer bit. Such a number
is an unnormalized number. Hardware does not directly support
denormalized and unnormalized numbers, but implicitly supports them by
trapping them as unimplemented data types, allowing efficient conversion
in software.

See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL",
    "1.6 FLOATING-POINT DATA TYPES"

We will implement in the m68k TCG emulator the FP_UNIMP exception to
trap into the kernel to normalize the number. In case of linux-user,
the number will be normalized by QEMU.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 include/fpu/softfloat.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 16ca697a73b7..f6eda4ca8e6c 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -791,7 +791,31 @@ static inline bool floatx80_unordered_quiet(floatx80 a, floatx80 b,
 *----------------------------------------------------------------------------*/
 static inline bool floatx80_invalid_encoding(floatx80 a)
 {
+#if defined(TARGET_M68K)
+    /*-------------------------------------------------------------------------
+    | With m68k, the explicit integer bit can be zero in the case of:
+    | - zeros                (exp == 0, mantissa == 0)
+    | - denormalized numbers (exp == 0, mantissa != 0)
+    | - unnormalized numbers (exp != 0, exp < 0x7FFF)
+    | - infinities           (exp == 0x7FFF, mantissa == 0)
+    | - not-a-numbers        (exp == 0x7FFF, mantissa != 0)
+    |
+    | For infinities and NaNs, the explicit integer bit can be either one or
+    | zero.
+    |
+    | The IEEE 754 standard does not define a zero integer bit. Such a number
+    | is an unnormalized number. Hardware does not directly support
+    | denormalized and unnormalized numbers, but implicitly supports them by
+    | trapping them as unimplemented data types, allowing efficient conversion
+    | in software.
+    |
+    | See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL",
+    |     "1.6 FLOATING-POINT DATA TYPES"
+    *------------------------------------------------------------------------*/
+    return false;
+#else
     return (a.low & (1ULL << 63)) == 0 && (a.high & 0x7FFF) != 0;
+#endif
 }
 
 #define floatx80_zero make_floatx80(0x0000, 0x0000000000000000LL)
-- 
2.26.2


Re: [PATCH] softfloat,m68k: disable floatx80_invalid_encoding() for m68k
Posted by Laurent Vivier 3 years, 10 months ago
Hi,

any comments from FPU emulation maintainers?

Thanks,
Laurent

Le 12/06/2020 à 16:04, Laurent Vivier a écrit :
> According to the comment, this definition of invalid encoding is given
> by intel developer's manual, and doesn't comply with 680x0 FPU.
> 
> With m68k, the explicit integer bit can be zero in the case of:
>  - zeros                (exp == 0, mantissa == 0)
>  - denormalized numbers (exp == 0, mantissa != 0)
>  - unnormalized numbers (exp != 0, exp < 0x7FFF)
>  - infinities           (exp == 0x7FFF, mantissa == 0)
>  - not-a-numbers        (exp == 0x7FFF, mantissa != 0)
> 
> For infinities and NaNs, the explicit integer bit can be either one or
> zero.
> 
> The IEEE 754 standard does not define a zero integer bit. Such a number
> is an unnormalized number. Hardware does not directly support
> denormalized and unnormalized numbers, but implicitly supports them by
> trapping them as unimplemented data types, allowing efficient conversion
> in software.
> 
> See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL",
>     "1.6 FLOATING-POINT DATA TYPES"
> 
> We will implement in the m68k TCG emulator the FP_UNIMP exception to
> trap into the kernel to normalize the number. In case of linux-user,
> the number will be normalized by QEMU.
> 
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  include/fpu/softfloat.h | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
> index 16ca697a73b7..f6eda4ca8e6c 100644
> --- a/include/fpu/softfloat.h
> +++ b/include/fpu/softfloat.h
> @@ -791,7 +791,31 @@ static inline bool floatx80_unordered_quiet(floatx80 a, floatx80 b,
>  *----------------------------------------------------------------------------*/
>  static inline bool floatx80_invalid_encoding(floatx80 a)
>  {
> +#if defined(TARGET_M68K)
> +    /*-------------------------------------------------------------------------
> +    | With m68k, the explicit integer bit can be zero in the case of:
> +    | - zeros                (exp == 0, mantissa == 0)
> +    | - denormalized numbers (exp == 0, mantissa != 0)
> +    | - unnormalized numbers (exp != 0, exp < 0x7FFF)
> +    | - infinities           (exp == 0x7FFF, mantissa == 0)
> +    | - not-a-numbers        (exp == 0x7FFF, mantissa != 0)
> +    |
> +    | For infinities and NaNs, the explicit integer bit can be either one or
> +    | zero.
> +    |
> +    | The IEEE 754 standard does not define a zero integer bit. Such a number
> +    | is an unnormalized number. Hardware does not directly support
> +    | denormalized and unnormalized numbers, but implicitly supports them by
> +    | trapping them as unimplemented data types, allowing efficient conversion
> +    | in software.
> +    |
> +    | See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL",
> +    |     "1.6 FLOATING-POINT DATA TYPES"
> +    *------------------------------------------------------------------------*/
> +    return false;
> +#else
>      return (a.low & (1ULL << 63)) == 0 && (a.high & 0x7FFF) != 0;
> +#endif
>  }
>  
>  #define floatx80_zero make_floatx80(0x0000, 0x0000000000000000LL)
> 


Re: [PATCH] softfloat,m68k: disable floatx80_invalid_encoding() for m68k
Posted by Alex Bennée 3 years, 10 months ago
Laurent Vivier <laurent@vivier.eu> writes:

> According to the comment, this definition of invalid encoding is given
> by intel developer's manual, and doesn't comply with 680x0 FPU.
>
> With m68k, the explicit integer bit can be zero in the case of:
>  - zeros                (exp == 0, mantissa == 0)
>  - denormalized numbers (exp == 0, mantissa != 0)
>  - unnormalized numbers (exp != 0, exp < 0x7FFF)
>  - infinities           (exp == 0x7FFF, mantissa == 0)
>  - not-a-numbers        (exp == 0x7FFF, mantissa != 0)
>
> For infinities and NaNs, the explicit integer bit can be either one or
> zero.
>
> The IEEE 754 standard does not define a zero integer bit. Such a number
> is an unnormalized number. Hardware does not directly support
> denormalized and unnormalized numbers, but implicitly supports them by
> trapping them as unimplemented data types, allowing efficient conversion
> in software.
>
> See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL",
>     "1.6 FLOATING-POINT DATA TYPES"
>
> We will implement in the m68k TCG emulator the FP_UNIMP exception to
> trap into the kernel to normalize the number. In case of linux-user,
> the number will be normalized by QEMU.
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>

Apologies for the private reply, was using my fallback tooling while
email was down and that doesn't automatically include the group address.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

By all means take it via the m68k tree. 

> ---
>  include/fpu/softfloat.h | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
> index 16ca697a73b7..f6eda4ca8e6c 100644
> --- a/include/fpu/softfloat.h
> +++ b/include/fpu/softfloat.h
> @@ -791,7 +791,31 @@ static inline bool floatx80_unordered_quiet(floatx80 a, floatx80 b,
>  *----------------------------------------------------------------------------*/
>  static inline bool floatx80_invalid_encoding(floatx80 a)
>  {
> +#if defined(TARGET_M68K)
> +    /*-------------------------------------------------------------------------
> +    | With m68k, the explicit integer bit can be zero in the case of:
> +    | - zeros                (exp == 0, mantissa == 0)
> +    | - denormalized numbers (exp == 0, mantissa != 0)
> +    | - unnormalized numbers (exp != 0, exp < 0x7FFF)
> +    | - infinities           (exp == 0x7FFF, mantissa == 0)
> +    | - not-a-numbers        (exp == 0x7FFF, mantissa != 0)
> +    |
> +    | For infinities and NaNs, the explicit integer bit can be either one or
> +    | zero.
> +    |
> +    | The IEEE 754 standard does not define a zero integer bit. Such a number
> +    | is an unnormalized number. Hardware does not directly support
> +    | denormalized and unnormalized numbers, but implicitly supports them by
> +    | trapping them as unimplemented data types, allowing efficient conversion
> +    | in software.
> +    |
> +    | See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL",
> +    |     "1.6 FLOATING-POINT DATA TYPES"
> +    *------------------------------------------------------------------------*/
> +    return false;
> +#else
>      return (a.low & (1ULL << 63)) == 0 && (a.high & 0x7FFF) != 0;
> +#endif
>  }
>  
>  #define floatx80_zero make_floatx80(0x0000, 0x0000000000000000LL)

-- 
Alex Bennée

Re: [PATCH] softfloat,m68k: disable floatx80_invalid_encoding() for m68k
Posted by Laurent Vivier 3 years, 10 months ago
Le 06/07/2020 à 18:58, Alex Bennée a écrit :
> Laurent Vivier <laurent@vivier.eu> writes:
> 
>> According to the comment, this definition of invalid encoding is given
>> by intel developer's manual, and doesn't comply with 680x0 FPU.
>>
>> With m68k, the explicit integer bit can be zero in the case of:
>>  - zeros                (exp == 0, mantissa == 0)
>>  - denormalized numbers (exp == 0, mantissa != 0)
>>  - unnormalized numbers (exp != 0, exp < 0x7FFF)
>>  - infinities           (exp == 0x7FFF, mantissa == 0)
>>  - not-a-numbers        (exp == 0x7FFF, mantissa != 0)
>>
>> For infinities and NaNs, the explicit integer bit can be either one or
>> zero.
>>
>> The IEEE 754 standard does not define a zero integer bit. Such a number
>> is an unnormalized number. Hardware does not directly support
>> denormalized and unnormalized numbers, but implicitly supports them by
>> trapping them as unimplemented data types, allowing efficient conversion
>> in software.
>>
>> See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL",
>>     "1.6 FLOATING-POINT DATA TYPES"
>>
>> We will implement in the m68k TCG emulator the FP_UNIMP exception to
>> trap into the kernel to normalize the number. In case of linux-user,
>> the number will be normalized by QEMU.
>>
>> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> 
> Apologies for the private reply, was using my fallback tooling while
> email was down and that doesn't automatically include the group address.
> 
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> 
> By all means take it via the m68k tree. 

Thank you.

Applied to my m68k branch.

Laurent