From e71827bc0ed50edb31bee6050bc96b3bd1e0c055 Mon Sep 17 00:00:00 2001 From: Aurelien Jarno Date: Sun, 31 Mar 2013 12:58:30 +0200 Subject: target-i386: add pclmulqdq instruction Reviewed-by: Richard Henderson Reviewed-by: Edgar E. Iglesias Signed-off-by: Aurelien Jarno --- target-i386/ops_sse.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'target-i386/ops_sse.h') diff --git a/target-i386/ops_sse.h b/target-i386/ops_sse.h index a11dba1566..2ee5b8d9dd 100644 --- a/target-i386/ops_sse.h +++ b/target-i386/ops_sse.h @@ -2179,6 +2179,30 @@ target_ulong helper_popcnt(CPUX86State *env, target_ulong n, uint32_t type) return POPCOUNT(n, 5); #endif } + +void glue(helper_pclmulqdq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, + uint32_t ctrl) +{ + uint64_t ah, al, b, resh, resl; + + ah = 0; + al = d->Q((ctrl & 1) != 0); + b = s->Q((ctrl & 16) != 0); + resh = resl = 0; + + while (b) { + if (b & 1) { + resl ^= al; + resh ^= ah; + } + ah = (ah << 1) | (al >> 63); + al <<= 1; + b >>= 1; + } + + d->Q(0) = resl; + d->Q(1) = resh; +} #endif #undef SHIFT -- cgit v1.2.3