add roms/pcbios
[qemupft.git] / gen-icount.h
blob3268f720a595073ae98c03db88e9eb60de3d76d6
1 /* Helpers for instruction counting code generation. */
3 static TCGArg *icount_arg;
4 static int icount_label;
6 static inline void gen_icount_start(void)
8 TCGv_i32 count;
10 if (!use_icount)
11 return;
13 icount_label = gen_new_label();
14 count = tcg_temp_local_new_i32();
15 tcg_gen_ld_i32(count, cpu_env, offsetof(CPUState, icount_decr.u32));
16 /* This is a horrid hack to allow fixing up the value later. */
17 icount_arg = gen_opparam_ptr + 1;
18 tcg_gen_subi_i32(count, count, 0xdeadbeef);
20 tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label);
21 tcg_gen_st16_i32(count, cpu_env, offsetof(CPUState, icount_decr.u16.low));
22 tcg_temp_free_i32(count);
25 static void gen_icount_end(TranslationBlock *tb, int num_insns)
27 if (use_icount) {
28 *icount_arg = num_insns;
29 gen_set_label(icount_label);
30 tcg_gen_exit_tb((long)tb + 2);
34 static inline void gen_io_start(void)
36 TCGv_i32 tmp = tcg_const_i32(1);
37 tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUState, can_do_io));
38 tcg_temp_free_i32(tmp);
41 static inline void gen_io_end(void)
43 TCGv_i32 tmp = tcg_const_i32(0);
44 tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUState, can_do_io));
45 tcg_temp_free_i32(tmp);