From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOxxu-0005Gg-AT for qemu-devel@nongnu.org; Sun, 17 Jul 2016 22:07:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bOxxp-0004Vu-Ub for qemu-devel@nongnu.org; Sun, 17 Jul 2016 22:07:26 -0400 Date: Mon, 18 Jul 2016 12:04:49 +1000 From: David Gibson Message-ID: <20160718020449.GK16769@voom.fritz.box> References: <1468346602-20700-1-git-send-email-nikunj@linux.vnet.ibm.com> <1468346602-20700-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="7ArrI7P/b+va1vZ8" Content-Disposition: inline In-Reply-To: <1468346602-20700-6-git-send-email-nikunj@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC 5/6] 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 --7ArrI7P/b+va1vZ8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 12, 2016 at 11:33:21PM +0530, Nikunj A Dadhania wrote: > Adding following instructions: >=20 > moduw: Modulo Unsigned Word > modsw: Modulo Signed Word >=20 > Signed-off-by: Nikunj A Dadhania Hrm.. any reason you're not using the TCG inbuilt remainder ops (tcg_gen_rem_i32() etc.)? > --- > target-ppc/translate.c | 50 ++++++++++++++++++++++++++++++++++++++++++++= ++++++ > 1 file changed, 50 insertions(+) >=20 > diff --git a/target-ppc/translate.c b/target-ppc/translate.c > index 8de217f..c505684 100644 > --- a/target-ppc/translate.c > +++ b/target-ppc/translate.c > @@ -1178,6 +1178,54 @@ 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); > + tcg_gen_div_i32(t2, t0, t1); > + } else { > + tcg_gen_divu_i32(t2, t0, t1); > + } > + tcg_gen_mul_i32(t2, t2, t1); > + tcg_gen_sub_i32(t2, t0, t2); > + tcg_gen_br(l2); > + gen_set_label(l1); > + if (sign) { > + tcg_gen_sari_i32(t2, t0, 31); > + } 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 +10292,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 --7ArrI7P/b+va1vZ8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXjDlBAAoJEGw4ysog2bOSZJoP/2U93NZ/cF1lBaRl2Gbt4A1U hvJADgHS6GUIVEzNYJl3arXJYdbU6iwsmQVk4YHRG2Lqy78Hnsw/MIy6QakFy+B4 OGPgLlDISpQ0NyauLe+3/J/UFuS8JTxjROFJ82JfbC3pCy0M9+DVRVdwWq3SPK9H cATUAwjtElD0OOqk3/Ywo2RTZ3tXdUJWB/5ExBvxTXxRrxhZaPc3srmTJfFApw4e 2XWUMKkvnypGWL931y3q0245+s7Q1pK48iLDE5uwwaiQT20ChhnNViTi2T5CNG3M vw878XxAh8nt7mm/4/p7ftUdHUwqmn19xIBRxcptjDHXocB2a/UOKHbotc9pX32f tN8b/REEDWRWNmt0f77LsufZZgRwhp1bVwSOlBLHI+1gmLlUhmP02JAO4W9VHLIs EBPNsafOsVP0U9MqDZRQpiFbAbibkKu4JftguGOzAlR9ecUshimDWQf3wFZMkbl0 h0z/R9uBZ0JPGPnpXqJ3wVHfU8Sl+mlZIwMWHTDZsPJfbZkRPelaWdROTYObKPdU JS4guP5D7yeDP1wDLwudCmGw8MQ3rMwloEA2OLxI4CSDcY1n37vPzZzoqtTSSLDR 8P98XGSwuaAQyKvi7ik3a1jVW9Q2ianKh17B6M8Ln9iUmU8NTH1h2SiyJtZa6qC2 +nM49Iih+juy/7QwX4Ba =Oj6Q -----END PGP SIGNATURE----- --7ArrI7P/b+va1vZ8--