@@ -366,6 +366,7 @@ enum {
OPC_DCLO = 0x25 | OPC_SPECIAL2,
/* MXU */
OPC_MXU_D16MUL = 0x08 | OPC_SPECIAL2,
+ OPC_MXU_D16MAC = 0x0A | OPC_SPECIAL2,
OPC_MXU_S8LDD = 0x22 | OPC_SPECIAL2,
OPC_MXU_S32I2M = 0x2F | OPC_SPECIAL2,
OPC_MXU_S32M2I = 0x2E | OPC_SPECIAL2,
@@ -3806,6 +3807,17 @@ typedef union {
uint32_t sel:2;
uint32_t special2:6;
} D16MUL;
+
+ struct {
+ uint32_t op:6;
+ uint32_t xra:4;
+ uint32_t xrb:4;
+ uint32_t xrc:4;
+ uint32_t xrd:4;
+ uint32_t optn2:2;
+ uint32_t aptn2:2;
+ uint32_t special2:6;
+ } D16MAC;
} MXU_OPCODE;
/* MXU Instructions */
@@ -3932,6 +3944,59 @@ static void gen_mxu(DisasContext *ctx, uint32_t opc)
gen_store_mxu_gpr(t3, opcode->D16MUL.xra);
gen_store_mxu_gpr(t2, opcode->D16MUL.xrd);
break;
+
+ case OPC_MXU_D16MAC:
+ gen_load_mxu_gpr(t1, opcode->D16MAC.xrb);
+ tcg_gen_ext16s_tl(t0, t1);
+ tcg_gen_shri_tl(t1, t1, 16);
+ tcg_gen_ext16s_tl(t1, t1);
+ gen_load_mxu_gpr(t3, opcode->D16MAC.xrc);
+ tcg_gen_ext16s_tl(t2, t3);
+ tcg_gen_shri_tl(t3, t3, 16);
+ tcg_gen_ext16s_tl(t3, t3);
+
+ switch (opcode->D16MAC.optn2) {
+ case 0: /* XRB.H*XRC.H == lop, XRB.L*XRC.L == rop */
+ tcg_gen_mul_tl(t3, t1, t3);
+ tcg_gen_mul_tl(t2, t0, t2);
+ break;
+ case 1: /* XRB.L*XRC.H == lop, XRB.L*XRC.L == rop */
+ tcg_gen_mul_tl(t3, t0, t3);
+ tcg_gen_mul_tl(t2, t0, t2);
+ break;
+ case 2: /* XRB.H*XRC.H == lop, XRB.H*XRC.L == rop */
+ tcg_gen_mul_tl(t3, t1, t3);
+ tcg_gen_mul_tl(t2, t1, t2);
+ break;
+ case 3: /* XRB.L*XRC.H == lop, XRB.H*XRC.L == rop */
+ tcg_gen_mul_tl(t3, t0, t3);
+ tcg_gen_mul_tl(t2, t1, t2);
+ break;
+ }
+ gen_load_mxu_gpr(t0, opcode->D16MAC.xra);
+ gen_load_mxu_gpr(t1, opcode->D16MAC.xrd);
+
+ switch (opcode->D16MAC.aptn2) {
+ case 0:
+ tcg_gen_add_tl(t3, t0, t3);
+ tcg_gen_add_tl(t2, t1, t2);
+ break;
+ case 1:
+ tcg_gen_add_tl(t3, t0, t3);
+ tcg_gen_sub_tl(t2, t1, t2);
+ break;
+ case 2:
+ tcg_gen_sub_tl(t3, t0, t3);
+ tcg_gen_add_tl(t2, t1, t2);
+ break;
+ case 3:
+ tcg_gen_sub_tl(t3, t0, t3);
+ tcg_gen_sub_tl(t2, t1, t2);
+ break;
+ }
+ gen_store_mxu_gpr(t3, opcode->D16MAC.xra);
+ gen_store_mxu_gpr(t2, opcode->D16MAC.xrd);
+ break;
}
tcg_temp_free(t0);
@@ -18028,6 +18093,7 @@ static void decode_opc_special2_legacy(CPUMIPSState *env, DisasContext *ctx)
case OPC_MXU_S32M2I:
case OPC_MXU_S8LDD:
case OPC_MXU_D16MUL:
+ case OPC_MXU_D16MAC:
gen_mxu(ctx, op1);
break;
Adds support for emulating the D16MAC instruction. Signed-off-by: Craig Janeczek <jancraig@amazon.com> --- target/mips/translate.c | 66 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+)