qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Markovic <stefan.markovic@rt-rk.com>
To: qemu-devel@nongnu.org
Cc: laurent@vivier.eu, riku.voipio@iki.fi,
	philippe.mathieu.daude@gmail.com, aurelien@aurel32.net,
	richard.henderson@linaro.org, amarkovic@wavecomp.com,
	smarkovic@wavecomp.com, pjovanovic@wavecomp.com,
	pburton@wavecomp.com, arikalo@wavecomp.com
Subject: [Qemu-devel] [PATCH v6 19/77] target/mips: Add emulation of nanoMIPS 16-bit arithmetic instructions
Date: Thu,  2 Aug 2018 16:16:06 +0200	[thread overview]
Message-ID: <1533219424-7627-20-git-send-email-stefan.markovic@rt-rk.com> (raw)
In-Reply-To: <1533219424-7627-1-git-send-email-stefan.markovic@rt-rk.com>

From: Yongbok Kim <yongbok.kim@mips.com>

Add emulation of nanoMIPS 16-bit arithmetic instructions.

Signed-off-by: Yongbok Kim <yongbok.kim@mips.com>
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Signed-off-by: Stefan Markovic <smarkovic@wavecomp.com>
---
 target/mips/translate.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 125 insertions(+)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index aba42be..d6f8dfc 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -16522,6 +16522,131 @@ static inline int decode_gpr_gpr4_zero(int r)
 
 static int decode_nanomips_opc(CPUMIPSState *env, DisasContext *ctx)
 {
+    uint32_t op;
+    int rt = decode_gpr_gpr3(NANOMIPS_EXTRACT_RD(ctx->opcode));
+    int rs = decode_gpr_gpr3(NANOMIPS_EXTRACT_RS(ctx->opcode));
+    int rd = decode_gpr_gpr3(NANOMIPS_EXTRACT_RS1(ctx->opcode));
+    int imm;
+
+    /* make sure instructions are on a halfword boundary */
+    if (ctx->base.pc_next & 0x1) {
+        TCGv tmp = tcg_const_tl(ctx->base.pc_next);
+        tcg_gen_st_tl(tmp, cpu_env, offsetof(CPUMIPSState, CP0_BadVAddr));
+        tcg_temp_free(tmp);
+        generate_exception_end(ctx, EXCP_AdEL);
+        return 2;
+    }
+
+    op = extract32(ctx->opcode, 10, 6);
+    switch (op) {
+    case NM_P16_MV:
+        break;
+    case NM_P16_SHIFT:
+        break;
+    case NM_P16C:
+        break;
+    case NM_P16_A1:
+        switch (extract32(ctx->opcode, 6, 1)) {
+        case NM_ADDIUR1SP:
+            imm = extract32(ctx->opcode, 0, 6) << 2;
+            gen_arith_imm(ctx, OPC_ADDIU, rt, 29, imm);
+            break;
+        default:
+            generate_exception_end(ctx, EXCP_RI);
+            break;
+        }
+        break;
+    case NM_P16_A2:
+        switch (extract32(ctx->opcode, 3, 1)) {
+        case NM_ADDIUR2:
+            imm = extract32(ctx->opcode, 0, 3) << 2;
+            gen_arith_imm(ctx, OPC_ADDIU, rt, rs, imm);
+            break;
+        case NM_P_ADDIURS5:
+            rt = extract32(ctx->opcode, 5, 5);
+            if (rt != 0) {
+                /* imm = sign_extend(s[3] . s[2:0] , from_nbits = 4) */
+                imm = (sextract32(ctx->opcode, 4, 1) << 3) |
+                      (extract32(ctx->opcode, 0, 3));
+                gen_arith_imm(ctx, OPC_ADDIU, rt, rt, imm);
+            }
+            break;
+        }
+        break;
+    case NM_P16_ADDU:
+        switch (ctx->opcode & 0x1) {
+        case NM_ADDU16:
+            gen_arith(ctx, OPC_ADDU, rd, rs, rt);
+            break;
+        case NM_SUBU16:
+            gen_arith(ctx, OPC_SUBU, rd, rs, rt);
+            break;
+        }
+        break;
+    case NM_P16_4X4:
+        rt = (extract32(ctx->opcode, 9, 1) << 3) |
+              extract32(ctx->opcode, 5, 3);
+        rs = (extract32(ctx->opcode, 4, 1) << 3) |
+              extract32(ctx->opcode, 0, 3);
+        rt = decode_gpr_gpr4(rt);
+        rs = decode_gpr_gpr4(rs);
+        switch ((extract32(ctx->opcode, 7, 2) & 0x2) |
+                (extract32(ctx->opcode, 3, 1))) {
+        case NM_ADDU4X4:
+            gen_arith(ctx, OPC_ADDU, rt, rs, rt);
+            break;
+        case NM_MUL4X4:
+            gen_r6_muldiv(ctx, R6_OPC_MUL, rt, rs, rt);
+            break;
+        default:
+            generate_exception_end(ctx, EXCP_RI);
+            break;
+        }
+        break;
+    case NM_LI16:
+        break;
+    case NM_ANDI16:
+        break;
+    case NM_P16_LB:
+        break;
+    case NM_P16_LH:
+        break;
+    case NM_LW16:
+        break;
+    case NM_LWSP16:
+        break;
+    case NM_LW4X4:
+        break;
+    case NM_SW4X4:
+        break;
+    case NM_LWGP16:
+        break;
+    case NM_SWSP16:
+        break;
+    case NM_SW16:
+        break;
+    case NM_SWGP16:
+        break;
+    case NM_BC16:
+        break;
+    case NM_BALC16:
+        break;
+    case NM_BEQZC16:
+        break;
+    case NM_BNEZC16:
+        break;
+    case NM_P16_BR:
+        break;
+    case NM_P16_SR:
+        break;
+    case NM_MOVEP:
+        break;
+    case NM_MOVEPREV:
+        break;
+    default:
+        break;
+    }
+
     return 2;
 }
 
-- 
1.9.1

  parent reply	other threads:[~2018-08-02 14:25 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-02 14:15 [Qemu-devel] [PATCH v6 00/77] Add nanoMIPS support to QEMU Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 01/77] MAINTAINERS: Update target/mips maintainer's email addresses Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 02/77] target/mips: Avoid case statements formulated by ranges Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 03/77] target/mips: Mark switch fallthroughs with interpretable comments Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 04/77] target/mips: Fix two instances of shadow variables Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 05/77] target/mips: Update some CP0 registers bit definitions Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 06/77] target/mips: Add CP0 BadInstrX register Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 07/77] target/mips: Add gen_op_addr_addi() Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 08/77] target/mips: Don't update BadVAddr register in Debug Mode Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 09/77] target/mips: Check ELPA flag only in some cases of MFHC0 and MTHC0 Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 10/77] elf: Remove duplicate preprocessor constant definition Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 11/77] elf: Add ELF flags for MIPS machine variants Stefan Markovic
2018-08-02 14:15 ` [Qemu-devel] [PATCH v6 12/77] linux-user: Update MIPS syscall numbers up to kernel 4.18 headers Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 13/77] linux-user: Add preprocessor availability control to some syscalls Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 14/77] target/mips: Add preprocessor constants for nanoMIPS Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 15/77] target/mips: Add nanoMIPS base instruction set opcodes Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 16/77] target/mips: Add nanoMIPS DSP ASE opcodes Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 17/77] target/mips: Add placeholder and invocation of decode_nanomips_opc() Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 18/77] target/mips: Add nanoMIPS decoding and extraction utilities Stefan Markovic
2018-08-02 14:16 ` Stefan Markovic [this message]
2018-08-02 17:32   ` [Qemu-devel] [PATCH v6 19/77] target/mips: Add emulation of nanoMIPS 16-bit arithmetic instructions Richard Henderson
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 20/77] target/mips: Add emulation of nanoMIPS 16-bit branch instructions Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 21/77] target/mips: Add emulation of nanoMIPS 16-bit shift instructions Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 22/77] target/mips: Add emulation of nanoMIPS 16-bit misc instructions Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 23/77] target/mips: Add emulation of nanoMIPS 16-bit load and store instructions Stefan Markovic
2018-08-02 17:39   ` Richard Henderson
2018-08-03 12:30     ` Aleksandar Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 24/77] target/mips: Add emulation of nanoMIPS 16-bit logic instructions Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 25/77] target/mips: Add emulation of nanoMIPS 16-bit save and restore instructions Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 26/77] target/mips: Add emulation of some common nanoMIPS 32-bit instructions Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 27/77] target/mips: Add emulation of nanoMIPS instructions MOVE.P and MOVE.PREV Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 28/77] target/mips: Add emulation of nanoMIPS 48-bit instructions Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 29/77] target/mips: Add emulation of nanoMIPS FP instructions Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 30/77] target/mips: Add emulation of misc nanoMIPS instructions (pool32a0) Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 31/77] target/mips: Add emulation of misc nanoMIPS instructions (pool32axf) Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 32/77] target/mips: Add emulation of misc nanoMIPS instructions (p_lsx) Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 33/77] target/mips: Implement emulation of nanoMIPS ROTX instruction Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 34/77] target/mips: Implement emulation of nanoMIPS EXTW instruction Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 35/77] target/mips: Add emulation of nanoMIPS 32-bit load and store instructions Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 36/77] target/mips: Add emulation of nanoMIPS 32-bit branch instructions Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 37/77] target/mips: Implement MT ASE support for nanoMIPS Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 38/77] target/mips: Add emulation of DSP ASE for nanoMIPS - part 1 Stefan Markovic
2018-08-03 10:55   ` Aleksandar Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 39/77] target/mips: Add emulation of DSP ASE for nanoMIPS - part 2 Stefan Markovic
2018-08-03 11:20   ` Aleksandar Markovic
2018-08-03 14:06     ` Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 40/77] target/mips: Add emulation of DSP ASE for nanoMIPS - part 3 Stefan Markovic
2018-08-03 11:27   ` Aleksandar Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 41/77] target/mips: Add emulation of DSP ASE for nanoMIPS - part 4 Stefan Markovic
2018-08-03 11:31   ` Aleksandar Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 42/77] target/mips: Add emulation of DSP ASE for nanoMIPS - part 5 Stefan Markovic
2018-08-03 11:55   ` Aleksandar Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 43/77] target/mips: Add emulation of DSP ASE for nanoMIPS - part 6 Stefan Markovic
2018-08-03 12:00   ` Aleksandar Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 44/77] target/mips: Add handling of branch delay slots for nanoMIPS Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 45/77] target/mips: Implement emulation of nanoMIPS LLWP/SCWP pair Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 46/77] target/mips: Add updating BadInstr, BadInstrP, BadInstrX for nanoMIPS Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 47/77] target/mips: Implement CP0 Config1.WR bit functionality Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 48/77] target/mips: Adjust exception_resume_pc() for nanoMIPS Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 49/77] target/mips: Adjust set_hflags_for_handler() " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 50/77] target/mips: Adjust set_pc() " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 51/77] target/mips: Fix ERET/ERETNC behavior related to ADEL exception Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 52/77] elf: Add nanoMIPS specific variations in ELF header fields Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 53/77] elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 54/77] elf: Don't check FCR31_NAN2008 bit for nanoMIPS Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 55/77] mips_malta: Add basic nanoMIPS boot code for MIPS' Malta Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 56/77] mips_malta: Setup GT64120 BARs in nanoMIPS bootloader Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 57/77] mips_malta: Fix semihosting argument passing for nanoMIPS bare metal Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 58/77] gdbstub: Disable handling of nanoMIPS ISA bit in the MIPS gdbstub Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 59/77] gdbstub: Add XML support for GDB for nanoMIPS Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 60/77] target/mips: Add definition of nanoMIPS I7200 CPU Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 61/77] linux-user: Add syscall numbers for nanoMIPS Stefan Markovic
2018-08-06 13:45   ` Aleksandar Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 62/77] linux-user: Add target_signal.h header " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 63/77] linux-user: Add termbits.h " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 64/77] linux-user: Update syscall_defs.h " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 65/77] linux-user: Add target_fcntl.h " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 66/77] linux-user: Add sockbits.h " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 67/77] linux-user: Add target_syscall.h " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 68/77] linux-user: Add target_cpu.h " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 69/77] linux-user: Add target_structs.h " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 70/77] linux-user: Add target_elf.h " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 71/77] linux-user: Add signal.c " Stefan Markovic
2018-08-02 14:16 ` [Qemu-devel] [PATCH v6 72/77] linux-user: Add support for nanoMIPS signal trampoline Stefan Markovic
2018-08-02 14:17 ` [Qemu-devel] [PATCH v6 73/77] linux-user: Add cpu_loop.c for nanoMIPS Stefan Markovic
2018-08-02 14:17 ` [Qemu-devel] [PATCH v6 74/77] linux-user: Amend support for sigaction() syscall " Stefan Markovic
2018-08-02 14:17 ` [Qemu-devel] [PATCH v6 75/77] linux-user: Add support for statx() syscall for all platforms Stefan Markovic
2018-08-02 14:17 ` [Qemu-devel] [PATCH v6 76/77] linux-user: Add nanoMIPS linux user mode configuration support Stefan Markovic
2018-08-02 14:17 ` [Qemu-devel] [PATCH v6 77/77] linux-user: Add nanoMIPS support in scripts/qemu-binfmt-conf.sh Stefan Markovic
2018-08-02 19:47   ` Laurent Vivier
2018-08-03 11:23     ` Aleksandar Rikalo
2018-08-03 11:57       ` Laurent Vivier
2018-08-02 18:02 ` [Qemu-devel] [PATCH v6 00/77] Add nanoMIPS support to QEMU no-reply
2018-08-03 12:42   ` Stefan 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=1533219424-7627-20-git-send-email-stefan.markovic@rt-rk.com \
    --to=stefan.markovic@rt-rk.com \
    --cc=amarkovic@wavecomp.com \
    --cc=arikalo@wavecomp.com \
    --cc=aurelien@aurel32.net \
    --cc=laurent@vivier.eu \
    --cc=pburton@wavecomp.com \
    --cc=philippe.mathieu.daude@gmail.com \
    --cc=pjovanovic@wavecomp.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=riku.voipio@iki.fi \
    --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 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).