From nobody Sat May 4 22:57:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547406222883591.0553029276169; Sun, 13 Jan 2019 11:03:42 -0800 (PST) Received: from localhost ([127.0.0.1]:38862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil2h-0003Rc-6R for importer@patchew.org; Sun, 13 Jan 2019 14:03:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil1h-0002wr-PW for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:02:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gil1Z-0003QJ-Rg for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:02:25 -0500 Received: from pio-pvt-msa2.bahnhof.se ([79.136.2.41]:55162) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gil1X-0003Ng-1o for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:02:19 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 17EA23F39C; Sun, 13 Jan 2019 20:02:12 +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 sNxdet-gfWpF; Sun, 13 Jan 2019 20:02:07 +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 34BA03F51F; Sun, 13 Jan 2019 20:02:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Sun, 13 Jan 2019 20:02:06 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Message-ID: <781155aaf175ea20903c12e26316ea40085457bb.1547403692.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.41 Subject: [Qemu-devel] [PATCH 1/9] target/mips: Require TARGET_MIPS64 for R5900 multimedia instructions 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" The R5900 MMIs operate on 128-bit registers that will be split into two halves: lower 64-bit GPRs and upper 64-bit MMRs. The MMIs will therefore be left unimplemented in 32-bit mode with the o32 ABI. Signed-off-by: Fredrik Noring --- target/mips/translate.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index 057aaf9a44..a538351032 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -27218,6 +27218,7 @@ static void decode_opc_special3_legacy(CPUMIPSState= *env, DisasContext *ctx) } } =20 +#if defined(TARGET_MIPS64) static void decode_mmi0(CPUMIPSState *env, DisasContext *ctx) { uint32_t opc =3D MASK_MMI0(ctx->opcode); @@ -27351,6 +27352,7 @@ static void decode_mmi3(CPUMIPSState *env, DisasCon= text *ctx) break; } } +#endif /* defined(TARGET_MIPS64) */ =20 static void decode_mmi(CPUMIPSState *env, DisasContext *ctx) { @@ -27360,18 +27362,6 @@ static void decode_mmi(CPUMIPSState *env, DisasCon= text *ctx) int rd =3D extract32(ctx->opcode, 11, 5); =20 switch (opc) { - case MMI_OPC_CLASS_MMI0: - decode_mmi0(env, ctx); - break; - case MMI_OPC_CLASS_MMI1: - decode_mmi1(env, ctx); - break; - case MMI_OPC_CLASS_MMI2: - decode_mmi2(env, ctx); - break; - case MMI_OPC_CLASS_MMI3: - decode_mmi3(env, ctx); - break; case MMI_OPC_MULT1: case MMI_OPC_MULTU1: case MMI_OPC_MADD: @@ -27392,6 +27382,7 @@ static void decode_mmi(CPUMIPSState *env, DisasCont= ext *ctx) case MMI_OPC_MFHI1: gen_HILO1_tx79(ctx, opc, rd); break; +#if defined(TARGET_MIPS64) case MMI_OPC_PLZCW: /* TODO: MMI_OPC_PLZCW */ case MMI_OPC_PMFHL: /* TODO: MMI_OPC_PMFHL */ case MMI_OPC_PMTHL: /* TODO: MMI_OPC_PMTHL */ @@ -27403,6 +27394,19 @@ static void decode_mmi(CPUMIPSState *env, DisasCon= text *ctx) case MMI_OPC_PSRAW: /* TODO: MMI_OPC_PSRAW */ generate_exception_end(ctx, EXCP_RI); /* TODO: MMI_OPC_CLASS_MM= I */ break; + case MMI_OPC_CLASS_MMI0: + decode_mmi0(env, ctx); + break; + case MMI_OPC_CLASS_MMI1: + decode_mmi1(env, ctx); + break; + case MMI_OPC_CLASS_MMI2: + decode_mmi2(env, ctx); + break; + case MMI_OPC_CLASS_MMI3: + decode_mmi3(env, ctx); + break; +#endif default: MIPS_INVAL("TX79 MMI class"); generate_exception_end(ctx, EXCP_RI); --=20 2.19.2 From nobody Sat May 4 22:57:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547406307704264.9840102967306; Sun, 13 Jan 2019 11:05:07 -0800 (PST) Received: from localhost ([127.0.0.1]:39224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil4D-0004OZ-VT for importer@patchew.org; Sun, 13 Jan 2019 14:05:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil2l-0003aD-MQ for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:03:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gil2j-00045i-RB for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:03:35 -0500 Received: from pio-pvt-msa2.bahnhof.se ([79.136.2.41]:55302) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gil2j-00044Q-K9 for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:03:33 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 09AF63F534; Sun, 13 Jan 2019 20:03:26 +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 Vx4CL8B_TGl2; Sun, 13 Jan 2019 20:03:21 +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 CA0D33F39C; Sun, 13 Jan 2019 20:03:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Sun, 13 Jan 2019 20:03:20 +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: 79.136.2.41 Subject: [Qemu-devel] [PATCH 2/9] target/mips: Introduce 32 R5900 128-bit multimedia registers 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" The 32 R5900 128-bit MMRs are split into two 64-bit halves: the lower halves are the GPRs and the upper halves are accessible by the R5900- specific multimedia instructions. Signed-off-by: Fredrik Noring Reviewed-by: Aleksandar Markovic --- target/mips/cpu.h | 2 ++ target/mips/translate.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 03c03fd8c6..9ff4a68d90 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -180,6 +180,8 @@ struct TCState { #define MXU_CR_RD_EN 1 #define MXU_CR_MXU_EN 0 =20 + /* Upper 64-bit MMRs (multimedia registers); the lower 64-bit are GPRs= */ + uint64_t mmr[32]; }; =20 typedef struct CPUMIPSState CPUMIPSState; diff --git a/target/mips/translate.c b/target/mips/translate.c index a538351032..9d5150ec8b 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -2455,7 +2455,10 @@ static TCGv_i32 fpu_fcr0, fpu_fcr31; static TCGv_i64 fpu_f64[32]; static TCGv_i64 msa_wr_d[64]; =20 -#if !defined(TARGET_MIPS64) +#if defined(TARGET_MIPS64) +/* Upper 64-bit MMRs (multimedia registers); the lower 64-bit are GPRs */ +static TCGv_i64 cpu_mmr[32]; +#else /* MXU registers */ static TCGv mxu_gpr[NUMBER_OF_MXU_REGISTERS - 1]; static TCGv mxu_CR; @@ -29785,7 +29788,14 @@ void mips_tcg_init(void) fpu_fcr31 =3D tcg_global_mem_new_i32(cpu_env, offsetof(CPUMIPSState, active_fpu.f= cr31), "fcr31"); -#if !defined(TARGET_MIPS64) +#if defined(TARGET_MIPS64) + cpu_mmr[0] =3D NULL; + for (i =3D 1; i < 32; i++) + cpu_mmr[i] =3D tcg_global_mem_new_i64(cpu_env, + offsetof(CPUMIPSState, + active_tc.mmr[i]), + regnames[i]); +#else for (i =3D 0; i < NUMBER_OF_MXU_REGISTERS - 1; i++) { mxu_gpr[i] =3D tcg_global_mem_new(cpu_env, offsetof(CPUMIPSState, --=20 2.19.2 From nobody Sat May 4 22:57:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547406328262347.6474990793316; Sun, 13 Jan 2019 11:05:28 -0800 (PST) Received: from localhost ([127.0.0.1]:39317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil4Y-0004bN-UJ for importer@patchew.org; Sun, 13 Jan 2019 14:05:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil3H-0003zG-FK for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:04:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gil3G-0004IT-7L for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:04:07 -0500 Received: from pio-pvt-msa3.bahnhof.se ([79.136.2.42]:38768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gil3G-0004I0-0z for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:04:06 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTP id 032BA3F31A; Sun, 13 Jan 2019 20:04:05 +0100 (CET) Received: from pio-pvt-msa3.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa3.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vex27hDSfdb5; Sun, 13 Jan 2019 20:04:04 +0100 (CET) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTPA id 808F53F4C5; Sun, 13 Jan 2019 20:03:59 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Sun, 13 Jan 2019 20:03:59 +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: 79.136.2.42 Subject: [Qemu-devel] [PATCH 3/9] target/mips: Support the R5900 PCPYLD multimedia instruction 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 | 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, DisasC= ontext *ctx) } } =20 +static void gen_mmi_pcpyld(DisasContext *ctx, int rd, int rs, int rt) +{ + if (rd !=3D 0) { + if (rs !=3D 0) { + tcg_gen_mov_i64(cpu_mmr[rd], cpu_gpr[rs]); + } else { + tcg_gen_movi_i64(cpu_mmr[rd], 0); + } + + if (rt !=3D 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 =3D MASK_MMI2(ctx->opcode); + int rs =3D extract32(ctx->opcode, 21, 5); + int rt =3D extract32(ctx->opcode, 16, 5); + int rd =3D extract32(ctx->opcode, 11, 5); =20 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, DisasCon= text *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 */ --=20 2.19.2 From nobody Sat May 4 22:57:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547406405967256.11772294263153; Sun, 13 Jan 2019 11:06:45 -0800 (PST) Received: from localhost ([127.0.0.1]:39716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil5o-0005SS-JU for importer@patchew.org; Sun, 13 Jan 2019 14:06:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil44-0004VJ-Av for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:04:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gil43-0004eX-0T for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:04:56 -0500 Received: from pio-pvt-msa1.bahnhof.se ([79.136.2.40]:35884) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gil42-0004e1-Pa for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:04:54 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTP id 677D03F735; Sun, 13 Jan 2019 20:04:48 +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 Dye_A54l7eP3; Sun, 13 Jan 2019 20:04:47 +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 B7F783F715; Sun, 13 Jan 2019 20:04:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Sun, 13 Jan 2019 20:04:47 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Message-ID: <25ac8b01ff9243ab79efdc6912ec165b12831531.1547403692.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 4/9] target/mips: Support the R5900 PCPYUD multimedia instruction 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 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index 40faf9cb36..8c350729bc 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -27351,11 +27351,34 @@ static void decode_mmi2(CPUMIPSState *env, DisasC= ontext *ctx) } } =20 +static void gen_mmi_pcpyud(DisasContext *ctx, int rd, int rs, int rt) +{ + if (rd !=3D 0) { + if (rs !=3D 0) { + tcg_gen_mov_i64(cpu_gpr[rd], cpu_mmr[rs]); + } else { + tcg_gen_movi_i64(cpu_gpr[rd], 0); + } + + if (rt !=3D 0) { + tcg_gen_mov_i64(cpu_mmr[rd], cpu_mmr[rt]); + } else { + tcg_gen_movi_i64(cpu_mmr[rd], 0); + } + } +} + static void decode_mmi3(CPUMIPSState *env, DisasContext *ctx) { uint32_t opc =3D MASK_MMI3(ctx->opcode); + int rs =3D extract32(ctx->opcode, 21, 5); + int rt =3D extract32(ctx->opcode, 16, 5); + int rd =3D extract32(ctx->opcode, 11, 5); =20 switch (opc) { + case MMI_OPC_3_PCPYUD: + gen_mmi_pcpyud(ctx, rd, rs, rt); + break; case MMI_OPC_3_PMADDUW: /* TODO: MMI_OPC_3_PMADDUW */ case MMI_OPC_3_PSRAVW: /* TODO: MMI_OPC_3_PSRAVW */ case MMI_OPC_3_PMTHI: /* TODO: MMI_OPC_3_PMTHI */ @@ -27363,7 +27386,6 @@ static void decode_mmi3(CPUMIPSState *env, DisasCon= text *ctx) case MMI_OPC_3_PINTEH: /* TODO: MMI_OPC_3_PINTEH */ case MMI_OPC_3_PMULTUW: /* TODO: MMI_OPC_3_PMULTUW */ case MMI_OPC_3_PDIVUW: /* TODO: MMI_OPC_3_PDIVUW */ - case MMI_OPC_3_PCPYUD: /* TODO: MMI_OPC_3_PCPYUD */ case MMI_OPC_3_POR: /* TODO: MMI_OPC_3_POR */ case MMI_OPC_3_PNOR: /* TODO: MMI_OPC_3_PNOR */ case MMI_OPC_3_PEXCH: /* TODO: MMI_OPC_3_PEXCH */ --=20 2.19.2 From nobody Sat May 4 22:57:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547406542531500.1355869234875; Sun, 13 Jan 2019 11:09:02 -0800 (PST) Received: from localhost ([127.0.0.1]:40155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil81-0006mY-04 for importer@patchew.org; Sun, 13 Jan 2019 14:09:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil5D-0005H6-JS for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:06:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gil5C-0005Po-Nk for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:06:07 -0500 Received: from pio-pvt-msa2.bahnhof.se ([79.136.2.41]:55532) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gil5B-0005P8-Tc for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:06:06 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id E9E193F52B; Sun, 13 Jan 2019 20:05:59 +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 h71IEPOmTtMZ; Sun, 13 Jan 2019 20:05: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 0AA383F510; Sun, 13 Jan 2019 20:05:54 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Sun, 13 Jan 2019 20:05:54 +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: 79.136.2.41 Subject: [Qemu-devel] [PATCH 5/9] target/mips: Support the R5900 LQ multimedia instruction 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 --- target/mips/translate.c | 46 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index 8c350729bc..79505bb6c2 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -2626,6 +2626,17 @@ static inline void gen_store_gpr (TCGv t, int reg) tcg_gen_mov_tl(cpu_gpr[reg], t); } =20 +#if defined(TARGET_MIPS64) +/* 128-bit multimedia register moves. */ +static inline void gen_store_mmr(TCGv_i64 hi, TCGv_i64 lo, int reg) +{ + if (reg !=3D 0) { + tcg_gen_mov_i64(cpu_mmr[reg], hi); + tcg_gen_mov_i64(cpu_gpr[reg], lo); + } +} +#endif /* defined(TARGET_MIPS64) */ + /* Moves to/from shadow registers. */ static inline void gen_load_srsgpr (int from, int to) { @@ -27463,7 +27474,40 @@ static void decode_mmi(CPUMIPSState *env, DisasCon= text *ctx) =20 static void gen_mmi_lq(CPUMIPSState *env, DisasContext *ctx) { - generate_exception_end(ctx, EXCP_RI); /* TODO: MMI_OPC_LQ */ +#if !defined(TARGET_MIPS64) + generate_exception_end(ctx, EXCP_RI); +#else + int base =3D extract32(ctx->opcode, 21, 5); + int rt =3D extract32(ctx->opcode, 16, 5); + int offset =3D sextract32(ctx->opcode, 0, 16); + + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 val0 =3D tcg_temp_new_i64(); + TCGv_i64 val1 =3D tcg_temp_new_i64(); + + gen_base_offset_addr(ctx, addr, base, offset); + + /* + * The least significant four bits of the effective address are + * masked to zero, effectively creating an aligned address. No + * address exceptions due to alignment are possible. + */ + tcg_gen_andi_i64(addr, addr, ~0xFULL); + + tcg_gen_qemu_ld_i64(val0, addr, ctx->mem_idx, MO_UNALN | MO_64); + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(val1, addr, ctx->mem_idx, MO_UNALN | MO_64); + +#if defined(TARGET_WORDS_BIGENDIAN) + gen_store_mmr(val0, val1, rt); +#else + gen_store_mmr(val1, val0, rt); +#endif + + tcg_temp_free_i64(val1); + tcg_temp_free_i64(val0); + tcg_temp_free_i64(addr); +#endif /* defined(TARGET_MIPS64) */ } =20 static void gen_mmi_sq(DisasContext *ctx, int base, int rt, int offset) --=20 2.19.2 From nobody Sat May 4 22:57:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547406536464601.0825621910088; Sun, 13 Jan 2019 11:08:56 -0800 (PST) Received: from localhost ([127.0.0.1]:40094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil7m-0006aQ-DV for importer@patchew.org; Sun, 13 Jan 2019 14:08:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil63-0005iD-Lr for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:07:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gil63-0005mU-0O for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:06:59 -0500 Received: from pio-pvt-msa1.bahnhof.se ([79.136.2.40]:36056) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gil62-0005kk-Pw for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:06:58 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTP id AD9243F735; Sun, 13 Jan 2019 20:06:52 +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 Ug0ixImCmi3x; Sun, 13 Jan 2019 20:06:52 +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 0C7523F715; Sun, 13 Jan 2019 20:06:51 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Sun, 13 Jan 2019 20:06:51 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Message-ID: <68f0239c8a101f2dd3d86f110f79496db89fb440.1547403692.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 6/9] target/mips: Support the R5900 SQ multimedia instruction 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 --- target/mips/translate.c | 44 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index 79505bb6c2..1c7c649d36 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -2628,6 +2628,17 @@ static inline void gen_store_gpr (TCGv t, int reg) =20 #if defined(TARGET_MIPS64) /* 128-bit multimedia register moves. */ +static inline void gen_load_mmr(TCGv_i64 hi, TCGv_i64 lo, int reg) +{ + if (reg =3D=3D 0) { + tcg_gen_movi_i64(hi, 0); + tcg_gen_movi_i64(lo, 0); + } else { + tcg_gen_mov_i64(hi, cpu_mmr[reg]); + tcg_gen_mov_i64(lo, cpu_gpr[reg]); + } +} + static inline void gen_store_mmr(TCGv_i64 hi, TCGv_i64 lo, int reg) { if (reg !=3D 0) { @@ -27512,7 +27523,36 @@ static void gen_mmi_lq(CPUMIPSState *env, DisasCon= text *ctx) =20 static void gen_mmi_sq(DisasContext *ctx, int base, int rt, int offset) { - generate_exception_end(ctx, EXCP_RI); /* TODO: MMI_OPC_SQ */ +#if !defined(TARGET_MIPS64) + generate_exception_end(ctx, EXCP_RI); +#else + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 val0 =3D tcg_temp_new_i64(); + TCGv_i64 val1 =3D tcg_temp_new_i64(); + + gen_base_offset_addr(ctx, addr, base, offset); + + /* + * The least significant four bits of the effective address are + * masked to zero, effectively creating an aligned address. No + * address exceptions due to alignment are possible. + */ + tcg_gen_andi_i64(addr, addr, ~0xFULL); + +#if defined(TARGET_WORDS_BIGENDIAN) + gen_load_mmr(val0, val1, rt); +#else + gen_load_mmr(val1, val0, rt); +#endif + + tcg_gen_qemu_st_i64(val0, addr, ctx->mem_idx, MO_UNALN | MO_64); + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_st_i64(val1, addr, ctx->mem_idx, MO_UNALN | MO_64); + + tcg_temp_free_i64(val1); + tcg_temp_free_i64(val0); + tcg_temp_free_i64(addr); +#endif /* defined(TARGET_MIPS64) */ } =20 /* @@ -27540,7 +27580,7 @@ static void decode_mmi_sq(CPUMIPSState *env, DisasC= ontext *ctx) { int base =3D extract32(ctx->opcode, 21, 5); int rt =3D extract32(ctx->opcode, 16, 5); - int offset =3D extract32(ctx->opcode, 0, 16); + int offset =3D sextract32(ctx->opcode, 0, 16); =20 #ifdef CONFIG_USER_ONLY uint32_t op1 =3D MASK_SPECIAL3(ctx->opcode); --=20 2.19.2 From nobody Sat May 4 22:57:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547406665150714.8794244385201; Sun, 13 Jan 2019 11:11:05 -0800 (PST) Received: from localhost ([127.0.0.1]:40776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil9z-0008VI-M1 for importer@patchew.org; Sun, 13 Jan 2019 14:11:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil6q-0006Gp-25 for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:07:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gil6o-00064n-5E for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:07:47 -0500 Received: from pio-pvt-msa2.bahnhof.se ([79.136.2.41]:55676) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gil6m-00063g-9C for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:07:44 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id D9DAF3F52B; Sun, 13 Jan 2019 20:07:37 +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 CImUAebCY5LH; Sun, 13 Jan 2019 20:07:30 +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 1D9B13F510; Sun, 13 Jan 2019 20:07:30 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Sun, 13 Jan 2019 20:07:29 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Message-ID: <5a4aa79777985d3d5c777ad2cdc6fdee9081345f.1547403692.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.41 Subject: [Qemu-devel] [PATCH 7/9] tests/tcg/mips: Test R5900 multimedia instructions PCPYUD and PCPYLD 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 --- tests/tcg/mips/mipsn32r5900/Makefile | 25 +++++++++++++++ tests/tcg/mips/mipsn32r5900/pcpyuld.c | 46 +++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 tests/tcg/mips/mipsn32r5900/Makefile create mode 100644 tests/tcg/mips/mipsn32r5900/pcpyuld.c diff --git a/tests/tcg/mips/mipsn32r5900/Makefile b/tests/tcg/mips/mipsn32r= 5900/Makefile new file mode 100644 index 0000000000..f4887678ae --- /dev/null +++ b/tests/tcg/mips/mipsn32r5900/Makefile @@ -0,0 +1,25 @@ +-include ../../config-host.mak + +CROSS=3Dmips64r5900el-unknown-linux-gnu- + +SIM=3Dqemu-mipsn32el +SIM_FLAGS=3D-cpu R5900 + +CC =3D $(CROSS)gcc +CFLAGS =3D -Wall -mabi=3Dn32 -march=3Dr5900 -static + +TESTCASES =3D pcpyuld.tst + +all: $(TESTCASES) + +%.tst: %.c + $(CC) $(CFLAGS) $< -o $@ + +check: $(TESTCASES) + @for case in $(TESTCASES); do \ + echo $(SIM) $(SIM_FLAGS) ./$$case;\ + $(SIM) $(SIM_FLAGS) ./$$case; \ + done + +clean: + $(RM) -rf $(TESTCASES) diff --git a/tests/tcg/mips/mipsn32r5900/pcpyuld.c b/tests/tcg/mips/mipsn32= r5900/pcpyuld.c new file mode 100644 index 0000000000..c92af6330b --- /dev/null +++ b/tests/tcg/mips/mipsn32r5900/pcpyuld.c @@ -0,0 +1,46 @@ +/* + * Test PCPYUD and PCPYLD. + */ + +#include +#include +#include +#include + +/* 128-bit multimedia register */ +struct mmr { uint64_t hi, lo; } __attribute__((aligned(16))); + +static void verify_zero(void) +{ + __asm__ __volatile__ ( + " pcpyud $0, $0, $0\n" + " pcpyld $0, $0, $0\n" + ); +} + +static void verify_copy(void) +{ + const struct mmr value =3D { + .hi =3D 0x6665646362613938, + .lo =3D 0x3736353433323130 + }; + struct mmr result =3D { }; + + __asm__ __volatile__ ( + " pcpyld %0, %2, %3\n" + " move %1, %0\n" + " pcpyud %0, %0, %0\n" + : "=3Dr" (result.hi), "=3Dr" (result.lo) + : "r" (value.hi), "r" (value.lo)); + + assert(value.hi =3D=3D result.hi); + assert(value.lo =3D=3D result.lo); +} + +int main() +{ + verify_zero(); + verify_copy(); + + return 0; +} --=20 2.19.2 From nobody Sat May 4 22:57:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547406720716897.5370129868038; Sun, 13 Jan 2019 11:12:00 -0800 (PST) Received: from localhost ([127.0.0.1]:41045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gilAt-0000pP-5J for importer@patchew.org; Sun, 13 Jan 2019 14:11:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil7p-00073H-0m for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:08:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gil7o-0006XM-4g for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:08:49 -0500 Received: from pio-pvt-msa3.bahnhof.se ([79.136.2.42]:39152) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gil7n-0006X4-QR for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:08:48 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTP id A163F3F532; Sun, 13 Jan 2019 20:08:46 +0100 (CET) Received: from pio-pvt-msa3.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa3.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5YbiLCd9PBpd; Sun, 13 Jan 2019 20:08:40 +0100 (CET) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTPA id 166803F524; Sun, 13 Jan 2019 20:08:39 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Sun, 13 Jan 2019 20:08:39 +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: 79.136.2.42 Subject: [Qemu-devel] [PATCH 8/9] tests/tcg/mips: Test R5900 multimedia instruction LQ 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 --- tests/tcg/mips/mipsn32r5900/Makefile | 3 +- tests/tcg/mips/mipsn32r5900/lq.c | 111 +++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/mips/mipsn32r5900/lq.c diff --git a/tests/tcg/mips/mipsn32r5900/Makefile b/tests/tcg/mips/mipsn32r= 5900/Makefile index f4887678ae..cb3ef9d26a 100644 --- a/tests/tcg/mips/mipsn32r5900/Makefile +++ b/tests/tcg/mips/mipsn32r5900/Makefile @@ -8,7 +8,8 @@ SIM_FLAGS=3D-cpu R5900 CC =3D $(CROSS)gcc CFLAGS =3D -Wall -mabi=3Dn32 -march=3Dr5900 -static =20 -TESTCASES =3D pcpyuld.tst +TESTCASES =3D lq.tst +TESTCASES +=3D pcpyuld.tst =20 all: $(TESTCASES) =20 diff --git a/tests/tcg/mips/mipsn32r5900/lq.c b/tests/tcg/mips/mipsn32r5900= /lq.c new file mode 100644 index 0000000000..5a16b12450 --- /dev/null +++ b/tests/tcg/mips/mipsn32r5900/lq.c @@ -0,0 +1,111 @@ +/* + * Test LQ. + */ + +#include +#include +#include + +/* 128-bit multimedia register */ +struct mmr { uint64_t hi, lo; } __attribute__((aligned(16))); + +#define LQ(base, offset) \ + ({ \ + uint64_t hi, lo; \ + \ + __asm__ __volatile__ ( \ + " pcpyld %1, %1, %1\n" \ + " lq %1, %3(%2)\n" \ + " pcpyud %0, %1, %1\n" \ + : "=3Dr" (hi), "=3Dr" (lo) \ + : "r" (base), "i" (offset)); \ + \ + (struct mmr) { .hi =3D hi, .lo =3D lo }; \ + }) + +static uint64_t ld_reference(const void *base, int16_t offset) +{ + const uint8_t *p =3D base; + uint64_t r =3D 0; + int i; + + for (i =3D 0; i < 8; i++) { + r |=3D (uint64_t)p[offset + i] << (8 * i); + } + + return r; +} + +static struct mmr lq_reference(const void *base, int16_t offset) +{ + /* + * The least significant four bits of the effective address are + * masked to zero, effectively creating an aligned address. No + * address exceptions due to alignment are possible. + */ + const uint8_t *b =3D base; + const uint8_t *o =3D &b[offset]; + const void *a =3D (const void*)((unsigned long)o & ~0xFUL); + + return (struct mmr) { + .hi =3D ld_reference(a, 8), + .lo =3D ld_reference(a, 0) + }; +} + +static void assert_equal_mmr(struct mmr a, struct mmr b) +{ + assert(a.hi =3D=3D b.hi); + assert(a.lo =3D=3D b.lo); +} + +#define VERIFY_LQ(base, offset) \ + assert_equal_mmr(LQ(base, offset), lq_reference(base, offset)) + +int main() +{ + static const char data[] __attribute__((aligned(16)))=3D + "0123456789abcdef" + "ghijklmnopqrstuv" + "wxyzABCDEFGHIJKL" + "MNOPQRSTUVWXYZ.,"; + int i; + + for (i =3D 16; i < 48; i++) { + VERIFY_LQ(&data[i], -16); + VERIFY_LQ(&data[i], -15); + VERIFY_LQ(&data[i], -14); + VERIFY_LQ(&data[i], -13); + VERIFY_LQ(&data[i], -12); + VERIFY_LQ(&data[i], -11); + VERIFY_LQ(&data[i], -10); + VERIFY_LQ(&data[i], -9); + VERIFY_LQ(&data[i], -8); + VERIFY_LQ(&data[i], -7); + VERIFY_LQ(&data[i], -6); + VERIFY_LQ(&data[i], -5); + VERIFY_LQ(&data[i], -4); + VERIFY_LQ(&data[i], -3); + VERIFY_LQ(&data[i], -2); + VERIFY_LQ(&data[i], -1); + VERIFY_LQ(&data[i], 0); + VERIFY_LQ(&data[i], 1); + VERIFY_LQ(&data[i], 2); + VERIFY_LQ(&data[i], 3); + VERIFY_LQ(&data[i], 4); + VERIFY_LQ(&data[i], 5); + VERIFY_LQ(&data[i], 6); + VERIFY_LQ(&data[i], 7); + VERIFY_LQ(&data[i], 8); + VERIFY_LQ(&data[i], 9); + VERIFY_LQ(&data[i], 10); + VERIFY_LQ(&data[i], 11); + VERIFY_LQ(&data[i], 12); + VERIFY_LQ(&data[i], 13); + VERIFY_LQ(&data[i], 14); + VERIFY_LQ(&data[i], 15); + VERIFY_LQ(&data[i], 16); + } + + return 0; +} --=20 2.19.2 From nobody Sat May 4 22:57:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547406692509372.2396379029525; Sun, 13 Jan 2019 11:11:32 -0800 (PST) Received: from localhost ([127.0.0.1]:40890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gilAR-0000NU-0t for importer@patchew.org; Sun, 13 Jan 2019 14:11:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gil8o-0007r1-Nw for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:09:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gil8n-0006zH-1W for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:09:50 -0500 Received: from pio-pvt-msa2.bahnhof.se ([79.136.2.41]:55846) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gil8l-0006y4-5b for qemu-devel@nongnu.org; Sun, 13 Jan 2019 14:09:47 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 31CC53F39C; Sun, 13 Jan 2019 20:09:45 +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 ejggW6P_csYR; Sun, 13 Jan 2019 20:09:44 +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 988C23F2A3; Sun, 13 Jan 2019 20:09:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Sun, 13 Jan 2019 20:09:44 +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: 79.136.2.41 Subject: [Qemu-devel] [PATCH 9/9] tests/tcg/mips: Test R5900 multimedia instruction SQ 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 --- tests/tcg/mips/mipsn32r5900/Makefile | 1 + tests/tcg/mips/mipsn32r5900/sq.c | 105 +++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 tests/tcg/mips/mipsn32r5900/sq.c diff --git a/tests/tcg/mips/mipsn32r5900/Makefile b/tests/tcg/mips/mipsn32r= 5900/Makefile index cb3ef9d26a..a9e9481457 100644 --- a/tests/tcg/mips/mipsn32r5900/Makefile +++ b/tests/tcg/mips/mipsn32r5900/Makefile @@ -10,6 +10,7 @@ CFLAGS =3D -Wall -mabi=3Dn32 -march=3Dr5900 -static =20 TESTCASES =3D lq.tst TESTCASES +=3D pcpyuld.tst +TESTCASES +=3D sq.tst =20 all: $(TESTCASES) =20 diff --git a/tests/tcg/mips/mipsn32r5900/sq.c b/tests/tcg/mips/mipsn32r5900= /sq.c new file mode 100644 index 0000000000..97b21711ba --- /dev/null +++ b/tests/tcg/mips/mipsn32r5900/sq.c @@ -0,0 +1,105 @@ +/* + * Test SQ. + */ + +#include +#include +#include +#include + +#define GUARD_BYTE 0xA9 + +/* 128-bit multimedia register */ +struct mmr { uint64_t hi, lo; } __attribute__((aligned(16))); + +static uint8_t data[64]; + +#define SQ(value, base, offset) \ + __asm__ __volatile__ ( \ + " pcpyld %0, %0, %1\n" \ + " sq %0, %3(%2)\n" \ + : \ + : "r" (value.hi), "r" (value.lo), \ + "r" (base), "i" (offset)) + +static void verify_sq(struct mmr value, const void *base, int16_t offset) +{ + /* + * The least significant four bits of the effective address are + * masked to zero, effectively creating an aligned address. No + * address exceptions due to alignment are possible. + */ + const uint8_t *b =3D base; + const uint8_t *o =3D &b[offset]; + const uint8_t *a =3D (const uint8_t*)((unsigned long)o & ~0xFUL); + size_t i; + + for (i =3D 0; i < sizeof(data); i++) { + ssize_t d =3D &data[i] - &a[0]; + + if (d < 0) { + assert(data[i] =3D=3D GUARD_BYTE); + } else if (d < 8) { + assert(data[i] =3D=3D ((value.lo >> (8 * (d - 0))) & 0xFF)); + } else if (d < 16) { + assert(data[i] =3D=3D ((value.hi >> (8 * (d - 8))) & 0xFF)); + } else { + assert(data[i] =3D=3D GUARD_BYTE); + } + } +} + +#define VERIFY_SQ(base, offset) \ + do { \ + struct mmr value =3D { \ + .hi =3D 0x6665646362613938, \ + .lo =3D 0x3736353433323130 \ + }; \ + \ + memset(data, GUARD_BYTE, sizeof(data)); \ + SQ(value, base, offset); \ + verify_sq(value, base, offset); \ + } while (0) + +int main() +{ + int i; + + for (i =3D 16; i < 48; i++) { + VERIFY_SQ(&data[i], -16); + VERIFY_SQ(&data[i], -15); + VERIFY_SQ(&data[i], -14); + VERIFY_SQ(&data[i], -13); + VERIFY_SQ(&data[i], -12); + VERIFY_SQ(&data[i], -11); + VERIFY_SQ(&data[i], -10); + VERIFY_SQ(&data[i], -9); + VERIFY_SQ(&data[i], -8); + VERIFY_SQ(&data[i], -7); + VERIFY_SQ(&data[i], -6); + VERIFY_SQ(&data[i], -5); + VERIFY_SQ(&data[i], -4); + VERIFY_SQ(&data[i], -3); + VERIFY_SQ(&data[i], -2); + VERIFY_SQ(&data[i], -1); + VERIFY_SQ(&data[i], 0); + VERIFY_SQ(&data[i], 1); + VERIFY_SQ(&data[i], 2); + VERIFY_SQ(&data[i], 3); + VERIFY_SQ(&data[i], 4); + VERIFY_SQ(&data[i], 5); + VERIFY_SQ(&data[i], 6); + VERIFY_SQ(&data[i], 7); + VERIFY_SQ(&data[i], 8); + VERIFY_SQ(&data[i], 9); + VERIFY_SQ(&data[i], 10); + VERIFY_SQ(&data[i], 11); + VERIFY_SQ(&data[i], 12); + VERIFY_SQ(&data[i], 13); + VERIFY_SQ(&data[i], 14); + VERIFY_SQ(&data[i], 15); + VERIFY_SQ(&data[i], 16); + } + + return 0; +} --=20 2.19.2