util/hbitmap: update orig_size on truncate
[qemu/ar7.git] / include / exec / gen-icount.h
blobf7669b684147ccbf83efc43f96231ad4bf93bd9e
1 #ifndef GEN_ICOUNT_H
2 #define GEN_ICOUNT_H
4 #include "qemu/timer.h"
6 /* Helpers for instruction counting code generation. */
8 static TCGOp *icount_start_insn;
10 static inline void gen_tb_start(TranslationBlock *tb)
12 TCGv_i32 count, imm;
14 tcg_ctx->exitreq_label = gen_new_label();
15 if (tb_cflags(tb) & CF_USE_ICOUNT) {
16 count = tcg_temp_local_new_i32();
17 } else {
18 count = tcg_temp_new_i32();
21 tcg_gen_ld_i32(count, cpu_env,
22 offsetof(ArchCPU, neg.icount_decr.u32) -
23 offsetof(ArchCPU, env));
25 if (tb_cflags(tb) & CF_USE_ICOUNT) {
26 imm = tcg_temp_new_i32();
27 /* We emit a movi with a dummy immediate argument. Keep the insn index
28 * of the movi so that we later (when we know the actual insn count)
29 * can update the immediate argument with the actual insn count. */
30 tcg_gen_movi_i32(imm, 0xdeadbeef);
31 icount_start_insn = tcg_last_op();
33 tcg_gen_sub_i32(count, count, imm);
34 tcg_temp_free_i32(imm);
37 tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, tcg_ctx->exitreq_label);
39 if (tb_cflags(tb) & CF_USE_ICOUNT) {
40 tcg_gen_st16_i32(count, cpu_env,
41 offsetof(ArchCPU, neg.icount_decr.u16.low) -
42 offsetof(ArchCPU, env));
45 tcg_temp_free_i32(count);
48 static inline void gen_tb_end(TranslationBlock *tb, int num_insns)
50 if (tb_cflags(tb) & CF_USE_ICOUNT) {
51 /* Update the num_insn immediate parameter now that we know
52 * the actual insn count. */
53 tcg_set_insn_param(icount_start_insn, 1, num_insns);
56 gen_set_label(tcg_ctx->exitreq_label);
57 tcg_gen_exit_tb(tb, TB_EXIT_REQUESTED);
60 static inline void gen_io_start(void)
62 TCGv_i32 tmp = tcg_const_i32(1);
63 tcg_gen_st_i32(tmp, cpu_env,
64 offsetof(ArchCPU, parent_obj.can_do_io) -
65 offsetof(ArchCPU, env));
66 tcg_temp_free_i32(tmp);
69 static inline void gen_io_end(void)
71 TCGv_i32 tmp = tcg_const_i32(0);
72 tcg_gen_st_i32(tmp, cpu_env,
73 offsetof(ArchCPU, parent_obj.can_do_io) -
74 offsetof(ArchCPU, env));
75 tcg_temp_free_i32(tmp);
78 #endif