qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yongbok Kim <yongbok.kim@mips.com>
To: qemu-devel@nongnu.org
Cc: aurelien@aurel32.net, Aleksandar.Markovic@mips.com,
	James.Hogan@mips.com, Paul.Burton@mips.com,
	Matthew.Fortune@mips.com, Stefan.Markovic@mips.com
Subject: [Qemu-devel] [PATCH 17/35] target/mips: Add nanoMIPS load store instructions
Date: Wed, 20 Jun 2018 13:06:02 +0100	[thread overview]
Message-ID: <20180620120620.12806-18-yongbok.kim@mips.com> (raw)
In-Reply-To: <20180620120620.12806-1-yongbok.kim@mips.com>

Add nanoMIPS load and store instructions

Signed-off-by: Yongbok Kim <yongbok.kim@mips.com>
---
 target/mips/translate.c | 271 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 271 insertions(+)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index 2e794da..08765a7 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -17379,10 +17379,281 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
         }
         break;
     case NM_P_GP_BH:
+    {
+        uint32_t u = extract32(ctx->opcode, 0, 18);
+        switch ((ctx->opcode >> 18) & 0x7) {
+        case NM_LBGP:
+            gen_ld(ctx, OPC_LB, rt, 28, u);
+            break;
+        case NM_SBGP:
+            gen_st(ctx, OPC_SB, rt, 28, u);
+            break;
+        case NM_LBUGP:
+            gen_ld(ctx, OPC_LBU, rt, 28, u);
+            break;
+        case NM_ADDIUGP_B:
+            gen_arith_imm(ctx, OPC_ADDIU, rt, 28, u);
+            break;
+        case NM_P_GP_LH:
+            u &= ~1;
+            switch (ctx->opcode & 1) {
+            case NM_LHGP:
+                gen_ld(ctx, OPC_LH, rt, 28, u);
+                break;
+            case NM_LHUGP:
+                gen_ld(ctx, OPC_LHU, rt, 28, u);
+                break;
+            }
+            break;
+        case NM_P_GP_SH:
+            u &= ~1;
+            switch (ctx->opcode & 1) {
+            case NM_SHGP:
+                gen_st(ctx, OPC_SH, rt, 28, u);
+                break;
+            default:
+                generate_exception_end(ctx, EXCP_RI);
+                break;
+            }
+            break;
+        case NM_P_GP_CP1:
+            u &= ~0x3;
+            switch ((ctx->opcode & 0x3)) {
+            case NM_LWC1GP:
+                gen_cop1_ldst(ctx, OPC_LWC1, rt, 28, u);
+                break;
+            case NM_LDC1GP:
+                gen_cop1_ldst(ctx, OPC_LDC1, rt, 28, u);
+                break;
+            case NM_SWC1GP:
+                gen_cop1_ldst(ctx, OPC_SWC1, rt, 28, u);
+                break;
+            case NM_SDC1GP:
+                gen_cop1_ldst(ctx, OPC_SDC1, rt, 28, u);
+                break;
+            }
+            break;
+        default:
+            generate_exception_end(ctx, EXCP_RI);
+            break;
+        }
+    }
         break;
     case NM_P_LS_U12:
+    {
+        uint32_t u = extract32(ctx->opcode, 0, 12);
+        switch ((ctx->opcode >> 12) & 0x0f) {
+        case NM_P_PREFU12:
+            if (rt == 31) {
+                /* SYNCI */
+                /* Break the TB to be able to sync copied instructions
+                   immediately */
+                ctx->base.is_jmp = DISAS_STOP;
+            } else {
+                /* PREF */
+                /* Treat as NOP. */
+            }
+            break;
+        case NM_LB:
+            gen_ld(ctx, OPC_LB, rt, rs, u);
+            break;
+        case NM_LH:
+            gen_ld(ctx, OPC_LH, rt, rs, u);
+            break;
+        case NM_LW:
+            gen_ld(ctx, OPC_LW, rt, rs, u);
+            break;
+        case NM_LBU:
+            gen_ld(ctx, OPC_LBU, rt, rs, u);
+            break;
+        case NM_LHU:
+            gen_ld(ctx, OPC_LHU, rt, rs, u);
+            break;
+        case NM_SB:
+            gen_st(ctx, OPC_SB, rt, rs, u);
+            break;
+        case NM_SH:
+            gen_st(ctx, OPC_SH, rt, rs, u);
+            break;
+        case NM_SW:
+            gen_st(ctx, OPC_SW, rt, rs, u);
+            break;
+        case NM_LWC1:
+            gen_cop1_ldst(ctx, OPC_LWC1, rt, rs, u);
+            break;
+        case NM_LDC1:
+            gen_cop1_ldst(ctx, OPC_LDC1, rt, rs, u);
+            break;
+        case NM_SWC1:
+            gen_cop1_ldst(ctx, OPC_SWC1, rt, rs, u);
+            break;
+        case NM_SDC1:
+            gen_cop1_ldst(ctx, OPC_SDC1, rt, rs, u);
+            break;
+        default:
+            generate_exception_end(ctx, EXCP_RI);
+            break;
+        }
+    }
         break;
     case NM_P_LS_S9:
+    {
+        int32_t s = (sextract32(ctx->opcode, 15, 1) << 8) |
+                    extract32(ctx->opcode, 0, 8);
+        switch ((ctx->opcode >> 8) & 0x07) {
+        case NM_P_LS_S0:
+            switch ((ctx->opcode >> 11) & 0x0f) {
+            case NM_LBS9:
+                gen_ld(ctx, OPC_LB, rt, rs, s);
+                break;
+            case NM_LHS9:
+                gen_ld(ctx, OPC_LH, rt, rs, s);
+                break;
+            case NM_LWS9:
+                gen_ld(ctx, OPC_LW, rt, rs, s);
+                break;
+            case NM_LBUS9:
+                gen_ld(ctx, OPC_LBU, rt, rs, s);
+                break;
+            case NM_LHUS9:
+                gen_ld(ctx, OPC_LHU, rt, rs, s);
+                break;
+            case NM_SBS9:
+                gen_st(ctx, OPC_SB, rt, rs, s);
+                break;
+            case NM_SHS9:
+                gen_st(ctx, OPC_SH, rt, rs, s);
+                break;
+            case NM_SWS9:
+                gen_st(ctx, OPC_SW, rt, rs, s);
+                break;
+            case NM_LWC1S9:
+                gen_cop1_ldst(ctx, OPC_LWC1, rt, rs, s);
+                break;
+            case NM_LDC1S9:
+                gen_cop1_ldst(ctx, OPC_LDC1, rt, rs, s);
+                break;
+            case NM_SWC1S9:
+                gen_cop1_ldst(ctx, OPC_SWC1, rt, rs, s);
+                break;
+            case NM_SDC1S9:
+                gen_cop1_ldst(ctx, OPC_SDC1, rt, rs, s);
+                break;
+            case NM_P_PREFS9:
+                if (rt == 31) {
+                    /* SYNCI */
+                    /* Break the TB to be able to sync copied instructions
+                       immediately */
+                    ctx->base.is_jmp = DISAS_STOP;
+                } else {
+                    /* PREF */
+                    /* Treat as NOP. */
+                }
+                break;
+            default:
+                generate_exception_end(ctx, EXCP_RI);
+                break;
+            }
+            break;
+        case NM_P_LS_S1:
+            switch ((ctx->opcode >> 11) & 0x0f) {
+            case NM_UALH:
+            case NM_UASH:
+            {
+                TCGv t0 = tcg_temp_new();
+                TCGv t1 = tcg_temp_new();
+
+                gen_base_offset_addr(ctx, t0, rs, s);
+
+                switch ((ctx->opcode >> 11) & 0x0f) {
+                case NM_UALH:
+                    tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TESW |
+                                       MO_UNALN);
+                    gen_store_gpr(t0, rt);
+                    break;
+                case NM_UASH:
+                    gen_load_gpr(t1, rt);
+                    tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUW |
+                                       MO_UNALN);
+                    break;
+                }
+                tcg_temp_free(t0);
+                tcg_temp_free(t1);
+            }
+                break;
+            case NM_P_LL:
+                switch (ctx->opcode & 0x03) {
+                case NM_LL:
+                    gen_ld(ctx, OPC_LL, rt, rs, s);
+                    break;
+                case NM_LLWP:
+                    break;
+                }
+                break;
+            case NM_P_SC:
+                switch (ctx->opcode & 0x03) {
+                case NM_SC:
+                    gen_st_cond(ctx, OPC_SC, rt, rs, s);
+                    break;
+                case NM_SCWP:
+                    break;
+                }
+                break;
+            case NM_CACHE:
+                check_cp0_enabled(ctx);
+                if (ctx->hflags & MIPS_HFLAG_ITC_CACHE) {
+                    gen_cache_operation(ctx, rt, rs, s);
+                }
+                break;
+            }
+            break;
+        case NM_P_LS_WM:
+        case NM_P_LS_UAWM:
+        {
+            int32_t offset = sextract32(ctx->opcode, 15, 1) << 8 |
+                            extract32(ctx->opcode, 0, 8);
+            int count = extract32(ctx->opcode, 12, 3);
+            int counter = 0;
+            TCGv va = tcg_temp_new();
+            TCGv t1 = tcg_temp_new();
+            TCGMemOp memop = ((ctx->opcode >> 8) & 0x07) == NM_P_LS_UAWM ?
+                            MO_UNALN : 0;
+
+            count = (count == 0) ? 8 : count;
+            while (counter != count) {
+                int this_rt = ((rt + counter) & 0x1f) | (rt & 0x10);
+                int32_t this_offset = offset + (counter << 2);
+
+                gen_base_offset_addr(ctx, va, rs, this_offset);
+
+                switch (extract32(ctx->opcode, 11, 1)) {
+                case NM_LWM:
+                    tcg_gen_qemu_ld_tl(t1, va, ctx->mem_idx,
+                                       memop | MO_TESL);
+                    gen_store_gpr(t1, this_rt);
+                    if ((this_rt == rs) &&
+                        (counter != (count - 1))) {
+                        /* UNPREDICTABLE */
+                    }
+                    break;
+                case NM_SWM:
+                    this_rt = (rt == 0) ? 0 : this_rt;
+                    gen_load_gpr(t1, this_rt);
+                    tcg_gen_qemu_st_tl(t1, va, ctx->mem_idx,
+                                       memop | MO_TEUL);
+                    break;
+                }
+                counter++;
+            }
+            tcg_temp_free(va);
+            tcg_temp_free(t1);
+        }
+            break;
+        default:
+            generate_exception_end(ctx, EXCP_RI);
+            break;
+        }
+    }
         break;
     case NM_MOVE_BALC:
         break;
-- 
1.9.1

  parent reply	other threads:[~2018-06-20 12:11 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-20 12:05 [Qemu-devel] [PATCH 00/35] nanoMIPS Yongbok Kim
2018-06-20 12:05 ` [Qemu-devel] [PATCH 01/35] target/mips: Raise a RI when given fs is n/a from CTC1 Yongbok Kim
2018-06-22 13:45   ` Aleksandar Markovic
2018-06-20 12:05 ` [Qemu-devel] [PATCH 02/35] target/mips: Fix microMIPS on reset Yongbok Kim
2018-06-22 13:45   ` Aleksandar Markovic
2018-06-20 12:05 ` [Qemu-devel] [PATCH 03/35] target/mips: Add nanoMIPS OPCODE table Yongbok Kim
2018-06-21 23:15   ` Richard Henderson
2018-06-20 12:05 ` [Qemu-devel] [PATCH 04/35] target/mips: Add decode_nanomips_opc() Yongbok Kim
2018-06-21 23:39   ` Richard Henderson
2018-06-20 12:05 ` [Qemu-devel] [PATCH 05/35] target/mips: Add nanoMIPS 16bit ld/st instructions Yongbok Kim
2018-06-21 23:48   ` Richard Henderson
2018-06-20 12:05 ` [Qemu-devel] [PATCH 06/35] target/mips: Add nanoMIPS pool16c instructions Yongbok Kim
2018-06-22  3:40   ` Richard Henderson
2018-06-20 12:05 ` [Qemu-devel] [PATCH 07/35] target/mips: Add nanoMIPS save and restore Yongbok Kim
2018-06-22  5:11   ` Richard Henderson
2018-06-20 12:05 ` [Qemu-devel] [PATCH 08/35] target/mips: Add nanoMIPS 32bit instructions Yongbok Kim
2018-06-24 23:32   ` Richard Henderson
2018-06-20 12:05 ` [Qemu-devel] [PATCH 09/35] target/mips: Add nanoMIPS 48bit instructions Yongbok Kim
2018-06-24 23:49   ` Richard Henderson
2018-06-20 12:05 ` [Qemu-devel] [PATCH 10/35] target/mips: Add nanoMIPS pool32f instructions Yongbok Kim
2018-06-20 12:05 ` [Qemu-devel] [PATCH 11/35] target/mips: Add nanoMIPS pool32a0 instructions Yongbok Kim
2018-06-24 23:59   ` Richard Henderson
2018-06-20 12:05 ` [Qemu-devel] [PATCH 12/35] target/mips: Add nanoMIPS pool32axf instructions Yongbok Kim
2018-06-20 12:05 ` [Qemu-devel] [PATCH 13/35] target/mips: Update gen_flt_ldst() Yongbok Kim
2018-06-22  4:13   ` Philippe Mathieu-Daudé
2018-06-22 13:46   ` Aleksandar Markovic
2018-06-20 12:05 ` [Qemu-devel] [PATCH 14/35] target/mips: Add nanoMIPS p_lsx instructions Yongbok Kim
2018-06-25  0:07   ` Richard Henderson
2018-06-20 12:06 ` [Qemu-devel] [PATCH 15/35] target/mips: Implement nanoMIPS EXTW instruction Yongbok Kim
2018-06-20 12:06 ` [Qemu-devel] [PATCH 16/35] target/mips: Add has_isa_mode Yongbok Kim
2018-06-20 12:06 ` Yongbok Kim [this message]
2018-06-20 12:06 ` [Qemu-devel] [PATCH 18/35] target/mips: Add nanoMIPS branch instructions Yongbok Kim
2018-06-25  0:23   ` Richard Henderson
2018-06-20 12:06 ` [Qemu-devel] [PATCH 19/35] target/mips: Implement nanoMIPS LLWP/SCWP pair Yongbok Kim
2018-06-25  0:27   ` Richard Henderson
2018-06-20 12:06 ` [Qemu-devel] [PATCH 20/35] target/mips: Fix not to update BadVAddr in Debug Mode Yongbok Kim
2018-06-22  4:15   ` Philippe Mathieu-Daudé
2018-06-20 12:06 ` [Qemu-devel] [PATCH 21/35] target/mips: Add nanoMIPS rotx instruction Yongbok Kim
2018-06-25  0:30   ` Richard Henderson
2018-06-20 12:06 ` [Qemu-devel] [PATCH 22/35] target/mips: Fix data type for offset Yongbok Kim
2018-06-22  4:16   ` Philippe Mathieu-Daudé
2018-06-22 13:47   ` Aleksandar Markovic
2018-06-20 12:06 ` [Qemu-devel] [PATCH 23/35] target/mips: Update BadInstr{P} regs on nanoMIPS Yongbok Kim
2018-06-20 12:06 ` [Qemu-devel] [PATCH 24/35] target/mips: Add nanoMIPS CP0_BadInstrX register Yongbok Kim
2018-06-20 12:06 ` [Qemu-devel] [PATCH 25/35] target/mips: Config3.ISAOnExc is read only in nanoMIPS Yongbok Kim
2018-06-20 12:06 ` [Qemu-devel] [PATCH 26/35] target/mips: Fix nanoMIPS exception_resume_pc Yongbok Kim
2018-06-20 12:06 ` [Qemu-devel] [PATCH 27/35] target/mips: Fix nanoMIPS set_hflags_for_handler Yongbok Kim
2018-06-20 12:06 ` [Qemu-devel] [PATCH 28/35] target/mips: Fix nanoMIPS set_pc Yongbok Kim
2018-06-20 12:06 ` [Qemu-devel] [PATCH 29/35] target/mips: Fix ERET/ERETNC can cause ADEL exception Yongbok Kim
2018-06-22  4:31   ` Philippe Mathieu-Daudé
2018-06-20 12:06 ` [Qemu-devel] [PATCH 30/35] hw/mips: Add basic nanoMIPS boot code Yongbok Kim
2018-06-20 12:06 ` [Qemu-devel] [PATCH 31/35] mips_malta: Setup GT64120 BARs in nanoMIPS bootloader Yongbok Kim
2018-06-20 12:06 ` [Qemu-devel] [PATCH 32/35] hw/mips: Fix semihosting argument passing for nanoMIPS bare metal Yongbok Kim
2018-06-20 12:06 ` [Qemu-devel] [PATCH 33/35] target/mips: Fix gdbstub to read/write 64 bit FP registers Yongbok Kim
2018-06-22 13:47   ` Aleksandar Markovic
2018-06-20 12:06 ` [Qemu-devel] [PATCH 34/35] target/mips: Disable gdbstub nanoMIPS ISA bit Yongbok Kim
2018-06-20 12:06 ` [Qemu-devel] [PATCH 35/35] target/mips: Add I7200 CPU Yongbok Kim
2018-06-22  4:26 ` [Qemu-devel] [PATCH 00/35] nanoMIPS Philippe Mathieu-Daudé
2018-06-22 14:39   ` Aleksandar Markovic
2018-06-22 15:16     ` Philippe Mathieu-Daudé
2018-06-22 15:31       ` Peter Maydell
2018-06-22 14:21 ` Aleksandar Markovic

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=20180620120620.12806-18-yongbok.kim@mips.com \
    --to=yongbok.kim@mips.com \
    --cc=Aleksandar.Markovic@mips.com \
    --cc=James.Hogan@mips.com \
    --cc=Matthew.Fortune@mips.com \
    --cc=Paul.Burton@mips.com \
    --cc=Stefan.Markovic@mips.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).