qemu-log: Rename CPULogItem, cpu_log_items to QEMULogItem, qemu_log_items
[qemu/pbrook.git] / include / exec / gen-icount.h
blob8043b3ba2688f6132a4d7e0aa51364f18d06117e
1 #ifndef GEN_ICOUNT_H
2 #define GEN_ICOUNT_H 1
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)
13 TCGv_i32 count;
15 if (!use_icount)
16 return;
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)
32 if (use_icount) {
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);
53 #endif