mirror of https://github.com/xemu-project/xemu.git
target/m68k: Convert to TranslatorOps
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20180512050250.12774-8-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
a575cbe01c
commit
11ab74b01e
|
@ -6059,80 +6059,72 @@ static void disas_m68k_insn(CPUM68KState * env, DisasContext *s)
|
||||||
do_release(s);
|
do_release(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generate intermediate code for basic block 'tb'. */
|
static void m68k_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu)
|
||||||
void gen_intermediate_code(CPUState *cs, TranslationBlock *tb)
|
|
||||||
{
|
{
|
||||||
CPUM68KState *env = cs->env_ptr;
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
||||||
DisasContext dc1, *dc = &dc1;
|
CPUM68KState *env = cpu->env_ptr;
|
||||||
target_ulong pc_start;
|
|
||||||
int pc_offset;
|
|
||||||
int num_insns;
|
|
||||||
int max_insns;
|
|
||||||
|
|
||||||
/* generate intermediate code */
|
|
||||||
pc_start = tb->pc;
|
|
||||||
|
|
||||||
dc->base.tb = tb;
|
|
||||||
|
|
||||||
dc->env = env;
|
dc->env = env;
|
||||||
dc->base.is_jmp = DISAS_NEXT;
|
dc->pc = dc->base.pc_first;
|
||||||
dc->pc = pc_start;
|
|
||||||
dc->cc_op = CC_OP_DYNAMIC;
|
dc->cc_op = CC_OP_DYNAMIC;
|
||||||
dc->cc_op_synced = 1;
|
dc->cc_op_synced = 1;
|
||||||
dc->base.singlestep_enabled = cs->singlestep_enabled;
|
|
||||||
dc->done_mac = 0;
|
dc->done_mac = 0;
|
||||||
dc->writeback_mask = 0;
|
dc->writeback_mask = 0;
|
||||||
num_insns = 0;
|
|
||||||
max_insns = tb_cflags(tb) & CF_COUNT_MASK;
|
|
||||||
if (max_insns == 0) {
|
|
||||||
max_insns = CF_COUNT_MASK;
|
|
||||||
}
|
|
||||||
if (max_insns > TCG_MAX_INSNS) {
|
|
||||||
max_insns = TCG_MAX_INSNS;
|
|
||||||
}
|
|
||||||
|
|
||||||
init_release_array(dc);
|
init_release_array(dc);
|
||||||
|
}
|
||||||
|
|
||||||
gen_tb_start(tb);
|
static void m68k_tr_tb_start(DisasContextBase *dcbase, CPUState *cpu)
|
||||||
do {
|
{
|
||||||
pc_offset = dc->pc - pc_start;
|
}
|
||||||
tcg_gen_insn_start(dc->pc, dc->cc_op);
|
|
||||||
num_insns++;
|
|
||||||
|
|
||||||
if (unlikely(cpu_breakpoint_test(cs, dc->pc, BP_ANY))) {
|
static void m68k_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu)
|
||||||
gen_exception(dc, dc->pc, EXCP_DEBUG);
|
{
|
||||||
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
||||||
|
tcg_gen_insn_start(dc->base.pc_next, dc->cc_op);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool m68k_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu,
|
||||||
|
const CPUBreakpoint *bp)
|
||||||
|
{
|
||||||
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
||||||
|
|
||||||
|
gen_exception(dc, dc->base.pc_next, EXCP_DEBUG);
|
||||||
/* The address covered by the breakpoint must be included in
|
/* The address covered by the breakpoint must be included in
|
||||||
[tb->pc, tb->pc + tb->size) in order to for it to be
|
[tb->pc, tb->pc + tb->size) in order to for it to be
|
||||||
properly cleared -- thus we increment the PC here so that
|
properly cleared -- thus we increment the PC here so that
|
||||||
the logic setting tb->size below does the right thing. */
|
the logic setting tb->size below does the right thing. */
|
||||||
dc->pc += 2;
|
dc->base.pc_next += 2;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) {
|
return true;
|
||||||
gen_io_start();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
static void m68k_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
|
||||||
|
{
|
||||||
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
||||||
|
|
||||||
|
disas_m68k_insn(cpu->env_ptr, dc);
|
||||||
dc->base.pc_next = dc->pc;
|
dc->base.pc_next = dc->pc;
|
||||||
disas_m68k_insn(env, dc);
|
|
||||||
} while (!dc->base.is_jmp && !tcg_op_buf_full() &&
|
|
||||||
!cs->singlestep_enabled &&
|
|
||||||
!singlestep &&
|
|
||||||
(pc_offset) < (TARGET_PAGE_SIZE - 32) &&
|
|
||||||
num_insns < max_insns);
|
|
||||||
|
|
||||||
if (tb_cflags(tb) & CF_LAST_IO)
|
if (dc->base.is_jmp == DISAS_NEXT
|
||||||
gen_io_end();
|
&& dc->pc - dc->base.pc_first >= TARGET_PAGE_SIZE - 32) {
|
||||||
if (unlikely(cs->singlestep_enabled)) {
|
dc->base.is_jmp = DISAS_TOO_MANY;
|
||||||
/* Make sure the pc is updated, and raise a debug exception. */
|
|
||||||
if (!dc->base.is_jmp) {
|
|
||||||
update_cc_op(dc);
|
|
||||||
tcg_gen_movi_i32(QREG_PC, dc->pc);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void m68k_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
|
||||||
|
{
|
||||||
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
||||||
|
|
||||||
|
if (dc->base.is_jmp == DISAS_NORETURN) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dc->base.singlestep_enabled) {
|
||||||
gen_helper_raise_exception(cpu_env, tcg_const_i32(EXCP_DEBUG));
|
gen_helper_raise_exception(cpu_env, tcg_const_i32(EXCP_DEBUG));
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (dc->base.is_jmp) {
|
switch (dc->base.is_jmp) {
|
||||||
case DISAS_NEXT:
|
case DISAS_TOO_MANY:
|
||||||
update_cc_op(dc);
|
update_cc_op(dc);
|
||||||
gen_jmp_tb(dc, 0, dc->pc);
|
gen_jmp_tb(dc, 0, dc->pc);
|
||||||
break;
|
break;
|
||||||
|
@ -6140,32 +6132,36 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb)
|
||||||
/* We updated CC_OP and PC in gen_jmp/gen_jmp_im. */
|
/* We updated CC_OP and PC in gen_jmp/gen_jmp_im. */
|
||||||
tcg_gen_lookup_and_goto_ptr();
|
tcg_gen_lookup_and_goto_ptr();
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
case DISAS_EXIT:
|
case DISAS_EXIT:
|
||||||
/* We updated CC_OP and PC in gen_exit_tb, but also modified
|
/* We updated CC_OP and PC in gen_exit_tb, but also modified
|
||||||
other state that may require returning to the main loop. */
|
other state that may require returning to the main loop. */
|
||||||
tcg_gen_exit_tb(NULL, 0);
|
tcg_gen_exit_tb(NULL, 0);
|
||||||
break;
|
break;
|
||||||
case DISAS_NORETURN:
|
default:
|
||||||
/* nothing more to generate */
|
g_assert_not_reached();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gen_tb_end(tb, num_insns);
|
|
||||||
|
|
||||||
#ifdef DEBUG_DISAS
|
static void m68k_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu)
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
{
|
||||||
&& qemu_log_in_addr_range(pc_start)) {
|
qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first));
|
||||||
qemu_log_lock();
|
log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size);
|
||||||
qemu_log("----------------\n");
|
}
|
||||||
qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
|
||||||
log_target_disas(cs, pc_start, dc->pc - pc_start);
|
static const TranslatorOps m68k_tr_ops = {
|
||||||
qemu_log("\n");
|
.init_disas_context = m68k_tr_init_disas_context,
|
||||||
qemu_log_unlock();
|
.tb_start = m68k_tr_tb_start,
|
||||||
}
|
.insn_start = m68k_tr_insn_start,
|
||||||
#endif
|
.breakpoint_check = m68k_tr_breakpoint_check,
|
||||||
tb->size = dc->pc - pc_start;
|
.translate_insn = m68k_tr_translate_insn,
|
||||||
tb->icount = num_insns;
|
.tb_stop = m68k_tr_tb_stop,
|
||||||
|
.disas_log = m68k_tr_disas_log,
|
||||||
|
};
|
||||||
|
|
||||||
|
void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb)
|
||||||
|
{
|
||||||
|
DisasContext dc;
|
||||||
|
translator_loop(&m68k_tr_ops, &dc.base, cpu, tb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static double floatx80_to_double(CPUM68KState *env, uint16_t high, uint64_t low)
|
static double floatx80_to_double(CPUM68KState *env, uint16_t high, uint64_t low)
|
||||||
|
|
Loading…
Reference in New Issue