Received: from eggs.gnu.org ([2001:4830:134:3::10]:35568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzcFL-0008N2-Kh for qemu-devel@nongnu.org; Thu, 27 Oct 2016 00:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzcFJ-0007JF-4t for qemu-devel@nongnu.org; Thu, 27 Oct 2016 00:24:55 -0400 Date: Thu, 27 Oct 2016 14:47:34 +1100 From: David Gibson Message-ID: <20161027034734.GN19918@umbus.fritz.box> References: <1477463189-26971-1-git-send-email-nikunj@linux.vnet.ibm.com> <1477463189-26971-6-git-send-email-nikunj@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CaPKgh3XHpq3rEUV" Content-Disposition: inline In-Reply-To: <1477463189-26971-6-git-send-email-nikunj@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v2 5/6] target-ppc: add vprtyb[w/d/q] instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikunj A Dadhania Cc: qemu-ppc@nongnu.org, rth@twiddle.net, qemu-devel@nongnu.org, bharata@linux.vnet.ibm.com, sandipandas1990@gmail.com, ego@linux.vnet.ibm.com, Ankit Kumar --CaPKgh3XHpq3rEUV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 26, 2016 at 11:56:28AM +0530, Nikunj A Dadhania wrote: > From: Ankit Kumar >=20 > Add following POWER ISA 3.0 instructions. > vprtybw: Vector Parity Byte Word > vprtybd: Vector Parity Byte Double Word > vprtybq: Vector Parity Byte Quad Word >=20 > Signed-off-by: Ankit Kumar > Signed-off-by: Nikunj A Dadhania > --- > target-ppc/helper.h | 3 +++ > target-ppc/int_helper.c | 31 +++++++++++++++++++++++++++++++ > target-ppc/translate/vmx-impl.inc.c | 3 +++ > target-ppc/translate/vmx-ops.inc.c | 4 ++++ > 4 files changed, 41 insertions(+) >=20 > diff --git a/target-ppc/helper.h b/target-ppc/helper.h > index d6ee26e..7d42f99 100644 > --- a/target-ppc/helper.h > +++ b/target-ppc/helper.h > @@ -223,6 +223,9 @@ DEF_HELPER_3(vsro, void, avr, avr, avr) > DEF_HELPER_3(vsrv, void, avr, avr, avr) > DEF_HELPER_3(vslv, void, avr, avr, avr) > DEF_HELPER_3(vaddcuw, void, avr, avr, avr) > +DEF_HELPER_2(vprtybw, void, avr, avr) > +DEF_HELPER_2(vprtybd, void, avr, avr) > +DEF_HELPER_2(vprtybq, void, avr, avr) > DEF_HELPER_3(vsubcuw, void, avr, avr, avr) > DEF_HELPER_2(lvsl, void, avr, tl) > DEF_HELPER_2(lvsr, void, avr, tl) > diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c > index 0fd92ed..358ffff 100644 > --- a/target-ppc/int_helper.c > +++ b/target-ppc/int_helper.c > @@ -527,6 +527,37 @@ void helper_vaddcuw(ppc_avr_t *r, ppc_avr_t *a, ppc_= avr_t *b) > } > } > =20 > +/* vprtyb[w/d] */ > +#define VPRTYB(name, element) \ > +void glue(helper_, name)(ppc_avr_t *r, ppc_avr_t *b) \ > +{ \ > + int i, j; \ > + uint8_t s; \ > + int nr_b =3D sizeof(b->element[0]) / sizeof(b->u8[0]); \ > + for (i =3D 0; i < ARRAY_SIZE(r->element); i++) { \ > + s =3D 0; \ > + for (j =3D i * nr_b; j < (i + 1) * nr_b; j++) { \ > + s ^=3D (b->u8[j] & 1); \ > + } \ > + r->element[i] =3D (!s) ? 0 : 1; \ > + } \ > +} > +VPRTYB(vprtybw, u32) > +VPRTYB(vprtybd, u64) > +#undef VPTRYB > + > +/* vprtybq */ > +void helper_vprtybq(ppc_avr_t *r, ppc_avr_t *b) > +{ > + int i; > + uint8_t s =3D 0; > + for (i =3D 0; i < 16; i++) { > + s ^=3D (b->u8[i] & 1); > + } > + r->u64[LO_IDX] =3D (!s) ? 0 : 1; > + r->u64[HI_IDX] =3D 0; > +} > + I think you can implement these better. First mask with 0x01010101 (of the appropriate length) to extract the LSB bits of each byte. Then XOR the two halves together, then quarters and so forth, ln2(size) times to arrive at the parity. This is similar to the usual Hamming weight implementation. > #define VARITH_DO(name, op, element) \ > void helper_v##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ > { \ > diff --git a/target-ppc/translate/vmx-impl.inc.c b/target-ppc/translate/v= mx-impl.inc.c > index 500c43f..e1d0897 100644 > --- a/target-ppc/translate/vmx-impl.inc.c > +++ b/target-ppc/translate/vmx-impl.inc.c > @@ -705,6 +705,9 @@ GEN_VXFORM_NOA_ENV(vrfim, 5, 11); > GEN_VXFORM_NOA_ENV(vrfin, 5, 8); > GEN_VXFORM_NOA_ENV(vrfip, 5, 10); > GEN_VXFORM_NOA_ENV(vrfiz, 5, 9); > +GEN_VXFORM_NOA(vprtybw, 1, 24); > +GEN_VXFORM_NOA(vprtybd, 1, 24); > +GEN_VXFORM_NOA(vprtybq, 1, 24); > =20 > #define GEN_VXFORM_SIMM(name, opc2, opc3) \ > static void glue(gen_, name)(DisasContext *ctx) = \ > diff --git a/target-ppc/translate/vmx-ops.inc.c b/target-ppc/translate/vm= x-ops.inc.c > index a5ad4d4..c631780 100644 > --- a/target-ppc/translate/vmx-ops.inc.c > +++ b/target-ppc/translate/vmx-ops.inc.c > @@ -122,6 +122,10 @@ GEN_VXFORM_300(vslv, 2, 29), > GEN_VXFORM(vslo, 6, 16), > GEN_VXFORM(vsro, 6, 17), > GEN_VXFORM(vaddcuw, 0, 6), > +GEN_HANDLER_E_2(vprtybw, 0x4, 0x1, 0x18, 8, 0, PPC_NONE, PPC2_ISA300), > +GEN_HANDLER_E_2(vprtybd, 0x4, 0x1, 0x18, 9, 0, PPC_NONE, PPC2_ISA300), > +GEN_HANDLER_E_2(vprtybq, 0x4, 0x1, 0x18, 10, 0, PPC_NONE, PPC2_ISA300), > + > GEN_VXFORM(vsubcuw, 0, 22), > GEN_VXFORM_DUAL(vaddubs, vmul10uq, 0, 8, PPC_ALTIVEC, PPC_NONE), > GEN_VXFORM_DUAL(vadduhs, vmul10euq, 0, 9, PPC_ALTIVEC, PPC_NONE), --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --CaPKgh3XHpq3rEUV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYEXjWAAoJEGw4ysog2bOS8AcP/2XJCtP11B1Ib8hF5jDCndH6 UE99FhDzVL26hxE6iDCA/j36adWlxNB9gDj+p5WvVnbOF4uY2xH/pyqbFL8doXN4 fDS4mYk+FuY3lfzFBwOsBWXs9xorVonKyZAq3ucvnW8MNtitbwQ9FjOOrBW7dosa NDngxYOvFvh5tu4Av7LhFQ09N/4l0ImcBSnZt8tEcJdoaLCtqRR+ZNrr9t15FfjN 4Fj/NurQSL/1H08+zuLChzV4GzAYf8jJtR0TueVK0wPDTShpf2hfi5SGMgUTueW6 04k3FACgGwbxFCoqhNIFSrSInc6v9h8ZVYYZEjii7OF89pu1A+GYodpU+4DLTaaD Ovx7QVCnYGbP6cevjSdfCsDRAIe11gQtH8ctgZvQ+/NDLFCDqLfyvuspEFdSUHEn rLheVXIbVqss1ztivvpvscTy1duxUyuBcfQjRtFXOYKQloJvjF6EkS8pAZeKdmfP uPaJtFOeAhH/o0k6nUuB0hVQ6GlNhZLR7f1cafBqXS013Ot+A0YrHBodV/dsJv5E xBuiq9v0mcJ8wlRX2Ty4UILfQTuhpsdI7EG5vW4iQeMUkmAqpHEyI+Bl5xwFeXhl phzrRNNfKsJ/0i5Sv6bryKPPx5/tTsqhU06en+Jmx8DsMNd3xXWOVn271TPfZ6bE xIzyA/0ftZVkb6RZFQFj =bGt5 -----END PGP SIGNATURE----- --CaPKgh3XHpq3rEUV--