fpu: Make floatx80 invalid encoding settable at runtime
Because floatx80 has an explicit integer bit, this permits some odd encodings where the integer bit is not set correctly for the floating point value type. In In Intel terminology the categories are: exp == 0, int = 0, mantissa == 0 : zeroes exp == 0, int = 0, mantissa != 0 : denormals exp == 0, int = 1 : pseudo-denormals 0 < exp < 0x7fff, int = 0 : unnormals 0 < exp < 0x7fff, int = 1 : normals exp == 0x7fff, int = 0, mantissa == 0 : pseudo-infinities exp == 0x7fff, int = 1, mantissa == 0 : infinities exp == 0x7fff, int = 0, mantissa != 0 : pseudo-NaNs exp == 0x7fff, int = 1, mantissa == 0 : NaNs The usual IEEE cases of zero, denormal, normal, inf and NaN are always valid. x87 permits as input also pseudo-denormals. m68k permits all those and also pseudo-infinities, pseudo-NaNs and unnormals. Currently we have an ifdef in floatx80_invalid_encoding() to select the x86 vs m68k behaviour. Add new floatx80_behaviour flags to select whether pseudo-NaN and unnormal are valid, and use these (plus the existing pseudo_inf_valid flag) to decide whether these encodings are invalid at runtime. We leave pseudo-denormals as always-valid, since both x86 and m68k accept them. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-id: 20250224111524.1101196-8-peter.maydell@linaro.org Message-id: 20250217125055.160887-6-peter.maydell@linaro.org
This commit is contained in:
parent
765fe845cc
commit
a261d3e331
3 changed files with 77 additions and 33 deletions
|
|
@ -111,9 +111,35 @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type)
|
|||
* m68k-specific floatx80 behaviour:
|
||||
* * default Infinity values have a zero Integer bit
|
||||
* * input Infinities may have the Integer bit either 0 or 1
|
||||
* * pseudo-denormals supported for input and output
|
||||
* * don't raise Invalid for pseudo-NaN/pseudo-Inf/Unnormal
|
||||
*
|
||||
* 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"
|
||||
*
|
||||
* Note though that QEMU's fp emulation does directly handle both
|
||||
* denormal and unnormal values, and does not trap to guest software.
|
||||
*/
|
||||
set_floatx80_behaviour(floatx80_default_inf_int_bit_is_zero |
|
||||
floatx80_pseudo_inf_valid,
|
||||
floatx80_pseudo_inf_valid |
|
||||
floatx80_pseudo_nan_valid |
|
||||
floatx80_unnormal_valid,
|
||||
&env->fp_status);
|
||||
|
||||
nan = floatx80_default_nan(&env->fp_status);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue