From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQSgK-0001RR-Rx for qemu-devel@nongnu.org; Fri, 22 Jul 2016 01:07:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQSgF-0006nX-Jg for qemu-devel@nongnu.org; Fri, 22 Jul 2016 01:07:27 -0400 Date: Fri, 22 Jul 2016 14:51:37 +1000 From: David Gibson Message-ID: <20160722045137.GO15941@voom.fritz.box> References: <1468861517-2508-1-git-send-email-nikunj@linux.vnet.ibm.com> <1468861517-2508-6-git-send-email-nikunj@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kVcb4xucqmsYUpQy" Content-Disposition: inline In-Reply-To: <1468861517-2508-6-git-send-email-nikunj@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC v1 05/13] target-ppc: add modulo word operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikunj A Dadhania Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com, benh@kernel.crashing.org --kVcb4xucqmsYUpQy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 18, 2016 at 10:35:09PM +0530, Nikunj A Dadhania wrote: > Adding following instructions: >=20 > moduw: Modulo Unsigned Word > modsw: Modulo Signed Word >=20 > Signed-off-by: Nikunj A Dadhania As rth has already mentioned this many branches probably means this wants a helper. > --- > target-ppc/translate.c | 48 ++++++++++++++++++++++++++++++++++++++++++++= ++++ > 1 file changed, 48 insertions(+) >=20 > diff --git a/target-ppc/translate.c b/target-ppc/translate.c > index d44f7af..487dd94 100644 > --- a/target-ppc/translate.c > +++ b/target-ppc/translate.c > @@ -1178,6 +1178,52 @@ GEN_DIVE(divde, divde, 0); > GEN_DIVE(divdeo, divde, 1); > #endif > =20 > +static inline void gen_op_arith_modw(DisasContext *ctx, TCGv ret, TCGv a= rg1, > + TCGv arg2, int sign) > +{ > + TCGLabel *l1 =3D gen_new_label(); > + TCGLabel *l2 =3D gen_new_label(); > + TCGv_i32 t0 =3D tcg_temp_local_new_i32(); > + TCGv_i32 t1 =3D tcg_temp_local_new_i32(); > + TCGv_i32 t2 =3D tcg_temp_local_new_i32(); > + > + tcg_gen_trunc_tl_i32(t0, arg1); > + tcg_gen_trunc_tl_i32(t1, arg2); > + tcg_gen_brcondi_i32(TCG_COND_EQ, t1, 0, l1); > + if (sign) { > + TCGLabel *l3 =3D gen_new_label(); > + tcg_gen_brcondi_i32(TCG_COND_NE, t1, -1, l3); > + tcg_gen_brcondi_i32(TCG_COND_EQ, t0, INT32_MIN, l1); > + gen_set_label(l3); It's not really clear to be what the logic above is doing. > + tcg_gen_rem_i32(t2, t0, t1); > + } else { > + tcg_gen_remu_i32(t2, t0, t1); > + } > + tcg_gen_br(l2); > + gen_set_label(l1); > + if (sign) { > + tcg_gen_sari_i32(t2, t0, 31); AFAICT this sets t2 to either 0 or -1 depending on the sign of t0, which seems like an odd thing to do. > + } else { > + tcg_gen_movi_i32(t2, 0); > + } > + gen_set_label(l2); > + tcg_gen_extu_i32_tl(ret, t2); > + tcg_temp_free_i32(t0); > + tcg_temp_free_i32(t1); > + tcg_temp_free_i32(t2); > +} > + > +#define GEN_INT_ARITH_MODW(name, opc3, sign) = \ > +static void glue(gen_, name)(DisasContext *ctx) = \ > +{ = \ > + gen_op_arith_modw(ctx, cpu_gpr[rD(ctx->opcode)], = \ > + cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]= , \ > + sign); = \ > +} > + > +GEN_INT_ARITH_MODW(modsw, 0x18, 1); > +GEN_INT_ARITH_MODW(moduw, 0x08, 0); > + > /* mulhw mulhw. */ > static void gen_mulhw(DisasContext *ctx) > { > @@ -10244,6 +10290,8 @@ GEN_HANDLER_E(divwe, 0x1F, 0x0B, 0x0D, 0, PPC_NON= E, PPC2_DIVE_ISA206), > GEN_HANDLER_E(divweo, 0x1F, 0x0B, 0x1D, 0, PPC_NONE, PPC2_DIVE_ISA206), > GEN_HANDLER_E(divweu, 0x1F, 0x0B, 0x0C, 0, PPC_NONE, PPC2_DIVE_ISA206), > GEN_HANDLER_E(divweuo, 0x1F, 0x0B, 0x1C, 0, PPC_NONE, PPC2_DIVE_ISA206), > +GEN_HANDLER_E(modsw, 0x1F, 0x0B, 0x18, 0x00000001, PPC_NONE, PPC2_ISA300= ), > +GEN_HANDLER_E(moduw, 0x1F, 0x0B, 0x08, 0x00000001, PPC_NONE, PPC2_ISA300= ), > =20 > #if defined(TARGET_PPC64) > #undef GEN_INT_ARITH_DIVD --=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 --kVcb4xucqmsYUpQy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXkaZZAAoJEGw4ysog2bOSi+sP+QGLqXf/EdZPEJr+8miEcFMk 7wq5DD9niBKyHS1349zHY64O00oKuV2F+Ik0IGW+Pg7Ajw+QxXD8VngyCYXJOmqU gUwtAQzhtWL0+BEXDhic0QuJR+8JgSWzYplFIHUA7fRCRcfVxXbSL/61JMky4RYx ls0B50cE3yPD1s7iUe5LOTnBRj7LIN0pp0vP+VC1J2mMey9jcuB6ChSVixXPPpJx S1iCXmt8ViAnkxmd33fUuqDAhkGjFbVLZdpuOw9L3Ef28Es7b1AEfQ7NxmrFM4ct DRyZQY0zXsaKJ+f0sjXAfmiDEHlF4w4cpYbg4ZYvb5pt2gW/WC0NEsQHNOu2dv9P N2VvBfgYnRv3FYO7kdzNgtJw5J1Ij/1CyUSH7YKMRsAiDzAEbsaAjljsFbay0JJN VqodLAh1hvXtx2iWxN46iwSiiDt6bqrbk1I2Nt//EaZfeWrtS8+E6ORgX6lK2vLb +z+KrGOTedPjtruVRouPQSrxJ4MdEb+FuoL8AW2ep2A7+nAoUvgS2f1+p4AhQBm+ mzdAd6bVkTv4jsYXOcy0P1P0i2RclNCdbCr8KxDAHIaG/Ob7J5uvA9pyYXMGW6n0 1a9OXXec9jz4Cu2MhLEfNqwn3SIdno428O66KbSwO89O3ymyKqZ3Ig2zo4WA217f iHRiuA0BwR9aAylMsFJc =mpdF -----END PGP SIGNATURE----- --kVcb4xucqmsYUpQy--