@samitouri / QOSamiQemu / commits / 55b69c355f

target/mips: add Octeon MTP instructions

Add the MTP0, MTP1, and MTP2 forms. MTP0 loads the low Octeon3 partial-product pair from rs/rt into P[0]/P[3], MTP1 loads the middle pair into P[1]/P[4], and MTP2 loads the high pair into P[2]/P[5]. For MTP0, also set P[1] to zero for backward compatibility with Octeon2 VMULU. Legacy single-source encodings have rt encoded as $zero, so the same translator path also preserves the older Octeon behavior. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: James Hilliard <james.hilliard1@gmail.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20260520172313.23777-20-philmd@linaro.org>

James Hilliard committed May 8, 2026 at 10:53 UTC 55b69c355fedbf18c23a05942fea6de14358b6f4
2 files changed +27
target/mips/tcg/octeon.decode
+4
@@ -51,6 +51,10 @@ MTM0 011100 ..... ..... 00000 00000 001000 @r2
51 MTM1 011100 ..... ..... 00000 00000 001100 @r2
52 MTM2 011100 ..... ..... 00000 00000 001101 @r2
53
54 +MTP0 011100 ..... ..... 00000 00000 001001 @r2
55 +MTP1 011100 ..... ..... 00000 00000 001010 @r2
56 +MTP2 011100 ..... ..... 00000 00000 001011 @r2
57 +
58 &saa base rt
59 @saa ...... base:5 rt:5 ................ &saa
60 SAA 011100 ..... ..... 00000 00000 011000 @saa
target/mips/tcg/octeon_translate.c
+23
@@ -241,3 +241,26 @@ static bool trans_mtm(DisasContext *ctx, arg_r2 *a, unsigned int index)
241 TRANS(MTM0, trans_mtm, 0);
242 TRANS(MTM1, trans_mtm, 1);
243 TRANS(MTM2, trans_mtm, 2);
244 +
245 +static bool trans_mtp(DisasContext *ctx, arg_r2 *a, unsigned int index)
246 +{
247 + /*
248 + * Octeon3 two-source MTP forms load lane index from rs and lane index + 3
249 + * from rt. Legacy one-source forms encode rt as $zero.
250 + */
251 + gen_load_gpr(oct_p[index], a->rs);
252 + gen_load_gpr(oct_p[index + 3], a->rt);
253 +
254 + /*
255 + * Octeon3 clears P1 with a write to P0 so that VMULU sequences remain
256 + * backward compatible with Octeon2.
257 + */
258 + if (index == 0) {
259 + tcg_gen_movi_i64(oct_p[1], 0);
260 + }
261 + return true;
262 +}
263 +
264 +TRANS(MTP0, trans_mtp, 0);
265 +TRANS(MTP1, trans_mtp, 1);
266 +TRANS(MTP2, trans_mtp, 2);