]>
Commit | Line | Data |
---|---|---|
29e922b6 BS |
1 | #include "qemu-timer.h" |
2 | ||
bf20dc07 | 3 | /* Helpers for instruction counting code generation. */ |
dd5d6fe9 PB |
4 | |
5 | static TCGArg *icount_arg; | |
6 | static int icount_label; | |
7 | ||
8 | static inline void gen_icount_start(void) | |
9 | { | |
a7812ae4 | 10 | TCGv_i32 count; |
dd5d6fe9 PB |
11 | |
12 | if (!use_icount) | |
13 | return; | |
14 | ||
15 | icount_label = gen_new_label(); | |
a7812ae4 | 16 | count = tcg_temp_local_new_i32(); |
9349b4f9 | 17 | tcg_gen_ld_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u32)); |
dd5d6fe9 PB |
18 | /* This is a horrid hack to allow fixing up the value later. */ |
19 | icount_arg = gen_opparam_ptr + 1; | |
20 | tcg_gen_subi_i32(count, count, 0xdeadbeef); | |
21 | ||
22 | tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label); | |
9349b4f9 | 23 | tcg_gen_st16_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u16.low)); |
a7812ae4 | 24 | tcg_temp_free_i32(count); |
dd5d6fe9 PB |
25 | } |
26 | ||
27 | static void gen_icount_end(TranslationBlock *tb, int num_insns) | |
28 | { | |
29 | if (use_icount) { | |
30 | *icount_arg = num_insns; | |
31 | gen_set_label(icount_label); | |
4b4a72e5 | 32 | tcg_gen_exit_tb((tcg_target_long)tb + 2); |
dd5d6fe9 PB |
33 | } |
34 | } | |
35 | ||
86178a57 | 36 | static inline void gen_io_start(void) |
dd5d6fe9 | 37 | { |
a7812ae4 | 38 | TCGv_i32 tmp = tcg_const_i32(1); |
9349b4f9 | 39 | tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); |
a7812ae4 | 40 | tcg_temp_free_i32(tmp); |
dd5d6fe9 PB |
41 | } |
42 | ||
43 | static inline void gen_io_end(void) | |
44 | { | |
a7812ae4 | 45 | TCGv_i32 tmp = tcg_const_i32(0); |
9349b4f9 | 46 | tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); |
a7812ae4 | 47 | tcg_temp_free_i32(tmp); |
dd5d6fe9 | 48 | } |