target/m68k: implement 680x0 FPU (part 3)
v3 cover target/m68k: implement 680x0 FPU (part 3)
Implement fmod, frem, fscale, fgetman and fgetexp.
Instead of using functions of libm (v1 of this series) and converting between host long double and floatx80 type the new version (v2) adds new floatx80 functions in softfloat.
All the floatx80 functions are copied from "Previous", the NeXT Computer Emulator, and written by Andreas Grabher.
v3: Move all new functions to target/m68k/softfloat.c
Exports needed functions from fpu/softfloat.c
Laurent Vivier (4):
softfloat: export some functions
target/m68k: add fmod/frem
softfloat: use floatx80_infinity in softfloat target/m68k: add fscale, fgetman and fgetexp
fpu/softfloat-specialize.h | 17 ++-
fpu/softfloat.c | 129 +++++------------
{fpu => include/fpu}/softfloat-macros.h | 10 +-
include/fpu/softfloat.h | 129 ++++++++++++++++-
target/m68k/Makefile.objs | 3 +-
target/m68k/cpu.h | 1 +
target/m68k/fpu_helper.c | 50 ++++++-
target/m68k/helper.h | 5 +
target/m68k/softfloat.c | 249 ++++++++++++++++++++++++++++++++
target/m68k/softfloat.h | 29 ++++
target/m68k/translate.c | 15 ++
11 files changed, 533 insertions(+), 104 deletions(-)
rename {fpu => include/fpu}/softfloat-macros.h (98%)
create mode 100644 target/m68k/softfloat.c
create mode 100644 target/m68k/softfloat.hSignature · 1 line
2.14.3
PATCH v3 1/4 softfloat: export some functions
Move fpu/softfloat-macros.h to include/fpu/
Export floatx80 functions to be used by target floatx80 specific implementations.
Exports:
propagateFloatx80NaN(), extractFloatx80Frac(), extractFloatx80Exp(), extractFloatx80Sign(), normalizeFloatx80Subnormal(), packFloatx80(), roundAndPackFloatx80(), normalizeRoundAndPackFloatx80()
Also exports packFloat32() that will be used to implement m68k fsinh, fcos, fsin, ftan operations.
---
CC: Aurelien Jarno <[email protected]>
CC: Alex Bennée <[email protected]>
CC: Peter Maydell <[email protected]>
fpu/softfloat-specialize.h | 3 +-
fpu/softfloat.c | 91 +++---------------------
{fpu => include/fpu}/softfloat-macros.h | 10 +--
include/fpu/softfloat.h | 120 ++++++++++++++++++++++++++++++++
4 files changed, 136 insertions(+), 88 deletions(-)
rename {fpu => include/fpu}/softfloat-macros.h (98%)fpu/softfloat-specialize.h +1 -2
@@ -1011,8 +1011,7 @@ static floatx80 commonNaNToFloatx80(commonNaNT a, float_status *status)| `b' is a signaling NaN, the invalid exception is raised. *----------------------------------------------------------------------------*/ -static floatx80 propagateFloatx80NaN (floatx80 a,floatx80 b, -float_status *status) +floatx80 propagateFloatx80NaN (floatx80 a,floatx80 b,float_status *status) {flag aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN;flag aIsLargerSignificand;
fpu/softfloat.c +10 -81
133 lines not on this page · raw message
include/fpu/softfloat-macros.h renamed from fpu/softfloat-macros.h +5 -5
@@ -603,7 +603,7 @@ static inline void| unsigned integer is returned. *----------------------------------------------------------------------------*/ -static uint64_t estimateDiv128To64 (uint64_t a0,uint64_t a1,uint64_t b ) +static inline uint64_t estimateDiv128To64 (uint64_t a0,uint64_t a1,uint64_t b) {uint64_t b0, b1;uint64_t rem0, rem1, term0, term1;
@@ -630,7 +630,7 @@ static uint64_t estimateDiv128To64( uint64_t a0, uint64_t a1, uint64_t b )* * Licensed under the GPLv2/LGPLv3 */ -static uint64_t div128To64 (uint64_t n0,uint64_t n1,uint64_t d) +static inline uint64_t div128To64 (uint64_t n0,uint64_t n1,uint64_t d) {uint64_t d0, d1, q0, q1, r1, r0, m;
@@ -683,7 +683,7 @@ static uint64_t div128To64(uint64_t n0, uint64_t n1, uint64_t d)| value. *----------------------------------------------------------------------------*/ -static uint32_t estimateSqrt32 (int aExp,uint32_t a) +static inline uint32_t estimateSqrt32 (int aExp,uint32_t a) {static const uint16_t sqrtOddAdjustments[] = {0x0004 ,0x0022 ,0x005D ,0x00B1 ,0x011D ,0x019F ,0x0236 ,0x02E0 ,
@@ -717,7 +717,7 @@ static uint32_t estimateSqrt32(int aExp, uint32_t a)| `a'. If `a' is zero, 32 is returned. *----------------------------------------------------------------------------*/ -static int8_t countLeadingZeros32 (uint32_t a ) +static inline int8_t countLeadingZeros32 (uint32_t a) {#if SOFTFLOAT_GNUC_PREREQ (3 ,4 )if (a) {
@@ -765,7 +765,7 @@ static int8_t countLeadingZeros32( uint32_t a )| `a'. If `a' is zero, 64 is returned. *----------------------------------------------------------------------------*/ -static int8_t countLeadingZeros64 (uint64_t a ) +static inline int8_t countLeadingZeros64 (uint64_t a) {#if SOFTFLOAT_GNUC_PREREQ (3 ,4 )if (a) {
include/fpu/softfloat.h +120 -0
132 lines not on this page · raw message
Signature · 1 line
2.14.3
Re: [Qemu-devel] [PATCH v3 1/4] softfloat: export some functions
Quoted 11 lines · Laurent Vivier
Move
fpu/softfloat-macros.htoinclude/fpu/Export floatx80 functions to be used by target floatx80 specific implementations.
Exports:
propagateFloatx80NaN(),extractFloatx80Frac(),extractFloatx80Exp(),extractFloatx80Sign(),normalizeFloatx80Subnormal(),packFloatx80(),roundAndPackFloatx80(),normalizeRoundAndPackFloatx80()
Quoted 8 lines
Also exports
packFloat32()that will be used to implement m68k fsinh, fcos, fsin, ftan operations.Signed-off-by Laurent Vivier <[email protected]>---
CC: Aurelien Jarno <[email protected]>
CC: Alex Bennée <[email protected]>
CC: Peter Maydell <[email protected]>
r~
PATCH v3 2/4 target/m68k: add fmod/frem
In reply to Laurent VivierUsing a local m68k floatx80_mod()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
The quotient byte of the FPSR is updated with
the result of the operation.
--- target/m68k/Makefile.objs | 3 +- target/m68k/cpu.h | 1 + target/m68k/fpu_helper.c | 35 +++++++++++++++- target/m68k/helper.h | 2 + target/m68k/softfloat.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 26 ++++++++++++ target/m68k/translate.c | 6 +++ 7 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 target/m68k/softfloat.c create mode 100644 target/m68k/softfloat.h
target/m68k/Makefile.objs +2 -1
@@ -1,4 +1,5 @@ obj-y += m68k-semi.o -obj-y += translate.o op_helper.o helper.o cpu.o fpu_helper.o +obj-y += translate.o op_helper.o helper.o cpu.o +obj-y += fpu_helper.o softfloat.o obj-y += gdbstub.o obj-$(CONFIG_SOFTMMU) += monitor.o
target/m68k/cpu.h +1 -0
@@ -427,6 +427,7 @@ typedef enum {/* Quotient */ #define FPSR_QT_MASK 0x00ff0000 +#define FPSR_QT_SHIFT 16/* Floating-Point Control Register */ /* Rounding mode */
target/m68k/fpu_helper.c +34 -1
@@ -23,7 +23,7 @@#include "exec/helper-proto.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" -#include "fpu/softfloat.h" +#include "softfloat.h" /* Undefined offsets may be different on various FPU. * On 68040 they return 0.0 (floatx80_zero)
@@ -509,3 +509,36 @@ uint32_t HELPER(fmovemd_ld_postinc)(CPUM68KState *env, uint32_t addr, {return fmovem_postinc (env, addr, mask, cpu_ld_float64_ra); } + +static void make_quotient (CPUM68KState *env,floatx80 val) +{ +int32_t quotient; +int sign; + +if (floatx80_is_any_nan (val)) { +return ; + } + + quotient =floatx80_to_int32 (val, &env->fp_status); + sign = quotient <0 ; +if (sign) { + quotient = -quotient; + } + + quotient = (sign <<7 ) | (quotient &0x7f ); + env->fpsr = (env->fpsr & ~FPSR_QT_MASK ) | (quotient <<FPSR_QT_SHIFT ); +} + +void HELPER (fmod )(CPUM68KState *env,FPReg *res,FPReg *val0,FPReg *val1) +{ + res->d =floatx80_mod (val1->d, val0->d, &env->fp_status); + +make_quotient (env, res->d); +} + +void HELPER (frem )(CPUM68KState *env,FPReg *res,FPReg *val0,FPReg *val1) +{ + res->d =floatx80_rem (val1->d, val0->d, &env->fp_status); + +make_quotient (env, res->d); +}
target/m68k/helper.h +2 -0
@@ -63,6 +63,8 @@ DEF_HELPER_3(fmovemx_ld_postinc, i32, env, i32, i32) DEF_HELPER_3(fmovemd_st_predec, i32, env, i32, i32) DEF_HELPER_3(fmovemd_st_postinc, i32, env, i32, i32) DEF_HELPER_3(fmovemd_ld_postinc, i32, env, i32, i32) +DEF_HELPER_4(fmod, void, env, fp, fp, fp) +DEF_HELPER_4(frem, void, env, fp, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c new file +105 -0
105 lines not on this page · raw message
target/m68k/softfloat.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Ported from a work by Andreas Grabher for Previous, NeXT Computer Emulator, +* derived from NetBSD M68040 FPSP functions, +* derived from release 2a of the SoftFloat IEC/IEEE Floating-point Arithmetic +* Package. Those parts of the code (and some later contributions) are +* provided under that license, as detailed below. +* It has subsequently been modified by contributors to the QEMU Project, +* so some portions are provided under: +* the SoftFloat-2a license +* the BSD license +* GPL-v2-or-later +* +* Any future contributions to this file will be taken to be licensed under +* the Softfloat-2a license unless specifically indicated otherwise. +*/ + +/* Portions of this work are licensed under the terms of the GNU GPL, +* version 2 or later. See the COPYING file in the top-level directory. +*/ + +#ifndef TARGET_M68K_SOFTFLOAT_H +#define TARGET_M68K_SOFTFLOAT_H +#include "fpu/softfloat.h" + +floatx80 floatx80_mod (floatx80 a,floatx80 b,float_status *status); +#endif
target/m68k/translate.c +6 -0
@@ -5081,6 +5081,9 @@ DISAS_INSN(fpu)case 0x64 :/* fddiv */ gen_helper_fddiv (cpu_env, cpu_dest, cpu_src, cpu_dest);break ; +case 0x21 :/* fmod */ +gen_helper_fmod (cpu_env, cpu_dest, cpu_src, cpu_dest); +break ;case 0x22 :/* fadd */ gen_helper_fadd (cpu_env, cpu_dest, cpu_src, cpu_dest);break ;
@@ -5102,6 +5105,9 @@ DISAS_INSN(fpu)case 0x24 :/* fsgldiv */ gen_helper_fsgldiv (cpu_env, cpu_dest, cpu_src, cpu_dest);break ; +case 0x25 :/* frem */ +gen_helper_frem (cpu_env, cpu_dest, cpu_src, cpu_dest); +break ;case 0x27 :/* fsglmul */ gen_helper_fsglmul (cpu_env, cpu_dest, cpu_src, cpu_dest);break ;
Signature · 1 line
2.14.3
Re: [Qemu-devel] [PATCH v3 2/4] target/m68k: add fmod/frem
Quoted 8 lines · Laurent Vivier
Using a local m68k
floatx80_mod()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]The quotient byte of the FPSR is updated with
the result of the operation.Signed-off-by Laurent Vivier <[email protected]>
Quoted 11 lines
--- target/m68k/Makefile.objs | 3 +- target/m68k/cpu.h | 1 + target/m68k/fpu_helper.c | 35 +++++++++++++++- target/m68k/helper.h | 2 + target/m68k/softfloat.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 26 ++++++++++++ target/m68k/translate.c | 6 +++ 7 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 target/m68k/softfloat.c create mode 100644 target/m68k/softfloat.h
r~
PATCH v3 3/4 softfloat: use floatx80_infinity in softfloat
In reply to Laurent VivierSince f3218a8 ("softfloat: add floatx80 constants") floatx80_infinity is defined but never used.
This patch updates floatx80 functions to use this definition.
This allows to define a different default Infinity value on m68k: the m68k FPU defines infinity with all bits set to zero in the mantissa.
---
CC: Aurelien Jarno <[email protected]>
fpu/softfloat-specialize.h | 14 ++++++++++++++ fpu/softfloat.c | 38 ++++++++++++++++++++++++++------------ include/fpu/softfloat.h | 9 +++++++-- 3 files changed, 47 insertions(+), 14 deletions(-)
fpu/softfloat-specialize.h +14 -0
@@ -177,6 +177,20 @@ floatx80 floatx80_default_nan(float_status *status)return r; } +/*---------------------------------------------------------------------------- +| The pattern for a default generated extended double-precision inf. +*----------------------------------------------------------------------------*/ + +#define floatx80_infinity_high 0x7FFF +#if defined(TARGET_M68K ) +#define floatx80_infinity_low LIT64(0x0000000000000000) +#else +#define floatx80_infinity_low LIT64(0x8000000000000000) +#endif + +const floatx80 floatx80_infinity + =make_floatx80_init (floatx80_infinity_high, floatx80_infinity_low); +/*---------------------------------------------------------------------------- | The pattern for a default generated quadruple-precision NaN. *----------------------------------------------------------------------------*/
fpu/softfloat.c +26 -12
@@ -2636,7 +2636,9 @@ floatx80 roundAndPackFloatx80(int8_t roundingPrecision, flag zSign, ) {return packFloatx80 ( zSign,0x7FFE , ~ roundMask ); } -return packFloatx80 ( zSign,0x7FFF ,LIT64 (0x8000000000000000 ) ); +return packFloatx80 (zSign, + floatx80_infinity_high, + floatx80_infinity_low); }if ( zExp <=0 ) { isTiny =
@@ -3182,7 +3184,9 @@ floatx80 float32_to_floatx80(float32 a, float_status *status)if (aSig) {return commonNaNToFloatx80 (float32ToCommonNaN (a, status), status); } -return packFloatx80 ( aSign,0x7FFF ,LIT64 (0x8000000000000000 ) ); +return packFloatx80 (aSign, + floatx80_infinity_high, + floatx80_infinity_low); }if ( aExp ==0 ) {if ( aSig ==0 )return packFloatx80 ( aSign,0 ,0 );
@@ -4037,7 +4041,9 @@ floatx80 float64_to_floatx80(float64 a, float_status *status)if (aSig) {return commonNaNToFloatx80 (float64ToCommonNaN (a, status), status); } -return packFloatx80 ( aSign,0x7FFF ,LIT64 (0x8000000000000000 ) ); +return packFloatx80 (aSign, + floatx80_infinity_high, + floatx80_infinity_low); }if ( aExp ==0 ) {if ( aSig ==0 )return packFloatx80 ( aSign,0 ,0 );
@@ -4550,8 +4556,8 @@ int64_t floatx80_to_int64(floatx80 a, float_status *status)if ( shiftCount ) {float_raise (float_flag_invalid, status);if ( ! aSign - || ( ( aExp ==0x7FFF ) - && ( aSig !=LIT64 (0x8000000000000000 ) ) ) + || ((aExp == floatx80_infinity_high) + && (aSig != floatx80_infinity_low)) ) {return LIT64 (0x7FFFFFFFFFFFFFFF ); }
@@ -4858,7 +4864,9 @@ static floatx80 addFloatx80Sigs(floatx80 a, floatx80 b, flag zSign,if ((uint64_t )(bSig <<1 )) {return propagateFloatx80NaN (a, b, status); } -return packFloatx80 ( zSign,0x7FFF ,LIT64 (0x8000000000000000 ) ); +return packFloatx80 (zSign, + floatx80_infinity_high, + floatx80_infinity_low); }if ( aExp ==0 ) ++expDiff;shift64ExtraRightJamming ( aSig,0 , - expDiff, &aSig, &zSig1 );
@@ -4933,7 +4941,8 @@ static floatx80 subFloatx80Sigs(floatx80 a, floatx80 b, flag zSign,if ((uint64_t )(bSig <<1 )) {return propagateFloatx80NaN (a, b, status); } -return packFloatx80 ( zSign ^1 ,0x7FFF ,LIT64 (0x8000000000000000 ) ); +return packFloatx80 (zSign ^1 , floatx80_infinity_high, + floatx80_infinity_low); }if ( aExp ==0 ) ++expDiff;shift128RightJamming ( aSig,0 , - expDiff, &aSig, &zSig1 );
@@ -5038,7 +5047,8 @@ floatx80 floatx80_mul(floatx80 a, floatx80 b, float_status *status)return propagateFloatx80NaN (a, b, status); }if ( ( bExp | bSig ) ==0 ) goto invalid; -return packFloatx80 ( zSign,0x7FFF ,LIT64 (0x8000000000000000 ) ); +return packFloatx80 (zSign, floatx80_infinity_high, + floatx80_infinity_low); }if ( bExp ==0x7FFF ) {if ((uint64_t )(bSig <<1 )) {
@@ -5049,7 +5059,8 @@ floatx80 floatx80_mul(floatx80 a, floatx80 b, float_status *status)float_raise (float_flag_invalid, status);return floatx80_default_nan (status); } -return packFloatx80 ( zSign,0x7FFF ,LIT64 (0x8000000000000000 ) ); +return packFloatx80 (zSign, floatx80_infinity_high, + floatx80_infinity_low); }if ( aExp ==0 ) {if ( aSig ==0 )return packFloatx80 ( zSign,0 ,0 );
@@ -5103,7 +5114,8 @@ floatx80 floatx80_div(floatx80 a, floatx80 b, float_status *status) } goto invalid; } -return packFloatx80 ( zSign,0x7FFF ,LIT64 (0x8000000000000000 ) ); +return packFloatx80 (zSign, floatx80_infinity_high, + floatx80_infinity_low); }if ( bExp ==0x7FFF ) {if ((uint64_t )(bSig <<1 )) {
@@ -5119,7 +5131,8 @@ floatx80 floatx80_div(floatx80 a, floatx80 b, float_status *status)return floatx80_default_nan (status); }float_raise (float_flag_divbyzero, status); -return packFloatx80 ( zSign,0x7FFF ,LIT64 (0x8000000000000000 ) ); +return packFloatx80 (zSign, floatx80_infinity_high, + floatx80_infinity_low); }normalizeFloatx80Subnormal ( bSig, &bExp, &bSig ); }
@@ -5942,7 +5955,8 @@ floatx80 float128_to_floatx80(float128 a, float_status *status)if ( aSig0 | aSig1 ) {return commonNaNToFloatx80 (float128ToCommonNaN (a, status), status); } -return packFloatx80 ( aSign,0x7FFF ,LIT64 (0x8000000000000000 ) ); +return packFloatx80 (aSign, floatx80_infinity_high, + floatx80_infinity_low); }if ( aExp ==0 ) {if ( ( aSig0 | aSig1 ) ==0 )return packFloatx80 ( aSign,0 ,0 );
include/fpu/softfloat.h +7 -2
@@ -563,6 +563,11 @@ float32 floatx80_to_float32(floatx80, float_status *status);float64 floatx80_to_float64 (floatx80 ,float_status *status);float128 floatx80_to_float128 (floatx80 ,float_status *status); +/*---------------------------------------------------------------------------- +| The pattern for an extended double-precision inf. +*----------------------------------------------------------------------------*/ +extern const floatx80 floatx80_infinity; +/*---------------------------------------------------------------------------- | Software IEC/IEEE extended double-precision operations. *----------------------------------------------------------------------------*/
@@ -603,7 +608,8 @@ static inline floatx80 floatx80_chs(floatx80 a)static inline int floatx80_is_infinity (floatx80 a) { -return (a.high &0x7fff ) ==0x7fff && a.low ==0x8000000000000000LL ; +return (a.high &0x7fff ) == floatx80_infinity.high && + a.low == floatx80_infinity.low; }static inline int floatx80_is_neg (floatx80 a)
@@ -646,7 +652,6 @@ static inline bool floatx80_invalid_encoding(floatx80 a)#define floatx80_ln2 make_floatx80(0x3ffe, 0xb17217f7d1cf79acLL)#define floatx80_pi make_floatx80(0x4000, 0xc90fdaa22168c235LL)#define floatx80_half make_floatx80(0x3ffe, 0x8000000000000000LL) -#define floatx80_infinity make_floatx80(0x7fff, 0x8000000000000000LL)/*---------------------------------------------------------------------------- | Returns the fraction bits of the extended double-precision floating-point
Signature · 1 line
2.14.3
Re: [Qemu-devel] [PATCH v3 3/4] softfloat: use floatx80_infinity in softfloat
fpu/softfloat.c int64_t floatx80_to_int64(floatx80 a, float_status *status) · line 4561
Quoted 9 lines · Laurent Vivier
fpu/softfloat.c +2
-2@@ -4550,8 +4556,8 @@ int64_t floatx80_to_int64(floatx80 a, float_status *status)if ( shiftCount ) {float_raise (float_flag_invalid, status);if ( ! aSign - || ( ( aExp ==0x7FFF ) - && ( aSig !=LIT64 (0x8000000000000000 ) ) ) + || ((aExp == floatx80_infinity_high) + && (aSig != floatx80_infinity_low)) ) {
As long as you're cleaning this up, m68k ignores the explicit integer bit when considering an infinity. However, Intel doesn't ignore the bit -- it appears to treat 7fff.0* as a NaN.
r~
Re: [Qemu-devel] [PATCH v3 3/4] softfloat: use floatx80_infinity in softfloat
Le 24/02/2018 à 03:26, Richard Henderson a écrit :
Quoted 6 lines · Laurent Vivier
Quoted 5 lines
fpu/softfloat.c +0
-1@@ -4550,8 +4556,8 @@ int64_t floatx80_to_int64(floatx80 a, float_status *status)if ( shiftCount ) {float_raise (float_flag_invalid, status); if ( ! aSign - || ( ( aExp == 0x7FFF )
Quoted 8 lines
fpu/softfloat.c int64_t floatx80_to_int64(floatx80 a, float_status *status) · line 4561
Quoted 4 lines
fpu/softfloat.c +2
-1- && ( aSig != LIT64( 0x8000000000000000 ) ) ) + || ((aExp == floatx80_infinity_high) + && (aSig != floatx80_infinity_low)) ) {As long as you're cleaning this up, m68k ignores the explicit integer bit when considering an infinity. However, Intel doesn't ignore the bit -- it appears to treat 7fff.0* as a NaN.
According to the comment above the function:
"... If a' is a NaN, the largest positive integer is returned. Otherwise, if the conversion overflows, the largest integer with the same sign as a' is returned."
I think the change should be in fact:
@@ -4549,10 +4555,7 @@ int64_t floatx80_to_int64(floatx80 a, float_status *status)
if ( shiftCount <= 0 ) {
if ( shiftCount ) {
float_raise(float_flag_invalid, status);- if ( ! aSign
- || ( ( aExp == 0x7FFF )
- && ( aSig != LIT64( 0x8000000000000000 ) ) )
- ) {
+ if (!aSign || floatx80_is_any_nan(a)) {
return LIT64( 0x7FFFFFFFFFFFFFFF );
}
return (int64_t) LIT64( 0x8000000000000000 );Do you agree?
Thanks,
Laurent
Re: [Qemu-devel] [PATCH v3 3/4] softfloat: use floatx80_infinity in softfloat
Quoted 16 lines · Laurent Vivier
I think the change should be in fact:
fpu/softfloat.c +1
-4@@ -4549,10 +4555,7 @@ int64_t floatx80_to_int64(floatx80 a, float_status *status)if ( shiftCount <=0 ) {if ( shiftCount ) {float_raise (float_flag_invalid, status); -if ( ! aSign - || ( ( aExp ==0x7FFF ) - && ( aSig !=LIT64 (0x8000000000000000 ) ) ) - ) { +if (!aSign ||floatx80_is_any_nan (a)) {return LIT64 (0x7FFFFFFFFFFFFFFF ); }return (int64_t) LIT64( 0x8000000000000000 );
Quoted 1 line
Do you agree?
Yep, looks good.
r~
Re: [Qemu-devel] [PATCH v3 3/4] softfloat: use floatx80_infinity in softfloat
Le 24/02/2018 à 18:26, Richard Henderson a écrit :
Quoted 17 lines · Laurent Vivier
Quoted 16 lines
I think the change should be in fact:
fpu/softfloat.c +1
-4@@ -4549,10 +4555,7 @@ int64_t floatx80_to_int64(floatx80 a, float_status *status)if ( shiftCount <=0 ) {if ( shiftCount ) {float_raise (float_flag_invalid, status); -if ( ! aSign - || ( ( aExp ==0x7FFF ) - && ( aSig !=LIT64 (0x8000000000000000 ) ) ) - ) { +if (!aSign ||floatx80_is_any_nan (a)) {return LIT64 (0x7FFFFFFFFFFFFFFF ); }return (int64_t) LIT64( 0x8000000000000000 );
Quoted 3 lines
Quoted 1 line
Do you agree?
Yep, looks good.
Thank you.
And according to your previous comment, floatx80_is_infinity() should become:
static inline int floatx80_is_infinity(floatx80 a) {
#if defined(TARGET_M68K)
return (a.high & 0x7fff) == floatx80_infinity.high && !(a.low << 1);
#else
return (a.high & 0x7fff) == floatx80_infinity.high &&
a.low == floatx80_infinity.low;#endif
}
Laurent
PATCH v3 4/4 target/m68k: add fscale, fgetman and fgetexp
In reply to Laurent VivierUsing local m68k floatx80_getman(), floatx80_getexp(), floatx80_scale() [copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
--- target/m68k/fpu_helper.c | 15 +++++ target/m68k/helper.h | 3 + target/m68k/softfloat.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 3 + target/m68k/translate.c | 9 +++ 5 files changed, 174 insertions(+)
target/m68k/fpu_helper.c +15 -0
@@ -542,3 +542,18 @@ void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)make_quotient (env, res->d); } + +void HELPER (fgetexp )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_getexp (val->d, &env->fp_status); +} + +void HELPER (fgetman )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_getman (val->d, &env->fp_status); +} + +void HELPER (fscale )(CPUM68KState *env,FPReg *res,FPReg *val0,FPReg *val1) +{ + res->d =floatx80_scale (val1->d, val0->d, &env->fp_status); +}
target/m68k/helper.h +3 -0
@@ -65,6 +65,9 @@ DEF_HELPER_3(fmovemd_st_postinc, i32, env, i32, i32) DEF_HELPER_3(fmovemd_ld_postinc, i32, env, i32, i32) DEF_HELPER_4(fmod, void, env, fp, fp, fp) DEF_HELPER_4(frem, void, env, fp, fp, fp) +DEF_HELPER_3(fgetexp, void, env, fp, fp) +DEF_HELPER_3(fgetman, void, env, fp, fp) +DEF_HELPER_4(fscale, void, env, fp, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +144 -0
153 lines not on this page · raw message
target/m68k/softfloat.h +3 -0
@@ -23,4 +23,7 @@#include "fpu/softfloat.h" floatx80 floatx80_mod (floatx80 a,floatx80 b,float_status *status); +floatx80 floatx80_getman (floatx80 a,float_status *status); +floatx80 floatx80_getexp (floatx80 a,float_status *status); +floatx80 floatx80_scale (floatx80 a,floatx80 b,float_status *status);#endif
target/m68k/translate.c +9 -0
@@ -5072,6 +5072,12 @@ DISAS_INSN(fpu)case 0x5e :/* fdneg */ gen_helper_fdneg (cpu_env, cpu_dest, cpu_src);break ; +case 0x1e :/* fgetexp */ +gen_helper_fgetexp (cpu_env, cpu_dest, cpu_src); +break ; +case 0x1f :/* fgetman */ +gen_helper_fgetman (cpu_env, cpu_dest, cpu_src); +break ;case 0x20 :/* fdiv */ gen_helper_fdiv (cpu_env, cpu_dest, cpu_src, cpu_dest);break ;
@@ -5108,6 +5114,9 @@ DISAS_INSN(fpu)case 0x25 :/* frem */ gen_helper_frem (cpu_env, cpu_dest, cpu_src, cpu_dest);break ; +case 0x26 :/* fscale */ +gen_helper_fscale (cpu_env, cpu_dest, cpu_src, cpu_dest); +break ;case 0x27 :/* fsglmul */ gen_helper_fsglmul (cpu_env, cpu_dest, cpu_src, cpu_dest);break ;
Signature · 1 line
2.14.3
Re: [Qemu-devel] [PATCH v3 4/4] target/m68k: add fscale, fgetman and fgetexp
Quoted 4 lines · Laurent Vivier
Using local m68k
floatx80_getman(),floatx80_getexp(),floatx80_scale()[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
Quoted 8 lines
Signed-off-by Laurent Vivier <[email protected]>--- target/m68k/fpu_helper.c | 15 +++++ target/m68k/helper.h | 3 + target/m68k/softfloat.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 3 + target/m68k/translate.c | 9 +++ 5 files changed, 174 insertions(+)
r~