[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/14] Add various NaN-handling macros
From: |
Nathan Froyd |
Subject: |
[Qemu-devel] [PATCH 02/14] Add various NaN-handling macros |
Date: |
Thu, 22 Jan 2009 12:44:02 -0800 |
These simplify the implementation of the floating-point Altivec
instructions and reduce clutter.
Signed-off-by: Nathan Froyd <address@hidden>
---
target-ppc/op_helper.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index d531dd8..9820040 100644
--- a/target-ppc/op_helper.c
+++ b/target-ppc/op_helper.c
@@ -1965,6 +1965,23 @@ target_ulong helper_dlmzb (target_ulong high,
target_ulong low, uint32_t update_
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) \
@@ -2808,6 +2825,10 @@ VUPK(lsh, s32, s16, UPKLO)
#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
--
1.6.0.5
- [Qemu-devel] [PATCH 00/14] target-ppc: add floating-point AltiVec instructions, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 05/14] Make mtvscr use a helper, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 14/14] Add vrsqrtefp instruction, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 09/14] Add vcmp{eq,ge,gt,b}fp{,.} instructions, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 13/14] Add vrefp instruction, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 01/14] Add f field to ppc_avr_t, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 10/14] Add vrfi{m,n,p,z} instructions, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 12/14] Add vct{u,s}xs instructions, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 02/14] Add various NaN-handling macros,
Nathan Froyd <=
- [Qemu-devel] [PATCH 04/14] Add calls to initialize VSCR on appropriate machines, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 11/14] Add vcf{u,s}x instructions, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 03/14] Rename spe_status to vec_status, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 08/14] Add vmaddfp and vnmsubfp instructions, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 07/14] Add v{add,sub}fp instructions, Nathan Froyd, 2009/01/22
- [Qemu-devel] [PATCH 06/14] Add v{max,min}fp instructions, Nathan Froyd, 2009/01/22