4 #include "qemu-timer.h"
6 /* Helpers for instruction counting code generation. */
8 static TCGArg *icount_arg;
9 static int icount_label;
11 static inline void gen_icount_start(void)
18 icount_label = gen_new_label();
19 count = tcg_temp_local_new_i32();
20 tcg_gen_ld_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u32));
21 /* This is a horrid hack to allow fixing up the value later. */
22 icount_arg = tcg_ctx.gen_opparam_ptr + 1;
23 tcg_gen_subi_i32(count, count, 0xdeadbeef);
25 tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label);
26 tcg_gen_st16_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u16.low));
27 tcg_temp_free_i32(count);
30 static void gen_icount_end(TranslationBlock *tb, int num_insns)
33 *icount_arg = num_insns;
34 gen_set_label(icount_label);
35 tcg_gen_exit_tb((tcg_target_long)tb + 2);
39 static inline void gen_io_start(void)
41 TCGv_i32 tmp = tcg_const_i32(1);
42 tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io));
43 tcg_temp_free_i32(tmp);
46 static inline void gen_io_end(void)
48 TCGv_i32 tmp = tcg_const_i32(0);
49 tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io));
50 tcg_temp_free_i32(tmp);