]> Git Repo - qemu.git/blobdiff - target-sh4/op_helper.c
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20161017' into...
[qemu.git] / target-sh4 / op_helper.c
index 74a5c4ea779532734b5f821c8377d05ba75e8bc7..684d3f37589c2ca53fc9581d6ad93ae5a1039e08 100644 (file)
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
-#include <assert.h>
-#include <stdlib.h>
+#include "qemu/osdep.h"
 #include "cpu.h"
 #include "exec/helper-proto.h"
+#include "exec/exec-all.h"
 #include "exec/cpu_ldst.h"
 
 #ifndef CONFIG_USER_ONLY
 
-void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
-              uintptr_t retaddr)
+void tlb_fill(CPUState *cs, target_ulong addr, MMUAccessType access_type,
+              int mmu_idx, uintptr_t retaddr)
 {
     int ret;
 
-    ret = superh_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
+    ret = superh_cpu_handle_mmu_fault(cs, addr, access_type, mmu_idx);
     if (ret) {
         /* now we have a real cpu fault */
         if (retaddr) {
@@ -109,7 +109,8 @@ void helper_movcal(CPUSH4State *env, uint32_t address, uint32_t value)
 {
     if (cpu_sh4_is_cached (env, address))
     {
-       memory_content *r = malloc (sizeof(memory_content));
+        memory_content *r = g_new(memory_content, 1);
+
        r->address = address;
        r->value = value;
        r->next = NULL;
@@ -126,7 +127,7 @@ void helper_discard_movcal_backup(CPUSH4State *env)
     while(current)
     {
        memory_content *next = current->next;
-       free (current);
+        g_free(current);
        env->movcal_backup = current = next;
        if (current == NULL)
            env->movcal_backup_tail = &(env->movcal_backup);
@@ -149,131 +150,13 @@ void helper_ocbi(CPUSH4State *env, uint32_t address)
                env->movcal_backup_tail = current;
            }
 
-           free (*current);
+            g_free(*current);
            *current = next;
            break;
        }
     }
 }
 
-#define T (env->sr & SR_T)
-#define Q (env->sr & SR_Q ? 1 : 0)
-#define M (env->sr & SR_M ? 1 : 0)
-#define SETT env->sr |= SR_T
-#define CLRT env->sr &= ~SR_T
-#define SETQ env->sr |= SR_Q
-#define CLRQ env->sr &= ~SR_Q
-#define SETM env->sr |= SR_M
-#define CLRM env->sr &= ~SR_M
-
-uint32_t helper_div1(CPUSH4State *env, uint32_t arg0, uint32_t arg1)
-{
-    uint32_t tmp0, tmp2;
-    uint8_t old_q, tmp1 = 0xff;
-
-    //printf("div1 arg0=0x%08x arg1=0x%08x M=%d Q=%d T=%d\n", arg0, arg1, M, Q, T);
-    old_q = Q;
-    if ((0x80000000 & arg1) != 0)
-       SETQ;
-    else
-       CLRQ;
-    tmp2 = arg0;
-    arg1 <<= 1;
-    arg1 |= T;
-    switch (old_q) {
-    case 0:
-       switch (M) {
-       case 0:
-           tmp0 = arg1;
-           arg1 -= tmp2;
-           tmp1 = arg1 > tmp0;
-           switch (Q) {
-           case 0:
-               if (tmp1)
-                   SETQ;
-               else
-                   CLRQ;
-               break;
-           case 1:
-               if (tmp1 == 0)
-                   SETQ;
-               else
-                   CLRQ;
-               break;
-           }
-           break;
-       case 1:
-           tmp0 = arg1;
-           arg1 += tmp2;
-           tmp1 = arg1 < tmp0;
-           switch (Q) {
-           case 0:
-               if (tmp1 == 0)
-                   SETQ;
-               else
-                   CLRQ;
-               break;
-           case 1:
-               if (tmp1)
-                   SETQ;
-               else
-                   CLRQ;
-               break;
-           }
-           break;
-       }
-       break;
-    case 1:
-       switch (M) {
-       case 0:
-           tmp0 = arg1;
-           arg1 += tmp2;
-           tmp1 = arg1 < tmp0;
-           switch (Q) {
-           case 0:
-               if (tmp1)
-                   SETQ;
-               else
-                   CLRQ;
-               break;
-           case 1:
-               if (tmp1 == 0)
-                   SETQ;
-               else
-                   CLRQ;
-               break;
-           }
-           break;
-       case 1:
-           tmp0 = arg1;
-           arg1 -= tmp2;
-           tmp1 = arg1 > tmp0;
-           switch (Q) {
-           case 0:
-               if (tmp1 == 0)
-                   SETQ;
-               else
-                   CLRQ;
-               break;
-           case 1:
-               if (tmp1)
-                   SETQ;
-               else
-                   CLRQ;
-               break;
-           }
-           break;
-       }
-       break;
-    }
-    if (Q == M)
-       SETT;
-    else
-       CLRT;
-    //printf("Output: arg1=0x%08x M=%d Q=%d T=%d\n", arg1, M, Q, T);
-    return arg1;
-}
-
 void helper_macl(CPUSH4State *env, uint32_t arg0, uint32_t arg1)
 {
     int64_t res;
@@ -282,7 +165,7 @@ void helper_macl(CPUSH4State *env, uint32_t arg0, uint32_t arg1)
     res += (int64_t) (int32_t) arg0 *(int64_t) (int32_t) arg1;
     env->mach = (res >> 32) & 0xffffffff;
     env->macl = res & 0xffffffff;
-    if (env->sr & SR_S) {
+    if (env->sr & (1u << SR_S)) {
        if (res < 0)
            env->mach |= 0xffff0000;
        else
@@ -298,7 +181,7 @@ void helper_macw(CPUSH4State *env, uint32_t arg0, uint32_t arg1)
     res += (int64_t) (int16_t) arg0 *(int64_t) (int16_t) arg1;
     env->mach = (res >> 32) & 0xffffffff;
     env->macl = res & 0xffffffff;
-    if (env->sr & SR_S) {
+    if (env->sr & (1u << SR_S)) {
        if (res < -0x80000000) {
            env->mach = 1;
            env->macl = 0x80000000;
@@ -309,16 +192,6 @@ void helper_macw(CPUSH4State *env, uint32_t arg0, uint32_t arg1)
     }
 }
 
-static inline void set_t(CPUSH4State *env)
-{
-    env->sr |= SR_T;
-}
-
-static inline void clr_t(CPUSH4State *env)
-{
-    env->sr &= ~SR_T;
-}
-
 void helper_ld_fpscr(CPUSH4State *env, uint32_t val)
 {
     env->fpscr = val & FPSCR_MASK;
@@ -403,10 +276,8 @@ void helper_fcmp_eq_FT(CPUSH4State *env, float32 t0, float32 t1)
     relation = float32_compare(t0, t1, &env->fp_status);
     if (unlikely(relation == float_relation_unordered)) {
         update_fpscr(env, GETPC());
-    } else if (relation == float_relation_equal) {
-        set_t(env);
     } else {
-        clr_t(env);
+        env->sr_t = (relation == float_relation_equal);
     }
 }
 
@@ -418,10 +289,8 @@ void helper_fcmp_eq_DT(CPUSH4State *env, float64 t0, float64 t1)
     relation = float64_compare(t0, t1, &env->fp_status);
     if (unlikely(relation == float_relation_unordered)) {
         update_fpscr(env, GETPC());
-    } else if (relation == float_relation_equal) {
-        set_t(env);
     } else {
-        clr_t(env);
+        env->sr_t = (relation == float_relation_equal);
     }
 }
 
@@ -433,10 +302,8 @@ void helper_fcmp_gt_FT(CPUSH4State *env, float32 t0, float32 t1)
     relation = float32_compare(t0, t1, &env->fp_status);
     if (unlikely(relation == float_relation_unordered)) {
         update_fpscr(env, GETPC());
-    } else if (relation == float_relation_greater) {
-        set_t(env);
     } else {
-        clr_t(env);
+        env->sr_t = (relation == float_relation_greater);
     }
 }
 
@@ -448,10 +315,8 @@ void helper_fcmp_gt_DT(CPUSH4State *env, float64 t0, float64 t1)
     relation = float64_compare(t0, t1, &env->fp_status);
     if (unlikely(relation == float_relation_unordered)) {
         update_fpscr(env, GETPC());
-    } else if (relation == float_relation_greater) {
-        set_t(env);
     } else {
-        clr_t(env);
+        env->sr_t = (relation == float_relation_greater);
     }
 }
 
This page took 0.032101 seconds and 4 git commands to generate.