Add missing Intel SSE2 intrinsics needed for Argon2

This commit is contained in:
Paul Kulchenko 2021-09-17 23:25:43 -07:00 committed by Justine Tunney
parent 42aafc847e
commit 2e4b40042a
4 changed files with 50 additions and 2 deletions

View file

@ -218,6 +218,54 @@ struct thatispacked mayalias __usi128ma {
#define _mm_cmpunord_sd(M128D_0, M128D_1) \
__builtin_ia32_cmpunordsd((__v2df)(M128D_0), (__v2df)(M128D_1))
#define _mm_mul_epu32(A, B) \
({ \
__m128i R = A; \
asm("pmuludq %1, %0" \
: "+x"(R) : "xm"(B)); \
R; \
})
#define _mm_add_epi64(A, B) \
({ \
__m128i R = A; \
asm("paddq %1, %0" \
: "+x"(R) : "xm"(B)); \
R; \
})
#define _mm_srli_epi64(A, B) \
({ \
__m128i R = A; \
asm("psrlq %1, %0" \
: "+x"(R) : "xm"(B)); \
R; \
})
#define _mm_slli_epi64(A, B) \
({ \
__m128i R = A; \
asm("psllq %1, %0" \
: "+x"(R) : "xm"(B)); \
R; \
})
#define _mm_unpacklo_epi64(A, B) \
({ \
__m128i R = A; \
asm("punpcklqdq %1, %0" \
: "+x"(R) : "xm"(B)); \
R; \
})
#define _mm_unpackhi_epi64(A, B) \
({ \
__m128i R = A; \
asm("punpckhqdq %1, %0" \
: "+x"(R) : "xm"(B)); \
R; \
})
/*───────────────────────────────────────────────────────────────────────────│─╗
cosmopolitan § it's a trap! » sse2 » miscellaneous
*/

View file

@ -19,6 +19,7 @@ THIRD_PARTY_ARGON2_A_DIRECTDEPS = \
LIBC_CALLS \
LIBC_FMT \
LIBC_INTRIN \
LIBC_BITS \
LIBC_NEXGEN32E \
LIBC_MEM \
LIBC_SYSV \

View file

@ -151,6 +151,4 @@ static BLAKE2_INLINE uint64_t rotr64(const uint64_t w, const unsigned c) {
return (w >> c) | (w << (64 - c));
}
void clear_internal_memory(void *v, size_t n);
#endif

View file

@ -21,6 +21,7 @@
#include "third_party/argon2/blake2.h"
#include "third_party/argon2/blake2-impl.h"
#include "third_party/argon2/core.h" // for clear_internal_memory
static const uint64_t blake2b_IV[8] = {
UINT64_C(0x6a09e667f3bcc908), UINT64_C(0xbb67ae8584caa73b),