From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3xFe-0004wp-Sh for qemu-devel@nongnu.org; Mon, 07 Nov 2016 22:39:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c3xFb-0007I1-Fv for qemu-devel@nongnu.org; Mon, 07 Nov 2016 22:39:10 -0500 Date: Tue, 8 Nov 2016 14:28:59 +1100 From: David Gibson Message-ID: <20161108032859.GG28688@umbus.fritz.box> References: <1478013888-22242-1-git-send-email-joserz@linux.vnet.ibm.com> <1478013888-22242-4-git-send-email-joserz@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="+sHJum3is6Tsg7/J" Content-Disposition: inline In-Reply-To: <1478013888-22242-4-git-send-email-joserz@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v4 3/4] target-ppc: Implement bcdcfz. 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 --+sHJum3is6Tsg7/J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 01, 2016 at 01:24:47PM -0200, Jose Ricardo Ziviani wrote: > bcdcfz. converts from Zoned numeric format to BCD. Zoned format uses > a byte to represent a digit where the most significant nibble is 0x3 > or 0xf, depending on the preferred signal. >=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 | 7 ++++++ > 3 files changed, 53 insertions(+) >=20 > diff --git a/target-ppc/helper.h b/target-ppc/helper.h > index 33286c6..8546bb9 100644 > --- a/target-ppc/helper.h > +++ b/target-ppc/helper.h > @@ -373,6 +373,7 @@ DEF_HELPER_4(bcdadd, i32, avr, avr, avr, i32) > DEF_HELPER_4(bcdsub, i32, avr, avr, avr, i32) > DEF_HELPER_3(bcdcfn, i32, avr, avr, i32) > DEF_HELPER_3(bcdctn, i32, avr, avr, i32) > +DEF_HELPER_3(bcdcfz, 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 3c21173..c546a9a 100644 > --- a/target-ppc/int_helper.c > +++ b/target-ppc/int_helper.c > @@ -2729,6 +2729,51 @@ uint32_t helper_bcdctn(ppc_avr_t *r, ppc_avr_t *b,= uint32_t ps) > return cr; > } > =20 > +uint32_t helper_bcdcfz(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps) > +{ > + int i; > + int j; > + int cr =3D 0; > + int invalid =3D 0; > + int zone_digit =3D 0; > + 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; > + > + if (unlikely((sgnb < 0xA) && ps)) { > + invalid =3D 1; > + } > + > + for (i =3D 0, j =3D 1; i < 31; i +=3D 2, j++) { Having these two loop counters in paralle is kind of clunky. I think it would be clearer to just have i go from 0..15, use i*2 for the input index and (i+1) for the output index. > + zone_digit =3D (i) ? b->u8[BCD_DIG_BYTE(i)] >> 4 : zone_lead; > + digit =3D b->u8[BCD_DIG_BYTE(i)] & 0xF; > + if (unlikely(zone_digit !=3D zone_lead || digit > 0x9)) { > + invalid =3D 1; > + break; > + } > + > + bcd_put_digit(&ret, digit, j); > + } > + > + if ((ps && (sgnb =3D=3D 0xB || sgnb =3D=3D 0xD)) || > + (!ps && (sgnb & 0x4))) { > + bcd_put_digit(&ret, BCD_NEG_PREF, 0); > + } else { > + bcd_put_digit(&ret, BCD_PLUS_PREF_1, 0); > + } > + > + cr =3D bcd_cmp_zero(&ret); > + > + if (unlikely(invalid)) { > + cr =3D 1 << 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 d5953a6..7e902a9 100644 > --- a/target-ppc/translate/vmx-impl.inc.c > +++ b/target-ppc/translate/vmx-impl.inc.c > @@ -972,6 +972,7 @@ GEN_BCD(bcdadd) > GEN_BCD(bcdsub) > GEN_BCD2(bcdcfn) > GEN_BCD2(bcdctn) > +GEN_BCD2(bcdcfz) > =20 > static void gen_xpnd04_1(DisasContext *ctx) > { > @@ -979,6 +980,9 @@ static void gen_xpnd04_1(DisasContext *ctx) > case 5: > gen_bcdctn(ctx); > break; > + case 6: > + gen_bcdcfz(ctx); > + break; > case 7: > gen_bcdcfn(ctx); > break; > @@ -991,6 +995,9 @@ static void gen_xpnd04_1(DisasContext *ctx) > static void gen_xpnd04_2(DisasContext *ctx) > { > switch (opc4(ctx->opcode)) { > + case 6: > + gen_bcdcfz(ctx); > + break; > case 7: > gen_bcdcfn(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 --+sHJum3is6Tsg7/J Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYIUZ4AAoJEGw4ysog2bOSnfgQAKugYW25+q9BonZysr4Z8VE4 AJYCx6mc5z1V40wfih9ZJI7p2Jd/ZxPtSY66gXHVS1u70OtsIHBm/7aW1IoxH3H+ ETpHcCSp8eDyAovTNULEQfBVRjCT5zUDxj2JaK2031YrV70PzMJxxkXvqy82tR6d qJQ6ZfcIQPDjYR+OCJBrPjH63MA0rZTRP6IrJP2efIc+MtzSQ3OkDWBe6ortEoVw 0Z7wbfnEcsl9YxshGmqM4Ozg5DP/L6E6GF4qCrkzoLBptjttpHetN1/wZWgd5LxA 7aD1VvL7QHjyQ097DlE/vPTrIJCiuK9gEbqBmfDvfxVa+OxxxSHQ5iUcHuz9PRcT tzLMhF42zVlr8IS8w98aTmDl65isVeVM1wpynh9bU7Zoa/XwZi2/S7cBS6WcGya0 Zwd/WUS1f08NJS9/tA/MT4uW3/8k0AMMvTehfJpCGitXBBnNj0mZx3d2Xb58XdGZ gfI4Uar5kxRaq1Jl54MGpgrKF+8uAUCM+XBpGjqLjS863AFVu1TVcOVB92+pq714 WUJY93GAJvUGe2T+deyu9a7lz/zBThnGQ4NQ59iEOM0cx4uY9KgSkzvNYoQSlu+i 752QeBBcCCeJ/dKX+Qt70rR9+I//KW4AhXm4d8WiQe3DuXwJNq7oIBTc0EwZIedD jDCjtHeeTUFHvfnsMTHU =RmcC -----END PGP SIGNATURE----- --+sHJum3is6Tsg7/J--