00001
00002
00003 static TCGArg *icount_arg;
00004 static int icount_label;
00005
00006 static inline void gen_icount_start(void)
00007 {
00008 TCGv_i32 count;
00009
00010 if (!use_icount)
00011 return;
00012
00013 icount_label = gen_new_label();
00014
00015
00016
00017 #ifndef ICOUNT_TEMP
00018 count = tcg_temp_local_new_i32();
00019 #else
00020 count = ICOUNT_TEMP;
00021 #endif
00022 tcg_gen_ld_i32(count, cpu_env, offsetof(CPUState, icount_decr.u32));
00023
00024 icount_arg = gen_opparam_ptr + 1;
00025 tcg_gen_subi_i32(count, count, 0xdeadbeef);
00026
00027 tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label);
00028 tcg_gen_st16_i32(count, cpu_env, offsetof(CPUState, icount_decr.u16.low));
00029
00030 #ifndef ICOUNT_TEMP
00031 tcg_temp_free_i32(count);
00032 #endif
00033 }
00034
00035 static void gen_icount_end(TranslationBlock *tb, int num_insns)
00036 {
00037 if (use_icount) {
00038 *icount_arg = num_insns;
00039 gen_set_label(icount_label);
00040 tcg_gen_exit_tb((long)tb + 2);
00041 }
00042 }
00043
00044 static void inline gen_io_start(void)
00045 {
00046 TCGv_i32 tmp = tcg_const_i32(1);
00047 tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUState, can_do_io));
00048 tcg_temp_free_i32(tmp);
00049 }
00050
00051 static inline void gen_io_end(void)
00052 {
00053 TCGv_i32 tmp = tcg_const_i32(0);
00054 tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUState, can_do_io));
00055 tcg_temp_free_i32(tmp);
00056 }