~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to include/exec/gen-icount.h

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
/* Helpers for instruction counting code generation.  */
7
7
 
8
8
static int icount_start_insn_idx;
9
 
static TCGLabel *icount_label;
10
9
static TCGLabel *exitreq_label;
11
10
 
12
11
static inline void gen_tb_start(TranslationBlock *tb)
13
12
{
14
 
    TCGv_i32 count, flag, imm;
 
13
    TCGv_i32 count, imm;
15
14
 
16
15
    exitreq_label = gen_new_label();
17
 
    flag = tcg_temp_new_i32();
18
 
    tcg_gen_ld_i32(flag, cpu_env,
19
 
                   offsetof(CPUState, tcg_exit_req) - ENV_OFFSET);
20
 
    tcg_gen_brcondi_i32(TCG_COND_NE, flag, 0, exitreq_label);
21
 
    tcg_temp_free_i32(flag);
22
 
 
23
 
    if (!(tb->cflags & CF_USE_ICOUNT)) {
24
 
        return;
 
16
    if (tb->cflags & CF_USE_ICOUNT) {
 
17
        count = tcg_temp_local_new_i32();
 
18
    } else {
 
19
        count = tcg_temp_new_i32();
25
20
    }
26
21
 
27
 
    icount_label = gen_new_label();
28
 
    count = tcg_temp_local_new_i32();
29
22
    tcg_gen_ld_i32(count, cpu_env,
30
23
                   -ENV_OFFSET + offsetof(CPUState, icount_decr.u32));
31
24
 
32
 
    imm = tcg_temp_new_i32();
33
 
    /* We emit a movi with a dummy immediate argument. Keep the insn index
34
 
     * of the movi so that we later (when we know the actual insn count)
35
 
     * can update the immediate argument with the actual insn count.  */
36
 
    icount_start_insn_idx = tcg_op_buf_count();
37
 
    tcg_gen_movi_i32(imm, 0xdeadbeef);
38
 
 
39
 
    tcg_gen_sub_i32(count, count, imm);
40
 
    tcg_temp_free_i32(imm);
41
 
 
42
 
    tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label);
43
 
    tcg_gen_st16_i32(count, cpu_env,
44
 
                     -ENV_OFFSET + offsetof(CPUState, icount_decr.u16.low));
 
25
    if (tb->cflags & 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
        icount_start_insn_idx = tcg_op_buf_count();
 
31
        tcg_gen_movi_i32(imm, 0xdeadbeef);
 
32
 
 
33
        tcg_gen_sub_i32(count, count, imm);
 
34
        tcg_temp_free_i32(imm);
 
35
    }
 
36
 
 
37
    tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, exitreq_label);
 
38
 
 
39
    if (tb->cflags & CF_USE_ICOUNT) {
 
40
        tcg_gen_st16_i32(count, cpu_env,
 
41
                         -ENV_OFFSET + offsetof(CPUState, icount_decr.u16.low));
 
42
    }
 
43
 
45
44
    tcg_temp_free_i32(count);
46
45
}
47
46
 
48
47
static void gen_tb_end(TranslationBlock *tb, int num_insns)
49
48
{
50
 
    gen_set_label(exitreq_label);
51
 
    tcg_gen_exit_tb((uintptr_t)tb + TB_EXIT_REQUESTED);
52
 
 
53
49
    if (tb->cflags & CF_USE_ICOUNT) {
54
50
        /* Update the num_insn immediate parameter now that we know
55
51
         * the actual insn count.  */
56
52
        tcg_set_insn_param(icount_start_insn_idx, 1, num_insns);
57
 
        gen_set_label(icount_label);
58
 
        tcg_gen_exit_tb((uintptr_t)tb + TB_EXIT_ICOUNT_EXPIRED);
59
53
    }
60
54
 
 
55
    gen_set_label(exitreq_label);
 
56
    tcg_gen_exit_tb((uintptr_t)tb + TB_EXIT_REQUESTED);
 
57
 
61
58
    /* Terminate the linked list.  */
62
59
    tcg_ctx.gen_op_buf[tcg_ctx.gen_op_buf[0].prev].next = 0;
63
60
}