Convert tick operations to TCG
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 2 Mar 2008 18:28:06 +0000 (18:28 +0000)
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 2 Mar 2008 18:28:06 +0000 (18:28 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4011 c046a42c-6fe2-441c-8c8c-71466251a162

target-sparc/cpu.h
target-sparc/helper.c
target-sparc/helper.h
target-sparc/op.c
target-sparc/translate.c

index 8a4cdbc..9b9d856 100644 (file)
@@ -320,9 +320,6 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
 void raise_exception(int tt);
 void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
                           int is_asi);
-void do_tick_set_count(void *opaque, uint64_t count);
-uint64_t do_tick_get_count(void *opaque);
-void do_tick_set_limit(void *opaque, uint64_t limit);
 void cpu_check_irqs(CPUSPARCState *env);
 
 #define CPUState CPUSPARCState
index 894e326..3437d13 100644 (file)
@@ -612,14 +612,14 @@ void memcpy32(target_ulong *dst, const target_ulong *src)
 #include "qemu-timer.h"
 #endif
 
-void do_tick_set_count(void *opaque, uint64_t count)
+void helper_tick_set_count(void *opaque, uint64_t count)
 {
 #if !defined(CONFIG_USER_ONLY)
     ptimer_set_count(opaque, -count);
 #endif
 }
 
-uint64_t do_tick_get_count(void *opaque)
+uint64_t helper_tick_get_count(void *opaque)
 {
 #if !defined(CONFIG_USER_ONLY)
     return -ptimer_get_count(opaque);
@@ -628,7 +628,7 @@ uint64_t do_tick_get_count(void *opaque)
 #endif
 }
 
-void do_tick_set_limit(void *opaque, uint64_t limit)
+void helper_tick_set_limit(void *opaque, uint64_t limit)
 {
 #if !defined(CONFIG_USER_ONLY)
     ptimer_set_limit(opaque, -limit, 0);
index 28a0d6c..3cdba68 100644 (file)
@@ -19,6 +19,9 @@ helper_cas_asi(target_ulong addr, target_ulong val1,
 target_ulong  TCG_HELPER_PROTO
 helper_casx_asi(target_ulong addr, target_ulong val1,
                 target_ulong val2, uint32_t asi);
+void TCG_HELPER_PROTO helper_tick_set_count(void *opaque, uint64_t count);
+uint64_t TCG_HELPER_PROTO helper_tick_get_count(void *opaque);
+void TCG_HELPER_PROTO helper_tick_set_limit(void *opaque, uint64_t limit);
 #endif
 void TCG_HELPER_PROTO helper_trap(target_ulong nb_trap);
 void TCG_HELPER_PROTO helper_trapcc(target_ulong nb_trap,
index 11a5519..ee5d56f 100644 (file)
@@ -806,42 +806,6 @@ void OPPROTO op_wrccr(void)
     PUT_CCR(env, T0);
 }
 
-void OPPROTO op_rdtick(void)
-{
-    T0 = do_tick_get_count(env->tick);
-}
-
-void OPPROTO op_wrtick(void)
-{
-    do_tick_set_count(env->tick, T0);
-}
-
-void OPPROTO op_wrtick_cmpr(void)
-{
-    do_tick_set_limit(env->tick, T0);
-}
-
-void OPPROTO op_rdstick(void)
-{
-    T0 = do_tick_get_count(env->stick);
-}
-
-void OPPROTO op_wrstick(void)
-{
-    do_tick_set_count(env->stick, T0);
-    do_tick_set_count(env->hstick, T0);
-}
-
-void OPPROTO op_wrstick_cmpr(void)
-{
-    do_tick_set_limit(env->stick, T0);
-}
-
-void OPPROTO op_wrhstick_cmpr(void)
-{
-    do_tick_set_limit(env->hstick, T0);
-}
-
 void OPPROTO op_rdtpc(void)
 {
     T0 = env->tpc[env->tl];
index 58be1c7..f09be0d 100644 (file)
@@ -1204,8 +1204,16 @@ static void disas_sparc_insn(DisasContext * dc)
                     gen_movl_T0_reg(rd);
                     break;
                 case 0x4: /* V9 rdtick */
-                    gen_op_rdtick();
-                    gen_movl_T0_reg(rd);
+                    {
+                        TCGv r_tickptr;
+
+                        r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
+                        tcg_gen_ld_ptr(r_tickptr, cpu_env,
+                                       offsetof(CPUState, tick));
+                        tcg_gen_helper_1_1(helper_tick_get_count, cpu_T[0],
+                                           r_tickptr);
+                        gen_movl_T0_reg(rd);
+                    }
                     break;
                 case 0x5: /* V9 rdpc */
                     tcg_gen_movi_tl(cpu_T[0], dc->pc);
@@ -1228,8 +1236,16 @@ static void disas_sparc_insn(DisasContext * dc)
                     gen_movl_T0_reg(rd);
                     break;
                 case 0x18: /* System tick */
-                    gen_op_rdstick();
-                    gen_movl_T0_reg(rd);
+                    {
+                        TCGv r_tickptr;
+
+                        r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
+                        tcg_gen_ld_ptr(r_tickptr, cpu_env,
+                                       offsetof(CPUState, stick));
+                        tcg_gen_helper_1_1(helper_tick_get_count, cpu_T[0],
+                                           r_tickptr);
+                        gen_movl_T0_reg(rd);
+                    }
                     break;
                 case 0x19: /* System tick compare */
                     gen_op_movtl_T0_env(offsetof(CPUSPARCState, stick_cmpr));
@@ -1299,7 +1315,16 @@ static void disas_sparc_insn(DisasContext * dc)
                     gen_op_rdtt();
                     break;
                 case 4: // tick
-                    gen_op_rdtick();
+                    {
+                        TCGv r_tickptr;
+
+                        r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
+                        tcg_gen_ld_ptr(r_tickptr, cpu_env,
+                                       offsetof(CPUState, tick));
+                        tcg_gen_helper_1_1(helper_tick_get_count, cpu_T[0],
+                                           r_tickptr);
+                        gen_movl_T0_reg(rd);
+                    }
                     break;
                 case 5: // tba
                     gen_op_movtl_T0_env(offsetof(CPUSPARCState, tbr));
@@ -2281,26 +2306,52 @@ static void disas_sparc_insn(DisasContext * dc)
                                 if (!supervisor(dc))
                                     goto illegal_insn;
 #endif
-                                gen_op_xor_T1_T0();
-                                gen_op_movtl_env_T0(offsetof(CPUSPARCState, tick_cmpr));
-                                gen_op_wrtick_cmpr();
+                                {
+                                    TCGv r_tickptr;
+
+                                    gen_op_xor_T1_T0();
+                                    gen_op_movtl_env_T0(offsetof(CPUSPARCState,
+                                                                 tick_cmpr));
+                                    r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
+                                    tcg_gen_ld_ptr(r_tickptr, cpu_env,
+                                                   offsetof(CPUState, tick));
+                                    tcg_gen_helper_0_2(helper_tick_set_limit,
+                                                       r_tickptr, cpu_T[0]);
+                                }
                                 break;
                             case 0x18: /* System tick */
 #if !defined(CONFIG_USER_ONLY)
                                 if (!supervisor(dc))
                                     goto illegal_insn;
 #endif
-                                gen_op_xor_T1_T0();
-                                gen_op_wrstick();
+                                {
+                                    TCGv r_tickptr;
+
+                                    gen_op_xor_T1_T0();
+                                    r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
+                                    tcg_gen_ld_ptr(r_tickptr, cpu_env,
+                                                   offsetof(CPUState, stick));
+                                    tcg_gen_helper_0_2(helper_tick_set_count,
+                                                       r_tickptr, cpu_T[0]);
+                                }
                                 break;
                             case 0x19: /* System tick compare */
 #if !defined(CONFIG_USER_ONLY)
                                 if (!supervisor(dc))
                                     goto illegal_insn;
 #endif
-                                gen_op_xor_T1_T0();
-                                gen_op_movtl_env_T0(offsetof(CPUSPARCState, stick_cmpr));
-                                gen_op_wrstick_cmpr();
+                                {
+                                    TCGv r_tickptr;
+
+                                    gen_op_xor_T1_T0();
+                                    gen_op_movtl_env_T0(offsetof(CPUSPARCState,
+                                                                 stick_cmpr));
+                                    r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
+                                    tcg_gen_ld_ptr(r_tickptr, cpu_env,
+                                                   offsetof(CPUState, stick));
+                                    tcg_gen_helper_0_2(helper_tick_set_limit,
+                                                       r_tickptr, cpu_T[0]);
+                                }
                                 break;
 
                             case 0x10: /* Performance Control */
@@ -2366,7 +2417,15 @@ static void disas_sparc_insn(DisasContext * dc)
                                 gen_op_wrtt();
                                 break;
                             case 4: // tick
-                                gen_op_wrtick();
+                                {
+                                    TCGv r_tickptr;
+
+                                    r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
+                                    tcg_gen_ld_ptr(r_tickptr, cpu_env,
+                                                   offsetof(CPUState, tick));
+                                    tcg_gen_helper_0_2(helper_tick_set_count,
+                                                       r_tickptr, cpu_T[0]);
+                                }
                                 break;
                             case 5: // tba
                                 gen_op_movtl_env_T0(offsetof(CPUSPARCState, tbr));
@@ -2448,8 +2507,17 @@ static void disas_sparc_insn(DisasContext * dc)
                                 gen_op_movl_env_T0(offsetof(CPUSPARCState, htba));
                                 break;
                             case 31: // hstick_cmpr
-                                gen_op_movtl_env_T0(offsetof(CPUSPARCState, hstick_cmpr));
-                                gen_op_wrhstick_cmpr();
+                                {
+                                    TCGv r_tickptr;
+
+                                    gen_op_movtl_env_T0(offsetof(CPUSPARCState,
+                                                                 hstick_cmpr));
+                                    r_tickptr = tcg_temp_new(TCG_TYPE_PTR);
+                                    tcg_gen_ld_ptr(r_tickptr, cpu_env,
+                                                   offsetof(CPUState, hstick));
+                                    tcg_gen_helper_0_2(helper_tick_set_limit,
+                                                       r_tickptr, cpu_T[0]);
+                                }
                                 break;
                             case 6: // hver readonly
                             default: