From nobody Wed May 1 22:28:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541618388375581.9438274359287; Wed, 7 Nov 2018 11:19:48 -0800 (PST) Received: from localhost ([::1]:50383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTMh-0006Rn-15 for importer@patchew.org; Wed, 07 Nov 2018 14:19:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTL8-0005S1-4T for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:18:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKTL5-0004Ge-9q for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:18:10 -0500 Received: from pio-pvt-msa1.bahnhof.se ([79.136.2.40]:60501) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKTL4-0004GO-Tv for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:18:07 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTP id F05E13F7CB; Wed, 7 Nov 2018 20:18:05 +0100 (CET) Received: from pio-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ndPs9s_uTbY9; Wed, 7 Nov 2018 20:18:01 +0100 (CET) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 54CE93F71C; Wed, 7 Nov 2018 20:18:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Wed, 7 Nov 2018 20:18:01 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Richard Henderson Message-ID: <3275cefbe30ccac35da7f5fc99fb038d46149192.1541616663.git.noring@nocrew.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 79.136.2.40 Subject: [Qemu-devel] [PATCH v2 1/6] target/mips: Fix decoding mechanism of R5900 MFLO1, MFHI1, MTLO1 and MTHI1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?Q?J=C3=BCrgen?= Urban , qemu-devel@nongnu.org, "Maciej W. Rozycki" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" MFLO1, MFHI1, MTLO1 and MTHI1 are generated in gen_HILO1_tx79 instead of the generic gen_HILO. Signed-off-by: Fredrik Noring Reviewed-by: Aleksandar Markovic --- target/mips/translate.c | 51 ++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index 60320cbe69..8601333554 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -4359,24 +4359,56 @@ static void gen_shift(DisasContext *ctx, uint32_t o= pc, tcg_temp_free(t1); } =20 +/* Copy GPR to and from TX79 HI1/LO1 register. */ +static void gen_HILO1_tx79(DisasContext *ctx, uint32_t opc, int reg) +{ + if (reg =3D=3D 0 && (opc =3D=3D TX79_MMI_MFHI1 || opc =3D=3D TX79_MMI_= MFLO1)) { + /* Treat as NOP. */ + return; + } + + switch (opc) { + case TX79_MMI_MFHI1: + tcg_gen_mov_tl(cpu_gpr[reg], cpu_HI[1]); + break; + case TX79_MMI_MFLO1: + tcg_gen_mov_tl(cpu_gpr[reg], cpu_LO[1]); + break; + case TX79_MMI_MTHI1: + if (reg !=3D 0) { + tcg_gen_mov_tl(cpu_HI[1], cpu_gpr[reg]); + } else { + tcg_gen_movi_tl(cpu_HI[1], 0); + } + break; + case TX79_MMI_MTLO1: + if (reg !=3D 0) { + tcg_gen_mov_tl(cpu_LO[1], cpu_gpr[reg]); + } else { + tcg_gen_movi_tl(cpu_LO[1], 0); + } + break; + default: + MIPS_INVAL("mfthilo1 TX79"); + generate_exception_end(ctx, EXCP_RI); + break; + } +} + /* Arithmetic on HI/LO registers */ static void gen_HILO(DisasContext *ctx, uint32_t opc, int acc, int reg) { - if (reg =3D=3D 0 && (opc =3D=3D OPC_MFHI || opc =3D=3D TX79_MMI_MFHI1 = || - opc =3D=3D OPC_MFLO || opc =3D=3D TX79_MMI_MFLO1)) { + if (reg =3D=3D 0 && (opc =3D=3D OPC_MFHI || opc =3D=3D OPC_MFLO)) { /* Treat as NOP. */ return; } =20 if (acc !=3D 0) { - if (!(ctx->insn_flags & INSN_R5900)) { - check_dsp(ctx); - } + check_dsp(ctx); } =20 switch (opc) { case OPC_MFHI: - case TX79_MMI_MFHI1: #if defined(TARGET_MIPS64) if (acc !=3D 0) { tcg_gen_ext32s_tl(cpu_gpr[reg], cpu_HI[acc]); @@ -4387,7 +4419,6 @@ static void gen_HILO(DisasContext *ctx, uint32_t opc,= int acc, int reg) } break; case OPC_MFLO: - case TX79_MMI_MFLO1: #if defined(TARGET_MIPS64) if (acc !=3D 0) { tcg_gen_ext32s_tl(cpu_gpr[reg], cpu_LO[acc]); @@ -4398,7 +4429,6 @@ static void gen_HILO(DisasContext *ctx, uint32_t opc,= int acc, int reg) } break; case OPC_MTHI: - case TX79_MMI_MTHI1: if (reg !=3D 0) { #if defined(TARGET_MIPS64) if (acc !=3D 0) { @@ -4413,7 +4443,6 @@ static void gen_HILO(DisasContext *ctx, uint32_t opc,= int acc, int reg) } break; case OPC_MTLO: - case TX79_MMI_MTLO1: if (reg !=3D 0) { #if defined(TARGET_MIPS64) if (acc !=3D 0) { @@ -26500,11 +26529,11 @@ static void decode_tx79_mmi(CPUMIPSState *env, Di= sasContext *ctx) break; case TX79_MMI_MTLO1: case TX79_MMI_MTHI1: - gen_HILO(ctx, opc, 1, rs); + gen_HILO1_tx79(ctx, opc, rs); break; case TX79_MMI_MFLO1: case TX79_MMI_MFHI1: - gen_HILO(ctx, opc, 1, rd); + gen_HILO1_tx79(ctx, opc, rd); break; case TX79_MMI_MADD: /* TODO: TX79_MMI_MADD */ case TX79_MMI_MADDU: /* TODO: TX79_MMI_MADDU */ --=20 2.18.1 From nobody Wed May 1 22:28:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541618533263488.1333883510532; Wed, 7 Nov 2018 11:22:13 -0800 (PST) Received: from localhost ([::1]:50399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTP2-0008II-2s for importer@patchew.org; Wed, 07 Nov 2018 14:22:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTLm-0006Ah-RH for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:18:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKTLh-0004lS-2H for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:18:48 -0500 Received: from pio-pvt-msa1.bahnhof.se ([79.136.2.40]:60532) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKTLe-0004UN-KY for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:18:43 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTP id 789273F7CB; Wed, 7 Nov 2018 20:18:24 +0100 (CET) Received: from pio-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mWOL8ES03prP; Wed, 7 Nov 2018 20:18:15 +0100 (CET) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 9464F3F744; Wed, 7 Nov 2018 20:18:15 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Wed, 7 Nov 2018 20:18:15 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Message-ID: <66a601730594bdf71aeacc9f5040f9b257803cb2.1541616663.git.noring@nocrew.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 79.136.2.40 Subject: [Qemu-devel] [PATCH v2 2/6] target/mips: Fix decoding mechanism of R5900 DIV1 and DIVU1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?Q?J=C3=BCrgen?= Urban , qemu-devel@nongnu.org, "Maciej W. Rozycki" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" DIV1 and DIVU1 are generated in gen_div1_tx79 instead of the generic gen_muldiv. Signed-off-by: Fredrik Noring Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/translate.c | 65 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index 8601333554..3ddd70043a 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -4743,6 +4743,63 @@ static void gen_r6_muldiv(DisasContext *ctx, int opc= , int rd, int rs, int rt) tcg_temp_free(t1); } =20 +static void gen_div1_tx79(DisasContext *ctx, uint32_t opc, int rs, int rt) +{ + TCGv t0, t1; + + t0 =3D tcg_temp_new(); + t1 =3D tcg_temp_new(); + + gen_load_gpr(t0, rs); + gen_load_gpr(t1, rt); + + switch (opc) { + case TX79_MMI_DIV1: + { + TCGv t2 =3D tcg_temp_new(); + TCGv t3 =3D tcg_temp_new(); + tcg_gen_ext32s_tl(t0, t0); + tcg_gen_ext32s_tl(t1, t1); + tcg_gen_setcondi_tl(TCG_COND_EQ, t2, t0, INT_MIN); + tcg_gen_setcondi_tl(TCG_COND_EQ, t3, t1, -1); + tcg_gen_and_tl(t2, t2, t3); + tcg_gen_setcondi_tl(TCG_COND_EQ, t3, t1, 0); + tcg_gen_or_tl(t2, t2, t3); + tcg_gen_movi_tl(t3, 0); + tcg_gen_movcond_tl(TCG_COND_NE, t1, t2, t3, t2, t1); + tcg_gen_div_tl(cpu_LO[1], t0, t1); + tcg_gen_rem_tl(cpu_HI[1], t0, t1); + tcg_gen_ext32s_tl(cpu_LO[1], cpu_LO[1]); + tcg_gen_ext32s_tl(cpu_HI[1], cpu_HI[1]); + tcg_temp_free(t3); + tcg_temp_free(t2); + } + break; + case TX79_MMI_DIVU1: + { + TCGv t2 =3D tcg_const_tl(0); + TCGv t3 =3D tcg_const_tl(1); + tcg_gen_ext32u_tl(t0, t0); + tcg_gen_ext32u_tl(t1, t1); + tcg_gen_movcond_tl(TCG_COND_EQ, t1, t1, t2, t3, t1); + tcg_gen_divu_tl(cpu_LO[1], t0, t1); + tcg_gen_remu_tl(cpu_HI[1], t0, t1); + tcg_gen_ext32s_tl(cpu_LO[1], cpu_LO[1]); + tcg_gen_ext32s_tl(cpu_HI[1], cpu_HI[1]); + tcg_temp_free(t3); + tcg_temp_free(t2); + } + break; + default: + MIPS_INVAL("div1 TX79"); + generate_exception_end(ctx, EXCP_RI); + goto out; + } + out: + tcg_temp_free(t0); + tcg_temp_free(t1); +} + static void gen_muldiv(DisasContext *ctx, uint32_t opc, int acc, int rs, int rt) { @@ -4755,14 +4812,11 @@ static void gen_muldiv(DisasContext *ctx, uint32_t = opc, gen_load_gpr(t1, rt); =20 if (acc !=3D 0) { - if (!(ctx->insn_flags & INSN_R5900)) { - check_dsp(ctx); - } + check_dsp(ctx); } =20 switch (opc) { case OPC_DIV: - case TX79_MMI_DIV1: { TCGv t2 =3D tcg_temp_new(); TCGv t3 =3D tcg_temp_new(); @@ -4784,7 +4838,6 @@ static void gen_muldiv(DisasContext *ctx, uint32_t op= c, } break; case OPC_DIVU: - case TX79_MMI_DIVU1: { TCGv t2 =3D tcg_const_tl(0); TCGv t3 =3D tcg_const_tl(1); @@ -26525,7 +26578,7 @@ static void decode_tx79_mmi(CPUMIPSState *env, Disa= sContext *ctx) break; case TX79_MMI_DIV1: case TX79_MMI_DIVU1: - gen_muldiv(ctx, opc, 1, rs, rt); + gen_div1_tx79(ctx, opc, rs, rt); break; case TX79_MMI_MTLO1: case TX79_MMI_MTHI1: --=20 2.18.1 From nobody Wed May 1 22:28:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541618453713668.7176159192621; Wed, 7 Nov 2018 11:20:53 -0800 (PST) Received: from localhost ([::1]:50388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTNk-0007ED-HM for importer@patchew.org; Wed, 07 Nov 2018 14:20:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTM1-0006Jj-P1 for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:19:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKTLy-0004zQ-N6 for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:19:05 -0500 Received: from pio-pvt-msa2.bahnhof.se ([79.136.2.41]:50445) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKTLy-0004yP-7G for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:19:02 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id A4D7F3F6FD; Wed, 7 Nov 2018 20:19:00 +0100 (CET) Received: from pio-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rKepASdUUsn8; Wed, 7 Nov 2018 20:18:55 +0100 (CET) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 64DAA3F6B6; Wed, 7 Nov 2018 20:18:55 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Wed, 7 Nov 2018 20:18:55 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Richard Henderson Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 79.136.2.41 Subject: [Qemu-devel] [PATCH v2 3/6] target/mips: Fix HI[ac] and LO[ac] 32-bit truncation with MIPS64 DSP ASE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?Q?J=C3=BCrgen?= Urban , Jia Liu , "Maciej W. Rozycki" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change removes the 32-bit truncation of the HI[ac] and LO[ac] special purpose registers when ac range from 1 to 3 for the instructions MFHI, MFLO, MTHI and MTLO. The "MIPS Architecture for Programmers Volume IV-e: MIPS DSP Module for MIPS64 Architecture" manual specifies that all 64 bits are copied in all cases: MFHI: GPR[rd]63..0 <- HI[ac]63..0 MFLO: GPR[rd]63..0 <- LO[ac]63..0 MTHI: HI[ac]63..0 <- GPR[rs]63..0 MTLO: LO[ac]63..0 <- GPR[rs]63..0 Fixes: 4133498f8e53 ("Use correct acc value to index cpu_HI/cpu_LO rather t= han using a fix number") Cc: Jia Liu Reported-by: Maciej W. Rozycki Signed-off-by: Fredrik Noring --- target/mips/translate.c | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index 3ddd70043a..19ae7d2f1c 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -4409,49 +4409,21 @@ static void gen_HILO(DisasContext *ctx, uint32_t op= c, int acc, int reg) =20 switch (opc) { case OPC_MFHI: -#if defined(TARGET_MIPS64) - if (acc !=3D 0) { - tcg_gen_ext32s_tl(cpu_gpr[reg], cpu_HI[acc]); - } else -#endif - { - tcg_gen_mov_tl(cpu_gpr[reg], cpu_HI[acc]); - } + tcg_gen_mov_tl(cpu_gpr[reg], cpu_HI[acc]); break; case OPC_MFLO: -#if defined(TARGET_MIPS64) - if (acc !=3D 0) { - tcg_gen_ext32s_tl(cpu_gpr[reg], cpu_LO[acc]); - } else -#endif - { - tcg_gen_mov_tl(cpu_gpr[reg], cpu_LO[acc]); - } + tcg_gen_mov_tl(cpu_gpr[reg], cpu_LO[acc]); break; case OPC_MTHI: if (reg !=3D 0) { -#if defined(TARGET_MIPS64) - if (acc !=3D 0) { - tcg_gen_ext32s_tl(cpu_HI[acc], cpu_gpr[reg]); - } else -#endif - { - tcg_gen_mov_tl(cpu_HI[acc], cpu_gpr[reg]); - } + tcg_gen_mov_tl(cpu_HI[acc], cpu_gpr[reg]); } else { tcg_gen_movi_tl(cpu_HI[acc], 0); } break; case OPC_MTLO: if (reg !=3D 0) { -#if defined(TARGET_MIPS64) - if (acc !=3D 0) { - tcg_gen_ext32s_tl(cpu_LO[acc], cpu_gpr[reg]); - } else -#endif - { - tcg_gen_mov_tl(cpu_LO[acc], cpu_gpr[reg]); - } + tcg_gen_mov_tl(cpu_LO[acc], cpu_gpr[reg]); } else { tcg_gen_movi_tl(cpu_LO[acc], 0); } --=20 2.18.1 From nobody Wed May 1 22:28:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541618579452730.6612147622733; Wed, 7 Nov 2018 11:22:59 -0800 (PST) Received: from localhost ([::1]:50400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTPm-0000U1-6D for importer@patchew.org; Wed, 07 Nov 2018 14:22:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTMe-0006mc-R2 for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:19:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKTMV-0005Bb-GZ for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:19:40 -0500 Received: from ste-pvt-msa2.bahnhof.se ([213.80.101.71]:1368) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKTMO-000594-8G for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:19:29 -0500 Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 4C2C53F8C5; Wed, 7 Nov 2018 20:19:24 +0100 (CET) Received: from ste-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (ste-ftg-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E6cA7TUfEXsj; Wed, 7 Nov 2018 20:19:14 +0100 (CET) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id D3EB13F8B3; Wed, 7 Nov 2018 20:19:14 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Wed, 7 Nov 2018 20:19:14 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 213.80.101.71 Subject: [Qemu-devel] [PATCH v2 4/6] target/mips: Fix decoding mechanism of special R5900 opcodes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?Q?J=C3=BCrgen?= Urban , qemu-devel@nongnu.org, "Maciej W. Rozycki" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" MOVN, MOVZ, MFHI, MFLO, MTHI, MTLO, MULT, MULTU, DIV, DIVU, DMULT, DMULTU, DDIV, DDIVU and JR are decoded in decode_opc_special_tx79 instead of the generic decode_opc_special_legacy. Signed-off-by: Fredrik Noring Reviewed-by: Aleksandar Markovic --- target/mips/translate.c | 54 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index 19ae7d2f1c..45ad70c097 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -23835,6 +23835,53 @@ static void decode_opc_special_r6(CPUMIPSState *en= v, DisasContext *ctx) } } =20 +static void decode_opc_special_tx79(CPUMIPSState *env, DisasContext *ctx) +{ + int rs =3D extract32(ctx->opcode, 21, 5); + int rt =3D extract32(ctx->opcode, 16, 5); + int rd =3D extract32(ctx->opcode, 11, 5); + uint32_t op1 =3D MASK_SPECIAL(ctx->opcode); + + switch (op1) { + case OPC_MOVN: /* Conditional move */ + case OPC_MOVZ: + gen_cond_move(ctx, op1, rd, rs, rt); + break; + case OPC_MFHI: /* Move from HI/LO */ + case OPC_MFLO: + gen_HILO(ctx, op1, 0, rd); + break; + case OPC_MTHI: + case OPC_MTLO: /* Move to HI/LO */ + gen_HILO(ctx, op1, 0, rs); + break; + case OPC_MULT: + case OPC_MULTU: + gen_mul_txx9(ctx, op1, rd, rs, rt); + break; + case OPC_DIV: + case OPC_DIVU: + gen_muldiv(ctx, op1, 0, rs, rt); + break; +#if defined(TARGET_MIPS64) + case OPC_DMULT: + case OPC_DMULTU: + case OPC_DDIV: + case OPC_DDIVU: + check_insn_opc_user_only(ctx, INSN_R5900); + gen_muldiv(ctx, op1, 0, rs, rt); + break; +#endif + case OPC_JR: + gen_compute_branch(ctx, op1, 4, rs, 0, 0, 4); + break; + default: /* Invalid */ + MIPS_INVAL("special_tx79"); + generate_exception_end(ctx, EXCP_RI); + break; + } +} + static void decode_opc_special_legacy(CPUMIPSState *env, DisasContext *ctx) { int rs, rt, rd, sa; @@ -23850,7 +23897,7 @@ static void decode_opc_special_legacy(CPUMIPSState = *env, DisasContext *ctx) case OPC_MOVN: /* Conditional move */ case OPC_MOVZ: check_insn(ctx, ISA_MIPS4 | ISA_MIPS32 | - INSN_LOONGSON2E | INSN_LOONGSON2F | INSN_R5900); + INSN_LOONGSON2E | INSN_LOONGSON2F); gen_cond_move(ctx, op1, rd, rs, rt); break; case OPC_MFHI: /* Move from HI/LO */ @@ -23877,8 +23924,6 @@ static void decode_opc_special_legacy(CPUMIPSState = *env, DisasContext *ctx) check_insn(ctx, INSN_VR54XX); op1 =3D MASK_MUL_VR54XX(ctx->opcode); gen_mul_vr54xx(ctx, op1, rd, rs, rt); - } else if (ctx->insn_flags & INSN_R5900) { - gen_mul_txx9(ctx, op1, rd, rs, rt); } else { gen_muldiv(ctx, op1, rd & 3, rs, rt); } @@ -23893,7 +23938,6 @@ static void decode_opc_special_legacy(CPUMIPSState = *env, DisasContext *ctx) case OPC_DDIV: case OPC_DDIVU: check_insn(ctx, ISA_MIPS3); - check_insn_opc_user_only(ctx, INSN_R5900); check_mips_64(ctx); gen_muldiv(ctx, op1, 0, rs, rt); break; @@ -24120,6 +24164,8 @@ static void decode_opc_special(CPUMIPSState *env, D= isasContext *ctx) default: if (ctx->insn_flags & ISA_MIPS32R6) { decode_opc_special_r6(env, ctx); + } else if (ctx->insn_flags & INSN_R5900) { + decode_opc_special_tx79(env, ctx); } else { decode_opc_special_legacy(env, ctx); } --=20 2.18.1 From nobody Wed May 1 22:28:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541618590701803.7702042754574; Wed, 7 Nov 2018 11:23:10 -0800 (PST) Received: from localhost ([::1]:50401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTPw-0000iI-SE for importer@patchew.org; Wed, 07 Nov 2018 14:23:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTMr-0006uu-Rl for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:19:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKTMo-0005Lv-Vs for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:19:57 -0500 Received: from ste-pvt-msa2.bahnhof.se ([213.80.101.71]:18493) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKTMo-0005Kn-Nu for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:19:54 -0500 Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id BC59F3F948; Wed, 7 Nov 2018 20:19:43 +0100 (CET) Received: from ste-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (ste-ftg-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zBcsTaNwFeMM; Wed, 7 Nov 2018 20:19:35 +0100 (CET) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 3DD573F8B3; Wed, 7 Nov 2018 20:19:35 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Wed, 7 Nov 2018 20:19:34 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Message-ID: <0c57a01dc6463a5298037e1b211ea214c1ea245f.1541616663.git.noring@nocrew.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 213.80.101.71 Subject: [Qemu-devel] [PATCH v2 5/6] target/mips: Guard check_insn_opc_user_only with INSN_R5900 check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?Q?J=C3=BCrgen?= Urban , qemu-devel@nongnu.org, "Maciej W. Rozycki" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Fredrik Noring Reviewed-by: Aleksandar Markovic --- target/mips/translate.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index 45ad70c097..c3ed4c21ce 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -28285,7 +28285,9 @@ static void decode_opc(CPUMIPSState *env, DisasCont= ext *ctx) break; case OPC_LL: /* Load and stores */ check_insn(ctx, ISA_MIPS2); - check_insn_opc_user_only(ctx, INSN_R5900); + if (ctx->insn_flags & INSN_R5900) { + check_insn_opc_user_only(ctx, INSN_R5900); + } /* Fallthrough */ case OPC_LWL: case OPC_LWR: @@ -28311,7 +28313,9 @@ static void decode_opc(CPUMIPSState *env, DisasCont= ext *ctx) case OPC_SC: check_insn(ctx, ISA_MIPS2); check_insn_opc_removed(ctx, ISA_MIPS32R6); - check_insn_opc_user_only(ctx, INSN_R5900); + if (ctx->insn_flags & INSN_R5900) { + check_insn_opc_user_only(ctx, INSN_R5900); + } gen_st_cond(ctx, op, rt, rs, imm); break; case OPC_CACHE: @@ -28579,7 +28583,9 @@ static void decode_opc(CPUMIPSState *env, DisasCont= ext *ctx) #if defined(TARGET_MIPS64) /* MIPS64 opcodes */ case OPC_LLD: - check_insn_opc_user_only(ctx, INSN_R5900); + if (ctx->insn_flags & INSN_R5900) { + check_insn_opc_user_only(ctx, INSN_R5900); + } /* fall through */ case OPC_LDL: case OPC_LDR: @@ -28603,7 +28609,9 @@ static void decode_opc(CPUMIPSState *env, DisasCont= ext *ctx) case OPC_SCD: check_insn_opc_removed(ctx, ISA_MIPS32R6); check_insn(ctx, ISA_MIPS3); - check_insn_opc_user_only(ctx, INSN_R5900); + if (ctx->insn_flags & INSN_R5900) { + check_insn_opc_user_only(ctx, INSN_R5900); + } check_mips_64(ctx); gen_st_cond(ctx, op, rt, rs, imm); break; --=20 2.18.1 From nobody Wed May 1 22:28:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541618665926443.56742053333517; Wed, 7 Nov 2018 11:24:25 -0800 (PST) Received: from localhost ([::1]:50408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTQy-0003x1-2B for importer@patchew.org; Wed, 07 Nov 2018 14:24:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKTMv-0006yo-Tl for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:20:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKTMv-0005Qu-7R for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:20:01 -0500 Received: from ste-pvt-msa2.bahnhof.se ([213.80.101.71]:50320) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKTMu-0005QE-Vp for qemu-devel@nongnu.org; Wed, 07 Nov 2018 14:20:01 -0500 Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id D2FFF3F8C5; Wed, 7 Nov 2018 20:19:54 +0100 (CET) Received: from ste-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (ste-ftg-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OUoCTE4UYDGX; Wed, 7 Nov 2018 20:19:45 +0100 (CET) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 87A1F3F8B3; Wed, 7 Nov 2018 20:19:45 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Wed, 7 Nov 2018 20:19:45 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Message-ID: <772fb0e8be790e1ab80569425a505890f26f1369.1541616663.git.noring@nocrew.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 213.80.101.71 Subject: [Qemu-devel] [PATCH v2 6/6] target/mips: Guard check_insn with INSN_R5900 check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?Q?J=C3=BCrgen?= Urban , qemu-devel@nongnu.org, "Maciej W. Rozycki" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Fredrik Noring Reviewed-by: Aleksandar Markovic --- target/mips/translate.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index c3ed4c21ce..007dfd2975 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -28329,8 +28329,11 @@ static void decode_opc(CPUMIPSState *env, DisasCon= text *ctx) break; case OPC_PREF: check_insn_opc_removed(ctx, ISA_MIPS32R6); - check_insn(ctx, ISA_MIPS4 | ISA_MIPS32 | - INSN_R5900); + if (ctx->insn_flags & INSN_R5900) { + /* The R5900 implements PREF. */ + } else { + check_insn(ctx, ISA_MIPS4 | ISA_MIPS32); + } /* Treat as NOP. */ break; =20 --=20 2.18.1