From nobody Wed Nov 12 08:40:01 2025 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 ARC-Seal: i=1; a=rsa-sha256; t=1569530799; cv=none; d=zoho.com; s=zohoarc; b=f36zF9Vbo1hGG6XKevJ0H142wMmVSa295B49Xl9dYmNsI1rFmbGjTs80liJHeZHaIe6iDpwc4rbeSrRjbhrKZkIAfrdG5CSEP4xJN7GNSpJ+CgkjwOP0GP739HiDsW3HmJh/AvzFvpYIol34ev0rVk6ZkyL07a3bflNcLb3P1rI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569530799; h=Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=Y+1oR31icrPOLh55pXioDUAtRYIr9OtGbBCkH05dwZc=; b=ZYAhWpmBTL/gWnamsK+T7N0jsIlmO58hfi4YmqQ83wXLBv61bEctANEBtvxrQlxU2t4W+OzkTqMZY7cysLhoVPfIX7mdaEKs3FB99e4p7G2HKbXODl7IduYAvkZgKYtk6cpA1XIJJDXy03ly5487gu1hePHoeAMV3/Bm29yGdTs= ARC-Authentication-Results: i=1; mx.zoho.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 1569530799351882.2059183178202; Thu, 26 Sep 2019 13:46:39 -0700 (PDT) Received: from localhost ([::1]:44316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDaeh-0001zz-TB for importer@patchew.org; Thu, 26 Sep 2019 16:46:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37818) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDadS-0000s1-Bd for qemu-devel@nongnu.org; Thu, 26 Sep 2019 16:45:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDadQ-0007Zi-T2 for qemu-devel@nongnu.org; Thu, 26 Sep 2019 16:45:10 -0400 Received: from mail.ilande.co.uk ([46.43.2.167]:40654 helo=mail.default.ilande.uk0.bigv.io) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iDadQ-0007XG-Mv; Thu, 26 Sep 2019 16:45:08 -0400 Received: from host86-138-245-63.range86-138.btcentralplus.com ([86.138.245.63] helo=kentang.home) by mail.default.ilande.uk0.bigv.io with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1iDadf-0002BU-Bs; Thu, 26 Sep 2019 21:45:23 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, pc@us.ibm.com, david@gibson.dropbear.id.au Date: Thu, 26 Sep 2019 21:44:53 +0100 Message-Id: <20190926204453.31837-1-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 86.138.245.63 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH] target/ppc: use Vsr macros in BCD helpers X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.uk0.bigv.io) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.43.2.167 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-Type: text/plain; charset="utf-8" This allows us to remove more endian-specific defines from int_helper.c. Signed-off-by: Mark Cave-Ayland Reviewed-by: Richard Henderson --- target/ppc/int_helper.c | 72 ++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 46deb57a34..6d238b989d 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -2052,15 +2052,11 @@ void helper_vsubecuq(ppc_avr_t *r, ppc_avr_t *a, pp= c_avr_t *b, ppc_avr_t *c) #define NATIONAL_PLUS 0x2B #define NATIONAL_NEG 0x2D =20 -#if defined(HOST_WORDS_BIGENDIAN) #define BCD_DIG_BYTE(n) (15 - ((n) / 2)) -#else -#define BCD_DIG_BYTE(n) ((n) / 2) -#endif =20 static int bcd_get_sgn(ppc_avr_t *bcd) { - switch (bcd->u8[BCD_DIG_BYTE(0)] & 0xF) { + switch (bcd->VsrB(BCD_DIG_BYTE(0)) & 0xF) { case BCD_PLUS_PREF_1: case BCD_PLUS_PREF_2: case BCD_PLUS_ALT_1: @@ -2095,9 +2091,9 @@ static uint8_t bcd_get_digit(ppc_avr_t *bcd, int n, i= nt *invalid) { uint8_t result; if (n & 1) { - result =3D bcd->u8[BCD_DIG_BYTE(n)] >> 4; + result =3D bcd->VsrB(BCD_DIG_BYTE(n)) >> 4; } else { - result =3D bcd->u8[BCD_DIG_BYTE(n)] & 0xF; + result =3D bcd->VsrB(BCD_DIG_BYTE(n)) & 0xF; } =20 if (unlikely(result > 9)) { @@ -2109,11 +2105,11 @@ static uint8_t bcd_get_digit(ppc_avr_t *bcd, int n,= int *invalid) static void bcd_put_digit(ppc_avr_t *bcd, uint8_t digit, int n) { if (n & 1) { - bcd->u8[BCD_DIG_BYTE(n)] &=3D 0x0F; - bcd->u8[BCD_DIG_BYTE(n)] |=3D (digit << 4); + bcd->VsrB(BCD_DIG_BYTE(n)) &=3D 0x0F; + bcd->VsrB(BCD_DIG_BYTE(n)) |=3D (digit << 4); } else { - bcd->u8[BCD_DIG_BYTE(n)] &=3D 0xF0; - bcd->u8[BCD_DIG_BYTE(n)] |=3D digit; + bcd->VsrB(BCD_DIG_BYTE(n)) &=3D 0xF0; + bcd->VsrB(BCD_DIG_BYTE(n)) |=3D digit; } } =20 @@ -2228,21 +2224,21 @@ uint32_t helper_bcdadd(ppc_avr_t *r, ppc_avr_t *a,= ppc_avr_t *b, uint32_t ps) =20 if (!invalid) { if (sgna =3D=3D sgnb) { - result.u8[BCD_DIG_BYTE(0)] =3D bcd_preferred_sgn(sgna, ps); + result.VsrB(BCD_DIG_BYTE(0)) =3D bcd_preferred_sgn(sgna, ps); bcd_add_mag(&result, a, b, &invalid, &overflow); cr =3D bcd_cmp_zero(&result); } else { int magnitude =3D bcd_cmp_mag(a, b); if (magnitude > 0) { - result.u8[BCD_DIG_BYTE(0)] =3D bcd_preferred_sgn(sgna, ps); + result.VsrB(BCD_DIG_BYTE(0)) =3D bcd_preferred_sgn(sgna, p= s); bcd_sub_mag(&result, a, b, &invalid, &overflow); cr =3D (sgna > 0) ? CRF_GT : CRF_LT; } else if (magnitude < 0) { - result.u8[BCD_DIG_BYTE(0)] =3D bcd_preferred_sgn(sgnb, ps); + result.VsrB(BCD_DIG_BYTE(0)) =3D bcd_preferred_sgn(sgnb, p= s); bcd_sub_mag(&result, b, a, &invalid, &overflow); cr =3D (sgnb > 0) ? CRF_GT : CRF_LT; } else { - result.u8[BCD_DIG_BYTE(0)] =3D bcd_preferred_sgn(0, ps); + result.VsrB(BCD_DIG_BYTE(0)) =3D bcd_preferred_sgn(0, ps); cr =3D CRF_EQ; } } @@ -2353,15 +2349,15 @@ uint32_t helper_bcdcfz(ppc_avr_t *r, ppc_avr_t *b, = uint32_t ps) int zone_lead =3D ps ? 0xF : 0x3; int digit =3D 0; ppc_avr_t ret =3D { .u64 =3D { 0, 0 } }; - int sgnb =3D b->u8[BCD_DIG_BYTE(0)] >> 4; + int sgnb =3D b->VsrB(BCD_DIG_BYTE(0)) >> 4; =20 if (unlikely((sgnb < 0xA) && ps)) { invalid =3D 1; } =20 for (i =3D 0; i < 16; i++) { - zone_digit =3D i ? b->u8[BCD_DIG_BYTE(i * 2)] >> 4 : zone_lead; - digit =3D b->u8[BCD_DIG_BYTE(i * 2)] & 0xF; + zone_digit =3D i ? b->VsrB(BCD_DIG_BYTE(i * 2)) >> 4 : zone_lead; + digit =3D b->VsrB(BCD_DIG_BYTE(i * 2)) & 0xF; if (unlikely(zone_digit !=3D zone_lead || digit > 0x9)) { invalid =3D 1; break; @@ -2407,7 +2403,7 @@ uint32_t helper_bcdctz(ppc_avr_t *r, ppc_avr_t *b, ui= nt32_t ps) break; } =20 - ret.u8[BCD_DIG_BYTE(i * 2)] =3D zone_lead + digit; + ret.VsrB(BCD_DIG_BYTE(i * 2)) =3D zone_lead + digit; } =20 if (ps) { @@ -2519,7 +2515,7 @@ uint32_t helper_bcdcpsgn(ppc_avr_t *r, ppc_avr_t *a, = ppc_avr_t *b, uint32_t ps) } =20 *r =3D *a; - bcd_put_digit(r, b->u8[BCD_DIG_BYTE(0)] & 0xF, 0); + bcd_put_digit(r, b->VsrB(BCD_DIG_BYTE(0)) & 0xF, 0); =20 for (i =3D 1; i < 32; i++) { bcd_get_digit(a, i, &invalid); @@ -2549,11 +2545,7 @@ uint32_t helper_bcdsetsgn(ppc_avr_t *r, ppc_avr_t *b= , uint32_t ps) uint32_t helper_bcds(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps) { int cr; -#if defined(HOST_WORDS_BIGENDIAN) - int i =3D a->s8[7]; -#else - int i =3D a->s8[8]; -#endif + int i =3D a->VsrSB(7); bool ox_flag =3D false; int sgnb =3D bcd_get_sgn(b); ppc_avr_t ret =3D *b; @@ -2602,11 +2594,7 @@ uint32_t helper_bcdus(ppc_avr_t *r, ppc_avr_t *a, pp= c_avr_t *b, uint32_t ps) } } =20 -#if defined(HOST_WORDS_BIGENDIAN) - i =3D a->s8[7]; -#else - i =3D a->s8[8]; -#endif + i =3D a->VsrSB(7); if (i >=3D 32) { ox_flag =3D true; ret.VsrD(1) =3D ret.VsrD(0) =3D 0; @@ -2637,13 +2625,11 @@ uint32_t helper_bcdsr(ppc_avr_t *r, ppc_avr_t *a, p= pc_avr_t *b, uint32_t ps) ppc_avr_t ret =3D *b; ret.VsrD(1) &=3D ~0xf; =20 -#if defined(HOST_WORDS_BIGENDIAN) - int i =3D a->s8[7]; - ppc_avr_t bcd_one =3D { .u64 =3D { 0, 0x10 } }; -#else - int i =3D a->s8[8]; - ppc_avr_t bcd_one =3D { .u64 =3D { 0x10, 0 } }; -#endif + int i =3D a->VsrSB(7); + ppc_avr_t bcd_one; + + bcd_one.VsrD(0) =3D 0; + bcd_one.VsrD(1) =3D 0x10; =20 if (bcd_is_valid(b) =3D=3D false) { return CRF_SO; @@ -2679,11 +2665,7 @@ uint32_t helper_bcdtrunc(ppc_avr_t *r, ppc_avr_t *a,= ppc_avr_t *b, uint32_t ps) { uint64_t mask; uint32_t ox_flag =3D 0; -#if defined(HOST_WORDS_BIGENDIAN) - int i =3D a->s16[3] + 1; -#else - int i =3D a->s16[4] + 1; -#endif + int i =3D a->VsrSH(3) + 1; ppc_avr_t ret =3D *b; =20 if (bcd_is_valid(b) =3D=3D false) { @@ -2728,11 +2710,7 @@ uint32_t helper_bcdutrunc(ppc_avr_t *r, ppc_avr_t *a= , ppc_avr_t *b, uint32_t ps) } } =20 -#if defined(HOST_WORDS_BIGENDIAN) - i =3D a->s16[3]; -#else - i =3D a->s16[4]; -#endif + i =3D a->VsrSH(3); if (i > 16 && i < 33) { mask =3D (uint64_t)-1 >> (128 - i * 4); if (ret.VsrD(0) & ~mask) { --=20 2.20.1