qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/4] target/m68k: pass sign directly into make_quotient()


From: Mark Cave-Ayland
Subject: Re: [PATCH 2/4] target/m68k: pass sign directly into make_quotient()
Date: Mon, 2 Jan 2023 10:04:03 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0

On 01/01/2023 17:26, Laurent Vivier wrote:

Le 01/01/2023 à 15:43, Mark Cave-Ayland a écrit :
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.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
  target/m68k/fpu_helper.c | 15 +++++----------
  1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
index 0932c464fd..ae839785fa 100644
--- a/target/m68k/fpu_helper.c
+++ b/target/m68k/fpu_helper.c
@@ -515,15 +515,8 @@ 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);
  }
@@ -536,7 +529,8 @@ void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
          return;
      }
-    make_quotient(env, floatx80_to_int32(res->d, &env->fp_status));
+    make_quotient(env, extractFloatx80Sign(res->d),
+                  floatx80_to_int32(res->d, &env->fp_status));
  }
  void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
@@ -547,7 +541,8 @@ void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
          return;
      }
-    make_quotient(env, floatx80_to_int32(res->d, &env->fp_status));
+    make_quotient(env, extractFloatx80Sign(res->d),
+                  floatx80_to_int32(res->d, &env->fp_status));
  }
  void HELPER(fgetexp)(CPUM68KState *env, FPReg *res, FPReg *val)

I think you need an "abs(floatx80_to_int32())" in both cases as you do in PATCH 
4

Ah yes that's probably true - I suspect I didn't notice because the static tests fail immediately until patches 3 and 4.


ATB,

Mark.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]