tcg/e2k: refactor movtd ctpr

This commit is contained in:
Denis Drakhnia 2024-03-20 10:44:00 +02:00
parent 03546ab0bc
commit 72a7184ef4
1 changed files with 16 additions and 18 deletions

View File

@ -838,25 +838,23 @@ static void tcg_out_alf2_rr(TCGContext *s, int alc, AlcOpc opc,
tcg_out_alf(s, alc, opc, GPR(dst), 0, GPR(src2), 0);
}
static void tcg_out_alf2_cr(TCGContext *s, int alc, AlcOpc opc,
CtprReg dst, TCGReg src2)
{
tcg_out_alf(s, alc, opc, CTPR(dst), 0, GPR(src2), 0);
}
static void tcg_out_alf2_ci(TCGContext *s, int alc, AlcOpc opc,
CtprReg dst, int64_t src2)
{
tcg_out_alf_lit(s, alc, opc, CTPR(dst), 0, src2, true, 0);
}
static void tcg_out_alf21_rrir(TCGContext *s, int alc, AlcOpc opc,
TCGReg dst, TCGReg src1, TCGArg src2, TCGReg src3)
{
tcg_out_alf_lit(s, alc, opc, GPR(dst), GPR(src1), src2, true, GPR(src3));
}
static void tcg_out_insn_prep(TCGContext *s, CtprReg dst, int32_t offset)
static void tcg_out_prep_addr(TCGContext *s, CtprReg dst, int64_t src2)
{
tcg_out_alf_lit(s, 0, ALC_MOVTD_CTPR, CTPR(dst), 0, src2, true, 0);
}
static void tcg_out_prep_gpr(TCGContext *s, CtprReg dst, TCGReg src2)
{
tcg_out_alf(s, 0, ALC_MOVTD_CTPR, CTPR(dst), 0, GPR(src2), 0);
}
static void tcg_out_prep_disp(TCGContext *s, CtprReg dst, int32_t offset)
{
Bundle bundle;
tcg_out_start(&bundle);
@ -1227,10 +1225,10 @@ static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool tail)
if (offset == (int32_t) offset) {
/* short jump +/-1GiB */
tcg_out_insn_prep(s, CTPR1, offset);
tcg_out_prep_disp(s, CTPR1, offset);
} else {
/* far jump: 64-bit */
tcg_out_alf2_ci(s, 0, ALC_MOVTD_CTPR, CTPR1, (int64_t) arg);
tcg_out_prep_addr(s, CTPR1, (int64_t) arg);
}
tcg_out_start(&bundle);
@ -1580,13 +1578,13 @@ static void tcg_out_goto_tb(TCGContext *s, int which)
{
/* Direct branch will be patched by tb_target_set_jmp_target. */
set_jmp_insn_offset(s, which);
tcg_out_insn_prep(s, CTPR1, 0);
tcg_out_prep_disp(s, CTPR1, 0);
tcg_out_ct(s, CTPR1, CT_ALWAYS, 0);
/* When branch is out of range, fall through to indirect. */
AlcOpc opc = TCG_TYPE_PTR == TCG_TYPE_I32 ? ALC_LW : ALC_LD;
tcg_out_alf1_rii(s, 0, opc, TCG_REG_TMP0, 0, get_jmp_target_addr(s, which));
tcg_out_alf2_cr(s, 0, ALC_MOVTD_CTPR, CTPR1, TCG_REG_TMP0);
tcg_out_prep_gpr(s, CTPR1, TCG_REG_TMP0);
tcg_out_ct(s, CTPR1, CT_ALWAYS, 0);
set_jmp_reset_offset(s, which);
}
@ -1622,7 +1620,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
switch (opc) {
case INDEX_op_goto_ptr:
tcg_out_alf2_cr(s, 0, ALC_MOVTD_CTPR, CTPR1, a0);
tcg_out_prep_gpr(s, CTPR1, a0);
tcg_out_ct(s, CTPR1, CT_ALWAYS, 0);
break;