aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/digest/argonish/internal/rotations/rotations_ssse3.h
blob: 39c9c5491be75c8edb56253c072bfd1b16229857 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once

#include <emmintrin.h>
#include <tmmintrin.h>

namespace NArgonish {
    static inline void XorValues(__m128i* result, __m128i* val1, __m128i* val2) {
        _mm_storeu_si128(result, _mm_xor_si128(
                                     _mm_loadu_si128(val1),
                                     _mm_loadu_si128(val2)));
    }

    static inline __m128i Rotr32(__m128i x) {
        return _mm_shuffle_epi32(x, _MM_SHUFFLE(2, 3, 0, 1));
    }

    static inline __m128i Rotr24(__m128i x) {
        return _mm_shuffle_epi8(x, _mm_setr_epi8(3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10));
    }

    static inline __m128i Rotr16(__m128i x) {
        return _mm_shuffle_epi8(x, _mm_setr_epi8(2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9));
    }

    static inline __m128i Rotr63(__m128i x) {
        return _mm_xor_si128(_mm_srli_epi64(x, 63), _mm_add_epi64(x, x));
    }
}