tcg/e2k: refactor exit_tb

This commit is contained in:
Denis Drakhnia 2024-03-23 09:34:45 +02:00
parent efad21f957
commit f6dc2e8270
1 changed files with 23 additions and 15 deletions

View File

@ -1312,6 +1312,14 @@ static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool tail)
e2k_out_call(&bundle, CTPR1, CT_ALWAYS, 0);
}
e2k_out_end(s, &bundle);
/* Always keep ctpr3 with a return address */
if (!tail) {
e2k_out_start(&bundle);
e2k_out_prep_return(&bundle);
bundle.latency = 1;
e2k_out_end(s, &bundle);
}
}
static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg,
@ -1648,17 +1656,13 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data_reg, TCGReg addr_reg,
}
}
static const tcg_insn_unit *tb_ret_addr;
static void tcg_out_exit_tb(TCGContext *s, uintptr_t a0)
{
/* Reuse the zeroing that exists for goto_ptr. */
if (a0 == 0) {
tcg_out_call_int(s, tcg_code_gen_epilogue, true);
} else {
tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_R0, a0);
tcg_out_call_int(s, tb_ret_addr, true);
}
Bundle bundle;
e2k_out_start(&bundle);
e2k_out_movi(&bundle, TCG_TYPE_REG, TCG_REG_R0, a0);
e2k_out_ct(&bundle, CTPR3, CT_ALWAYS, 0);
e2k_out_end(s, &bundle);
}
static void tcg_out_goto_tb(TCGContext *s, int which)
@ -2214,6 +2218,14 @@ static void tcg_target_qemu_prologue(TCGContext *s)
e2k_out_movi(&bundle, 2, TCG_GUEST_BASE_REG, guest_base);
tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG);
#endif
int latency = bundle.latency - 1;
bundle.latency = 1;
e2k_out_end(s, &bundle);
/* Always keep ctpr3 with a return address */
e2k_out_start(&bundle);
e2k_out_prep_return(&bundle);
bundle.latency = latency;
e2k_out_end(s, &bundle);
e2k_out_start(&bundle);
@ -2226,16 +2238,12 @@ static void tcg_target_qemu_prologue(TCGContext *s)
/* Return path for goto_ptr. Set return value to 0 */
tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr);
tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_R0, 0);
/* TB epilogue */
tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr);
e2k_out_start(&bundle);
e2k_out_prep_return(&bundle);
e2k_out_movi(&bundle, TCG_TYPE_REG, TCG_REG_R0, 0);
e2k_out_ct(&bundle, CTPR3, CT_ALWAYS, 0);
e2k_out_end(s, &bundle);
tcg_out_ct(s, CTPR3, CT_ALWAYS, 0);
}
static void tcg_target_init(TCGContext *s)