All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>
To: qemu-devel@nongnu.org
Cc: aurelien@aurel32.net, richard.henderson@linaro.org,
	jancraig@amazon.com, amarkovic@wavecomp.com,
	smarkovic@wavecomp.com, pjovanovic@wavecomp.com
Subject: [Qemu-devel] [PATCH v5 14/14] target/mips: Add emulation of MXU instructions S32LDD and S32LDDR
Date: Fri, 19 Oct 2018 18:33:48 +0200	[thread overview]
Message-ID: <1539966828-20947-15-git-send-email-aleksandar.markovic@rt-rk.com> (raw)
In-Reply-To: <1539966828-20947-1-git-send-email-aleksandar.markovic@rt-rk.com>

From: Craig Janeczek <jancraig@amazon.com>

Add support for emulating the S32LDD and S32LDDR MXU instructions.

Signed-off-by: Craig Janeczek <jancraig@amazon.com>
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
---
 target/mips/translate.c | 54 ++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 47 insertions(+), 7 deletions(-)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index 76859bf..99184ab 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -23737,6 +23737,52 @@ static void gen_mxu_q8mul_q8mulsu(DisasContext *ctx)
     tcg_temp_free(t7);
 }
 
+/*
+ * S32LDD  XRa, Rb, S12 - Load a word from memory to XRF
+ * S32LDDR XRa, Rb, S12 - Load a word from memory to XRF, reversed byte seq.
+ */
+static void gen_mxu_s32ldd_s32lddr(DisasContext *ctx)
+{
+    TCGv t0, t1;
+    TCGLabel *l0;
+    uint32_t XRa, Rb, s12, sel;
+
+    t0 = tcg_temp_new();
+    t1 = tcg_temp_new();
+
+    l0 = gen_new_label();
+
+    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(t0);
+    tcg_gen_andi_tl(t0, t0, MXU_CR_MXU_EN);
+    tcg_gen_brcondi_tl(TCG_COND_NE, t0, MXU_CR_MXU_EN, l0);
+
+    gen_load_gpr(t0, Rb);
+
+    tcg_gen_movi_tl(t1, s12);
+    tcg_gen_shli_tl(t1, t1, 2);
+    if (s12 & 0x200) {
+        tcg_gen_ori_tl(t1, t1, 0xFFFFF000);
+    }
+    tcg_gen_add_tl(t1, t0, t1);
+    tcg_gen_qemu_ld_tl(t1, t1, ctx->mem_idx, MO_SL);
+
+    if (sel == 1) {
+        /* S32LDDR */
+        tcg_gen_bswap32_tl(t1, t1);
+    }
+    gen_store_mxu_gpr(t1, XRa);
+
+    gen_set_label(l0);
+
+    tcg_temp_free(t0);
+    tcg_temp_free(t1);
+}
+
 
 /*
  * Decoding engine for MXU
@@ -23998,14 +24044,8 @@ static void decode_opc_mxu__pool05(CPUMIPSState *env, DisasContext *ctx)
 
     switch (opcode) {
     case OPC_MXU_S32LDD:
-        /* TODO: Implement emulation of S32LDD instruction. */
-        MIPS_INVAL("OPC_MXU_S32LDD");
-        generate_exception_end(ctx, EXCP_RI);
-        break;
     case OPC_MXU_S32LDDR:
-        /* TODO: Implement emulation of S32LDDR instruction. */
-        MIPS_INVAL("OPC_MXU_S32LDDR");
-        generate_exception_end(ctx, EXCP_RI);
+        gen_mxu_s32ldd_s32lddr(ctx);
         break;
     default:
         MIPS_INVAL("decode_opc_mxu");
-- 
2.7.4

      parent reply	other threads:[~2018-10-19 16:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-19 16:33 [Qemu-devel] [PATCH v5 00/14] Add limited MXU instruction support Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 01/14] target/mips: Introduce MXU registers Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 02/14] target/mips: Define a bit for MXU in insn_flags Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 03/14] target/mips: Add and integrate MXU decoding engine placeholder Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 04/14] target/mips: Add MXU decoding engine Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 05/14] target/mips: Add bit encoding for MXU add/subtract patterns 'aptn2' Aleksandar Markovic
2018-10-19 17:12   ` Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 06/14] target/mips: Add bit encoding for MXU operand getting patterns 'optn2' Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 07/14] target/mips: Add bit encoding for MXU operand getting patterns 'optn3' Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 08/14] target/mips: Add emulation of non-MXU MULL within MXU decoding engine Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 09/14] target/mips: Add emulation of MXU instructions S32I2M and S32M2I Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 10/14] target/mips: Add emulation of MXU instruction S8LDD Aleksandar Markovic
2018-10-19 17:15   ` Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 11/14] target/mips: Add emulation of MXU instruction D16MUL Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 12/14] target/mips: Add emulation of MXU instruction D16MAC Aleksandar Markovic
2018-10-19 16:33 ` [Qemu-devel] [PATCH v5 13/14] target/mips: Add emulation of MXU instructions Q8MUL and Q8MULSU Aleksandar Markovic
2018-10-19 16:33 ` Aleksandar Markovic [this message]

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=1539966828-20947-15-git-send-email-aleksandar.markovic@rt-rk.com \
    --to=aleksandar.markovic@rt-rk.com \
    --cc=amarkovic@wavecomp.com \
    --cc=aurelien@aurel32.net \
    --cc=jancraig@amazon.com \
    --cc=pjovanovic@wavecomp.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=smarkovic@wavecomp.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.