From: Craig Janeczek <jancraig@amazon.com>
To: qemu-devel@nongnu.org
Cc: amarkovic@wavecomp.com, aurelien@aurel32.net,
Craig Janeczek <jancraig@amazon.com>
Subject: [Qemu-devel] [PATCH 4/7] target/mips: Add MXU instruction D16MUL
Date: Fri, 24 Aug 2018 15:44:05 -0400 [thread overview]
Message-ID: <20819a8ef4216527bccc346de4a50ce14386034c.1535133089.git.jancraig@amazon.com> (raw)
In-Reply-To: <cover.1535133088.git.jancraig@amazon.com>
Adds support for emulating the D16MUL instruction.
Signed-off-by: Craig Janeczek <jancraig@amazon.com>
---
target/mips/translate.c | 55 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/target/mips/translate.c b/target/mips/translate.c
index 4ccccd5849..64fc6089bb 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -365,6 +365,7 @@ enum {
OPC_DCLZ = 0x24 | OPC_SPECIAL2,
OPC_DCLO = 0x25 | OPC_SPECIAL2,
/* MXU */
+ OPC_MXU_D16MUL = 0x08 | OPC_SPECIAL2,
OPC_MXU_S8LDD = 0x22 | OPC_SPECIAL2,
OPC_MXU_S32I2M = 0x2F | OPC_SPECIAL2,
OPC_MXU_S32M2I = 0x2E | OPC_SPECIAL2,
@@ -3794,15 +3795,28 @@ typedef union {
uint32_t rb:5;
uint32_t special2:6;
} S8LDD;
+
+ 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 sel:2;
+ uint32_t special2:6;
+ } D16MUL;
} MXU_OPCODE;
/* MXU Instructions */
static void gen_mxu(DisasContext *ctx, uint32_t opc)
{
#ifndef TARGET_MIPS64 /* Only works in 32 bit mode */
- TCGv t0, t1;
+ TCGv t0, t1, t2, t3;
t0 = tcg_temp_new();
t1 = tcg_temp_new();
+ t2 = tcg_temp_new();
+ t3 = tcg_temp_new();
MXU_OPCODE *opcode = (MXU_OPCODE *)&ctx->opcode;
switch (opc) {
@@ -3882,10 +3896,48 @@ static void gen_mxu(DisasContext *ctx, uint32_t opc)
}
gen_store_mxu_gpr(t0, opcode->S8LDD.xra);
break;
+
+ case OPC_MXU_D16MUL:
+ if (opcode->D16MUL.sel == 1) {
+ /* D16MULE is not supported */
+ generate_exception_end(ctx, EXCP_RI);
+ }
+ gen_load_mxu_gpr(t1, opcode->D16MUL.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->D16MUL.xrc);
+ tcg_gen_ext16s_tl(t2, t3);
+ tcg_gen_shri_tl(t3, t3, 16);
+ tcg_gen_ext16s_tl(t3, t3);
+
+ switch (opcode->D16MUL.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_store_mxu_gpr(t3, opcode->D16MUL.xra);
+ gen_store_mxu_gpr(t2, opcode->D16MUL.xrd);
+ break;
}
tcg_temp_free(t0);
tcg_temp_free(t1);
+ tcg_temp_free(t2);
+ tcg_temp_free(t3);
#else
generate_exception_end(ctx, EXCP_RI);
#endif
@@ -17975,6 +18027,7 @@ static void decode_opc_special2_legacy(CPUMIPSState *env, DisasContext *ctx)
case OPC_MXU_S32I2M:
case OPC_MXU_S32M2I:
case OPC_MXU_S8LDD:
+ case OPC_MXU_D16MUL:
gen_mxu(ctx, op1);
break;
--
2.18.0
next prev parent reply other threads:[~2018-08-24 19:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-24 19:44 [Qemu-devel] [PATCH 0/7] Add limited MXU instruction support Craig Janeczek
2018-08-24 19:44 ` [Qemu-devel] [PATCH 1/7] target/mips: Add MXU register support Craig Janeczek
2018-08-25 16:50 ` Richard Henderson
2018-08-27 12:35 ` Aleksandar Markovic
2018-08-27 12:41 ` Aleksandar Markovic
2018-08-24 19:44 ` [Qemu-devel] [PATCH 2/7] target/mips: Add MXU instructions S32I2M and S32M2I Craig Janeczek
2018-08-25 17:07 ` Richard Henderson
2018-08-27 12:14 ` Janeczek, Craig
2018-08-27 13:21 ` Aleksandar Markovic
2018-08-27 12:22 ` Janeczek, Craig
2018-08-27 13:25 ` Aleksandar Markovic
2018-08-24 19:44 ` [Qemu-devel] [PATCH 3/7] target/mips: Add MXU instruction S8LDD Craig Janeczek
2018-08-25 17:17 ` Richard Henderson
2018-08-24 19:44 ` Craig Janeczek [this message]
2018-08-25 17:23 ` [Qemu-devel] [PATCH 4/7] target/mips: Add MXU instruction D16MUL Richard Henderson
2018-08-24 19:44 ` [Qemu-devel] [PATCH 5/7] target/mips: Add MXU instruction D16MAC Craig Janeczek
2018-08-24 19:44 ` [Qemu-devel] [PATCH 6/7] target/mips: Add MXU instructions Q8MUL and Q8MULSU Craig Janeczek
2018-08-24 19:44 ` [Qemu-devel] [PATCH 7/7] target/mips: Add MXU instructions S32LDD and S32LDDR Craig Janeczek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20819a8ef4216527bccc346de4a50ce14386034c.1535133089.git.jancraig@amazon.com \
--to=jancraig@amazon.com \
--cc=amarkovic@wavecomp.com \
--cc=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).