Skip to content

Commit

Permalink
target/ppc: Use clmul_8* routines
Browse files Browse the repository at this point in the history
Use generic routines for 8-bit carry-less multiply.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Sep 15, 2023
1 parent 2d8bc68 commit cec4090
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion target/ppc/int_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "exec/helper-proto.h"
#include "crypto/aes.h"
#include "crypto/aes-round.h"
#include "crypto/clmul.h"
#include "fpu/softfloat.h"
#include "qapi/error.h"
#include "qemu/guest-random.h"
Expand Down Expand Up @@ -1424,6 +1425,18 @@ void helper_vbpermq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
#undef VBPERMQ_INDEX
#undef VBPERMQ_DW

/*
* There is no carry across the two doublewords, so their order does
* not matter. Nor is there partial overlap between registers.
*/
void helper_vpmsumb(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
{
for (int i = 0; i < 2; ++i) {
uint64_t aa = a->u64[i], bb = b->u64[i];
r->u64[i] = clmul_8x4_even(aa, bb) ^ clmul_8x4_odd(aa, bb);
}
}

#define PMSUM(name, srcfld, trgfld, trgtyp) \
void helper_##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \
{ \
Expand All @@ -1444,7 +1457,6 @@ void helper_##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \
} \
}

PMSUM(vpmsumb, u8, u16, uint16_t)
PMSUM(vpmsumh, u16, u32, uint32_t)
PMSUM(vpmsumw, u32, u64, uint64_t)

Expand Down

0 comments on commit cec4090

Please sign in to comment.