target: e2k: Fix udivs exception hack.

This commit is contained in:
Denis Drakhnia 2020-12-14 09:22:21 +02:00
parent d3739540cb
commit f0f36b5c78
7 changed files with 41 additions and 15 deletions

View File

@ -143,8 +143,10 @@ void e2k_cpu_dump_state(CPUState *cs, FILE *f, int flags)
CPUE2KState *env = &cpu->env;
unsigned int i;
qemu_fprintf(f, "cr0_lo/pf = 0x%016lx\n", env->cr0_lo);
qemu_fprintf(f, "cr0_hi/ip = 0x%016lx\n", env->cr0_hi);
qemu_fprintf(f, " ip = 0x%016lx\n", env->ip);
qemu_fprintf(f, " pregs = 0x%016lx\n", env->pregs);
qemu_fprintf(f, " cr0_lo = 0x%016lx\n", env->cr0_lo);
qemu_fprintf(f, " cr0_hi = 0x%016lx\n", env->cr0_hi);
qemu_fprintf(f, " cr1_lo = 0x%016lx\n", e2k_state_cr1_lo(env));
qemu_fprintf(f, " cr1_hi = 0x%016lx\n", e2k_state_cr1_hi(env));
qemu_fprintf(f, " pcsp_lo = 0x%016lx\n", e2k_state_pcsp_lo(env));

View File

@ -261,6 +261,13 @@ void helper_raise_exception(CPUE2KState *env, int tt)
cpu_loop_exit(cs);
}
void HELPER(raise_exception_no_spill)(CPUE2KState *env, int tt)
{
CPUState *cs = env_cpu(env);
cs->exception_index = tt;
cpu_loop_exit(cs);
}
void e2k_break_save_state(CPUE2KState *env)
{
env->is_bp = true;

View File

@ -1,4 +1,5 @@
DEF_HELPER_2(raise_exception, noreturn, env, int)
DEF_HELPER_2(raise_exception_no_spill, noreturn, env, int)
DEF_HELPER_1(debug, void, env)
DEF_HELPER_2(prep_return, i64, env, int)
DEF_HELPER_1(return, void, env)

View File

@ -226,6 +226,17 @@ void e2k_tr_gen_exception(DisasContext *ctx, int which)
tcg_temp_free_i32(t);
}
void e2k_tr_gen_exception_no_spill(DisasContext *ctx, int excp)
{
TCGv_i32 t0 = tcg_const_i32(excp);
e2k_gen_save_cpu_state(ctx);
gen_helper_raise_exception_no_spill(cpu_env, t0);
ctx->base.is_jmp = DISAS_NORETURN;
tcg_temp_free_i32(t0);
}
static inline void gen_ctpr_tag(TCGv_i64 ret, TCGv_i64 ctpr)
{
tcg_gen_extract_i64(ret, ctpr, CTPR_TAG_OFF, CTPR_TAG_LEN);

View File

@ -200,6 +200,7 @@ typedef struct DisasContext {
/* exception generated in translation time */
void e2k_tr_gen_exception(DisasContext *dc, int which);
void e2k_tr_gen_exception_no_spill(DisasContext *ctx, int excp);
/* exception generated in runtime */
static inline void e2k_gen_exception(int excp)
@ -212,6 +213,7 @@ static inline void e2k_gen_exception(int excp)
tcg_temp_free_i32(t0);
}
#define e2k_todo(ctx, fmt, ...) \
do { \
if (unlikely(qemu_loglevel_mask(LOG_UNIMP))) { \
@ -224,8 +226,8 @@ static inline void e2k_gen_exception(int excp)
#define e2k_todo_illop(ctx, fmt, ...) \
do { \
e2k_todo(ctx, fmt, ## __VA_ARGS__); \
e2k_tr_gen_exception(ctx, E2K_EXCP_ILLOPC); \
e2k_todo(ctx, fmt, ## __VA_ARGS__); \
e2k_tr_gen_exception(ctx, E2K_EXCP_ILLOPC); \
} while (0)
static inline void e2k_gen_mask_i64(TCGv_i64 ret, TCGv_i64 len)

View File

@ -2036,11 +2036,10 @@ static void execute_ext_00(DisasContext *ctx, Instr *instr)
case 0x40:
if (chan == 5) {
// FIXME: temp hack
TCGLabel *l0 = gen_new_label();
Src64 s2 = get_src2_i64(ctx, chan);
tcg_gen_brcondi_i64(TCG_COND_NE, s2.value, 0, l0);
e2k_gen_exception(0);
gen_set_label(l0);
if (instr->src2 == 0xc0) {
e2k_tr_gen_exception_no_spill(ctx, 0);
return;
}
/* udivs */
gen_alopf1_tag_i32(ctx, chan, gen_udivs);

View File

@ -134,12 +134,11 @@ static void gen_advance_loop_counters(void)
void e2k_stubs_commit(DisasContext *ctx)
{
uint32_t ss = ctx->bundle.ss;
// unsigned int vfdi = (ss & 0x04000000) >> 26;
// unsigned int abg = (ss & 0x01800000) >> 23;
int alc = GET_FIELD(ss, 16, 2);
int abp = GET_FIELD(ss, 18, 2);
int abn = GET_FIELD(ss, 21, 2);
int abg = GET_FIELD(ss, 23, 2);
int alc = extract32(ss, 16, 2);
int abp = extract32(ss, 18, 2);
int abn = extract32(ss, 21, 2);
int abg = extract32(ss, 23, 2);
int vfdi = extract32(ss, 26, 1);
if (alc) {
TCGLabel *l0 = gen_new_label();
@ -165,6 +164,11 @@ void e2k_stubs_commit(DisasContext *ctx)
// TODO: impl abg
e2k_todo_illop(ctx, "abg");
}
if (vfdi != 0) {
// TODO: impl vfdi
e2k_todo_illop(ctx, "vfdi");
}
}
static void gen_cs0(DisasContext *dc)