Richard Henderson <r...@twiddle.net> 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