From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cA8Va-0005Zn-AL for qemu-devel@nongnu.org; Thu, 24 Nov 2016 23:53:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cA8VW-00080K-5E for qemu-devel@nongnu.org; Thu, 24 Nov 2016 23:53:10 -0500 Date: Fri, 25 Nov 2016 15:52:36 +1100 From: David Gibson Message-ID: <20161125045236.GF12287@umbus.fritz.box> References: <1480046013-24788-1-git-send-email-joserz@linux.vnet.ibm.com> <1480046013-24788-2-git-send-email-joserz@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ExXT7PjY8AI4Hyfa" Content-Disposition: inline In-Reply-To: <1480046013-24788-2-git-send-email-joserz@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v3 1/4] target-ppc: Implement bcdcfsq. 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 --ExXT7PjY8AI4Hyfa Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 25, 2016 at 01:53:30AM -0200, Jose Ricardo Ziviani wrote: > bcdcfsq.: Decimal convert from signed quadword. It is not possible > to convert values less than -10^31-1 or greater than 10^31-1 to be > represented in packed decimal format. >=20 > Signed-off-by: Jose Ricardo Ziviani > --- > target-ppc/helper.h | 1 + > target-ppc/int_helper.c | 38 +++++++++++++++++++++++++++++++= ++++++ > target-ppc/translate/vmx-impl.inc.c | 7 +++++++ > 3 files changed, 46 insertions(+) >=20 > diff --git a/target-ppc/helper.h b/target-ppc/helper.h > index 3b26678..efb384a 100644 > --- a/target-ppc/helper.h > +++ b/target-ppc/helper.h > @@ -382,6 +382,7 @@ DEF_HELPER_3(bcdcfn, i32, avr, avr, i32) > DEF_HELPER_3(bcdctn, i32, avr, avr, i32) > DEF_HELPER_3(bcdcfz, i32, avr, avr, i32) > DEF_HELPER_3(bcdctz, i32, avr, avr, i32) > +DEF_HELPER_3(bcdcfsq, i32, 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 fbf477f..9d753e2 100644 > --- a/target-ppc/int_helper.c > +++ b/target-ppc/int_helper.c > @@ -2874,6 +2874,44 @@ uint32_t helper_bcdctz(ppc_avr_t *r, ppc_avr_t *b,= uint32_t ps) > return cr; > } > =20 > +uint32_t helper_bcdcfsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps) > +{ > + int i; > + int cr =3D 0; > + uint64_t lo_value; > + uint64_t hi_value; > + ppc_avr_t ret =3D { .u64 =3D { 0, 0 } }; > + > + if (b->s64[HI_IDX] < 0) { > + lo_value =3D -b->s64[LO_IDX]; > + hi_value =3D ~b->u64[HI_IDX] + !lo_value; > + bcd_put_digit(&ret, 0xD, 0); > + } else { > + lo_value =3D b->u64[LO_IDX]; > + hi_value =3D b->u64[HI_IDX]; > + bcd_put_digit(&ret, bcd_preferred_sgn(0, ps), 0); > + } > + > + if (divu128(&lo_value, &hi_value, 1000000000000000ULL) || > + lo_value > 99999999999999999ULL) { This is 10^17-1, but it should be 10^16-1. I've corrected that in my tree, but please try to be more careful in future. > + cr =3D CRF_SO; > + } > + > + for (i =3D 1; i < 16; hi_value /=3D 10, i++) { > + bcd_put_digit(&ret, hi_value % 10, i); > + } > + > + for (; i < 32; lo_value /=3D 10, i++) { > + bcd_put_digit(&ret, lo_value % 10, i); > + } > + > + cr |=3D bcd_cmp_zero(&ret); > + > + *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 7143eb3..36141e5 100644 > --- a/target-ppc/translate/vmx-impl.inc.c > +++ b/target-ppc/translate/vmx-impl.inc.c > @@ -989,10 +989,14 @@ GEN_BCD2(bcdcfn) > GEN_BCD2(bcdctn) > GEN_BCD2(bcdcfz) > GEN_BCD2(bcdctz) > +GEN_BCD2(bcdcfsq) > =20 > static void gen_xpnd04_1(DisasContext *ctx) > { > switch (opc4(ctx->opcode)) { > + case 2: > + gen_bcdcfsq(ctx); > + break; > case 4: > gen_bcdctz(ctx); > break; > @@ -1014,6 +1018,9 @@ static void gen_xpnd04_1(DisasContext *ctx) > static void gen_xpnd04_2(DisasContext *ctx) > { > switch (opc4(ctx->opcode)) { > + case 2: > + gen_bcdcfsq(ctx); > + break; > case 4: > gen_bcdctz(ctx); > break; --=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 --ExXT7PjY8AI4Hyfa Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYN8ORAAoJEGw4ysog2bOSUqkP/2T+3/KEX55b2r3z4YGlqjpN S6odxI3hWyTyzxpBkO4TTeiLlVhRBy20kOtnL9cDewxjPvFI1KP5PckjfxM+TkVc bhYThxjm5IAvKHHMgFXBm4CbbWqdjiG4b6sv9dI1RShzq7v0ZlU4pf6HueFmCtRn qT++1aVsZc2d3cvl1lSvaVv/Lx0/5qy5s+P/BUILy01p06mJCnGQ0BW+CPkTP/IM vyPXo/eyoRCOJKyF/vI9dLqj/rD+TvGQ51sZnu+45ORHAPOPDl5fAu+YNpzZy/eg h21CXEPob3d+3WWe3mrDtqZ1qYNKovHyBQhHAmDXqHYHAbCHMqpvbZOJQklefJfN H76pfluYXLuPfEVAnvdyVc5bCKzUwT5IRpdK6GvsNfr8NoORMifuAD+HnLCTmMpc tGsq5gaJcD9ns1GEtDbdmO9Rr6AJ2NeNMPE4pfKbHEQA0QaThY9/m7bn1NjNFelW 98tPxFk6Rq9skQs5qzNyw1clRylkXIBuBQS+Gpr15+QJnAGu44hVgZDnzOYUQzWk qsUBF/8pMLRtAYovtclrNwFTXsFRj/0oh3Xdgr5vgBjrE0TqASb4JG4vAhmm4Xiy BnITvs7rEQOIHiQruuOPYXabiqzaizeKGalEv6JcmQlm2FqO2Noub8CFpDtcPZQM fTTyDtT30EZUKZFlaV0B =5Hey -----END PGP SIGNATURE----- --ExXT7PjY8AI4Hyfa--