qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v1 5/8] target-ppc: add vcmpnez[b, h, w][.] inst


From: Nikunj A Dadhania
Subject: Re: [Qemu-devel] [PATCH v1 5/8] target-ppc: add vcmpnez[b, h, w][.] instructions
Date: Thu, 28 Jul 2016 23:01:17 +0530
User-agent: Notmuch/0.21 (https://notmuchmail.org) Emacs/25.0.94.1 (x86_64-redhat-linux-gnu)

Richard Henderson <address@hidden> writes:

> On 07/28/2016 12:19 PM, Nikunj A Dadhania wrote:
>> +#define VCMPNEZ_DO(suffix, element, record)                         \
>> +void helper_vcmpnez##suffix(CPUPPCState *env, ppc_avr_t *r,         \
>> +                            ppc_avr_t *a, ppc_avr_t *b)                 \
>> +{                                                                       \
>> +    uint64_t ones = (uint64_t)-1;                                       \
>> +    uint64_t all = ones;                                                \
>> +    uint64_t none = 0;                                                  \
>> +    int i;                                                              \
>> +                                                                        \
>> +    for (i = 0; i < ARRAY_SIZE(r->element); i++) {                      \
>> +        uint64_t result = ((a->element[i] == 0)                         \
>> +                           || (b->element[i] == 0)                      \
>> +                           || (a->element[i] != b->element[i]) ?        \
>> +                           ones : 0x0);                                 \
>
> Don't you have the proper type to use, as opposed to widening everything to 
> uint64_t?

And then truncating them as well. One option could be passing the
element type in the macro.

#define VCMPNEZ_DO(suffix, element, etype, record)                  \
void helper_vcmpnez##suffix(CPUPPCState *env, ppc_avr_t *r,         \
                            ppc_avr_t *a, ppc_avr_t *b)                 \
{                                                                       \
    etype ones = (etype)-1;                                             \
    etype all = ones;                                                   \
    etype none = 0;                                                     \
    int i;                                                              \
                                                                        \
    for (i = 0; i < ARRAY_SIZE(r->element); i++) {                      \
        etype result = ((a->element[i] == 0)                            \
                           || (b->element[i] == 0)                      \
                           || (a->element[i] != b->element[i]) ?        \
                           ones : 0x0);                                 \
        r->element[i] = result;                                         \
        all &= result;                                                  \
        none |= result;                                                 \
    }                                                                   \
    if (record) {                                                       \
        env->crf[6] = ((all != 0) << 3) | ((none == 0) << 1);           \
    }                                                                   \
}

/* VCMPNEZ - Vector compare not equal to zero
 *   suffix  - instruction mnemonic suffix (b: byte, h: halfword, w: word)
 *   element - element type to access from vector
 */
#define VCMPNEZ(suffix, element, etype)         \
    VCMPNEZ_DO(suffix, element, etype, 0)       \
    VCMPNEZ_DO(suffix##_dot, element, etype, 1)
VCMPNEZ(b, u8, uint8_t)
VCMPNEZ(h, u16, uint16_t)
VCMPNEZ(w, u32, uint32_t)
#undef VCMPNEZ_DO
#undef VCMPNEZ


> I would guess element##_t would do the job.

That would be u32_t, we would need uint32_t

Regards
Nikunj




reply via email to

[Prev in Thread] Current Thread [Next in Thread]