From nobody Thu Sep 19 02:11:32 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) 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 1549272661081293.9067363692029; Mon, 4 Feb 2019 01:31:01 -0800 (PST) Received: from localhost ([127.0.0.1]:39384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqaaW-0007uc-6y for importer@patchew.org; Mon, 04 Feb 2019 04:30:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqa9r-0001WW-9G for qemu-devel@nongnu.org; Mon, 04 Feb 2019 04:03:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqa9o-0000k3-DS for qemu-devel@nongnu.org; Mon, 04 Feb 2019 04:03:14 -0500 Received: from ozlabs.org ([203.11.71.1]:60247) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqa9n-0000GR-LC; Mon, 04 Feb 2019 04:03:12 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 43tMCB6kXmz9sPZ; Mon, 4 Feb 2019 20:01:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1549270902; bh=sNtSa/Qmz80wVoPRMkpCfAh2BbhuIPgZ2u7aFZfhwUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CxsmAZGToXSj/klVsOZghA6bAcF2fjW5GBOh7e53cDvSQFOc3rW0jNSU3fxjP5cKf w9mpnobTifbrUGpbqu8syvoKaaYvTs7oVIVS+5eLcR2ivjVASSJdk3NO7CUshxqJWd LbbxtyluSv9soTT2LuRLkJdClqW/sqHp7o9njNQ0= From: David Gibson To: peter.maydell@linaro.org Date: Mon, 4 Feb 2019 20:01:20 +1100 Message-Id: <20190204090124.26191-34-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204090124.26191-1-david@gibson.dropbear.id.au> References: <20190204090124.26191-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 33/37] target/ppc: remove various HOST_WORDS_BIGENDIAN hacks in int_helper.c 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: lvivier@redhat.com, Richard Henderson , Mark Cave-Ayland , qemu-devel@nongnu.org, groug@kaod.org, spopovyc@redhat.com, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland Following on from the previous work, there are numerous endian-related hacks in int_helper.c that can now be replaced with Vsr* macros. There are also a few places where the VECTOR_FOR_INORDER_I macro can be replaced with a normal iterator since the processing order is irrelevant. Signed-off-by: Mark Cave-Ayland Reviewed-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/int_helper.c | 155 ++++++++++++---------------------------- 1 file changed, 45 insertions(+), 110 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 916d10c25b..8efc283388 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -443,8 +443,8 @@ void helper_lvsl(ppc_avr_t *r, target_ulong sh) { int i, j =3D (sh & 0xf); =20 - VECTOR_FOR_INORDER_I(i, u8) { - r->u8[i] =3D j++; + for (i =3D 0; i < ARRAY_SIZE(r->u8); i++) { + r->VsrB(i) =3D j++; } } =20 @@ -452,18 +452,14 @@ void helper_lvsr(ppc_avr_t *r, target_ulong sh) { int i, j =3D 0x10 - (sh & 0xf); =20 - VECTOR_FOR_INORDER_I(i, u8) { - r->u8[i] =3D j++; + for (i =3D 0; i < ARRAY_SIZE(r->u8); i++) { + r->VsrB(i) =3D j++; } } =20 void helper_mtvscr(CPUPPCState *env, ppc_avr_t *r) { -#if defined(HOST_WORDS_BIGENDIAN) - env->vscr =3D r->u32[3]; -#else - env->vscr =3D r->u32[0]; -#endif + env->vscr =3D r->VsrW(3); set_flush_to_zero(vscr_nj, &env->vec_status); } =20 @@ -870,8 +866,8 @@ target_ulong helper_vclzlsbb(ppc_avr_t *r) { target_ulong count =3D 0; int i; - VECTOR_FOR_INORDER_I(i, u8) { - if (r->u8[i] & 0x01) { + for (i =3D 0; i < ARRAY_SIZE(r->u8); i++) { + if (r->VsrB(i) & 0x01) { break; } count++; @@ -883,12 +879,8 @@ target_ulong helper_vctzlsbb(ppc_avr_t *r) { target_ulong count =3D 0; int i; -#if defined(HOST_WORDS_BIGENDIAN) for (i =3D ARRAY_SIZE(r->u8) - 1; i >=3D 0; i--) { -#else - for (i =3D 0; i < ARRAY_SIZE(r->u8); i++) { -#endif - if (r->u8[i] & 0x01) { + if (r->VsrB(i) & 0x01) { break; } count++; @@ -1137,18 +1129,14 @@ void helper_vperm(CPUPPCState *env, ppc_avr_t *r, p= pc_avr_t *a, ppc_avr_t *b, ppc_avr_t result; int i; =20 - VECTOR_FOR_INORDER_I(i, u8) { - int s =3D c->u8[i] & 0x1f; -#if defined(HOST_WORDS_BIGENDIAN) + for (i =3D 0; i < ARRAY_SIZE(r->u8); i++) { + int s =3D c->VsrB(i) & 0x1f; int index =3D s & 0xf; -#else - int index =3D 15 - (s & 0xf); -#endif =20 if (s & 0x10) { - result.u8[i] =3D b->u8[index]; + result.VsrB(i) =3D b->VsrB(index); } else { - result.u8[i] =3D a->u8[index]; + result.VsrB(i) =3D a->VsrB(index); } } *r =3D result; @@ -1160,18 +1148,14 @@ void helper_vpermr(CPUPPCState *env, ppc_avr_t *r, = ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t result; int i; =20 - VECTOR_FOR_INORDER_I(i, u8) { - int s =3D c->u8[i] & 0x1f; -#if defined(HOST_WORDS_BIGENDIAN) + for (i =3D 0; i < ARRAY_SIZE(r->u8); i++) { + int s =3D c->VsrB(i) & 0x1f; int index =3D 15 - (s & 0xf); -#else - int index =3D s & 0xf; -#endif =20 if (s & 0x10) { - result.u8[i] =3D a->u8[index]; + result.VsrB(i) =3D a->VsrB(index); } else { - result.u8[i] =3D b->u8[index]; + result.VsrB(i) =3D b->VsrB(index); } } *r =3D result; @@ -1868,25 +1852,14 @@ void helper_vsldoi(ppc_avr_t *r, ppc_avr_t *a, ppc_= avr_t *b, uint32_t shift) int i; ppc_avr_t result; =20 -#if defined(HOST_WORDS_BIGENDIAN) for (i =3D 0; i < ARRAY_SIZE(r->u8); i++) { int index =3D sh + i; if (index > 0xf) { - result.u8[i] =3D b->u8[index - 0x10]; - } else { - result.u8[i] =3D a->u8[index]; - } - } -#else - for (i =3D 0; i < ARRAY_SIZE(r->u8); i++) { - int index =3D (16 - sh) + i; - if (index > 0xf) { - result.u8[i] =3D a->u8[index - 0x10]; + result.VsrB(i) =3D b->VsrB(index - 0x10); } else { - result.u8[i] =3D b->u8[index]; + result.VsrB(i) =3D a->VsrB(index); } } -#endif *r =3D result; } =20 @@ -1905,25 +1878,20 @@ void helper_vslo(ppc_avr_t *r, ppc_avr_t *a, ppc_av= r_t *b) =20 /* Experimental testing shows that hardware masks the immediate. */ #define _SPLAT_MASKED(element) (splat & (ARRAY_SIZE(r->element) - 1)) -#if defined(HOST_WORDS_BIGENDIAN) #define SPLAT_ELEMENT(element) _SPLAT_MASKED(element) -#else -#define SPLAT_ELEMENT(element) \ - (ARRAY_SIZE(r->element) - 1 - _SPLAT_MASKED(element)) -#endif -#define VSPLT(suffix, element) \ +#define VSPLT(suffix, element, access) \ void helper_vsplt##suffix(ppc_avr_t *r, ppc_avr_t *b, uint32_t splat) \ { \ - uint32_t s =3D b->element[SPLAT_ELEMENT(element)]; \ + uint32_t s =3D b->access(SPLAT_ELEMENT(element)); \ int i; \ \ for (i =3D 0; i < ARRAY_SIZE(r->element); i++) { \ - r->element[i] =3D s; \ + r->access(i) =3D s; \ } \ } -VSPLT(b, u8) -VSPLT(h, u16) -VSPLT(w, u32) +VSPLT(b, u8, VsrB) +VSPLT(h, u16, VsrH) +VSPLT(w, u32, VsrW) #undef VSPLT #undef SPLAT_ELEMENT #undef _SPLAT_MASKED @@ -1984,17 +1952,10 @@ void helper_xxextractuw(CPUPPCState *env, target_ul= ong xtn, getVSR(xbn, &xb, env); memset(&xt, 0, sizeof(xt)); =20 -#if defined(HOST_WORDS_BIGENDIAN) ext_index =3D index; for (i =3D 0; i < es; i++, ext_index++) { - xt.u8[8 - es + i] =3D xb.u8[ext_index % 16]; - } -#else - ext_index =3D 15 - index; - for (i =3D es - 1; i >=3D 0; i--, ext_index--) { - xt.u8[8 + i] =3D xb.u8[ext_index % 16]; + xt.VsrB(8 - es + i) =3D xb.VsrB(ext_index % 16); } -#endif =20 putVSR(xtn, &xt, env); } @@ -2009,17 +1970,10 @@ void helper_xxinsertw(CPUPPCState *env, target_ulon= g xtn, getVSR(xbn, &xb, env); getVSR(xtn, &xt, env); =20 -#if defined(HOST_WORDS_BIGENDIAN) ins_index =3D index; for (i =3D 0; i < es && ins_index < 16; i++, ins_index++) { - xt.u8[ins_index] =3D xb.u8[8 - es + i]; - } -#else - ins_index =3D 15 - index; - for (i =3D es - 1; i >=3D 0 && ins_index >=3D 0; i--, ins_index--) { - xt.u8[ins_index] =3D xb.u8[8 + i]; + xt.VsrB(ins_index) =3D xb.VsrB(8 - es + i); } -#endif =20 putVSR(xtn, &xt, env); } @@ -2028,7 +1982,7 @@ void helper_xxinsertw(CPUPPCState *env, target_ulong = xtn, void helper_##name(ppc_avr_t *r, ppc_avr_t *b) \ { \ int i; \ - VECTOR_FOR_INORDER_I(i, element) { \ + for (i =3D 0; i < ARRAY_SIZE(r->element); i++) { \ r->element[i] =3D (cast)b->element[i]; \ } \ } @@ -2043,7 +1997,7 @@ VEXT_SIGNED(vextsw2d, s64, int32_t) void helper_##name(ppc_avr_t *r, ppc_avr_t *b) \ { \ int i; \ - VECTOR_FOR_INORDER_I(i, element) { \ + for (i =3D 0; i < ARRAY_SIZE(r->element); i++) { \ r->element[i] =3D -b->element[i]; \ } \ } @@ -2115,17 +2069,13 @@ void helper_vsumsws(CPUPPCState *env, ppc_avr_t *r,= ppc_avr_t *a, ppc_avr_t *b) ppc_avr_t result; int sat =3D 0; =20 -#if defined(HOST_WORDS_BIGENDIAN) - upper =3D ARRAY_SIZE(r->s32)-1; -#else - upper =3D 0; -#endif - t =3D (int64_t)b->s32[upper]; + upper =3D ARRAY_SIZE(r->s32) - 1; + t =3D (int64_t)b->VsrSW(upper); for (i =3D 0; i < ARRAY_SIZE(r->s32); i++) { - t +=3D a->s32[i]; - result.s32[i] =3D 0; + t +=3D a->VsrSW(i); + result.VsrSW(i) =3D 0; } - result.s32[upper] =3D cvtsdsw(t, &sat); + result.VsrSW(upper) =3D cvtsdsw(t, &sat); *r =3D result; =20 if (sat) { @@ -2139,19 +2089,15 @@ void helper_vsum2sws(CPUPPCState *env, ppc_avr_t *r= , ppc_avr_t *a, ppc_avr_t *b) ppc_avr_t result; int sat =3D 0; =20 -#if defined(HOST_WORDS_BIGENDIAN) upper =3D 1; -#else - upper =3D 0; -#endif for (i =3D 0; i < ARRAY_SIZE(r->u64); i++) { - int64_t t =3D (int64_t)b->s32[upper + i * 2]; + int64_t t =3D (int64_t)b->VsrSW(upper + i * 2); =20 - result.u64[i] =3D 0; + result.VsrW(i) =3D 0; for (j =3D 0; j < ARRAY_SIZE(r->u64); j++) { - t +=3D a->s32[2 * i + j]; + t +=3D a->VsrSW(2 * i + j); } - result.s32[upper + i * 2] =3D cvtsdsw(t, &sat); + result.VsrSW(upper + i * 2) =3D cvtsdsw(t, &sat); } =20 *r =3D result; @@ -2276,7 +2222,7 @@ VUPK(lsw, s64, s32, UPKLO) { \ int i; \ \ - VECTOR_FOR_INORDER_I(i, element) { \ + for (i =3D 0; i < ARRAY_SIZE(r->element); i++) { \ r->element[i] =3D name(b->element[i]); \ } \ } @@ -2616,20 +2562,12 @@ static int bcd_cmp_zero(ppc_avr_t *bcd) =20 static uint16_t get_national_digit(ppc_avr_t *reg, int n) { -#if defined(HOST_WORDS_BIGENDIAN) - return reg->u16[7 - n]; -#else - return reg->u16[n]; -#endif + return reg->VsrH(7 - n); } =20 static void set_national_digit(ppc_avr_t *reg, uint8_t val, int n) { -#if defined(HOST_WORDS_BIGENDIAN) - reg->u16[7 - n] =3D val; -#else - reg->u16[n] =3D val; -#endif + reg->VsrH(7 - n) =3D val; } =20 static int bcd_cmp_mag(ppc_avr_t *a, ppc_avr_t *b) @@ -3373,14 +3311,11 @@ void helper_vpermxor(ppc_avr_t *r, ppc_avr_t *a, p= pc_avr_t *b, ppc_avr_t *c) ppc_avr_t result; int i; =20 - VECTOR_FOR_INORDER_I(i, u8) { - int indexA =3D c->u8[i] >> 4; - int indexB =3D c->u8[i] & 0xF; -#if defined(HOST_WORDS_BIGENDIAN) - result.u8[i] =3D a->u8[indexA] ^ b->u8[indexB]; -#else - result.u8[i] =3D a->u8[15-indexA] ^ b->u8[15-indexB]; -#endif + for (i =3D 0; i < ARRAY_SIZE(r->u8); i++) { + int indexA =3D c->VsrB(i) >> 4; + int indexB =3D c->VsrB(i) & 0xF; + + result.VsrB(i) =3D a->VsrB(indexA) ^ b->VsrB(indexB); } *r =3D result; } --=20 2.20.1