On 02/12/2014 01:23 PM, Tom Musta wrote: > +#define PMSUM(name, srcfld, trgfld, trgtyp) \ > +void helper_##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ > +{ \ > + int i, j; \ > + trgtyp prod[sizeof(ppc_avr_t)/sizeof(a->srcfld[0])]; \ > + \ > + VECTOR_FOR_INORDER_I(i, srcfld) { \ > + prod[i] = 0; \ > + for (j = 0; j < sizeof(a->srcfld[0]) * 8; j++) { \ > + if (a->srcfld[i] & (1ull<<j)) { \ > + prod[i] ^= ((trgtyp)b->srcfld[i] << j); \ > + } \ > + } \ > + } \ > + \ > + VECTOR_FOR_INORDER_I(i, trgfld) { \ > + r->trgfld[i] = prod[2*i] ^ prod[2*i+1]; \ > + } \ > +} > + > +PMSUM(vpmsumb, u8, u16, uint16_t) > +PMSUM(vpmsumh, u16, u32, uint32_t) > +PMSUM(vpmsumw, u32, u64, uint64_t)
Given that we've now got three targets actually implementing poly multiply (four if anyone ever gets around to implementing the sparc64-2011 insn), perhaps it's time to implement this generically? Perhaps declared in host-utils.c and implemented in util/? Cleanup for another patchset, of course. r~