root / gen-icount.h @ 1bb62099
History | View | Annotate | Download (1.2 kB)
1 | bf20dc07 | ths | /* Helpers for instruction counting code generation. */
|
---|---|---|---|
2 | dd5d6fe9 | pbrook | |
3 | dd5d6fe9 | pbrook | static TCGArg *icount_arg;
|
4 | dd5d6fe9 | pbrook | static int icount_label; |
5 | dd5d6fe9 | pbrook | |
6 | dd5d6fe9 | pbrook | static inline void gen_icount_start(void) |
7 | dd5d6fe9 | pbrook | { |
8 | a7812ae4 | pbrook | TCGv_i32 count; |
9 | dd5d6fe9 | pbrook | |
10 | dd5d6fe9 | pbrook | if (!use_icount)
|
11 | dd5d6fe9 | pbrook | return;
|
12 | dd5d6fe9 | pbrook | |
13 | dd5d6fe9 | pbrook | icount_label = gen_new_label(); |
14 | a7812ae4 | pbrook | count = tcg_temp_local_new_i32(); |
15 | dd5d6fe9 | pbrook | tcg_gen_ld_i32(count, cpu_env, offsetof(CPUState, icount_decr.u32)); |
16 | dd5d6fe9 | pbrook | /* This is a horrid hack to allow fixing up the value later. */
|
17 | dd5d6fe9 | pbrook | icount_arg = gen_opparam_ptr + 1;
|
18 | dd5d6fe9 | pbrook | tcg_gen_subi_i32(count, count, 0xdeadbeef);
|
19 | dd5d6fe9 | pbrook | |
20 | dd5d6fe9 | pbrook | tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label);
|
21 | dd5d6fe9 | pbrook | tcg_gen_st16_i32(count, cpu_env, offsetof(CPUState, icount_decr.u16.low)); |
22 | a7812ae4 | pbrook | tcg_temp_free_i32(count); |
23 | dd5d6fe9 | pbrook | } |
24 | dd5d6fe9 | pbrook | |
25 | dd5d6fe9 | pbrook | static void gen_icount_end(TranslationBlock *tb, int num_insns) |
26 | dd5d6fe9 | pbrook | { |
27 | dd5d6fe9 | pbrook | if (use_icount) {
|
28 | dd5d6fe9 | pbrook | *icount_arg = num_insns; |
29 | dd5d6fe9 | pbrook | gen_set_label(icount_label); |
30 | dd5d6fe9 | pbrook | tcg_gen_exit_tb((long)tb + 2); |
31 | dd5d6fe9 | pbrook | } |
32 | dd5d6fe9 | pbrook | } |
33 | dd5d6fe9 | pbrook | |
34 | 86178a57 | Juan Quintela | static inline void gen_io_start(void) |
35 | dd5d6fe9 | pbrook | { |
36 | a7812ae4 | pbrook | TCGv_i32 tmp = tcg_const_i32(1);
|
37 | dd5d6fe9 | pbrook | tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUState, can_do_io)); |
38 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp); |
39 | dd5d6fe9 | pbrook | } |
40 | dd5d6fe9 | pbrook | |
41 | dd5d6fe9 | pbrook | static inline void gen_io_end(void) |
42 | dd5d6fe9 | pbrook | { |
43 | a7812ae4 | pbrook | TCGv_i32 tmp = tcg_const_i32(0);
|
44 | dd5d6fe9 | pbrook | tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUState, can_do_io)); |
45 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp); |
46 | dd5d6fe9 | pbrook | } |