target: e2k: Move ct cond to cpu env.

This commit is contained in:
Denis Drakhnia 2020-11-19 22:47:25 +02:00 committed by Alibek Omarov
parent 17d175a2d8
commit 31af59b8d5
5 changed files with 11 additions and 11 deletions

View File

@ -237,6 +237,7 @@ typedef struct {
/* control registers */
target_ulong ctprs[4]; // Control Transfer Preparation Register (CTPR)
target_ulong ct_cond;
/* special registers */
target_ulong ip; /* instruction address */

View File

@ -323,7 +323,7 @@ static inline void do_branch(DisasContext *ctx)
if (ctx->ct.has_cond) {
TCGLabel *l = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_NE, ctx->ct.cond, 0, l);
tcg_gen_brcondi_tl(TCG_COND_NE, e2k_cs.ct_cond, 0, l);
tcg_gen_movi_tl(e2k_cs.pc, ctx->npc);
tcg_gen_exit_tb(NULL, 0);
@ -337,7 +337,7 @@ static inline void do_branch(DisasContext *ctx)
case CT_JUMP:
ctx->base.is_jmp = DISAS_NORETURN;
gen_save_cpu_state(ctx);
gen_helper_jump(e2k_cs.pc, cpu_env, ctx->ct.cond, ctx->ct.u.ctpr);
gen_helper_jump(e2k_cs.pc, cpu_env, e2k_cs.ct_cond, ctx->ct.u.ctpr);
tcg_gen_lookup_and_goto_ptr();
break;
case CT_CALL:
@ -345,7 +345,7 @@ static inline void do_branch(DisasContext *ctx)
TCGv_i32 wbs = tcg_const_i32(ctx->ct.wbs);
ctx->base.is_jmp = DISAS_NORETURN;
gen_save_cpu_state(ctx);
gen_helper_call(e2k_cs.pc, cpu_env, ctx->ct.cond, ctx->ct.u.ctpr, wbs);
gen_helper_call(e2k_cs.pc, cpu_env, e2k_cs.ct_cond, ctx->ct.u.ctpr, wbs);
tcg_temp_free_i32(wbs);
tcg_gen_lookup_and_goto_ptr();
break;
@ -388,7 +388,7 @@ static void e2k_tr_tb_start(DisasContextBase *db, CPUState *cs)
{
DisasContext *ctx = container_of(db, DisasContext, base);
ctx->ct.cond = tcg_const_tl(1);
tcg_gen_movi_tl(e2k_cs.ct_cond, 1);
}
static void e2k_tr_insn_start(DisasContextBase *db, CPUState *cs)
@ -436,8 +436,6 @@ static void e2k_tr_tb_stop(DisasContextBase *db, CPUState *cs)
g_assert_not_reached();
break;
}
tcg_temp_free(ctx->ct.cond);
}
static void e2k_tr_disas_log(const DisasContextBase *db, CPUState *cpu)
@ -495,6 +493,7 @@ void e2k_tcg_initialize(void) {
static const struct { TCGv *ptr; int off; const char *name; } rtl[] = {
{ &e2k_cs.pc, offsetof(CPUE2KState, ip), "pc" },
{ &e2k_cs.npc, offsetof(CPUE2KState, nip), "npc" },
{ &e2k_cs.ct_cond, offsetof(CPUE2KState, ct_cond), "cond" },
};
unsigned int i;

View File

@ -58,6 +58,7 @@ typedef struct CPUE2KStateTCG {
TCGv pc;
TCGv npc;
TCGv ctprs[4];
TCGv ct_cond;
TCGv_i64 lsr;
TCGv_i64 wregs[WREGS_SIZE];
TCGv_i64 gregs[GREGS_SIZE];
@ -124,7 +125,6 @@ typedef enum {
typedef struct {
bool has_cond;
TCGv cond;
ControlTransferType type;
union {
target_ulong target;

View File

@ -546,7 +546,7 @@ static void execute_alopf_simple(DisasContext *dc, int chan)
break;
}
case 0x40: // TODO: udivs used as temporary UD
e2k_gen_exception(dc, E2K_EXCP_UNIMPL);
e2k_gen_exception(dc, 0);
break;
case 0x61:
if (chan == 2 || chan == 5) {

View File

@ -102,7 +102,7 @@ static inline void gen_cur_dec(DisasContext *ctx, TCGv_i32 ret, int cond,
TCGv_i32 t0 = tcg_const_i32(n);
TCGv_i32 t1 = tcg_temp_new_i32();
tcg_gen_trunc_tl_i32(c, ctx->ct.cond);
tcg_gen_trunc_tl_i32(c, e2k_cs.ct_cond);
gen_helper_cur_dec(t1, cpu_env, cur, t0, size);
gen_movcond_flag_i32(ret, cond, c, t1, cur);
@ -126,7 +126,7 @@ void e2k_commit_stubs(DisasContext *ctx)
TCGv_i64 t0 = tcg_temp_new_i64();
gen_lcnt_dec(t0, e2k_cs.lsr);
gen_movcond_flag_i64(e2k_cs.lsr, alc, ctx->ct.cond, t0, e2k_cs.lsr);
gen_movcond_flag_i64(e2k_cs.lsr, alc, e2k_cs.ct_cond, t0, e2k_cs.lsr);
tcg_temp_free_i64(t0);
}
@ -504,7 +504,7 @@ static void gen_jmp(DisasContext *dc)
TCGv preg = tcg_temp_new();
TCGv loop_end = tcg_temp_new();
TCGv not_loop_end = tcg_temp_new();
TCGv cond = dc->ct.cond;
TCGv cond = e2k_cs.ct_cond;
TCGv_i64 t0 = tcg_temp_new_i64();
e2k_gen_preg(t0, psrc);