target: e2k: Add basic getsp instr.

This commit is contained in:
Denis Drakhnia 2020-11-15 20:25:40 +02:00
parent 89b9789906
commit a7e726dcb4
4 changed files with 22 additions and 13 deletions

View File

@ -70,6 +70,8 @@ void e2k_tcg_initialize(void);
#define PSP_LO_WRITE_OFF 60
#define PSP_LO_WRITE_BIT (1UL << PSP_LO_WRITE_OFF)
#define PSHTP
#define CR1_HI_BR_OFF 0
#define CR1_HI_BR_END 27
#define CR1_HI_BR_LEN (CR1_HI_BR_END - CR1_HI_BR_OFF + 1)
@ -173,6 +175,7 @@ typedef struct {
/* Procedure stack pointer (for regs) */
uint64_t psp_lo;
uint64_t psp_hi;
uint64_t pshtp;
uint64_t lsr; /* loop status register */

View File

@ -60,7 +60,7 @@ static inline void do_call(CPUE2KState *env, target_ulong ctpr)
new_wbs = (wbs + env->call_wbs) % WREGS_SIZE;
new_wsz = wsz - env->call_wbs;
if (wsz < 0) {
if (new_wsz < 0) {
/* TODO: SIGSEGV */
abort();
}
@ -259,3 +259,15 @@ void helper_save_pcur(CPUE2KState *env, int pcur)
BR_PCUR_LEN
);
}
uint64_t helper_getsp(CPUE2KState *env, uint64_t src2) {
uint64_t base = GET_FIELD(env->psp_lo, PSP_LO_BASE_OFF, PSP_LO_BASE_END);
base += src2;
/* TODO: stack overflow */
env->psp_lo = SET_FIELD(env->psp_lo, base, PSP_LO_BASE_OFF,
PSP_LO_BASE_LEN);
return base;
}

View File

@ -10,3 +10,4 @@ DEF_HELPER_2(state_reg_get, i64, env, int)
DEF_HELPER_3(state_reg_set, void, env, int, i64)
DEF_HELPER_2(save_rcur, void, env, int)
DEF_HELPER_2(save_pcur, void, env, int)
DEF_HELPER_2(getsp, i64, env, i64) /* FIXME: return tl? */

View File

@ -323,20 +323,13 @@ static inline void gen_rws(DisasContext *dc, int chan)
static void gen_getsp(DisasContext *dc, int chan)
{
// uint32_t als = dc->bundle.als[chan];
// TCGv_i64 src2 = get_src2(dc, als);
// TCGv_i64 t0 = tcg_temp_new_i64();
// TCGv_i64 t1 = tcg_temp_new_i64();
uint32_t als = dc->bundle.als[chan];
TCGv_i64 src2 = get_src2(dc, als);
TCGv_i64 t0 = e2k_get_temp_i64(dc);
abort();
gen_helper_getsp(t0, cpu_env, src2);
/* TODO: exception stack overflow */
// tcg_gen_extract_i64(t0, e2k_cs.usd_lo, 0, 48);
// tcg_gen_add_i64(t1, t0, src2);
// tcg_gen_deposit_i64(e2k_cs.usd_lo, e2k_cs.usd_lo, t1, 0, 48);
// tcg_temp_free_i64(t1);
// tcg_temp_free_i64(t0);
store_reg_alc_result(dc, chan, t0);
}
/* FIXME: movtd: don't know what it does */