target: e2k: Fix instr return.

This commit is contained in:
Denis Drakhnia 2020-11-28 11:32:50 +02:00
parent 038eb6f4ff
commit 963288c9d2
4 changed files with 28 additions and 4 deletions

View File

@ -192,6 +192,25 @@ static inline void do_call(CPUE2KState *env, int wbs, target_ulong pc_next)
reset_ctprs(env);
}
uint64_t helper_prep_return(CPUE2KState *env, int ipd)
{
uint64_t pc, ret = 0;
void *p;
if (env->pcsp.index < 32) {
helper_raise_exception(env, E2K_EXCP_MAPERR);
return 0;
}
p = (void *) env->pcsp.base + env->pcsp.index - 24;
memcpy(&pc, p, 8);
ret |= deposit64(ret, CTPR_BASE_OFF, CTPR_BASE_LEN, pc);
ret |= deposit64(ret, CTPR_TAG_OFF, CTPR_TAG_LEN, CTPR_TAG_RETURN);
ret |= deposit64(ret, CTPR_IPD_OFF, CTPR_IPD_LEN, ipd);
return ret;
}
void helper_return(CPUE2KState *env)
{
uint32_t new_wd_size, new_wd_base, offset;

View File

@ -1,5 +1,6 @@
DEF_HELPER_2(raise_exception, noreturn, env, int)
DEF_HELPER_1(debug, void, env)
DEF_HELPER_2(prep_return, i64, env, int)
DEF_HELPER_1(return, void, env)
DEF_HELPER_4(call, void, env, i64, int, tl)
DEF_HELPER_2(sxt, i64, i64, i64)

View File

@ -382,7 +382,6 @@ static inline void do_branch(DisasContext *ctx, target_ulong pc_next)
gen_goto_ctpr_disp(ctx->ct.u.ctpr);
gen_set_label(l1);
// FIXME: gdb does not see IP change
gen_helper_return(cpu_env);
tcg_gen_lookup_and_goto_ptr();
break;

View File

@ -296,9 +296,14 @@ static void gen_cs0(DisasContext *dc)
lowermost ones are undefined, while the latter also known as "type"
field should be filled in with zeroes. */
if (type == RETURN) {
uint64_t reg = ((uint64_t) CTPR_TAG_RETURN << CTPR_TAG_OFF) |
((uint64_t) ipd << CTPR_IPD_OFF);
tcg_gen_movi_tl(e2k_cs.ctprs[ctpr - 1], reg);
TCGv_i32 t0 = tcg_const_i32(ipd);
if (ctpr != 3) {
e2k_tr_gen_exception(dc, E2K_EXCP_ILLOPN);
}
gen_helper_prep_return(e2k_cs.ctprs[2], cpu_env, t0);
tcg_temp_free_i32(t0);
}
/* GETTSD has as meaningless `CS0.param' as RETURN. The only