M68k next patches
The following changes since commit 886fb67020e32ce6a2cf7049c6f017acf1f0d69a:
Merge tag 'pull-target-arm-20230113' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2023-01-13 14:12:43 +0000)
are available in the Git repository at:
https://github.com/vivier/qemu-m68k.git tags/m68k-next-pull-request
for you to fetch changes up to 1a282f60a971aa86e3cdd1b7ca000790e43bb310:
target/m68k: fix FPSR quotient byte for frem instruction (2023-01-16 09:47:31 +0100)
----------------------------------------------------------------
M68K pull request 20230116
fix FPSR quotient byte
----------------------------------------------------------------
Mark Cave-Ayland (4):
target/m68k: pass quotient directly into make_quotient() target/m68k: pass sign directly into make_quotient() target/m68k: fix FPSR quotient byte for fmod instruction target/m68k: fix FPSR quotient byte for frem instruction
target/m68k/fpu_helper.c | 49 +++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 18 deletions(-)
Signature · 1 line
2.38.1
[PULL 1/4] target/m68k: pass quotient directly into make_quotient()
From: Mark Cave-Ayland <[email protected]>
Message-Id: <[email protected]>
--- target/m68k/fpu_helper.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
target/m68k/fpu_helper.c +11 -9
@@ -515,16 +515,10 @@ 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) +static void make_quotient (CPUM68KState *env,int32_t quotient) { -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;
@@ -538,14 +532,22 @@ 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); +if (floatx80_is_any_nan (res->d)) { +return ; + } + +make_quotient (env,floatx80_to_int32 (res->d, &env->fp_status)); }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); +if (floatx80_is_any_nan (res->d)) { +return ; + } + +make_quotient (env,floatx80_to_int32 (res->d, &env->fp_status)); }void HELPER (fgetexp )(CPUM68KState *env,FPReg *res,FPReg *val)
Signature · 1 line
2.38.1
[PULL 4/4] target/m68k: fix FPSR quotient byte for frem instruction
In reply to Laurent VivierFrom: Mark Cave-Ayland <[email protected]>
The FPSR quotient byte should be set to the value of the quotient and not the result. Manually calculate the quotient in the frem helper in round to nearest even mode (note this is different from the quotient calculated internally for fmod), and use it to set the quotient byte accordingly.
Message-Id: <[email protected]>
--- target/m68k/fpu_helper.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
target/m68k/fpu_helper.c +19 -10
@@ -538,18 +538,27 @@ void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)void HELPER (frem )(CPUM68KState *env,FPReg *res,FPReg *val0,FPReg *val1) { -uint32_t quotient; -int sign; - - res->d =floatx80_rem (val1->d, val0->d, &env->fp_status); - -if (floatx80_is_any_nan (res->d)) { -return ; +FPReg fp_quot; +floatx80 fp_rem; + + fp_rem =floatx80_rem (val1->d, val0->d, &env->fp_status); +if (!floatx80_is_any_nan (fp_rem)) { +float_status fp_status = { }; +uint32_t quotient; +int sign; + +/* Calculate quotient directly using round to nearest mode */ +set_float_rounding_mode (float_round_nearest_even, &fp_status); +set_floatx80_rounding_precision ( +get_floatx80_rounding_precision (&env->fp_status), &fp_status); + fp_quot.d =floatx80_div (val1->d, val0->d, &fp_status); + + sign =extractFloatx80Sign (fp_quot.d); + quotient =floatx80_to_int32 (floatx80_abs (fp_quot.d), &env->fp_status); +make_quotient (env, sign, quotient); } - sign =extractFloatx80Sign (res->d); - quotient =floatx80_to_int32 (floatx80_abs (res->d), &env->fp_status); -make_quotient (env, sign, quotient); + res->d = fp_rem; }void HELPER (fgetexp )(CPUM68KState *env,FPReg *res,FPReg *val)
Signature · 1 line
2.38.1
[PULL 2/4] target/m68k: pass sign directly into make_quotient()
In reply to Laurent VivierFrom: Mark Cave-Ayland <[email protected]>
This enables the quotient parameter to be changed from int32_t to uint32_t and also allows the extra sign logic in make_quotient() to be removed.
Message-Id: <[email protected]>
--- target/m68k/fpu_helper.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
target/m68k/fpu_helper.c +13 -10
@@ -515,39 +515,42 @@ 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,int32_t quotient) +static void make_quotient (CPUM68KState *env,int sign,uint32_t quotient) { -int sign; - - 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) { +uint32_t quotient; +int sign; + res->d =floatx80_mod (val1->d, val0->d, &env->fp_status);if (floatx80_is_any_nan (res->d)) {return ; } -make_quotient (env,floatx80_to_int32 (res->d, &env->fp_status)); + sign =extractFloatx80Sign (res->d); + quotient =floatx80_to_int32 (floatx80_abs (res->d), &env->fp_status); +make_quotient (env, sign, quotient); }void HELPER (frem )(CPUM68KState *env,FPReg *res,FPReg *val0,FPReg *val1) { +uint32_t quotient; +int sign; + res->d =floatx80_rem (val1->d, val0->d, &env->fp_status);if (floatx80_is_any_nan (res->d)) {return ; } -make_quotient (env,floatx80_to_int32 (res->d, &env->fp_status)); + sign =extractFloatx80Sign (res->d); + quotient =floatx80_to_int32 (floatx80_abs (res->d), &env->fp_status); +make_quotient (env, sign, quotient); }void HELPER (fgetexp )(CPUM68KState *env,FPReg *res,FPReg *val)
Signature · 1 line
2.38.1
[PULL 3/4] target/m68k: fix FPSR quotient byte for fmod instruction
In reply to Laurent VivierFrom: Mark Cave-Ayland <[email protected]>
The FPSR quotient byte should be set to the value of the quotient and not the result. Switch from using floatx80_mod() to floatx80_modrem() which returns the quotient as a uint64_t which can be used for the quotient byte.
Message-Id: <[email protected]>
--- target/m68k/fpu_helper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
target/m68k/fpu_helper.c +4 -5
@@ -523,17 +523,16 @@ static void make_quotient(CPUM68KState *env, int sign, uint32_t quotient)void HELPER (fmod )(CPUM68KState *env,FPReg *res,FPReg *val0,FPReg *val1) { -uint32_t quotient; -int sign; +uint64_t quotient; +int sign =extractFloatx80Sign (val1->d) ^extractFloatx80Sign (val0->d); - res->d =floatx80_mod (val1->d, val0->d, &env->fp_status); + res->d =floatx80_modrem (val1->d, val0->d, true, "ient, + &env->fp_status);if (floatx80_is_any_nan (res->d)) {return ; } - sign =extractFloatx80Sign (res->d); - quotient =floatx80_to_int32 (floatx80_abs (res->d), &env->fp_status);make_quotient (env, sign, quotient); }
Signature · 1 line
2.38.1
Peter Maydell
AppliedQuoted 11 lines · Laurent Vivier
The following changes since commit
886fb67020e32ce6a2cf7049c6f017acf1f0d69a:Merge tag 'pull-target-arm-20230113' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2023-01-13 14:12:43 +0000)
are available in the Git repository at:
https://github.com/vivier/qemu-m68k.git tags/m68k-next-pull-request
for you to fetch changes up to
1a282f60a971aa86e3cdd1b7ca000790e43bb310:
Quoted 8 lines
target/m68k: fix FPSR quotient byte for frem instruction (2023-01-16 09:47:31 +0100)
----------------------------------------------------------------
M68K pull request 20230116fix FPSR quotient byte
----------------------------------------------------------------
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/8.0
for any user-visible changes.
-- PMM