From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUdhk-0005KR-OW for qemu-devel@nongnu.org; Wed, 04 Feb 2009 04:05:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUdhj-0005JV-T1 for qemu-devel@nongnu.org; Wed, 04 Feb 2009 04:05:56 -0500 Received: from [199.232.76.173] (port=46487 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUdhj-0005J6-LV for qemu-devel@nongnu.org; Wed, 04 Feb 2009 04:05:55 -0500 Received: from savannah.gnu.org ([199.232.41.3]:34150 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LUdhj-0006eF-8I for qemu-devel@nongnu.org; Wed, 04 Feb 2009 04:05:55 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LUdhi-0006PW-PJ for qemu-devel@nongnu.org; Wed, 04 Feb 2009 09:05:54 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LUdhi-0006PS-G0 for qemu-devel@nongnu.org; Wed, 04 Feb 2009 09:05:54 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Wed, 04 Feb 2009 09:05:54 +0000 Subject: [Qemu-devel] [6511] Add various NaN-handling macros Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6511 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6511 Author: aurel32 Date: 2009-02-04 09:05:53 +0000 (Wed, 04 Feb 2009) Log Message: ----------- Add various NaN-handling macros These simplify the implementation of the floating-point Altivec instructions and reduce clutter. Signed-off-by: Nathan Froyd Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/target-ppc/op_helper.c Modified: trunk/target-ppc/op_helper.c =================================================================== --- trunk/target-ppc/op_helper.c 2009-02-03 23:06:34 UTC (rev 6510) +++ trunk/target-ppc/op_helper.c 2009-02-04 09:05:53 UTC (rev 6511) @@ -1965,6 +1965,23 @@ for (index = ARRAY_SIZE(r->element)-1; index >= 0; index--) #endif +/* If X is a NaN, store the corresponding QNaN into RESULT. Otherwise, + * execute the following block. */ +#define DO_HANDLE_NAN(result, x) \ + if (float32_is_nan(x) || float32_is_signaling_nan(x)) { \ + CPU_FloatU __f; \ + __f.f = x; \ + __f.l = __f.l | (1 << 22); /* Set QNaN bit. */ \ + result = __f.f; \ + } else + +#define HANDLE_NAN1(result, x) \ + DO_HANDLE_NAN(result, x) +#define HANDLE_NAN2(result, x, y) \ + DO_HANDLE_NAN(result, x) DO_HANDLE_NAN(result, y) +#define HANDLE_NAN3(result, x, y, z) \ + DO_HANDLE_NAN(result, x) DO_HANDLE_NAN(result, y) DO_HANDLE_NAN(result, z) + /* Saturating arithmetic helpers. */ #define SATCVT(from, to, from_type, to_type, min, max, use_min, use_max) \ static always_inline to_type cvt##from##to (from_type x, int *sat) \ @@ -2818,6 +2835,10 @@ #undef UPKHI #undef UPKLO +#undef DO_HANDLE_NAN +#undef HANDLE_NAN1 +#undef HANDLE_NAN2 +#undef HANDLE_NAN3 #undef VECTOR_FOR_INORDER_I #undef HI_IDX #undef LO_IDX