qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 1/2] target-ppc: add vextu[bhw]lx instruction


From: Nikunj A Dadhania
Subject: Re: [Qemu-devel] [PATCH v2 1/2] target-ppc: add vextu[bhw]lx instructions
Date: Fri, 25 Nov 2016 12:43:37 +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 11/24/2016 12:32 PM, Nikunj A Dadhania wrote:
>> +#if defined(HOST_WORDS_BIGENDIAN)
>> +# if defined(CONFIG_INT128)
>> +# define VEXTULX_DO(name, size)                                     \
>> +    target_ulong glue(helper_, name)(target_ulong a, ppc_avr_t *b)  \
>> +    {                                                               \
>> +        int index = (a & 0xf) * 8;                                  \
>> +        return int128_rshift(b->u128, index) &                      \
>> +            MAKE_64BIT_MASK(0, size);                               \
>> +    }
>> +# else
>> +# define VEXTULX_DO(name, size)                                     \
>> +    target_ulong glue(helper_, name)(target_ulong a, ppc_avr_t *b)  \
>> +    {                                                               \
>> +        int index = (a & 0xf) * 8;                                  \
>> +        Int128 value = int128_make128(b->u64[LO_IDX],               \
>> +                                      b->u64[HI_IDX]);              \
>> +        return int128_rshift(value, index) &                        \
>> +            MAKE_64BIT_MASK(0, size);                               \
>> +    }
>> +# endif
>
> Why are these duplicated?
>
> Clearly the missed trick is that you should *never* check CONFIG_INT128 and 
> always rely on Int128.

Because of this:

/* Altivec registers (128 bits) */
union ppc_avr_t {

[ SNIP ]

    uint64_t u64[2];
    int64_t s64[2];
#ifdef CONFIG_INT128
    __uint128_t u128;
#endif
};

So I composed a Int128 using make128 with lo and hi to get a
Int128, and then call int128_rshift. 

I think I can use "Int128 u128" in that union and that should do the
trick ! I will try that out.

Regards
Nikunj




reply via email to

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