Revision 819ca121 target-ppc/op_helper.c

b/target-ppc/op_helper.c
2220 2220
#undef VCMP_DO
2221 2221
#undef VCMP
2222 2222

  
2223
#define VCMPFP_DO(suffix, compare, order, record)                       \
2224
    void helper_vcmp##suffix (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \
2225
    {                                                                   \
2226
        uint32_t ones = (uint32_t)-1;                                   \
2227
        uint32_t all = ones;                                            \
2228
        uint32_t none = 0;                                              \
2229
        int i;                                                          \
2230
        for (i = 0; i < ARRAY_SIZE(r->f); i++) {                        \
2231
            uint32_t result;                                            \
2232
            int rel = float32_compare_quiet(a->f[i], b->f[i], &env->vec_status); \
2233
            if (rel == float_relation_unordered) {                      \
2234
                result = 0;                                             \
2235
            } else if (rel compare order) {                             \
2236
                result = ones;                                          \
2237
            } else {                                                    \
2238
                result = 0;                                             \
2239
            }                                                           \
2240
            r->u32[i] = result;                                         \
2241
            all &= result;                                              \
2242
            none |= result;                                             \
2243
        }                                                               \
2244
        if (record) {                                                   \
2245
            env->crf[6] = ((all != 0) << 3) | ((none == 0) << 1);       \
2246
        }                                                               \
2247
    }
2248
#define VCMPFP(suffix, compare, order)           \
2249
    VCMPFP_DO(suffix, compare, order, 0)         \
2250
    VCMPFP_DO(suffix##_dot, compare, order, 1)
2251
VCMPFP(eqfp, ==, float_relation_equal)
2252
VCMPFP(gefp, !=, float_relation_less)
2253
VCMPFP(gtfp, ==, float_relation_greater)
2254
#undef VCMPFP_DO
2255
#undef VCMPFP
2256

  
2257
static always_inline void vcmpbfp_internal (ppc_avr_t *r, ppc_avr_t *a,
2258
                                            ppc_avr_t *b, int record)
2259
{
2260
    int i;
2261
    int all_in = 0;
2262
    for (i = 0; i < ARRAY_SIZE(r->f); i++) {
2263
        int le_rel = float32_compare_quiet(a->f[i], b->f[i], &env->vec_status);
2264
        if (le_rel == float_relation_unordered) {
2265
            r->u32[i] = 0xc0000000;
2266
            /* ALL_IN does not need to be updated here.  */
2267
        } else {
2268
            float32 bneg = float32_chs(b->f[i]);
2269
            int ge_rel = float32_compare_quiet(a->f[i], bneg, &env->vec_status);
2270
            int le = le_rel != float_relation_greater;
2271
            int ge = ge_rel != float_relation_less;
2272
            r->u32[i] = ((!le) << 31) | ((!ge) << 30);
2273
            all_in |= (!le | !ge);
2274
        }
2275
    }
2276
    if (record) {
2277
        env->crf[6] = (all_in == 0) << 1;
2278
    }
2279
}
2280

  
2281
void helper_vcmpbfp (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
2282
{
2283
    vcmpbfp_internal(r, a, b, 0);
2284
}
2285

  
2286
void helper_vcmpbfp_dot (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
2287
{
2288
    vcmpbfp_internal(r, a, b, 1);
2289
}
2290

  
2223 2291
void helper_vmaddfp (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
2224 2292
{
2225 2293
    int i;

Also available in: Unified diff