]> Git Repo - qemu.git/blobdiff - target-mips/translate.c
Remove the temporaries cache of the MIPS target.
[qemu.git] / target-mips / translate.c
index 6f295d4a506b5c04b7d6d73f76ef2398c197be39..458e74d673c7de13f961b713573e780dc182fa71 100644 (file)
@@ -423,47 +423,7 @@ enum {
 };
 
 /* global register indices */
-static TCGv cpu_env, current_tc_gprs, cpu_T[2];
-
-/* The code generator doesn't like lots of temporaries, so maintain our own
-   cache for reuse within a function.  */
-#define MAX_TEMPS 4
-static int num_temps;
-static TCGv temps[MAX_TEMPS];
-
-/* Allocate a temporary variable.  */
-static TCGv new_tmp(void)
-{
-    TCGv tmp;
-    if (num_temps == MAX_TEMPS)
-        abort();
-
-    if (GET_TCGV(temps[num_temps]))
-      return temps[num_temps++];
-
-    tmp = tcg_temp_new(TCG_TYPE_I32);
-    temps[num_temps++] = tmp;
-    return tmp;
-}
-
-/* Release a temporary variable.  */
-static void dead_tmp(TCGv tmp)
-{
-    int i;
-    num_temps--;
-    i = num_temps;
-    if (GET_TCGV(temps[i]) == GET_TCGV(tmp))
-        return;
-
-    /* Shuffle this temp to the last slot.  */
-    while (GET_TCGV(temps[i]) != GET_TCGV(tmp))
-        i--;
-    while (i < num_temps) {
-        temps[i] = temps[i + 1];
-        i++;
-    }
-    temps[i] = tmp;
-}
+static TCGv cpu_env, current_tc_gprs, current_tc_hi, cpu_T[2];
 
 typedef struct DisasContext {
     struct TranslationBlock *tb;
@@ -531,13 +491,40 @@ static inline void gen_store_gpr (TCGv t, int reg)
         tcg_gen_st_tl(t, current_tc_gprs, sizeof(target_ulong) * reg);
 }
 
+/* Moves to/from HI and LO registers.  */
+static inline void gen_load_LO (TCGv t, int reg)
+{
+    tcg_gen_ld_tl(t, current_tc_hi,
+                  offsetof(CPUState, LO)
+                  - offsetof(CPUState, HI)
+                  + sizeof(target_ulong) * reg);
+}
+
+static inline void gen_store_LO (TCGv t, int reg)
+{
+    tcg_gen_st_tl(t, current_tc_hi,
+                  offsetof(CPUState, LO)
+                  - offsetof(CPUState, HI)
+                  + sizeof(target_ulong) * reg);
+}
+
+static inline void gen_load_HI (TCGv t, int reg)
+{
+    tcg_gen_ld_tl(t, current_tc_hi, sizeof(target_ulong) * reg);
+}
+
+static inline void gen_store_HI (TCGv t, int reg)
+{
+    tcg_gen_st_tl(t, current_tc_hi, sizeof(target_ulong) * reg);
+}
+
 /* Moves to/from shadow registers. */
 static inline void gen_load_srsgpr (TCGv t, int reg)
 {
     if (reg == 0)
         tcg_gen_movi_tl(t, 0);
     else {
-        TCGv r_tmp = new_tmp();
+        TCGv r_tmp = tcg_temp_new(TCG_TYPE_I32);
 
         tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSCtl));
         tcg_gen_shri_i32(r_tmp, r_tmp, CP0SRSCtl_PSS);
@@ -546,14 +533,14 @@ static inline void gen_load_srsgpr (TCGv t, int reg)
         tcg_gen_add_i32(r_tmp, cpu_env, r_tmp);
 
         tcg_gen_ld_tl(t, r_tmp, sizeof(target_ulong) * reg);
-        dead_tmp(r_tmp);
+        tcg_temp_free(r_tmp);
     }
 }
 
 static inline void gen_store_srsgpr (TCGv t, int reg)
 {
     if (reg != 0) {
-        TCGv r_tmp = new_tmp();
+        TCGv r_tmp = tcg_temp_new(TCG_TYPE_I32);
 
         tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSCtl));
         tcg_gen_shri_i32(r_tmp, r_tmp, CP0SRSCtl_PSS);
@@ -562,7 +549,7 @@ static inline void gen_store_srsgpr (TCGv t, int reg)
         tcg_gen_add_i32(r_tmp, cpu_env, r_tmp);
 
         tcg_gen_st_tl(t, r_tmp, sizeof(target_ulong) * reg);
-        dead_tmp(r_tmp);
+        tcg_temp_free(r_tmp);
     }
 }
 
@@ -679,7 +666,7 @@ void glue(gen_op_, name) (target_ulong val)                   \
     int l1 = gen_new_label();                                 \
     int l2 = gen_new_label();                                 \
                                                               \
-    tcg_gen_brcond_tl(cond, cpu_T[0], tcg_const_tl(val), l1); \
+    tcg_gen_brcondi_tl(cond, cpu_T[0], val, l1);              \
     tcg_gen_movi_tl(cpu_T[0], 0);                             \
     tcg_gen_br(l2);                                           \
     gen_set_label(l1);                                        \
@@ -696,7 +683,7 @@ void glue(gen_op_, name) (void)                               \
     int l1 = gen_new_label();                                 \
     int l2 = gen_new_label();                                 \
                                                               \
-    tcg_gen_brcond_tl(cond, cpu_T[0], tcg_const_tl(0), l1);   \
+    tcg_gen_brcondi_tl(cond, cpu_T[0], 0, l1);                \
     tcg_gen_movi_tl(cpu_T[0], 0);                             \
     tcg_gen_br(l2);                                           \
     gen_set_label(l1);                                        \
@@ -712,33 +699,39 @@ OP_CONDZ(ltz, TCG_COND_LT);
 static inline void gen_save_pc(target_ulong pc)
 {
     TCGv r_tmp = tcg_temp_new(TCG_TYPE_TL);
-    TCGv r_tc_off = new_tmp();
-    TCGv r_tc_off_tl = tcg_temp_new(TCG_TYPE_TL);
+    TCGv r_tc_off = tcg_temp_new(TCG_TYPE_I32);
+    TCGv r_tc_off_ptr = tcg_temp_new(TCG_TYPE_PTR);
     TCGv r_ptr = tcg_temp_new(TCG_TYPE_PTR);
 
     tcg_gen_movi_tl(r_tmp, pc);
     tcg_gen_ld_i32(r_tc_off, cpu_env, offsetof(CPUState, current_tc));
     tcg_gen_muli_i32(r_tc_off, r_tc_off, sizeof(target_ulong));
-    tcg_gen_ext_i32_ptr(r_tc_off_tl, r_tc_off);
-    tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_tl);
+    tcg_gen_ext_i32_ptr(r_tc_off_ptr, r_tc_off);
+    tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_ptr);
     tcg_gen_st_tl(r_tmp, r_ptr, offsetof(CPUState, PC));
-    dead_tmp(r_tc_off);
+    tcg_temp_free(r_tc_off);
+    tcg_temp_free(r_tc_off_tl);
+    tcg_temp_free(r_ptr);
+    tcg_temp_free(r_tmp);
 }
 
 static inline void gen_breg_pc(void)
 {
     TCGv r_tmp = tcg_temp_new(TCG_TYPE_TL);
-    TCGv r_tc_off = new_tmp();
-    TCGv r_tc_off_tl = tcg_temp_new(TCG_TYPE_TL);
+    TCGv r_tc_off = tcg_temp_new(TCG_TYPE_I32);
+    TCGv r_tc_off_ptr = tcg_temp_new(TCG_TYPE_PTR);
     TCGv r_ptr = tcg_temp_new(TCG_TYPE_PTR);
 
     tcg_gen_ld_tl(r_tmp, cpu_env, offsetof(CPUState, btarget));
     tcg_gen_ld_i32(r_tc_off, cpu_env, offsetof(CPUState, current_tc));
     tcg_gen_muli_i32(r_tc_off, r_tc_off, sizeof(target_ulong));
-    tcg_gen_ext_i32_ptr(r_tc_off_tl, r_tc_off);
-    tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_tl);
+    tcg_gen_ext_i32_ptr(r_tc_off_ptr, r_tc_off);
+    tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_ptr);
     tcg_gen_st_tl(r_tmp, r_ptr, offsetof(CPUState, PC));
-    dead_tmp(r_tc_off);
+    tcg_temp_free(r_tc_off);
+    tcg_temp_free(r_tc_off_tl);
+    tcg_temp_free(r_ptr);
+    tcg_temp_free(r_tmp);
 }
 
 static inline void gen_save_btarget(target_ulong btarget)
@@ -826,18 +819,24 @@ static inline void gen_op_addr_add (void)
        with Status_UX = 0 should be casted to 32-bit and sign extended.
        See the MIPS64 PRA manual, section 4.10. */
     {
-        TCGv r_tmp = new_tmp();
         int l1 = gen_new_label();
 
-        tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, hflags));
-        tcg_gen_andi_i32(r_tmp, r_tmp, MIPS_HFLAG_KSU);
-        tcg_gen_brcond_i32(TCG_COND_NE, r_tmp, tcg_const_i32(MIPS_HFLAG_UM), l1);
-        tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Status));
-        tcg_gen_andi_i32(r_tmp, r_tmp, (1 << CP0St_UX));
-        tcg_gen_brcond_i32(TCG_COND_NE, r_tmp, tcg_const_i32(0), l1);
+        {
+            TCGv r_tmp = tcg_temp_new(TCG_TYPE_I32);
+
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, hflags));
+            tcg_gen_andi_i32(r_tmp, r_tmp, MIPS_HFLAG_KSU);
+            tcg_gen_brcondi_i32(TCG_COND_NE, r_tmp, MIPS_HFLAG_UM, l1);
+        }
+        {
+            TCGv r_tmp = tcg_temp_new(TCG_TYPE_I32);
+
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Status));
+            tcg_gen_andi_i32(r_tmp, r_tmp, (1 << CP0St_UX));
+            tcg_gen_brcondi_i32(TCG_COND_NE, r_tmp, 0, l1);
+        }
         tcg_gen_ext32s_i64(cpu_T[0], cpu_T[0]);
         gen_set_label(l1);
-        dead_tmp(r_tmp);
     }
 #endif
 }
@@ -995,9 +994,9 @@ void inline op_ldst_##insn(DisasContext *ctx)                           \
     int l3 = gen_new_label();                                           \
                                                                         \
     tcg_gen_andi_tl(r_tmp, cpu_T[0], almask);                           \
-    tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp, tcg_const_tl(0), l1);         \
+    tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp, 0, l1);                      \
     tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_BadVAddr)); \
-    generate_exception(ctx, EXCP_AdES);                             \
+    generate_exception(ctx, EXCP_AdES);                                 \
     gen_set_label(l1);                                                  \
     tcg_gen_ld_tl(r_tmp, cpu_env, offsetof(CPUState, CP0_LLAddr));      \
     tcg_gen_brcond_tl(TCG_COND_NE, cpu_T[0], r_tmp, l2);                \
@@ -1296,7 +1295,7 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc,
             tcg_gen_xori_tl(r_tmp2, cpu_T[0], uimm);
             tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
             tcg_gen_shri_tl(r_tmp1, r_tmp1, 31);
-            tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
             /* operands of same sign, result different sign */
             generate_exception(ctx, EXCP_OVERFLOW);
             gen_set_label(l1);
@@ -1327,7 +1326,7 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc,
             tcg_gen_xori_tl(r_tmp2, cpu_T[0], uimm);
             tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
             tcg_gen_shri_tl(r_tmp1, r_tmp1, 63);
-            tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
             /* operands of same sign, result different sign */
             generate_exception(ctx, EXCP_OVERFLOW);
             gen_set_label(l1);
@@ -1386,8 +1385,8 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc,
             /* rotr is decoded as srl on non-R2 CPUs */
             if (env->insn_flags & ISA_MIPS32R2) {
                 if (uimm != 0) {
-                    TCGv r_tmp1 = new_tmp();
-                    TCGv r_tmp2 = new_tmp();
+                    TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);
+                    TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_I32);
 
                     tcg_gen_trunc_tl_i32(r_tmp1, cpu_T[0]);
                     tcg_gen_movi_i32(r_tmp2, 0x20);
@@ -1395,9 +1394,9 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc,
                     tcg_gen_shl_i32(r_tmp2, r_tmp1, r_tmp2);
                     tcg_gen_shri_i32(r_tmp1, r_tmp1, uimm);
                     tcg_gen_or_i32(r_tmp1, r_tmp1, r_tmp2);
-                    tcg_gen_ext_i32_tl(r_tmp1, cpu_T[0]);
-                    dead_tmp(r_tmp1);
-                    dead_tmp(r_tmp2);
+                    tcg_gen_ext_i32_tl(cpu_T[0], r_tmp1);
+                    tcg_temp_free(r_tmp1);
+                    tcg_temp_free(r_tmp2);
                 }
                 opn = "rotr";
             } else {
@@ -1539,7 +1538,7 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
             tcg_gen_xor_tl(r_tmp2, cpu_T[0], cpu_T[1]);
             tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
             tcg_gen_shri_tl(r_tmp1, r_tmp1, 31);
-            tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
             /* operands of same sign, result different sign */
             generate_exception(ctx, EXCP_OVERFLOW);
             gen_set_label(l1);
@@ -1570,7 +1569,7 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
             tcg_gen_xor_tl(r_tmp1, r_tmp1, cpu_T[0]);
             tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
             tcg_gen_shri_tl(r_tmp1, r_tmp1, 31);
-            tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
             /* operands of different sign, first operand and result different sign */
             generate_exception(ctx, EXCP_OVERFLOW);
             gen_set_label(l1);
@@ -1602,7 +1601,7 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
             tcg_gen_xor_tl(r_tmp2, cpu_T[0], cpu_T[1]);
             tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
             tcg_gen_shri_tl(r_tmp1, r_tmp1, 63);
-            tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
             /* operands of same sign, result different sign */
             generate_exception(ctx, EXCP_OVERFLOW);
             gen_set_label(l1);
@@ -1627,7 +1626,7 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
             tcg_gen_xor_tl(r_tmp1, r_tmp1, cpu_T[0]);
             tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
             tcg_gen_shri_tl(r_tmp1, r_tmp1, 63);
-            tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
             /* operands of different sign, first operand and result different sign */
             generate_exception(ctx, EXCP_OVERFLOW);
             gen_set_label(l1);
@@ -1675,7 +1674,7 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
         {
             int l1 = gen_new_label();
 
-            tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[1], tcg_const_tl(0), l1);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_T[1], 0, l1);
             gen_store_gpr(cpu_T[0], rd);
             gen_set_label(l1);
         }
@@ -1685,7 +1684,7 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
         {
             int l1 = gen_new_label();
 
-            tcg_gen_brcond_tl(TCG_COND_NE, cpu_T[1], tcg_const_tl(0), l1);
+            tcg_gen_brcondi_tl(TCG_COND_NE, cpu_T[1], 0, l1);
             gen_store_gpr(cpu_T[0], rd);
             gen_set_label(l1);
         }
@@ -1722,11 +1721,11 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
                 int l2 = gen_new_label();
 
                 tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x1f);
-                tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[0], tcg_const_tl(0), l1);
+                tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_T[0], 0, l1);
                 {
-                    TCGv r_tmp1 = new_tmp();
-                    TCGv r_tmp2 = new_tmp();
-                    TCGv r_tmp3 = new_tmp();
+                    TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);
+                    TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_I32);
+                    TCGv r_tmp3 = tcg_temp_new(TCG_TYPE_I32);
 
                     tcg_gen_trunc_tl_i32(r_tmp1, cpu_T[0]);
                     tcg_gen_trunc_tl_i32(r_tmp2, cpu_T[1]);
@@ -1735,10 +1734,10 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
                     tcg_gen_shl_i32(r_tmp3, r_tmp2, r_tmp3);
                     tcg_gen_shr_i32(r_tmp1, r_tmp2, r_tmp1);
                     tcg_gen_or_i32(r_tmp1, r_tmp1, r_tmp3);
-                    tcg_gen_ext_i32_tl(r_tmp1, cpu_T[0]);
-                    dead_tmp(r_tmp1);
-                    dead_tmp(r_tmp2);
-                    dead_tmp(r_tmp3);
+                    tcg_gen_ext_i32_tl(cpu_T[0], r_tmp1);
+                    tcg_temp_free(r_tmp1);
+                    tcg_temp_free(r_tmp2);
+                    tcg_temp_free(r_tmp3);
                     tcg_gen_br(l2);
                 }
                 gen_set_label(l1);
@@ -1784,7 +1783,7 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
                 int l2 = gen_new_label();
 
                 tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x3f);
-                tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[0], tcg_const_tl(0), l1);
+                tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_T[0], 0, l1);
                 {
                     TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_TL);
 
@@ -1834,23 +1833,23 @@ static void gen_HILO (DisasContext *ctx, uint32_t opc, int reg)
     }
     switch (opc) {
     case OPC_MFHI:
-        tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, HI[0]));
+        gen_load_HI(cpu_T[0], 0);
         gen_store_gpr(cpu_T[0], reg);
         opn = "mfhi";
         break;
     case OPC_MFLO:
-        tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, LO[0]));
+        gen_load_LO(cpu_T[0], 0);
         gen_store_gpr(cpu_T[0], reg);
         opn = "mflo";
         break;
     case OPC_MTHI:
         gen_load_gpr(cpu_T[0], reg);
-        tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUState, HI[0]));
+        gen_store_HI(cpu_T[0], 0);
         opn = "mthi";
         break;
     case OPC_MTLO:
         gen_load_gpr(cpu_T[0], reg);
-        tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUState, LO[0]));
+        gen_store_LO(cpu_T[0], 0);
         opn = "mtlo";
         break;
     default:
@@ -1873,31 +1872,24 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,
         {
             int l1 = gen_new_label();
 
-            tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[1], tcg_const_tl(0), l1);
+            tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
+            tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_T[1], 0, l1);
             {
-                TCGv r_tmp1 = new_tmp();
-                TCGv r_tmp2 = new_tmp();
-                TCGv r_tmp3 = new_tmp();
-                TCGv r_tc_off = new_tmp();
-                TCGv r_tc_off_tl = tcg_temp_new(TCG_TYPE_TL);
-                TCGv r_ptr = tcg_temp_new(TCG_TYPE_PTR);
-
-                tcg_gen_ext_i32_tl(r_tmp1, cpu_T[0]);
-                tcg_gen_ext_i32_tl(r_tmp2, cpu_T[1]);
-                tcg_gen_div_i32(r_tmp3, r_tmp1, r_tmp2);
-                tcg_gen_rem_i32(r_tmp1, r_tmp1, r_tmp2);
-                tcg_gen_trunc_tl_i32(cpu_T[0], r_tmp3);
-                tcg_gen_trunc_tl_i32(cpu_T[1], r_tmp1);
-                dead_tmp(r_tmp1);
-                dead_tmp(r_tmp2);
-                dead_tmp(r_tmp3);
-                tcg_gen_ld_i32(r_tc_off, cpu_env, offsetof(CPUState, current_tc));
-                tcg_gen_muli_i32(r_tc_off, r_tc_off, sizeof(target_ulong));
-                tcg_gen_ext_i32_ptr(r_tc_off_tl, r_tc_off);
-                tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_tl);
-                tcg_gen_st_tl(cpu_T[0], r_ptr, offsetof(CPUState, LO));
-                tcg_gen_st_tl(cpu_T[1], r_ptr, offsetof(CPUState, HI));
-                dead_tmp(r_tc_off);
+                TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I64);
+                TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_I64);
+                TCGv r_tmp3 = tcg_temp_new(TCG_TYPE_I64);
+
+                tcg_gen_ext_tl_i64(r_tmp1, cpu_T[0]);
+                tcg_gen_ext_tl_i64(r_tmp2, cpu_T[1]);
+                tcg_gen_div_i64(r_tmp3, r_tmp1, r_tmp2);
+                tcg_gen_rem_i64(r_tmp2, r_tmp1, r_tmp2);
+                tcg_gen_trunc_i64_tl(cpu_T[0], r_tmp3);
+                tcg_gen_trunc_i64_tl(cpu_T[1], r_tmp2);
+                tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
+                tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
+                gen_store_LO(cpu_T[0], 0);
+                gen_store_HI(cpu_T[1], 0);
             }
             gen_set_label(l1);
         }
@@ -1907,31 +1899,24 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,
         {
             int l1 = gen_new_label();
 
-            tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[1], tcg_const_tl(0), l1);
+            tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_T[1], 0, l1);
             {
-                TCGv r_tmp1 = new_tmp();
-                TCGv r_tmp2 = new_tmp();
-                TCGv r_tmp3 = new_tmp();
-                TCGv r_tc_off = new_tmp();
-                TCGv r_tc_off_tl = tcg_temp_new(TCG_TYPE_TL);
-                TCGv r_ptr = tcg_temp_new(TCG_TYPE_PTR);
-
-                tcg_gen_ext_i32_tl(r_tmp1, cpu_T[0]);
-                tcg_gen_ext_i32_tl(r_tmp2, cpu_T[1]);
+                TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);
+                TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_I32);
+                TCGv r_tmp3 = tcg_temp_new(TCG_TYPE_I32);
+
+                tcg_gen_trunc_tl_i32(r_tmp1, cpu_T[0]);
+                tcg_gen_trunc_tl_i32(r_tmp2, cpu_T[1]);
                 tcg_gen_divu_i32(r_tmp3, r_tmp1, r_tmp2);
                 tcg_gen_remu_i32(r_tmp1, r_tmp1, r_tmp2);
-                tcg_gen_trunc_tl_i32(cpu_T[0], r_tmp3);
-                tcg_gen_trunc_tl_i32(cpu_T[1], r_tmp1);
-                dead_tmp(r_tmp1);
-                dead_tmp(r_tmp2);
-                dead_tmp(r_tmp3);
-                tcg_gen_ld_i32(r_tc_off, cpu_env, offsetof(CPUState, current_tc));
-                tcg_gen_muli_i32(r_tc_off, r_tc_off, sizeof(target_ulong));
-                tcg_gen_ext_i32_ptr(r_tc_off_tl, r_tc_off);
-                tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_tl);
-                tcg_gen_st_tl(cpu_T[0], r_ptr, offsetof(CPUState, LO));
-                tcg_gen_st_tl(cpu_T[1], r_ptr, offsetof(CPUState, HI));
-                dead_tmp(r_tc_off);
+                tcg_gen_ext_i32_tl(cpu_T[0], r_tmp3);
+                tcg_gen_ext_i32_tl(cpu_T[1], r_tmp1);
+                tcg_temp_free(r_tmp1);
+                tcg_temp_free(r_tmp2);
+                tcg_temp_free(r_tmp3);
+                gen_store_LO(cpu_T[0], 0);
+                gen_store_HI(cpu_T[1], 0);
             }
             gen_set_label(l1);
         }
@@ -1950,31 +1935,28 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,
         {
             int l1 = gen_new_label();
 
-            tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[1], tcg_const_tl(0), l1);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_T[1], 0, l1);
             {
-                TCGv r_tc_off = new_tmp();
-                TCGv r_tc_off_tl = tcg_temp_new(TCG_TYPE_TL);
-                TCGv r_ptr = tcg_temp_new(TCG_TYPE_PTR);
                 int l2 = gen_new_label();
-                int l3 = gen_new_label();
 
-                tcg_gen_brcond_tl(TCG_COND_NE, cpu_T[0], tcg_const_tl(1ULL << 63), l2);
-                tcg_gen_brcond_tl(TCG_COND_NE, cpu_T[1], tcg_const_tl(-1ULL), l2);
-                tcg_gen_div_i64(cpu_T[0], cpu_T[0], cpu_T[1]);
-                tcg_gen_movi_tl(cpu_T[1], 0);
-                tcg_gen_br(l3);
+                tcg_gen_brcondi_tl(TCG_COND_NE, cpu_T[0], -1LL << 63, l2);
+                tcg_gen_brcondi_tl(TCG_COND_NE, cpu_T[1], -1LL, l2);
+                {
+                    tcg_gen_movi_tl(cpu_T[1], 0);
+                    gen_store_LO(cpu_T[0], 0);
+                    gen_store_HI(cpu_T[1], 0);
+                    tcg_gen_br(l1);
+                }
                 gen_set_label(l2);
-                tcg_gen_div_i64(cpu_T[0], cpu_T[0], cpu_T[1]);
-                tcg_gen_rem_i64(cpu_T[1], cpu_T[0], cpu_T[1]);
-                gen_set_label(l3);
-
-                tcg_gen_ld_i32(r_tc_off, cpu_env, offsetof(CPUState, current_tc));
-                tcg_gen_muli_i32(r_tc_off, r_tc_off, sizeof(target_ulong));
-                tcg_gen_ext_i32_ptr(r_tc_off_tl, r_tc_off);
-                tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_tl);
-                tcg_gen_st_tl(cpu_T[0], r_ptr, offsetof(CPUState, LO));
-                tcg_gen_st_tl(cpu_T[1], r_ptr, offsetof(CPUState, HI));
-                dead_tmp(r_tc_off);
+                {
+                    TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I64);
+                    TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_I64);
+
+                    tcg_gen_div_i64(r_tmp1, cpu_T[0], cpu_T[1]);
+                    tcg_gen_rem_i64(r_tmp2, cpu_T[0], cpu_T[1]);
+                    gen_store_LO(r_tmp1, 0);
+                    gen_store_HI(r_tmp2, 0);
+                }
             }
             gen_set_label(l1);
         }
@@ -1984,23 +1966,15 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,
         {
             int l1 = gen_new_label();
 
-            tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[1], tcg_const_tl(0), l1);
+            tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_T[1], 0, l1);
             {
                 TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I64);
                 TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_I64);
-                TCGv r_tc_off = new_tmp();
-                TCGv r_tc_off_tl = tcg_temp_new(TCG_TYPE_TL);
-                TCGv r_ptr = tcg_temp_new(TCG_TYPE_PTR);
 
                 tcg_gen_divu_i64(r_tmp1, cpu_T[0], cpu_T[1]);
                 tcg_gen_remu_i64(r_tmp2, cpu_T[0], cpu_T[1]);
-                tcg_gen_ld_i32(r_tc_off, cpu_env, offsetof(CPUState, current_tc));
-                tcg_gen_muli_i32(r_tc_off, r_tc_off, sizeof(target_ulong));
-                tcg_gen_ext_i32_ptr(r_tc_off_tl, r_tc_off);
-                tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_tl);
-                tcg_gen_st_tl(r_tmp1, r_ptr, offsetof(CPUState, LO));
-                tcg_gen_st_tl(r_tmp2, r_ptr, offsetof(CPUState, HI));
-                dead_tmp(r_tc_off);
+                gen_store_LO(r_tmp1, 0);
+                gen_store_HI(r_tmp2, 0);
             }
             gen_set_label(l1);
         }
@@ -2568,6 +2542,8 @@ fail:
 static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
 {
     const char *rn = "invalid";
+    TCGv r_tmp = tcg_temp_new(TCG_TYPE_I32);
+    TCGv r_tmp64 = tcg_temp_new(TCG_TYPE_I64);
 
     if (sel != 0)
         check_insn(env, ctx, ISA_MIPS32);
@@ -2576,7 +2552,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 0:
         switch (sel) {
         case 0:
-            gen_op_mfc0_index();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Index));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Index";
             break;
         case 1:
@@ -2606,37 +2583,44 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
             break;
         case 1:
             check_insn(env, ctx, ASE_MT);
-            gen_op_mfc0_vpecontrol();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_VPEControl));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "VPEControl";
             break;
         case 2:
             check_insn(env, ctx, ASE_MT);
-            gen_op_mfc0_vpeconf0();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_VPEConf0));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "VPEConf0";
             break;
         case 3:
             check_insn(env, ctx, ASE_MT);
-            gen_op_mfc0_vpeconf1();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_VPEConf1));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "VPEConf1";
             break;
         case 4:
             check_insn(env, ctx, ASE_MT);
-            gen_op_mfc0_yqmask();
+            tcg_gen_ld_i64(r_tmp64, cpu_env, offsetof(CPUState, CP0_YQMask));
+            tcg_gen_trunc_i64_tl(cpu_T[0], r_tmp64);
             rn = "YQMask";
             break;
         case 5:
             check_insn(env, ctx, ASE_MT);
-            gen_op_mfc0_vpeschedule();
+            tcg_gen_ld_tl(r_tmp64, cpu_env, offsetof(CPUState, CP0_VPESchedule));
+            tcg_gen_trunc_i64_tl(cpu_T[0], r_tmp64);
             rn = "VPESchedule";
             break;
         case 6:
             check_insn(env, ctx, ASE_MT);
-            gen_op_mfc0_vpeschefback();
+            tcg_gen_ld_tl(r_tmp64, cpu_env, offsetof(CPUState, CP0_VPEScheFBack));
+            tcg_gen_trunc_i64_tl(cpu_T[0], r_tmp64);
             rn = "VPEScheFBack";
             break;
         case 7:
             check_insn(env, ctx, ASE_MT);
-            gen_op_mfc0_vpeopt();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_VPEOpt));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "VPEOpt";
             break;
         default:
@@ -2646,7 +2630,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 2:
         switch (sel) {
         case 0:
-            gen_op_mfc0_entrylo0();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_EntryLo0));
+            tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
             rn = "EntryLo0";
             break;
         case 1:
@@ -2691,7 +2676,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 3:
         switch (sel) {
         case 0:
-            gen_op_mfc0_entrylo1();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_EntryLo1));
+            tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
             rn = "EntryLo1";
             break;
         default:
@@ -2701,7 +2687,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 4:
         switch (sel) {
         case 0:
-            gen_op_mfc0_context();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_Context));
+            tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
             rn = "Context";
             break;
         case 1:
@@ -2715,12 +2702,14 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 5:
         switch (sel) {
         case 0:
-            gen_op_mfc0_pagemask();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_PageMask));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "PageMask";
             break;
         case 1:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_pagegrain();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_PageGrain));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "PageGrain";
             break;
         default:
@@ -2730,32 +2719,38 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 6:
         switch (sel) {
         case 0:
-            gen_op_mfc0_wired();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Wired));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Wired";
             break;
         case 1:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsconf0();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSConf0));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSConf0";
             break;
         case 2:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsconf1();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSConf1));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSConf1";
             break;
         case 3:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsconf2();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSConf2));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSConf2";
             break;
         case 4:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsconf3();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSConf3));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSConf3";
             break;
         case 5:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsconf4();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSConf4));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSConf4";
             break;
         default:
@@ -2766,7 +2761,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
         switch (sel) {
         case 0:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_hwrena();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_HWREna));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "HWREna";
             break;
         default:
@@ -2776,8 +2772,9 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 8:
         switch (sel) {
         case 0:
-            gen_op_mfc0_badvaddr();
-            rn = "BadVaddr";
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_BadVAddr));
+            tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
+            rn = "BadVAddr";
             break;
         default:
             goto die;
@@ -2797,7 +2794,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 10:
         switch (sel) {
         case 0:
-            gen_op_mfc0_entryhi();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_EntryHi));
+            tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
             rn = "EntryHi";
             break;
         default:
@@ -2807,7 +2805,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 11:
         switch (sel) {
         case 0:
-            gen_op_mfc0_compare();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Compare));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Compare";
             break;
         /* 6,7 are implementation dependent */
@@ -2818,22 +2817,26 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 12:
         switch (sel) {
         case 0:
-            gen_op_mfc0_status();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Status));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Status";
             break;
         case 1:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_intctl();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_IntCtl));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "IntCtl";
             break;
         case 2:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsctl();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSCtl));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSCtl";
             break;
         case 3:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsmap();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSMap));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSMap";
             break;
         default:
@@ -2843,7 +2846,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 13:
         switch (sel) {
         case 0:
-            gen_op_mfc0_cause();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Cause));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Cause";
             break;
         default:
@@ -2853,7 +2857,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 14:
         switch (sel) {
         case 0:
-            gen_op_mfc0_epc();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_EPC));
+            tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
             rn = "EPC";
             break;
         default:
@@ -2863,12 +2868,14 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 15:
         switch (sel) {
         case 0:
-            gen_op_mfc0_prid();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_PRid));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "PRid";
             break;
         case 1:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_ebase();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_EBase));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "EBase";
             break;
         default:
@@ -2878,29 +2885,35 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 16:
         switch (sel) {
         case 0:
-            gen_op_mfc0_config0();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config0));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Config";
             break;
         case 1:
-            gen_op_mfc0_config1();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config1));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Config1";
             break;
         case 2:
-            gen_op_mfc0_config2();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config2));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Config2";
             break;
         case 3:
-            gen_op_mfc0_config3();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config3));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Config3";
             break;
         /* 4,5 are reserved */
         /* 6,7 are implementation dependent */
         case 6:
-            gen_op_mfc0_config6();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config6));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Config6";
             break;
         case 7:
-            gen_op_mfc0_config7();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config7));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Config7";
             break;
         default:
@@ -2942,7 +2955,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
         case 0:
 #if defined(TARGET_MIPS64)
             check_insn(env, ctx, ISA_MIPS3);
-            gen_op_mfc0_xcontext();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_XContext));
+            tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
             rn = "XContext";
             break;
 #endif
@@ -2954,7 +2968,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
        /* Officially reserved, but sel 0 is used for R1x000 framemask */
         switch (sel) {
         case 0:
-            gen_op_mfc0_framemask();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Framemask));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Framemask";
             break;
         default:
@@ -2994,7 +3009,9 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 24:
         switch (sel) {
         case 0:
-            gen_op_mfc0_depc(); /* EJTAG support */
+            /* EJTAG support */
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_DEPC));
+            tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
             rn = "DEPC";
             break;
         default:
@@ -3004,7 +3021,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 25:
         switch (sel) {
         case 0:
-            gen_op_mfc0_performance0();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Performance0));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Performance0";
             break;
         case 1:
@@ -3058,14 +3076,16 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
         case 2:
         case 4:
         case 6:
-            gen_op_mfc0_taglo();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_TagLo));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "TagLo";
             break;
         case 1:
         case 3:
         case 5:
         case 7:
-            gen_op_mfc0_datalo();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_DataLo));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "DataLo";
             break;
         default:
@@ -3078,14 +3098,16 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
         case 2:
         case 4:
         case 6:
-            gen_op_mfc0_taghi();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_TagHi));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "TagHi";
             break;
         case 1:
         case 3:
         case 5:
         case 7:
-            gen_op_mfc0_datahi();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_DataHi));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "DataHi";
             break;
         default:
@@ -3095,7 +3117,8 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 30:
         switch (sel) {
         case 0:
-            gen_op_mfc0_errorepc();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_ErrorEPC));
+            tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
             rn = "ErrorEPC";
             break;
         default:
@@ -3105,7 +3128,9 @@ static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 31:
         switch (sel) {
         case 0:
-            gen_op_mfc0_desave(); /* EJTAG support */
+            /* EJTAG support */
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_DESAVE));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "DESAVE";
             break;
         default:
@@ -3343,7 +3368,7 @@ static void gen_mtc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
         break;
     case 8:
         /* ignored */
-        rn = "BadVaddr";
+        rn = "BadVAddr";
         break;
     case 9:
         switch (sel) {
@@ -3736,6 +3761,7 @@ die:
 static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
 {
     const char *rn = "invalid";
+    TCGv r_tmp = tcg_temp_new(TCG_TYPE_I32);
 
     if (sel != 0)
         check_insn(env, ctx, ISA_MIPS64);
@@ -3744,7 +3770,8 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 0:
         switch (sel) {
         case 0:
-            gen_op_mfc0_index();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Index));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Index";
             break;
         case 1:
@@ -3774,37 +3801,41 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
             break;
         case 1:
             check_insn(env, ctx, ASE_MT);
-            gen_op_mfc0_vpecontrol();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_VPEControl));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "VPEControl";
             break;
         case 2:
             check_insn(env, ctx, ASE_MT);
-            gen_op_mfc0_vpeconf0();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_VPEConf0));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "VPEConf0";
             break;
         case 3:
             check_insn(env, ctx, ASE_MT);
-            gen_op_mfc0_vpeconf1();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_VPEConf1));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "VPEConf1";
             break;
         case 4:
             check_insn(env, ctx, ASE_MT);
-            gen_op_dmfc0_yqmask();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_YQMask));
             rn = "YQMask";
             break;
         case 5:
             check_insn(env, ctx, ASE_MT);
-            gen_op_dmfc0_vpeschedule();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_VPESchedule));
             rn = "VPESchedule";
             break;
         case 6:
             check_insn(env, ctx, ASE_MT);
-            gen_op_dmfc0_vpeschefback();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_VPEScheFBack));
             rn = "VPEScheFBack";
             break;
         case 7:
             check_insn(env, ctx, ASE_MT);
-            gen_op_mfc0_vpeopt();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_VPEOpt));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "VPEOpt";
             break;
         default:
@@ -3814,7 +3845,7 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 2:
         switch (sel) {
         case 0:
-            gen_op_dmfc0_entrylo0();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_EntryLo0));
             rn = "EntryLo0";
             break;
         case 1:
@@ -3859,7 +3890,7 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 3:
         switch (sel) {
         case 0:
-            gen_op_dmfc0_entrylo1();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_EntryLo1));
             rn = "EntryLo1";
             break;
         default:
@@ -3869,7 +3900,7 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 4:
         switch (sel) {
         case 0:
-            gen_op_dmfc0_context();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_Context));
             rn = "Context";
             break;
         case 1:
@@ -3883,12 +3914,14 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 5:
         switch (sel) {
         case 0:
-            gen_op_mfc0_pagemask();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_PageMask));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "PageMask";
             break;
         case 1:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_pagegrain();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_PageGrain));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "PageGrain";
             break;
         default:
@@ -3898,32 +3931,38 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 6:
         switch (sel) {
         case 0:
-            gen_op_mfc0_wired();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Wired));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Wired";
             break;
         case 1:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsconf0();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSConf0));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSConf0";
             break;
         case 2:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsconf1();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSConf1));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSConf1";
             break;
         case 3:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsconf2();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSConf2));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSConf2";
             break;
         case 4:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsconf3();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSConf3));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSConf3";
             break;
         case 5:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsconf4();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSConf4));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSConf4";
             break;
         default:
@@ -3934,7 +3973,8 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
         switch (sel) {
         case 0:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_hwrena();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_HWREna));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "HWREna";
             break;
         default:
@@ -3944,8 +3984,8 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 8:
         switch (sel) {
         case 0:
-            gen_op_dmfc0_badvaddr();
-            rn = "BadVaddr";
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_BadVAddr));
+            rn = "BadVAddr";
             break;
         default:
             goto die;
@@ -3965,7 +4005,7 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 10:
         switch (sel) {
         case 0:
-            gen_op_dmfc0_entryhi();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_EntryHi));
             rn = "EntryHi";
             break;
         default:
@@ -3975,7 +4015,8 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 11:
         switch (sel) {
         case 0:
-            gen_op_mfc0_compare();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Compare));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Compare";
             break;
         /* 6,7 are implementation dependent */
@@ -3986,22 +4027,26 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 12:
         switch (sel) {
         case 0:
-            gen_op_mfc0_status();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Status));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Status";
             break;
         case 1:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_intctl();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_IntCtl));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "IntCtl";
             break;
         case 2:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsctl();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSCtl));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSCtl";
             break;
         case 3:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_srsmap();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_SRSMap));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "SRSMap";
             break;
         default:
@@ -4011,7 +4056,8 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 13:
         switch (sel) {
         case 0:
-            gen_op_mfc0_cause();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Cause));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Cause";
             break;
         default:
@@ -4021,7 +4067,7 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 14:
         switch (sel) {
         case 0:
-            gen_op_dmfc0_epc();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_EPC));
             rn = "EPC";
             break;
         default:
@@ -4031,12 +4077,14 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 15:
         switch (sel) {
         case 0:
-            gen_op_mfc0_prid();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_PRid));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "PRid";
             break;
         case 1:
             check_insn(env, ctx, ISA_MIPS32R2);
-            gen_op_mfc0_ebase();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_EBase));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "EBase";
             break;
         default:
@@ -4046,22 +4094,36 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 16:
         switch (sel) {
         case 0:
-            gen_op_mfc0_config0();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config0));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Config";
             break;
         case 1:
-            gen_op_mfc0_config1();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config1));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Config1";
             break;
         case 2:
-            gen_op_mfc0_config2();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config2));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Config2";
             break;
         case 3:
-            gen_op_mfc0_config3();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config3));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Config3";
             break;
        /* 6,7 are implementation dependent */
+        case 6:
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config6));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
+            rn = "Config6";
+            break;
+        case 7:
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Config7));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
+            rn = "Config7";
+            break;
         default:
             goto die;
         }
@@ -4100,7 +4162,7 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
         switch (sel) {
         case 0:
             check_insn(env, ctx, ISA_MIPS3);
-            gen_op_dmfc0_xcontext();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_XContext));
             rn = "XContext";
             break;
         default:
@@ -4111,7 +4173,8 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
        /* Officially reserved, but sel 0 is used for R1x000 framemask */
         switch (sel) {
         case 0:
-            gen_op_mfc0_framemask();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Framemask));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Framemask";
             break;
         default:
@@ -4151,7 +4214,8 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 24:
         switch (sel) {
         case 0:
-            gen_op_dmfc0_depc(); /* EJTAG support */
+            /* EJTAG support */
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_DEPC));
             rn = "DEPC";
             break;
         default:
@@ -4161,7 +4225,8 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 25:
         switch (sel) {
         case 0:
-            gen_op_mfc0_performance0();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Performance0));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "Performance0";
             break;
         case 1:
@@ -4215,14 +4280,16 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
         case 2:
         case 4:
         case 6:
-            gen_op_mfc0_taglo();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_TagLo));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "TagLo";
             break;
         case 1:
         case 3:
         case 5:
         case 7:
-            gen_op_mfc0_datalo();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_DataLo));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "DataLo";
             break;
         default:
@@ -4235,14 +4302,16 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
         case 2:
         case 4:
         case 6:
-            gen_op_mfc0_taghi();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_TagHi));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "TagHi";
             break;
         case 1:
         case 3:
         case 5:
         case 7:
-            gen_op_mfc0_datahi();
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_DataHi));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "DataHi";
             break;
         default:
@@ -4252,7 +4321,7 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 30:
         switch (sel) {
         case 0:
-            gen_op_dmfc0_errorepc();
+            tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_ErrorEPC));
             rn = "ErrorEPC";
             break;
         default:
@@ -4262,7 +4331,9 @@ static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
     case 31:
         switch (sel) {
         case 0:
-            gen_op_mfc0_desave(); /* EJTAG support */
+            /* EJTAG support */
+            tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_DESAVE));
+            tcg_gen_ext_i32_tl(cpu_T[0], r_tmp);
             rn = "DESAVE";
             break;
         default:
@@ -4500,7 +4571,7 @@ static void gen_dmtc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
         break;
     case 8:
         /* ignored */
-        rn = "BadVaddr";
+        rn = "BadVAddr";
         break;
     case 9:
         switch (sel) {
@@ -5450,18 +5521,34 @@ static void gen_cp1 (DisasContext *ctx, uint32_t opc, int rt, int fs)
 
 static void gen_movci (DisasContext *ctx, int rd, int rs, int cc, int tf)
 {
+    int l1 = gen_new_label();
     uint32_t ccbit;
+    TCGCond cond;
 
-    gen_load_gpr(cpu_T[0], rd);
-    gen_load_gpr(cpu_T[1], rs);
-    if (cc) {
+    if (cc)
         ccbit = 1 << (24 + cc);
-    else
+    else
         ccbit = 1 << 23;
-    if (!tf)
-        gen_op_movf(ccbit);
+    if (tf)
+        cond = TCG_COND_EQ;
     else
-        gen_op_movt(ccbit);
+        cond = TCG_COND_NE;
+
+    gen_load_gpr(cpu_T[0], rd);
+    gen_load_gpr(cpu_T[1], rs);
+    {
+        TCGv r_ptr = tcg_temp_new(TCG_TYPE_PTR);
+        TCGv r_tmp = tcg_temp_new(TCG_TYPE_I32);
+
+        tcg_gen_ld_ptr(r_ptr, cpu_env, offsetof(CPUState, fpu));
+        tcg_gen_ld_i32(r_tmp, r_ptr, offsetof(CPUMIPSFPUContext, fcr31));
+        tcg_temp_free(r_ptr);
+        tcg_gen_andi_i32(r_tmp, r_tmp, ccbit);
+        tcg_gen_brcondi_i32(cond, r_tmp, 0, l1);
+    }
+    tcg_gen_mov_tl(cpu_T[0], cpu_T[1]);
+
+    gen_set_label(l1);
     gen_store_gpr(cpu_T[0], rd);
 }
 
@@ -5481,7 +5568,6 @@ static void glue(gen_movcf_, fmt) (DisasContext *ctx, int cc, int tf) \
 }
 GEN_MOVCF(d);
 GEN_MOVCF(s);
-GEN_MOVCF(ps);
 #undef GEN_MOVCF
 
 static void gen_farith (DisasContext *ctx, uint32_t op1,
@@ -6100,7 +6186,10 @@ static void gen_farith (DisasContext *ctx, uint32_t op1,
         GEN_LOAD_FREG_FTN(WTH0, fs);
         GEN_LOAD_FREG_FTN(WT2, fd);
         GEN_LOAD_FREG_FTN(WTH2, fd);
-        gen_movcf_ps(ctx, (ft >> 2) & 0x7, ft & 0x1);
+        if (ft & 0x1)
+            gen_op_float_movt_ps ((ft >> 2) & 0x7);
+        else
+            gen_op_float_movf_ps ((ft >> 2) & 0x7);
         GEN_STORE_FTN_FREG(fd, WT2);
         GEN_STORE_FTN_FREG(fd, WTH2);
         opn = "movcf.ps";
@@ -6545,7 +6634,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
 
         MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4);
         tcg_gen_ld_tl(r_tmp, cpu_env, offsetof(CPUState, bcond));
-        tcg_gen_brcond_tl(TCG_COND_NE, r_tmp, tcg_const_tl(0), l1);
+        tcg_gen_brcondi_tl(TCG_COND_NE, r_tmp, 0, l1);
         gen_op_save_state(ctx->hflags & ~MIPS_HFLAG_BMASK);
         gen_goto_tb(ctx, 1, ctx->pc + 4);
         gen_set_label(l1);
@@ -7103,7 +7192,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
                 int l1 = gen_new_label();
 
                 tcg_gen_ld_tl(r_tmp, cpu_env, offsetof(CPUState, bcond));
-                tcg_gen_brcond_tl(TCG_COND_NE, r_tmp, tcg_const_tl(0), l1);
+                tcg_gen_brcondi_tl(TCG_COND_NE, r_tmp, 0, l1);
                 gen_goto_tb(ctx, 1, ctx->pc + 4);
                 gen_set_label(l1);
                 gen_goto_tb(ctx, 0, ctx->btarget);
@@ -7134,12 +7223,6 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,
     if (search_pc && loglevel)
         fprintf (logfile, "search pc %d\n", search_pc);
 
-    num_temps = 0;
-    memset(temps, 0, sizeof(temps));
-
-    num_temps = 0;
-    memset(temps, 0, sizeof(temps));
-
     pc_start = tb->pc;
     gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
     ctx.pc = pc_start;
@@ -7194,12 +7277,6 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,
         }
         ctx.opcode = ldl_code(ctx.pc);
         decode_opc(env, &ctx);
-        if (num_temps) {
-            fprintf(stderr,
-                    "Internal resource leak before " TARGET_FMT_lx "\n",
-                    ctx.pc);
-            num_temps = 0;
-        }
         ctx.pc += 4;
 
         if (env->singlestep_enabled)
@@ -7397,6 +7474,10 @@ static void mips_tcg_init(void)
                                          TCG_AREG0,
                                          offsetof(CPUState, current_tc_gprs),
                                          "current_tc_gprs");
+    current_tc_hi = tcg_global_mem_new(TCG_TYPE_PTR,
+                                       TCG_AREG0,
+                                       offsetof(CPUState, current_tc_hi),
+                                       "current_tc_hi");
 #if TARGET_LONG_BITS > HOST_LONG_BITS
     cpu_T[0] = tcg_global_mem_new(TCG_TYPE_TL,
                                   TCG_AREG0, offsetof(CPUState, t0), "T0");
This page took 0.075706 seconds and 4 git commands to generate.