]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fix JIT FPU support.
authorToni Wilen <twilen@winuae.net>
Sat, 11 Mar 2017 20:32:24 +0000 (22:32 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 11 Mar 2017 20:32:24 +0000 (22:32 +0200)
fpp.cpp
jit/compemu_support.cpp

diff --git a/fpp.cpp b/fpp.cpp
index a12c3334ad3e64273c174e53b81952a28beb3106..2daea2d5aef97271c45bd2531a3c651d6c5f6f5e 100644 (file)
--- a/fpp.cpp
+++ b/fpp.cpp
@@ -606,11 +606,6 @@ uae_u32 fpp_get_fpsr (void)
     return regs.fpsr;
 }
 
-static void fpp_set_fpsr (uae_u32 val)
-{
-    regs.fpsr = val;
-}
-
 static void fpp_set_fpcr (uae_u32 val)
 {
        fpp_set_mode(val);
@@ -631,6 +626,25 @@ static void fpset (fpdata *fpd, uae_s32 val)
     fpp_from_int(fpd, val);
 }
 
+static void fpp_set_fpsr (uae_u32 val)
+{
+    regs.fpsr = val;
+
+#ifdef JIT
+       // check comment in fpp_cond
+       if (currprefs.compfpu) {
+               if (val & 0x01000000)
+                       fpnan(&regs.fp_result);
+               else if (val & 0x04000000)
+                       fpset(&regs.fp_result, 0);
+               else if (val & 0x08000000)
+                       fpset(&regs.fp_result, -1);
+               else
+                       fpset(&regs.fp_result, 1);
+       }
+#endif
+}
+
 bool fpu_get_constant(fpdata *fpd, int cr)
 {
     uae_u32 *f = NULL;
@@ -1812,11 +1826,23 @@ static int get_fp_ad (uae_u32 opcode, uae_u32 * ad)
 
 int fpp_cond (int condition)
 {
-       int NotANumber = (regs.fpsr & FPSR_CC_NAN) != 0;
-       int N = (regs.fpsr & FPSR_CC_N) != 0;
-       int Z = (regs.fpsr & FPSR_CC_Z) != 0;
+       int NotANumber, N, Z;
+
+#ifdef JIT
+       if (currprefs.compfpu) {
+               // JIT reads and writes regs.fpu_result
+               NotANumber = fpp_is_nan(&regs.fp_result);
+               N = fpp_is_neg(&regs.fp_result);
+               Z = fpp_is_zero(&regs.fp_result);
+       } else
+#endif
+       {
+               NotANumber = (regs.fpsr & FPSR_CC_NAN) != 0;
+               N = (regs.fpsr & FPSR_CC_N) != 0;
+               Z = (regs.fpsr & FPSR_CC_Z) != 0;
+       }
 
-    if ((condition & 0x10) && NotANumber) {
+       if ((condition & 0x10) && NotANumber) {
         if (fpsr_set_bsun())
             return -2;
     }
index 03312d02c2c85d99c844907ec82caee5e9558cb3..4afbc3719a23de9029ff9308943ae01ca08968f7 100644 (file)
@@ -2789,7 +2789,7 @@ void init_comp(void)
                }
                else if (i==FP_RESULT) {
 #ifdef UAE
-                       live.fate[i].mem=(uae_u32*)(&regs.fp_result);
+                       live.fate[i].mem=(uae_u32*)(&regs.fp_result.fp);
 #else
                        live.fate[i].mem=(uae_u32*)(&fpu.result);
 #endif