mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-24 00:25:42 +00:00
target/mips: Move MXU_EN check one level higher
Move MXU_EN check to the main MXU decoding function, to avoid code repetition. Backports commit e5bf8a08293a1c576f8b6094f4deae7bdafceade from qemu
This commit is contained in:
parent
f2c3e173ad
commit
702abac53f
|
@ -24251,23 +24251,16 @@ static void gen_mxu_s8ldd(DisasContext *ctx)
|
|||
{
|
||||
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
|
||||
TCGv t0, t1;
|
||||
TCGLabel *l0;
|
||||
uint32_t XRa, Rb, s8, optn3;
|
||||
|
||||
t0 = tcg_temp_new(tcg_ctx);
|
||||
t1 = tcg_temp_new(tcg_ctx);
|
||||
|
||||
l0 = gen_new_label(tcg_ctx);
|
||||
|
||||
XRa = extract32(ctx->opcode, 6, 4);
|
||||
s8 = extract32(ctx->opcode, 10, 8);
|
||||
optn3 = extract32(ctx->opcode, 18, 3);
|
||||
Rb = extract32(ctx->opcode, 21, 5);
|
||||
|
||||
gen_load_mxu_cr(ctx, t0);
|
||||
tcg_gen_andi_tl(tcg_ctx, t0, t0, MXU_CR_MXU_EN);
|
||||
tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_NE, t0, MXU_CR_MXU_EN, l0);
|
||||
|
||||
gen_load_gpr(ctx, t0, Rb);
|
||||
tcg_gen_addi_tl(tcg_ctx, t0, t0, (int8_t)s8);
|
||||
|
||||
|
@ -24325,8 +24318,6 @@ static void gen_mxu_s8ldd(DisasContext *ctx)
|
|||
|
||||
gen_store_mxu_gpr(ctx, t0, XRa);
|
||||
|
||||
gen_set_label(tcg_ctx, l0);
|
||||
|
||||
tcg_temp_free(tcg_ctx, t0);
|
||||
tcg_temp_free(tcg_ctx, t1);
|
||||
}
|
||||
|
@ -24338,7 +24329,6 @@ static void gen_mxu_d16mul(DisasContext *ctx)
|
|||
{
|
||||
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
|
||||
TCGv t0, t1, t2, t3;
|
||||
TCGLabel *l0;
|
||||
uint32_t XRa, XRb, XRc, XRd, optn2;
|
||||
|
||||
t0 = tcg_temp_new(tcg_ctx);
|
||||
|
@ -24346,18 +24336,12 @@ static void gen_mxu_d16mul(DisasContext *ctx)
|
|||
t2 = tcg_temp_new(tcg_ctx);
|
||||
t3 = tcg_temp_new(tcg_ctx);
|
||||
|
||||
l0 = gen_new_label(tcg_ctx);
|
||||
|
||||
XRa = extract32(ctx->opcode, 6, 4);
|
||||
XRb = extract32(ctx->opcode, 10, 4);
|
||||
XRc = extract32(ctx->opcode, 14, 4);
|
||||
XRd = extract32(ctx->opcode, 18, 4);
|
||||
optn2 = extract32(ctx->opcode, 22, 2);
|
||||
|
||||
gen_load_mxu_cr(ctx, t0);
|
||||
tcg_gen_andi_tl(tcg_ctx, t0, t0, MXU_CR_MXU_EN);
|
||||
tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_NE, t0, MXU_CR_MXU_EN, l0);
|
||||
|
||||
gen_load_mxu_gpr(ctx, t1, XRb);
|
||||
tcg_gen_sextract_tl(tcg_ctx, t0, t1, 0, 16);
|
||||
tcg_gen_sextract_tl(tcg_ctx, t1, t1, 16, 16);
|
||||
|
@ -24386,8 +24370,6 @@ static void gen_mxu_d16mul(DisasContext *ctx)
|
|||
gen_store_mxu_gpr(ctx, t3, XRa);
|
||||
gen_store_mxu_gpr(ctx, t2, XRd);
|
||||
|
||||
gen_set_label(tcg_ctx, l0);
|
||||
|
||||
tcg_temp_free(tcg_ctx, t0);
|
||||
tcg_temp_free(tcg_ctx, t1);
|
||||
tcg_temp_free(tcg_ctx, t2);
|
||||
|
@ -24402,7 +24384,6 @@ static void gen_mxu_d16mac(DisasContext *ctx)
|
|||
{
|
||||
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
|
||||
TCGv t0, t1, t2, t3;
|
||||
TCGLabel *l0;
|
||||
uint32_t XRa, XRb, XRc, XRd, optn2, aptn2;
|
||||
|
||||
t0 = tcg_temp_new(tcg_ctx);
|
||||
|
@ -24410,8 +24391,6 @@ static void gen_mxu_d16mac(DisasContext *ctx)
|
|||
t2 = tcg_temp_new(tcg_ctx);
|
||||
t3 = tcg_temp_new(tcg_ctx);
|
||||
|
||||
l0 = gen_new_label(tcg_ctx);
|
||||
|
||||
XRa = extract32(ctx->opcode, 6, 4);
|
||||
XRb = extract32(ctx->opcode, 10, 4);
|
||||
XRc = extract32(ctx->opcode, 14, 4);
|
||||
|
@ -24419,10 +24398,6 @@ static void gen_mxu_d16mac(DisasContext *ctx)
|
|||
optn2 = extract32(ctx->opcode, 22, 2);
|
||||
aptn2 = extract32(ctx->opcode, 24, 2);
|
||||
|
||||
gen_load_mxu_cr(ctx, t0);
|
||||
tcg_gen_andi_tl(tcg_ctx, t0, t0, MXU_CR_MXU_EN);
|
||||
tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_NE, t0, MXU_CR_MXU_EN, l0);
|
||||
|
||||
gen_load_mxu_gpr(ctx, t1, XRb);
|
||||
tcg_gen_sextract_tl(tcg_ctx, t0, t1, 0, 16);
|
||||
tcg_gen_sextract_tl(tcg_ctx, t1, t1, 16, 16);
|
||||
|
@ -24473,8 +24448,6 @@ static void gen_mxu_d16mac(DisasContext *ctx)
|
|||
gen_store_mxu_gpr(ctx, t3, XRa);
|
||||
gen_store_mxu_gpr(ctx, t2, XRd);
|
||||
|
||||
gen_set_label(tcg_ctx, l0);
|
||||
|
||||
tcg_temp_free(tcg_ctx, t0);
|
||||
tcg_temp_free(tcg_ctx, t1);
|
||||
tcg_temp_free(tcg_ctx, t2);
|
||||
|
@ -24489,7 +24462,6 @@ static void gen_mxu_q8mul_q8mulsu(DisasContext *ctx)
|
|||
{
|
||||
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
|
||||
TCGv t0, t1, t2, t3, t4, t5, t6, t7;
|
||||
TCGLabel *l0;
|
||||
uint32_t XRa, XRb, XRc, XRd, sel;
|
||||
|
||||
t0 = tcg_temp_new(tcg_ctx);
|
||||
|
@ -24501,18 +24473,12 @@ static void gen_mxu_q8mul_q8mulsu(DisasContext *ctx)
|
|||
t6 = tcg_temp_new(tcg_ctx);
|
||||
t7 = tcg_temp_new(tcg_ctx);
|
||||
|
||||
l0 = gen_new_label(tcg_ctx);
|
||||
|
||||
XRa = extract32(ctx->opcode, 6, 4);
|
||||
XRb = extract32(ctx->opcode, 10, 4);
|
||||
XRc = extract32(ctx->opcode, 14, 4);
|
||||
XRd = extract32(ctx->opcode, 18, 4);
|
||||
sel = extract32(ctx->opcode, 22, 2);
|
||||
|
||||
gen_load_mxu_cr(ctx, t0);
|
||||
tcg_gen_andi_tl(tcg_ctx, t0, t0, MXU_CR_MXU_EN);
|
||||
tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_NE, t0, MXU_CR_MXU_EN, l0);
|
||||
|
||||
gen_load_mxu_gpr(ctx, t3, XRb);
|
||||
gen_load_mxu_gpr(ctx, t7, XRc);
|
||||
|
||||
|
@ -24563,8 +24529,6 @@ static void gen_mxu_q8mul_q8mulsu(DisasContext *ctx)
|
|||
gen_store_mxu_gpr(ctx, t0, XRd);
|
||||
gen_store_mxu_gpr(ctx, t1, XRa);
|
||||
|
||||
gen_set_label(tcg_ctx, l0);
|
||||
|
||||
tcg_temp_free(tcg_ctx, t0);
|
||||
tcg_temp_free(tcg_ctx, t1);
|
||||
tcg_temp_free(tcg_ctx, t2);
|
||||
|
@ -24583,23 +24547,16 @@ static void gen_mxu_s32ldd_s32lddr(DisasContext *ctx)
|
|||
{
|
||||
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
|
||||
TCGv t0, t1;
|
||||
TCGLabel *l0;
|
||||
uint32_t XRa, Rb, s12, sel;
|
||||
|
||||
t0 = tcg_temp_new(tcg_ctx);
|
||||
t1 = tcg_temp_new(tcg_ctx);
|
||||
|
||||
l0 = gen_new_label(tcg_ctx);
|
||||
|
||||
XRa = extract32(ctx->opcode, 6, 4);
|
||||
s12 = extract32(ctx->opcode, 10, 10);
|
||||
sel = extract32(ctx->opcode, 20, 1);
|
||||
Rb = extract32(ctx->opcode, 21, 5);
|
||||
|
||||
gen_load_mxu_cr(ctx, t0);
|
||||
tcg_gen_andi_tl(tcg_ctx, t0, t0, MXU_CR_MXU_EN);
|
||||
tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_NE, t0, MXU_CR_MXU_EN, l0);
|
||||
|
||||
gen_load_gpr(ctx, t0, Rb);
|
||||
|
||||
tcg_gen_movi_tl(tcg_ctx, t1, s12);
|
||||
|
@ -24616,8 +24573,6 @@ static void gen_mxu_s32ldd_s32lddr(DisasContext *ctx)
|
|||
}
|
||||
gen_store_mxu_gpr(ctx, t1, XRa);
|
||||
|
||||
gen_set_label(tcg_ctx, l0);
|
||||
|
||||
tcg_temp_free(tcg_ctx, t0);
|
||||
tcg_temp_free(tcg_ctx, t1);
|
||||
}
|
||||
|
@ -25513,6 +25468,7 @@ static void decode_opc_mxu__pool20(CPUMIPSState *env, DisasContext *ctx)
|
|||
*/
|
||||
static void decode_opc_mxu(CPUMIPSState *env, DisasContext *ctx)
|
||||
{
|
||||
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
|
||||
/*
|
||||
* TODO: Investigate necessity of including handling of
|
||||
* CLZ, CLO, SDBB in this function, as they belong to
|
||||
|
@ -25543,6 +25499,14 @@ static void decode_opc_mxu(CPUMIPSState *env, DisasContext *ctx)
|
|||
return;
|
||||
}
|
||||
|
||||
{
|
||||
TCGv t_mxu_cr = tcg_temp_new(tcg_ctx);
|
||||
TCGLabel *l_exit = gen_new_label(tcg_ctx);
|
||||
|
||||
gen_load_mxu_cr(ctx, t_mxu_cr);
|
||||
tcg_gen_andi_tl(tcg_ctx, t_mxu_cr, t_mxu_cr, MXU_CR_MXU_EN);
|
||||
tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_NE, t_mxu_cr, MXU_CR_MXU_EN, l_exit);
|
||||
|
||||
switch (opcode) {
|
||||
case OPC_MXU_S32MADD:
|
||||
/* TODO: Implement emulation of S32MADD instruction. */
|
||||
|
@ -25770,6 +25734,10 @@ static void decode_opc_mxu(CPUMIPSState *env, DisasContext *ctx)
|
|||
MIPS_INVAL("decode_opc_mxu");
|
||||
generate_exception_end(ctx, EXCP_RI);
|
||||
}
|
||||
|
||||
gen_set_label(tcg_ctx, l_exit);
|
||||
tcg_temp_free(tcg_ctx, t_mxu_cr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue