From nobody Fri Nov 7 04:08:02 2025 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 1546007146462627.2194548858616; Fri, 28 Dec 2018 06:25:46 -0800 (PST) Received: from localhost ([127.0.0.1]:59560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gct57-0004Zs-2O for importer@patchew.org; Fri, 28 Dec 2018 09:25:45 -0500 Received: from eggs.gnu.org ([208.118.235.92]:46699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gcsrP-0007ik-MX for qemu-devel@nongnu.org; Fri, 28 Dec 2018 09:11:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gcsZI-0006gD-VM for qemu-devel@nongnu.org; Fri, 28 Dec 2018 08:52:55 -0500 Received: from chuckie.co.uk ([82.165.15.123]:36260 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gcsZI-0006eQ-MT; Fri, 28 Dec 2018 08:52:52 -0500 Received: from host86-138-87-125.range86-138.btcentralplus.com ([86.138.87.125] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gcsZW-0001RB-H4; Fri, 28 Dec 2018 13:53:07 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, richard.henderson@linaro.org, david@gibson.dropbear.id.au Date: Fri, 28 Dec 2018 13:52:29 +0000 Message-Id: <20181228135235.6859-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181228135235.6859-1-mark.cave-ayland@ilande.co.uk> References: <20181228135235.6859-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.138.87.125 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH v2 2/8] target/ppc: rework vmrg{l, h}{b, h, w} instructions to use Vsr* macros 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: , 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" The current implementations make use of the endian-specific macros MRGLO/MR= GHI and also reference HI_IDX and LO_IDX directly to calculate array offsets. Rework the implementation to use the Vsr* macros so that these per-endian references can be removed. Signed-off-by: Mark Cave-Ayland --- target/ppc/int_helper.c | 52 ++++++++++++++++++++++++---------------------= ---- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 598731d47a..f084a706ee 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -976,43 +976,41 @@ void helper_vmladduhm(ppc_avr_t *r, ppc_avr_t *a, ppc= _avr_t *b, ppc_avr_t *c) } } =20 -#define VMRG_DO(name, element, highp) \ +#define VMRG_DOLO(name, element, access) \ void helper_v##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ { \ ppc_avr_t result; \ int i; \ - size_t n_elems =3D ARRAY_SIZE(r->element); \ + int m =3D ARRAY_SIZE(r->element) - 1; \ \ - for (i =3D 0; i < n_elems / 2; i++) { \ - if (highp) { \ - result.element[i*2+HI_IDX] =3D a->element[i]; \ - result.element[i*2+LO_IDX] =3D b->element[i]; \ - } else { \ - result.element[n_elems - i * 2 - (1 + HI_IDX)] =3D \ - b->element[n_elems - i - 1]; \ - result.element[n_elems - i * 2 - (1 + LO_IDX)] =3D \ - a->element[n_elems - i - 1]; \ - } \ + for (i =3D 0; i < ARRAY_SIZE(r->element); i++) { \ + result.access(m - i) =3D (i & 1) ? a->access(m - (i >> 1)) \ + : b->access(m - (i >> 1)); \ } \ *r =3D result; \ } -#if defined(HOST_WORDS_BIGENDIAN) -#define MRGHI 0 -#define MRGLO 1 -#else -#define MRGHI 1 -#define MRGLO 0 -#endif -#define VMRG(suffix, element) \ - VMRG_DO(mrgl##suffix, element, MRGHI) \ - VMRG_DO(mrgh##suffix, element, MRGLO) -VMRG(b, u8) -VMRG(h, u16) -VMRG(w, u32) + +#define VMRG_DOHI(name, element, access) \ + void helper_v##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ + { \ + ppc_avr_t result; \ + int i; \ + \ + for (i =3D 0; i < ARRAY_SIZE(r->element); i++) { \ + result.access(i) =3D (i & 1) ? b->access(i >> 1) \ + : a->access(i >> 1); \ + } \ + *r =3D result; \ + } + +#define VMRG(suffix, element, access) \ + VMRG_DOLO(mrgl##suffix, element, access) \ + VMRG_DOHI(mrgh##suffix, element, access) +VMRG(b, u8, VsrB) +VMRG(h, u16, VsrH) +VMRG(w, u32, VsrW) #undef VMRG_DO #undef VMRG -#undef MRGHI -#undef MRGLO =20 void helper_vmsummbm(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c) --=20 2.11.0