Received: from eggs.gnu.org ([2001:4830:134:3::10]:60079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzw8T-0001z7-K3 for qemu-devel@nongnu.org; Thu, 27 Oct 2016 21:39:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzw8P-0002oD-DD for qemu-devel@nongnu.org; Thu, 27 Oct 2016 21:39:09 -0400 Date: Fri, 28 Oct 2016 12:30:14 +1100 From: David Gibson Message-ID: <20161028013014.GD19349@umbus.fritz.box> References: <1477463189-26971-1-git-send-email-nikunj@linux.vnet.ibm.com> <1477463189-26971-4-git-send-email-nikunj@linux.vnet.ibm.com> <20161027033809.GL19918@umbus.fritz.box> <87d1im2nuq.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3Gf/FFewwPeBMqCJ" Content-Disposition: inline In-Reply-To: <87d1im2nuq.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> Subject: Re: [Qemu-devel] [PATCH v2 3/6] target-ppc: add vrldnmi and vrlwmi instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikunj A Dadhania Cc: qemu-ppc@nongnu.org, rth@twiddle.net, qemu-devel@nongnu.org, bharata@linux.vnet.ibm.com, sandipandas1990@gmail.com, ego@linux.vnet.ibm.com --3Gf/FFewwPeBMqCJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 27, 2016 at 02:03:01PM +0530, Nikunj A Dadhania wrote: > David Gibson writes: > >> diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c > >> index dca4798..b54cd7c 100644 > >> --- a/target-ppc/int_helper.c > >> +++ b/target-ppc/int_helper.c > >> @@ -1717,6 +1717,52 @@ void helper_vrsqrtefp(CPUPPCState *env, ppc_avr= _t *r, ppc_avr_t *b) > >> } > >> } > >> =20 > >> +#define MASK(size, max_val) \ > >> +static inline uint##size##_t mask_u##size(uint##size##_t start, \ > >> + uint##size##_t end) \ > >> +{ \ > >> + uint##size##_t ret, max_bit =3D size - 1; \ > >> + \ > >> + if (likely(start =3D=3D 0)) { \ > >> + ret =3D max_val << (max_bit - end); \ > >> + } else if (likely(end =3D=3D max_bit)) { \ > >> + ret =3D max_val >> start; \ > >> + } else { \ > >> + ret =3D (((uint##size##_t)(-1ULL)) >> (start)) ^ \ > >> + (((uint##size##_t)(-1ULL) >> (end)) >> 1); \ > >> + if (unlikely(start > end)) { \ > >> + return ~ret; \ > >> + } \ > >> + } \ > >> + \ > >> + return ret; \ > >> +} > >> + > >> +MASK(32, UINT32_MAX); > >> +MASK(64, UINT64_MAX); > > > > It would be nicer to merge this mask generation with the > > implementation in target-ppc/translate.c (called MASK()). >=20 > How about something like this in target-ppc/cpu.h >=20 > #define FUNC_MASK(name, ret_type, size, max_val) \ > static inline ret_type name (uint##size##_t start, \ > uint##size##_t end) \ > { \ > ret_type ret, max_bit =3D size - 1; \ > \ > if (likely(start =3D=3D 0)) { \ > ret =3D max_val << (max_bit - end); \ > } else if (likely(end =3D=3D max_bit)) { \ > ret =3D max_val >> start; \ > } else { \ > ret =3D (((uint##size##_t)(-1ULL)) >> (start)) ^ \ > (((uint##size##_t)(-1ULL) >> (end)) >> 1); \ > if (unlikely(start > end)) { \ > return ~ret; \ > } \ > } \ > \ > return ret; \ > } >=20 > #if defined(TARGET_PPC64) > FUNC_MASK(MASK, target_ulong, 64, UINT64_MAX); > #else > FUNC_MASK(MASK, target_ulong, 32, UINT32_MAX); > #endif > FUNC_MASK(mask_u32, uint32_t, 32, UINT32_MAX); > FUNC_MASK(mask_u64, uint64_t, 64, UINT64_MAX); That seems reasonable. --=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 --3Gf/FFewwPeBMqCJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYEqohAAoJEGw4ysog2bOSbsMQAIOBTn2OyGmPmd0FZ4YN+BH0 XNjwCVSdl8cmTCZuIv43ThXn3HmUew3tQdJ75wcG5xaOuGWrGD9dlZcB7HgRX5an Dn5cd+bJZyQXuFNDimIBp/PHlX5f1Kd+M7QUgw+59YT4hJ2Z8VLjDm9eFqgYhnRo gEL/fS9OnxCIBTisnILVMiYCd6zbe2Fo0if24zC9SN1E4VIeyt4jJuK/Qv7yfhzP 74hwL6ScE+s4zgpg/hg9U/5TvAVDfIwGbHs2T9T6vvUk7olcPmD2vBOuUQ3kFcPP ZprbENlTiNRpXqvgomXR2nTwD1xYewlKk08PQSQLJWjlrvdP3rdqDQ0Wg6hmSVT6 Val0cjGYXYvEhucU7JB5WVs/3PGphxw4omnlRGjcM//KlbiGYjj7cGDkPitys/Y5 8hf4ZpJzWSnAOpEjjlmrrGAb54G8mBT4KIkKeftBbCCs7piSUE2+9/+JZn1eUQdt vn8ZD/tBSAvfHfEuJA/ZMH62Q2igLMWjNqcp6qLpum6eiJaN/T7ut3EC+Sw6qNtl MSmpEP0Tq2Dc+iwG5Ub41K78Kl+QNEkJf+bTAYZnJSf0OLB15wjAGFpwDSwGCkFt Hd9MrvkQthYYKOBph/yIvwFw+3pTMtpkElusu0yE1NGQZObagxxzggi5C0ROigSP Y71sK9FTd0X4GDGUhiCc =pABJ -----END PGP SIGNATURE----- --3Gf/FFewwPeBMqCJ--