From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDjs0-0005JT-RL for qemu-devel@nongnu.org; Sun, 04 Dec 2016 22:23:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cDjrw-0008M3-Kc for qemu-devel@nongnu.org; Sun, 04 Dec 2016 22:23:12 -0500 Date: Mon, 5 Dec 2016 14:19:26 +1100 From: David Gibson Message-ID: <20161205031926.GA32366@umbus.fritz.box> References: <1480741206-32737-1-git-send-email-joserz@linux.vnet.ibm.com> <1480741206-32737-6-git-send-email-joserz@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="sm4nu43k4a2Rpi4c" Content-Disposition: inline In-Reply-To: <1480741206-32737-6-git-send-email-joserz@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH 5/7] target-ppc: Implement bcdsr. instruction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jose Ricardo Ziviani Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, nikunj@linux.vnet.ibm.com, bharata@linux.vnet.ibm.com --sm4nu43k4a2Rpi4c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Dec 03, 2016 at 03:00:04AM -0200, Jose Ricardo Ziviani wrote: > bcdsr.: Decimal shift and round. This instruction works like bcds. > however, when performing right shift, 1 will be added to the > result if the last digit was >=3D 5. >=20 > Signed-off-by: Jose Ricardo Ziviani > --- > target-ppc/helper.h | 1 + > target-ppc/int_helper.c | 45 +++++++++++++++++++++++++++++++= ++++++ > target-ppc/translate/vmx-impl.inc.c | 1 + > target-ppc/translate/vmx-ops.inc.c | 2 ++ > 4 files changed, 49 insertions(+) >=20 > diff --git a/target-ppc/helper.h b/target-ppc/helper.h > index 386ea67..d9528eb 100644 > --- a/target-ppc/helper.h > +++ b/target-ppc/helper.h > @@ -394,6 +394,7 @@ DEF_HELPER_4(bcdcpsgn, i32, avr, avr, avr, i32) > DEF_HELPER_3(bcdsetsgn, i32, avr, avr, i32) > DEF_HELPER_4(bcds, i32, avr, avr, avr, i32) > DEF_HELPER_4(bcdus, i32, avr, avr, avr, i32) > +DEF_HELPER_4(bcdsr, i32, avr, avr, avr, i32) > =20 > DEF_HELPER_2(xsadddp, void, env, i32) > DEF_HELPER_2(xssubdp, void, env, i32) > diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c > index 4b5eea1..c9fcb1a 100644 > --- a/target-ppc/int_helper.c > +++ b/target-ppc/int_helper.c > @@ -3124,6 +3124,51 @@ uint32_t helper_bcdus(ppc_avr_t *r, ppc_avr_t *a, = ppc_avr_t *b, uint32_t ps) > return cr; > } > =20 > +uint32_t helper_bcdsr(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t= ps) > +{ > + int cr; > + int i; > + int unused =3D 0; > + int invalid =3D 0; > + bool ox_flag =3D false; > + int sgnb =3D bcd_get_sgn(b); > + ppc_avr_t ret =3D *b; > + ret.u64[LO_IDX] &=3D ~0xf; > + > +#if defined(HOST_WORDS_BIGENDIAN) > + ppc_avr_t bcd_one =3D { .u64 =3D { 0, 0x10 } }; > + int upper =3D ARRAY_SIZE(a->s32) - 1; Same comment as previous patches about the shift argument. > +#else > + ppc_avr_t bcd_one =3D { .u64 =3D { 0x10, 0 } }; > + int upper =3D 0; > +#endif > + > + if (bcd_is_valid(b) =3D=3D false) { > + return CRF_SO; > + } > + > + if (a->s32[upper] > 0) { > + i =3D (a->s32[upper] > 31) ? 31 : a->s32[upper]; > + ulshift(&ret.u64[LO_IDX], &ret.u64[HI_IDX], i * 4, &ox_flag); > + } else { > + i =3D (a->s32[upper] < -31) ? 31 : -a->s32[upper]; > + urshift(&ret.u64[LO_IDX], &ret.u64[HI_IDX], i * 4); > + > + if (bcd_get_digit(&ret, 0, &invalid) >=3D 5) { So, the ISA actually says you increment only if the last digit is > 5. That doesn't seem like correct rounding, so it might be an error in the ISA document - best check this with the hardware people. > + bcd_add_mag(&ret, &ret, &bcd_one, &invalid, &unused); > + } > + } > + bcd_put_digit(&ret, bcd_preferred_sgn(sgnb, ps), 0); > + > + cr =3D bcd_cmp_zero(&ret); > + if (unlikely(ox_flag)) { > + cr |=3D CRF_SO; > + } > + *r =3D ret; > + > + return cr; > +} > + > void helper_vsbox(ppc_avr_t *r, ppc_avr_t *a) > { > int i; > diff --git a/target-ppc/translate/vmx-impl.inc.c b/target-ppc/translate/v= mx-impl.inc.c > index fc54881..451abb5 100644 > --- a/target-ppc/translate/vmx-impl.inc.c > +++ b/target-ppc/translate/vmx-impl.inc.c > @@ -1018,6 +1018,7 @@ GEN_BCD2(bcdsetsgn) > GEN_BCD(bcdcpsgn); > GEN_BCD(bcds); > GEN_BCD(bcdus); > +GEN_BCD(bcdsr); > =20 > static void gen_xpnd04_1(DisasContext *ctx) > { > diff --git a/target-ppc/translate/vmx-ops.inc.c b/target-ppc/translate/vm= x-ops.inc.c > index cdd3abe..fa9c996 100644 > --- a/target-ppc/translate/vmx-ops.inc.c > +++ b/target-ppc/translate/vmx-ops.inc.c > @@ -132,6 +132,8 @@ GEN_HANDLER_E_2(vprtybd, 0x4, 0x1, 0x18, 9, 0, PPC_NO= NE, PPC2_ISA300), > GEN_HANDLER_E_2(vprtybq, 0x4, 0x1, 0x18, 10, 0, PPC_NONE, PPC2_ISA300), > =20 > GEN_VXFORM_DUAL(vsubcuw, xpnd04_1, 0, 22, PPC_ALTIVEC, PPC_NONE), > +GEN_VXFORM_300(bcdsr, 0, 23), > +GEN_VXFORM_300(bcdsr, 0, 31), > GEN_VXFORM_DUAL(vaddubs, vmul10uq, 0, 8, PPC_ALTIVEC, PPC_NONE), > GEN_VXFORM_DUAL(vadduhs, vmul10euq, 0, 9, PPC_ALTIVEC, PPC_NONE), > GEN_VXFORM(vadduws, 0, 10), --=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 --sm4nu43k4a2Rpi4c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYRNy9AAoJEGw4ysog2bOSPzQQANx/TPtBhl8q0P+IoOuVVUzP uEKrvBmX04kr+RuWQPPEx3sItd9d3YU9RNyTUHs5pkwJ7Jka5giEwtXge3POyj0N 7y6uHWsW3c1vAVc1JhqoP2Ot2o9F8SF+FE0Hf5lARhsBCWIyJkd5zKkJMlcfKfJw 4Ccm7XRwwHB1uLacDBD1/1Ea/65+T0W5g7R5ULUFbbeCi5E8eQOSc9lI5f9EwSKb fs6YskJlmg8QhG8g2teC5ceqLmUJq9/OrBlfQT1Dw3VcIXTNqRnG9bNjbcxn1Z01 nSA80t8TRIAIw7jnJ5YUlNABYuwZDT4Xm5G9u0BynBSglLSsiVvjQrst/giMvibL +gAwfCpE2SNEwmefNVfimYp8gMWZ4mUf2hS/Zo4pE+CQJXlTn5nN45+CI2xO18rR 5H4fNN72kYEuS1STOknPTGTuM5T/SD0gWHm4pluD/fwHkL5P1rgNY27hzNSQYm+5 wlthcO6m4ysYewjuagKD1py+Rc/J7FqanLxMDGu4oZXct1zafLpJAEpkU5NxCqEu 7r2UDrfDYVQ/m8PDyHilMClZamb3gzKQf/ZwS0X4GaJMyXQKh1QgXFA+ixkBpM0V Cw0VN9BHIJWU1JGgfJZUTCABzMASuYAc87eGcY3j53igU4Py19LWIe+BUkhl8y1Z 94AAYJmzb7JqNJM++xGm =YlQA -----END PGP SIGNATURE----- --sm4nu43k4a2Rpi4c--