diff options
Diffstat (limited to 'src/utils/simd_32')
-rw-r--r-- | src/utils/simd_32/simd_altivec.h | 9 | ||||
-rw-r--r-- | src/utils/simd_32/simd_scalar.h | 9 | ||||
-rw-r--r-- | src/utils/simd_32/simd_sse.h | 22 |
3 files changed, 29 insertions, 11 deletions
diff --git a/src/utils/simd_32/simd_altivec.h b/src/utils/simd_32/simd_altivec.h index c3d1a76dc..e1aa62002 100644 --- a/src/utils/simd_32/simd_altivec.h +++ b/src/utils/simd_32/simd_altivec.h @@ -168,6 +168,15 @@ class SIMD_Altivec return vec_nor(reg, reg); } + SIMD_Altivec bswap() const + { + __vector unsigned char perm = vec_lvsl(0, (u32bit*)0); + + perm = vec_xor(perm, vec_splat_u8(3)); + + return SIMD_Altivec(vec_perm(reg, reg, perm)); + } + static void transpose(SIMD_Altivec& B0, SIMD_Altivec& B1, SIMD_Altivec& B2, SIMD_Altivec& B3) { diff --git a/src/utils/simd_32/simd_scalar.h b/src/utils/simd_32/simd_scalar.h index 606923289..5fc20b462 100644 --- a/src/utils/simd_32/simd_scalar.h +++ b/src/utils/simd_32/simd_scalar.h @@ -9,6 +9,7 @@ #define BOTAN_SIMD_SCALAR_H__ #include <botan/loadstor.h> +#include <botan/bswap.h> namespace Botan { @@ -170,6 +171,14 @@ class SIMD_Scalar return SIMD_Scalar(~R0, ~R1, ~R2, ~R3); } + SIMD_Scalar bswap() const + { + return SIMD_Scalar(reverse_bytes(R0), + reverse_bytes(R1), + reverse_bytes(R2), + reverse_bytes(R3)); + } + static void transpose(SIMD_Scalar& B0, SIMD_Scalar& B1, SIMD_Scalar& B2, SIMD_Scalar& B3) { diff --git a/src/utils/simd_32/simd_sse.h b/src/utils/simd_32/simd_sse.h index fcfe6f203..c45d8032f 100644 --- a/src/utils/simd_32/simd_sse.h +++ b/src/utils/simd_32/simd_sse.h @@ -121,6 +121,17 @@ class SIMD_SSE2 return _mm_xor_si128(reg, all_ones); } + SIMD_SSE2 bswap() const + { + __m128i T = reg; + + T = _mm_shufflehi_epi16(T, _MM_SHUFFLE(2, 3, 0, 1)); + T = _mm_shufflelo_epi16(T, _MM_SHUFFLE(2, 3, 0, 1)); + + return _mm_or_si128(_mm_srli_epi16(T, 8), + _mm_slli_epi16(T, 8)); + } + static void transpose(SIMD_SSE2& B0, SIMD_SSE2& B1, SIMD_SSE2& B2, SIMD_SSE2& B3) { @@ -137,17 +148,6 @@ class SIMD_SSE2 private: SIMD_SSE2(__m128i in) { reg = in; } - SIMD_SSE2 bswap() const - { - __m128i T = reg; - - T = _mm_shufflehi_epi16(T, _MM_SHUFFLE(2, 3, 0, 1)); - T = _mm_shufflelo_epi16(T, _MM_SHUFFLE(2, 3, 0, 1)); - - return _mm_or_si128(_mm_srli_epi16(T, 8), - _mm_slli_epi16(T, 8)); - } - __m128i reg; }; |