From nobody Tue May 21 17:04:16 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 15532702759481016.1022516416498; Fri, 22 Mar 2019 08:57:55 -0700 (PDT) Received: from localhost ([127.0.0.1]:59327 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7MYK-0005e9-Q7 for importer@patchew.org; Fri, 22 Mar 2019 11:57:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7MWN-0004G5-I7 for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7MWM-00080F-8v for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:51 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:46053 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h7MWL-0005Ln-KE for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:50 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id AACBC1A2264; Fri, 22 Mar 2019 16:54:46 +0100 (CET) Received: from rtrkw310-lin.domain.local (rtrkw310-lin.domain.local [10.10.13.97]) by mail.rt-rk.com (Postfix) with ESMTPSA id 8B3611A2252; Fri, 22 Mar 2019 16:54:46 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com From: Mateja Marjanovic To: qemu-devel@nongnu.org Date: Fri, 22 Mar 2019 16:54:37 +0100 Message-Id: <1553270080-7829-2-git-send-email-mateja.marjanovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553270080-7829-1-git-send-email-mateja.marjanovic@rt-rk.com> References: <1553270080-7829-1-git-send-email-mateja.marjanovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH 1/4] target/mips: Fix . MSA instructions for MIPS big endian host 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: arikalo@wavecomp.com, amarkovic@wavecomp.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mateja Marjanovic Load and store MSA instructions when executed on a MIPS big endian CPU, didn't change the endianness, and were behaving like on little endian. Signed-off-by: Mateja Marjanovic --- target/mips/op_helper.c | 79 ++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index 0f272a5..5441ab2 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -4371,18 +4371,37 @@ FOP_CONDN_S(sne, (float32_lt(fst1, fst0, &env->act= ive_fpu.fp_status) #define MEMOP_IDX(DF) #endif =20 -#define MSA_LD_DF(DF, TYPE, LD_INSN, ...) \ -void helper_msa_ld_ ## TYPE(CPUMIPSState *env, uint32_t wd, \ - target_ulong addr) \ -{ \ - wr_t *pwd =3D &(env->active_fpu.fpr[wd].wr); \ - wr_t wx; \ - int i; \ - MEMOP_IDX(DF) \ - for (i =3D 0; i < DF_ELEMENTS(DF); i++) { \ - wx.TYPE[i] =3D LD_INSN(env, addr + (i << DF), ##__VA_ARGS__); \ - } \ - memcpy(pwd, &wx, sizeof(wr_t)); \ +#if defined(HOST_WORDS_BIGENDIAN) + bool big_endian =3D 1; +#else + bool big_endian =3D 0; +#endif + +#define MSA_LD_DF(DF, TYPE, LD_INSN, ...) = \ +void helper_msa_ld_ ## TYPE(CPUMIPSState *env, uint32_t wd, = \ + target_ulong addr) = \ +{ = \ + wr_t *pwd =3D &(env->active_fpu.fpr[wd].wr); = \ + wr_t wx; = \ + int i, k; = \ + MEMOP_IDX(DF) = \ + if (!big_endian) { = \ + for (i =3D 0; i < DF_ELEMENTS(DF); i++) { = \ + wx.TYPE[i] =3D LD_INSN(env, addr + (i << DF), ##__VA_ARGS__); = \ + } = \ + } else { = \ + for (i =3D 0; i < DF_ELEMENTS(DF); i++) { = \ + if (i < DF_ELEMENTS(DF) / 2) { = \ + k =3D DF_ELEMENTS(DF) / 2 - i - 1; = \ + wx.TYPE[i] =3D LD_INSN(env, addr + (k << DF), ##__VA_ARGS_= _); \ + } else { = \ + k =3D 3 * DF_ELEMENTS(DF) / 2 - i - 1; = \ + wx.TYPE[i] =3D LD_INSN(env, addr + (k << DF), ##__VA_ARGS_= _); \ + } = \ + } = \ + } = \ + = \ + memcpy(pwd, &wx, sizeof(wr_t)); = \ } =20 #if !defined(CONFIG_USER_ONLY) @@ -4417,18 +4436,30 @@ static inline void ensure_writable_pages(CPUMIPSSta= te *env, #endif } =20 -#define MSA_ST_DF(DF, TYPE, ST_INSN, ...) \ -void helper_msa_st_ ## TYPE(CPUMIPSState *env, uint32_t wd, \ - target_ulong addr) \ -{ \ - wr_t *pwd =3D &(env->active_fpu.fpr[wd].wr); \ - int mmu_idx =3D cpu_mmu_index(env, false); \ - int i; \ - MEMOP_IDX(DF) \ - ensure_writable_pages(env, addr, mmu_idx, GETPC()); \ - for (i =3D 0; i < DF_ELEMENTS(DF); i++) { \ - ST_INSN(env, addr + (i << DF), pwd->TYPE[i], ##__VA_ARGS__); \ - } \ +#define MSA_ST_DF(DF, TYPE, ST_INSN, ...) = \ +void helper_msa_st_ ## TYPE(CPUMIPSState *env, uint32_t wd, = \ + target_ulong addr) = \ +{ = \ + wr_t *pwd =3D &(env->active_fpu.fpr[wd].wr); = \ + int mmu_idx =3D cpu_mmu_index(env, false); = \ + int i, k; = \ + MEMOP_IDX(DF) = \ + ensure_writable_pages(env, addr, mmu_idx, GETPC()); = \ + if (!big_endian) { = \ + for (i =3D 0; i < DF_ELEMENTS(DF); i++) { = \ + ST_INSN(env, addr + (i << DF), pwd->TYPE[i], ##__VA_ARGS__); = \ + } = \ + } else { = \ + for (i =3D 0; i < DF_ELEMENTS(DF); i++) { = \ + if (i < DF_ELEMENTS(DF) / 2) { = \ + k =3D DF_ELEMENTS(DF) / 2 - i - 1; = \ + ST_INSN(env, addr + (k << DF), pwd->TYPE[i], ##__VA_ARGS__= ); \ + } else { = \ + k =3D 3 * DF_ELEMENTS(DF) / 2 - i - 1; = \ + ST_INSN(env, addr + (k << DF), pwd->TYPE[i], ##__VA_ARGS__= ); \ + } = \ + } = \ + } = \ } =20 #if !defined(CONFIG_USER_ONLY) --=20 2.7.4 From nobody Tue May 21 17:04:16 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 1553270299624568.9984360207388; Fri, 22 Mar 2019 08:58:19 -0700 (PDT) Received: from localhost ([127.0.0.1]:59329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7MYc-00062u-JN for importer@patchew.org; Fri, 22 Mar 2019 11:58:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7MWN-0004Eo-7I for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7MWM-000801-4m for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:51 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:46055 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h7MWL-0005M3-KH for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:50 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id BDD1D1A2252; Fri, 22 Mar 2019 16:54:46 +0100 (CET) Received: from rtrkw310-lin.domain.local (rtrkw310-lin.domain.local [10.10.13.97]) by mail.rt-rk.com (Postfix) with ESMTPSA id 9A8341A225D; Fri, 22 Mar 2019 16:54:46 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com From: Mateja Marjanovic To: qemu-devel@nongnu.org Date: Fri, 22 Mar 2019 16:54:38 +0100 Message-Id: <1553270080-7829-3-git-send-email-mateja.marjanovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553270080-7829-1-git-send-email-mateja.marjanovic@rt-rk.com> References: <1553270080-7829-1-git-send-email-mateja.marjanovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH 2/4] target/mips: Fix copy_s. for MIPS big endian host 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: arikalo@wavecomp.com, amarkovic@wavecomp.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mateja Marjanovic Signed element copy from MSA registers to GPR when executed on a MIPS big endian CPU, didn't pick the right element, and was behaving like on little endian. Signed-off-by: Mateja Marjanovic --- target/mips/msa_helper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/mips/msa_helper.c b/target/mips/msa_helper.c index 421dced..012f373 100644 --- a/target/mips/msa_helper.c +++ b/target/mips/msa_helper.c @@ -1435,6 +1435,13 @@ void helper_msa_copy_s_df(CPUMIPSState *env, uint32_= t df, uint32_t rd, uint32_t ws, uint32_t n) { n %=3D DF_ELEMENTS(df); +#if defined(HOST_WORDS_BIGENDIAN) + if (n < DF_ELEMENTS(df) / 2) { + n =3D DF_ELEMENTS(df) / 2 - n - 1; + } else { + n =3D 3 * DF_ELEMENTS(df) / 2 - n - 1; + } +#endif =20 switch (df) { case DF_BYTE: --=20 2.7.4 From nobody Tue May 21 17:04:16 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 1553270455245193.2144607882483; Fri, 22 Mar 2019 09:00:55 -0700 (PDT) Received: from localhost ([127.0.0.1]:59384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7MbE-0008R6-95 for importer@patchew.org; Fri, 22 Mar 2019 12:00:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7MWN-0004Eg-6B for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7MWM-0007zt-4D for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:51 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:46056 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h7MWL-0005M8-Kn for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:50 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id C52021A225D; Fri, 22 Mar 2019 16:54:46 +0100 (CET) Received: from rtrkw310-lin.domain.local (rtrkw310-lin.domain.local [10.10.13.97]) by mail.rt-rk.com (Postfix) with ESMTPSA id A59161A2228; Fri, 22 Mar 2019 16:54:46 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com From: Mateja Marjanovic To: qemu-devel@nongnu.org Date: Fri, 22 Mar 2019 16:54:39 +0100 Message-Id: <1553270080-7829-4-git-send-email-mateja.marjanovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553270080-7829-1-git-send-email-mateja.marjanovic@rt-rk.com> References: <1553270080-7829-1-git-send-email-mateja.marjanovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH 3/4] target/mips: Fix copy_u. for MIPS big endian host 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: arikalo@wavecomp.com, amarkovic@wavecomp.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mateja Marjanovic Unsigned element copy from MSA registers to GPR when executed on a MIPS big endian CPU, didn't pick the right element, and was behaving like on little endian. Signed-off-by: Mateja Marjanovic --- target/mips/msa_helper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/mips/msa_helper.c b/target/mips/msa_helper.c index 012f373..8caf186 100644 --- a/target/mips/msa_helper.c +++ b/target/mips/msa_helper.c @@ -1467,6 +1467,13 @@ void helper_msa_copy_u_df(CPUMIPSState *env, uint32_= t df, uint32_t rd, uint32_t ws, uint32_t n) { n %=3D DF_ELEMENTS(df); +#if defined(HOST_WORDS_BIGENDIAN) + if (n < DF_ELEMENTS(df) / 2) { + n =3D DF_ELEMENTS(df) / 2 - n - 1; + } else { + n =3D 3 * DF_ELEMENTS(df) / 2 - n - 1; + } +#endif =20 switch (df) { case DF_BYTE: --=20 2.7.4 From nobody Tue May 21 17:04:16 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 1553270397669815.0573875072347; Fri, 22 Mar 2019 08:59:57 -0700 (PDT) Received: from localhost ([127.0.0.1]:59354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7MaH-0007qP-EO for importer@patchew.org; Fri, 22 Mar 2019 11:59:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7MWN-0004Ea-5j for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7MWM-0007zX-1X for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:51 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:46061 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h7MWL-0005MF-KG for qemu-devel@nongnu.org; Fri, 22 Mar 2019 11:55:49 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id CB4881A2228; Fri, 22 Mar 2019 16:54:46 +0100 (CET) Received: from rtrkw310-lin.domain.local (rtrkw310-lin.domain.local [10.10.13.97]) by mail.rt-rk.com (Postfix) with ESMTPSA id AF21E1A2274; Fri, 22 Mar 2019 16:54:46 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com From: Mateja Marjanovic To: qemu-devel@nongnu.org Date: Fri, 22 Mar 2019 16:54:40 +0100 Message-Id: <1553270080-7829-5-git-send-email-mateja.marjanovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553270080-7829-1-git-send-email-mateja.marjanovic@rt-rk.com> References: <1553270080-7829-1-git-send-email-mateja.marjanovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH 4/4] target/mips: Fix insert. for MIPS big endian host 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: arikalo@wavecomp.com, amarkovic@wavecomp.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mateja Marjanovic Inserting from GPR to an element in a MSA register when executed on a MIPS big endian CPU, didn't pick the right element, and was behaving like on little endian. Signed-off-by: Mateja Marjanovic --- target/mips/msa_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target/mips/msa_helper.c b/target/mips/msa_helper.c index 8caf186..0049191 100644 --- a/target/mips/msa_helper.c +++ b/target/mips/msa_helper.c @@ -1500,6 +1500,13 @@ void helper_msa_insert_df(CPUMIPSState *env, uint32_= t df, uint32_t wd, { wr_t *pwd =3D &(env->active_fpu.fpr[wd].wr); target_ulong rs =3D env->active_tc.gpr[rs_num]; +#if defined(HOST_WORDS_BIGENDIAN) + if (n < DF_ELEMENTS(df) / 2) { + n =3D DF_ELEMENTS(df) / 2 - n - 1; + } else { + n =3D 3 * DF_ELEMENTS(df) / 2 - n - 1; + } +#endif =20 switch (df) { case DF_BYTE: @@ -1511,9 +1518,11 @@ void helper_msa_insert_df(CPUMIPSState *env, uint32_= t df, uint32_t wd, case DF_WORD: pwd->w[n] =3D (int32_t)rs; break; +#ifdef TARGET_MIPS64 case DF_DOUBLE: pwd->d[n] =3D (int64_t)rs; break; +#endif default: assert(0); } --=20 2.7.4