diff mbox series

[3/9] target/mips: Support the R5900 PCPYLD multimedia instruction

Message ID b05a382fc4a444e74b3787052248b1f9fda5ab88.1547403692.git.noring@nocrew.org
State New
Headers show
Series target/mips: Limited support for R5900 multimedia instructions | expand

Commit Message

Fredrik Noring Jan. 13, 2019, 7:03 p.m. UTC
Signed-off-by: Fredrik Noring <noring@nocrew.org>
---
 target/mips/translate.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

Comments

Aleksandar Markovic Jan. 15, 2019, 9:24 p.m. UTC | #1
> From: Fredrik Noring <noring@nocrew.org>
> Sent: Sunday, January 13, 2019 8:03 PM
> To: Aleksandar Markovic; Aurelien Jarno; Philippe Mathieu-Daudé
> Cc: Jürgen Urban; Maciej W. Rozycki; qemu-devel@nongnu.org
> Subject: [PATCH 3/9] target/mips: Support the R5900 PCPYLD multimedia instruction
> 
> Signed-off-by: Fredrik Noring <noring@nocrew.org>
> ---
>  target/mips/translate.c | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/target/mips/translate.c b/target/mips/translate.c
> index 9d5150ec8b..40faf9cb36 100644
> --- a/target/mips/translate.c
> +++ b/target/mips/translate.c
> @@ -27293,11 +27293,34 @@ static void decode_mmi1(CPUMIPSState *env, DisasContext *ctx)
>      }
>  }
> 
> +static void gen_mmi_pcpyld(DisasContext *ctx, int rd, int rs, int rt)
> +{
> +    if (rd != 0) {
> +        if (rs != 0) {
> +            tcg_gen_mov_i64(cpu_mmr[rd], cpu_gpr[rs]);
> +        } else {
> +            tcg_gen_movi_i64(cpu_mmr[rd], 0);
> +        }
> +
> +        if (rt != 0) {
> +            tcg_gen_mov_i64(cpu_gpr[rd], cpu_gpr[rt]);
> +        } else {
> +            tcg_gen_movi_i64(cpu_gpr[rd], 0);
> +        }
> +    }
> +}
> +
>  static void decode_mmi2(CPUMIPSState *env, DisasContext *ctx)
>  {
>      uint32_t opc = MASK_MMI2(ctx->opcode);
> +    int rs = extract32(ctx->opcode, 21, 5);
> +    int rt = extract32(ctx->opcode, 16, 5);
> +    int rd = extract32(ctx->opcode, 11, 5);
> 

If you move last three lines to gen_mmi_pcpyld(), and correct its arguments,
this patch has:

Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>

>      switch (opc) {
> +    case MMI_OPC_2_PCPYLD:
> +        gen_mmi_pcpyld(ctx, rd, rs, rt);
> +        break;
>      case MMI_OPC_2_PMADDW:    /* TODO: MMI_OPC_2_PMADDW */
>      case MMI_OPC_2_PSLLVW:    /* TODO: MMI_OPC_2_PSLLVW */
>      case MMI_OPC_2_PSRLVW:    /* TODO: MMI_OPC_2_PSRLVW */
> @@ -27307,7 +27330,6 @@ static void decode_mmi2(CPUMIPSState *env, DisasContext *ctx)
>      case MMI_OPC_2_PINTH:     /* TODO: MMI_OPC_2_PINTH */
>      case MMI_OPC_2_PMULTW:    /* TODO: MMI_OPC_2_PMULTW */
>      case MMI_OPC_2_PDIVW:     /* TODO: MMI_OPC_2_PDIVW */
> -    case MMI_OPC_2_PCPYLD:    /* TODO: MMI_OPC_2_PCPYLD */
>      case MMI_OPC_2_PMADDH:    /* TODO: MMI_OPC_2_PMADDH */
>      case MMI_OPC_2_PHMADH:    /* TODO: MMI_OPC_2_PHMADH */
>      case MMI_OPC_2_PAND:      /* TODO: MMI_OPC_2_PAND */
> --
> 2.19.2
diff mbox series

Patch

diff --git a/target/mips/translate.c b/target/mips/translate.c
index 9d5150ec8b..40faf9cb36 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -27293,11 +27293,34 @@  static void decode_mmi1(CPUMIPSState *env, DisasContext *ctx)
     }
 }
 
+static void gen_mmi_pcpyld(DisasContext *ctx, int rd, int rs, int rt)
+{
+    if (rd != 0) {
+        if (rs != 0) {
+            tcg_gen_mov_i64(cpu_mmr[rd], cpu_gpr[rs]);
+        } else {
+            tcg_gen_movi_i64(cpu_mmr[rd], 0);
+        }
+
+        if (rt != 0) {
+            tcg_gen_mov_i64(cpu_gpr[rd], cpu_gpr[rt]);
+        } else {
+            tcg_gen_movi_i64(cpu_gpr[rd], 0);
+        }
+    }
+}
+
 static void decode_mmi2(CPUMIPSState *env, DisasContext *ctx)
 {
     uint32_t opc = MASK_MMI2(ctx->opcode);
+    int rs = extract32(ctx->opcode, 21, 5);
+    int rt = extract32(ctx->opcode, 16, 5);
+    int rd = extract32(ctx->opcode, 11, 5);
 
     switch (opc) {
+    case MMI_OPC_2_PCPYLD:
+        gen_mmi_pcpyld(ctx, rd, rs, rt);
+        break;
     case MMI_OPC_2_PMADDW:    /* TODO: MMI_OPC_2_PMADDW */
     case MMI_OPC_2_PSLLVW:    /* TODO: MMI_OPC_2_PSLLVW */
     case MMI_OPC_2_PSRLVW:    /* TODO: MMI_OPC_2_PSRLVW */
@@ -27307,7 +27330,6 @@  static void decode_mmi2(CPUMIPSState *env, DisasContext *ctx)
     case MMI_OPC_2_PINTH:     /* TODO: MMI_OPC_2_PINTH */
     case MMI_OPC_2_PMULTW:    /* TODO: MMI_OPC_2_PMULTW */
     case MMI_OPC_2_PDIVW:     /* TODO: MMI_OPC_2_PDIVW */
-    case MMI_OPC_2_PCPYLD:    /* TODO: MMI_OPC_2_PCPYLD */
     case MMI_OPC_2_PMADDH:    /* TODO: MMI_OPC_2_PMADDH */
     case MMI_OPC_2_PHMADH:    /* TODO: MMI_OPC_2_PHMADH */
     case MMI_OPC_2_PAND:      /* TODO: MMI_OPC_2_PAND */