]> git.proxmox.com Git - mirror_qemu.git/blob - gen-icount.h
block: move include files to include/block/
[mirror_qemu.git] / gen-icount.h
1 #ifndef GEN_ICOUNT_H
2 #define GEN_ICOUNT_H 1
3
4 #include "qemu-timer.h"
5
6 /* Helpers for instruction counting code generation. */
7
8 static TCGArg *icount_arg;
9 static int icount_label;
10
11 static inline void gen_icount_start(void)
12 {
13 TCGv_i32 count;
14
15 if (!use_icount)
16 return;
17
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);
24
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);
28 }
29
30 static void gen_icount_end(TranslationBlock *tb, int num_insns)
31 {
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);
36 }
37 }
38
39 static inline void gen_io_start(void)
40 {
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);
44 }
45
46 static inline void gen_io_end(void)
47 {
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);
51 }
52
53 #endif