Commit 34ba2857a067e142301e73cc04a294fd64fc1bc2
1 parent
54c5a2ae
Add various NaN-handling macros
These simplify the implementation of the floating-point Altivec instructions and reduce clutter. Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6511 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
21 additions
and
0 deletions
target-ppc/op_helper.c
... | ... | @@ -1965,6 +1965,23 @@ target_ulong helper_dlmzb (target_ulong high, target_ulong low, uint32_t update_ |
1965 | 1965 | for (index = ARRAY_SIZE(r->element)-1; index >= 0; index--) |
1966 | 1966 | #endif |
1967 | 1967 | |
1968 | +/* If X is a NaN, store the corresponding QNaN into RESULT. Otherwise, | |
1969 | + * execute the following block. */ | |
1970 | +#define DO_HANDLE_NAN(result, x) \ | |
1971 | + if (float32_is_nan(x) || float32_is_signaling_nan(x)) { \ | |
1972 | + CPU_FloatU __f; \ | |
1973 | + __f.f = x; \ | |
1974 | + __f.l = __f.l | (1 << 22); /* Set QNaN bit. */ \ | |
1975 | + result = __f.f; \ | |
1976 | + } else | |
1977 | + | |
1978 | +#define HANDLE_NAN1(result, x) \ | |
1979 | + DO_HANDLE_NAN(result, x) | |
1980 | +#define HANDLE_NAN2(result, x, y) \ | |
1981 | + DO_HANDLE_NAN(result, x) DO_HANDLE_NAN(result, y) | |
1982 | +#define HANDLE_NAN3(result, x, y, z) \ | |
1983 | + DO_HANDLE_NAN(result, x) DO_HANDLE_NAN(result, y) DO_HANDLE_NAN(result, z) | |
1984 | + | |
1968 | 1985 | /* Saturating arithmetic helpers. */ |
1969 | 1986 | #define SATCVT(from, to, from_type, to_type, min, max, use_min, use_max) \ |
1970 | 1987 | static always_inline to_type cvt##from##to (from_type x, int *sat) \ |
... | ... | @@ -2818,6 +2835,10 @@ VUPK(lsh, s32, s16, UPKLO) |
2818 | 2835 | #undef UPKHI |
2819 | 2836 | #undef UPKLO |
2820 | 2837 | |
2838 | +#undef DO_HANDLE_NAN | |
2839 | +#undef HANDLE_NAN1 | |
2840 | +#undef HANDLE_NAN2 | |
2841 | +#undef HANDLE_NAN3 | |
2821 | 2842 | #undef VECTOR_FOR_INORDER_I |
2822 | 2843 | #undef HI_IDX |
2823 | 2844 | #undef LO_IDX | ... | ... |