target/i386: introduce gen_jr helper to generate lookup_and_goto_ptr

This helper will be used by subsequent changes.

Backports commit 1ebb1af1b8068fca36f48f738eb7146ecdf03625 from qemu
This commit is contained in:
Emilio G. Cota 2018-03-03 14:05:58 -05:00 committed by Lioncash
parent 9aaad9ed27
commit baa017d29b
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -121,6 +121,7 @@ typedef struct DisasContext {
} DisasContext;
static void gen_eob(DisasContext *s);
static void gen_jr(DisasContext *s, TCGv dest);
static void gen_jmp(DisasContext *s, target_ulong eip);
static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num);
static void gen_op(DisasContext *s, int op, TCGMemOp ot, int d);
@ -2845,7 +2846,8 @@ static void gen_bnd_jmp(DisasContext *s)
If INHIBIT, set HF_INHIBIT_IRQ_MASK if it isn't already set.
If RECHECK_TF, emit a rechecking helper for #DB, ignoring the state of
S->TF. This is used by the syscall/sysret insns. */
static void gen_eob_worker(DisasContext *s, bool inhibit, bool recheck_tf)
static void
do_gen_eob_worker(DisasContext *s, bool inhibit, bool recheck_tf, TCGv jr)
{
TCGContext *tcg_ctx = s->uc->tcg_ctx;
@ -2868,12 +2870,27 @@ static void gen_eob_worker(DisasContext *s, bool inhibit, bool recheck_tf)
tcg_gen_exit_tb(tcg_ctx, 0);
} else if (s->tf) {
gen_helper_single_step(tcg_ctx, tcg_ctx->cpu_env);
} else if (!TCGV_IS_UNUSED(jr)) {
TCGv vaddr = tcg_temp_new(tcg_ctx);
tcg_gen_add_tl(tcg_ctx, vaddr, jr, tcg_ctx->cpu_seg_base[R_CS]);
tcg_gen_lookup_and_goto_ptr(tcg_ctx, vaddr);
tcg_temp_free(tcg_ctx, vaddr);
} else {
tcg_gen_exit_tb(tcg_ctx, 0);
}
s->is_jmp = DISAS_TB_JUMP;
}
static inline void
gen_eob_worker(DisasContext *s, bool inhibit, bool recheck_tf)
{
TCGv unused;
TCGV_UNUSED(unused);
do_gen_eob_worker(s, inhibit, recheck_tf, unused);
}
/* End of block.
If INHIBIT, set HF_INHIBIT_IRQ_MASK if it isn't already set. */
static void gen_eob_inhibit_irq(DisasContext *s, bool inhibit)
@ -2887,6 +2904,12 @@ static void gen_eob(DisasContext *s)
gen_eob_worker(s, false, false);
}
/* Jump to register */
static void gen_jr(DisasContext *s, TCGv dest)
{
do_gen_eob_worker(s, false, false, dest);
}
/* generate a jump to eip. No segment change must happen before as a
direct call to the next block may occur */
static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num)