tcg/e2k: zero extend address for 32-bit guests

This commit is contained in:
Denis Drakhnia 2024-04-01 16:46:00 +03:00
parent c0e179df44
commit 926300c9e6
3 changed files with 9 additions and 13 deletions

View File

@ -1374,7 +1374,7 @@ bool tcg_target_has_memory_bswap(MemOp memop)
/* We have three temps, we might as well expose them. */
static const TCGLdstHelperParam ldst_helper_param = {
.ntmp = 3, .tmp = { TCG_REG_TMP0, TCG_REG_TMP1, TCG_REG_TMP2 }
.ntmp = 4, .tmp = { TCG_REG_TMP0, TCG_REG_TMP1, TCG_REG_TMP2, TCG_REG_TMP3 }
};
static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l)
@ -1455,18 +1455,13 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, TCGReg *pbase,
e2k_out_ld(&bundle, 0, TCG_TYPE_PTR, TCG_REG_TMP0, TCG_AREG0, mask_ofs);
e2k_out_ld(&bundle, 2, TCG_TYPE_PTR, TCG_REG_TMP1, TCG_AREG0, table_ofs);
if (addr_type == TCG_TYPE_I32) {
e2k_out_alf2_rr(&bundle, 1, ALC_SXTW, TCG_REG_TMP2, addr_reg);
bundle.latency -= 1;
} else {
e2k_out_alf1_rri(&bundle, 1, ALC_SHRD, TCG_REG_TMP2, addr_reg,
s->page_bits - CPU_TLB_ENTRY_BITS);
e2k_out_alf2_rr(&bundle, 1, ALC_ZXTW, TCG_REG_TMP3, addr_reg);
addr_reg = TCG_REG_TMP3;
}
e2k_out_end(s, &bundle);
if (addr_type == TCG_TYPE_I32) {
tcg_out_alf1_rri(s, 0, ALC_SHRD, TCG_REG_TMP2, TCG_REG_TMP2,
s->page_bits - CPU_TLB_ENTRY_BITS);
}
tcg_out_alf1_rri(s, 0, ALC_SHRD, TCG_REG_TMP2, addr_reg,
s->page_bits - CPU_TLB_ENTRY_BITS);
tcg_out_alf1_rrr(s, 0, ALC_ANDD, TCG_REG_TMP2, TCG_REG_TMP2, TCG_REG_TMP0);
e2k_out_start(&bundle);
@ -1479,8 +1474,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, TCGReg *pbase,
addr_adj = addr_reg;
if (a_mask < s_mask) {
addr_adj = TCG_REG_TMP0;
e2k_out_alf1_rri(&bundle, 1, addr_type == TCG_TYPE_I32 ? ALC_ADDW : ALC_ADDD,
addr_adj, addr_reg, s_mask - a_mask);
e2k_out_alf1_rri(&bundle, 1, ALC_ADDD, addr_adj, addr_reg, s_mask - a_mask);
}
e2k_out_end(s, &bundle);
@ -2258,6 +2252,7 @@ static void tcg_target_init(TCGContext *s)
tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP0);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP1);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP2);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP3);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP);
}

View File

@ -53,6 +53,7 @@ typedef enum {
TCG_REG_TMP0 = TCG_REG_G31,
TCG_REG_TMP1 = TCG_REG_G30,
TCG_REG_TMP2 = TCG_REG_G29,
TCG_REG_TMP3 = TCG_REG_G28,
} TCGReg;
/* used for function call generation */

View File

@ -182,7 +182,7 @@ static int tcg_out_ldst_finalize(TCGContext *s);
typedef struct TCGLdstHelperParam {
TCGReg (*ra_gen)(TCGContext *s, const TCGLabelQemuLdst *l, int arg_reg);
unsigned ntmp;
int tmp[3];
int tmp[4];
} TCGLdstHelperParam;
static void tcg_out_ld_helper_args(TCGContext *s, const TCGLabelQemuLdst *l,