Botan 3.14.1
Crypto and TLS for C&
Botan::SIMD_2x64 Class Referencefinal

#include <simd_2x64.h>

Public Member Functions

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 andc (const SIMD_2x64 &other) const noexcept
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 bswap () const
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 operator& (const SIMD_2x64 &other) const
void BOTAN_FN_ISA_SIMD_2X64 operator&= (const SIMD_2x64 &other)
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 operator+ (const SIMD_2x64 &other) const
void BOTAN_FN_ISA_SIMD_2X64 operator+= (const SIMD_2x64 &other)
SIMD_2x64 & operator= (const SIMD_2x64 &other)=default
SIMD_2x64 & operator= (SIMD_2x64 &&other)=default
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 operator^ (const SIMD_2x64 &other) const
void BOTAN_FN_ISA_SIMD_2X64 operator^= (const SIMD_2x64 &other)
native_simd_type BOTAN_FN_ISA_SIMD_2X64 raw () const noexcept
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 reverse_all_bytes () const
template<size_t ROT>
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 rotl () const
template<size_t ROT>
requires (ROT > 0 && ROT < 64)
BOTAN_FN_ISA_SIMD_2X64 SIMD_2x64 rotr () const
template<int SHIFT>
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 shl () const noexcept
template<int SHIFT>
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 shr () const noexcept
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 sigma0 () const
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 sigma1 () const
BOTAN_FN_ISA_SIMD_2X64 SIMD_2x64 ()
 SIMD_2x64 (const SIMD_2x64 &other)=default
BOTAN_FN_ISA_SIMD_2X64 SIMD_2x64 (native_simd_type x)
 SIMD_2x64 (SIMD_2x64 &&other)=default
BOTAN_FN_ISA_SIMD_2X64 SIMD_2x64 (uint64_t low, uint64_t high)
void BOTAN_FN_ISA_SIMD_2X64 store_be (std::span< uint8_t, 16 > out) const
void BOTAN_FN_ISA_SIMD_2X64 store_be (uint64_t out[2]) const
void BOTAN_FN_ISA_SIMD_2X64 store_be (uint8_t out[]) const
void BOTAN_FN_ISA_SIMD_2X64 store_le (std::span< uint8_t, 16 > out) const
void BOTAN_FN_ISA_SIMD_2X64 store_le (uint64_t out[2]) const
void BOTAN_FN_ISA_SIMD_2X64 store_le (uint8_t out[]) const
void BOTAN_FN_ISA_SIMD_2X64 store_native (void *out) const
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 swap_lanes () const
 ~SIMD_2x64 ()=default

Static Public Member Functions

static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 alignr8 (const SIMD_2x64 &a, const SIMD_2x64 &b)
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 all_ones ()
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 choose (const SIMD_2x64 &mask, const SIMD_2x64 &a, const SIMD_2x64 &b)
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 interleave_high (const SIMD_2x64 &a, const SIMD_2x64 &b)
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 interleave_low (const SIMD_2x64 &a, const SIMD_2x64 &b)
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 load_be (const void *in)
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 load_be (std::span< const uint8_t, 16 > in)
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 load_le (const void *in)
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 load_le (std::span< const uint8_t, 16 > in)
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 load_native (const void *in)
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 majority (const SIMD_2x64 &x, const SIMD_2x64 &y, const SIMD_2x64 &z)
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 mul2_32 (const SIMD_2x64 &x, const SIMD_2x64 &y)
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 splat (uint64_t v)
static void BOTAN_FN_ISA_SIMD_2X64 twist (SIMD_2x64 &B0, SIMD_2x64 &B1, SIMD_2x64 &C0, SIMD_2x64 &C1, SIMD_2x64 &D0, SIMD_2x64 &D1)
static void BOTAN_FN_ISA_SIMD_2X64 untwist (SIMD_2x64 &B0, SIMD_2x64 &B1, SIMD_2x64 &C0, SIMD_2x64 &C1, SIMD_2x64 &D0, SIMD_2x64 &D1)

Detailed Description

Definition at line 38 of file simd_2x64.h.

Constructor & Destructor Documentation

◆ SIMD_2x64() [1/5]

◆ SIMD_2x64() [2/5]

Botan::SIMD_2x64::SIMD_2x64 ( SIMD_2x64 && other)
default

References SIMD_2x64().

◆ ~SIMD_2x64()

Botan::SIMD_2x64::~SIMD_2x64 ( )
default

◆ SIMD_2x64() [3/5]

BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::SIMD_2x64 ( )
inline

Definition at line 59 of file simd_2x64.h.

59 :
60#if defined(BOTAN_SIMD_USE_SSSE3)
61 m_simd(_mm_setzero_si128())
62#elif defined(BOTAN_SIMD_USE_NEON)
63 m_simd(vdupq_n_u64(0))
64#elif defined(BOTAN_SIMD_USE_SIMD128)
65 m_simd(wasm_u64x2_const_splat(0))
66#elif defined(BOTAN_SIMD_USE_VSX)
67 m_simd(vec_splats(static_cast<unsigned long long>(0)))
68#endif
69 {
70 }

Referenced by alignr8(), all_ones(), andc(), bswap(), choose(), interleave_high(), interleave_low(), load_native(), majority(), mul2_32(), reverse_all_bytes(), rotr(), shl(), shr(), splat(), and swap_lanes().

◆ SIMD_2x64() [4/5]

BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::SIMD_2x64 ( uint64_t low,
uint64_t high )
inline

Definition at line 96 of file simd_2x64.h.

96 :
97#if defined(BOTAN_SIMD_USE_SSSE3)
98 m_simd(_mm_set_epi64x(high, low))
99#elif defined(BOTAN_SIMD_USE_NEON)
100 m_simd(vcombine_u64(vcreate_u64(low), vcreate_u64(high)))
101#elif defined(BOTAN_SIMD_USE_SIMD128)
102 m_simd(wasm_u64x2_make(low, high))
103#elif defined(BOTAN_SIMD_USE_VSX)
104 m_simd(native_simd_type{low, high})
105#endif
106 {
107 }

◆ SIMD_2x64() [5/5]

BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::SIMD_2x64 ( native_simd_type x)
inlineexplicit

Definition at line 507 of file simd_2x64.h.

507: m_simd(x) {}

Member Function Documentation

◆ alignr8()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::alignr8 ( const SIMD_2x64 & a,
const SIMD_2x64 & b )
inlinestatic

Definition at line 401 of file simd_2x64.h.

401 {
402#if defined(BOTAN_SIMD_USE_SSSE3)
403 return SIMD_2x64(_mm_alignr_epi8(a.m_simd, b.m_simd, 8));
404#elif defined(BOTAN_SIMD_USE_NEON)
405 return SIMD_2x64(vextq_u64(b.m_simd, a.m_simd, 1));
406#elif defined(BOTAN_SIMD_USE_SIMD128)
407 return SIMD_2x64(
408 wasm_i8x16_shuffle(b.m_simd, a.m_simd, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23));
409#elif defined(BOTAN_SIMD_USE_VSX)
410 const __vector unsigned char mask = {8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23};
411 return SIMD_2x64(vec_perm(b.m_simd, a.m_simd, mask));
412#endif
413 }
BOTAN_FN_ISA_SIMD_2X64 SIMD_2x64()
Definition simd_2x64.h:59

References SIMD_2x64(), and SIMD_2x64().

Referenced by twist(), and untwist().

◆ all_ones()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::all_ones ( )
inlinestatic

Definition at line 84 of file simd_2x64.h.

84 {
85#if defined(BOTAN_SIMD_USE_SSSE3)
86 return SIMD_2x64(_mm_set1_epi8(-1));
87#elif defined(BOTAN_SIMD_USE_NEON)
88 return SIMD_2x64(vdupq_n_u64(~uint64_t(0)));
89#elif defined(BOTAN_SIMD_USE_SIMD128)
90 return SIMD_2x64(wasm_i8x16_splat(0xFF));
91#elif defined(BOTAN_SIMD_USE_VSX)
92 return SIMD_2x64(vec_splats(~static_cast<unsigned long long>(0)));
93#endif
94 }

References SIMD_2x64(), and SIMD_2x64().

◆ andc()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::andc ( const SIMD_2x64 & other) const
inlinenoexcept

Definition at line 278 of file simd_2x64.h.

278 {
279#if defined(BOTAN_SIMD_USE_SSSE3)
280 return SIMD_2x64(_mm_andnot_si128(m_simd, other.m_simd));
281#elif defined(BOTAN_SIMD_USE_NEON)
282 // NEON vbic is a & ~b
283 return SIMD_2x64(vbicq_u64(other.m_simd, m_simd));
284#elif defined(BOTAN_SIMD_USE_SIMD128)
285 // SIMD128 is a & ~b
286 return SIMD_2x64(wasm_v128_andnot(other.m_simd, m_simd));
287#elif defined(BOTAN_SIMD_USE_VSX)
288 // VSX is a & ~b
289 return SIMD_2x64(vec_andc(other.m_simd, m_simd));
290#endif
291 }

References SIMD_2x64(), and SIMD_2x64().

Referenced by choose().

◆ bswap()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::bswap ( ) const
inline

Definition at line 148 of file simd_2x64.h.

148 {
149#if defined(BOTAN_SIMD_USE_SSSE3)
150 const auto idx = _mm_set_epi8(8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7);
151 return SIMD_2x64(_mm_shuffle_epi8(m_simd, idx));
152#elif defined(BOTAN_SIMD_USE_NEON)
153 return SIMD_2x64(vreinterpretq_u64_u8(vrev64q_u8(vreinterpretq_u8_u64(m_simd))));
154#elif defined(BOTAN_SIMD_USE_SIMD128)
155 return SIMD_2x64(wasm_i8x16_shuffle(m_simd, m_simd, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8));
156#elif defined(BOTAN_SIMD_USE_VSX)
157 return SIMD_2x64(vec_revb(m_simd));
158#endif
159 }

References SIMD_2x64(), and SIMD_2x64().

Referenced by load_be(), load_le(), reverse_all_bytes(), store_be(), and store_le().

◆ choose()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::choose ( const SIMD_2x64 & mask,
const SIMD_2x64 & a,
const SIMD_2x64 & b )
inlinestatic

Definition at line 358 of file simd_2x64.h.

358 {
359#if defined(BOTAN_SIMD_USE_VSX)
360 return SIMD_2x64(vec_sel(b.m_simd, a.m_simd, mask.m_simd));
361#else
362 return (mask & a) ^ mask.andc(b);
363#endif
364 }

References andc(), SIMD_2x64(), and SIMD_2x64().

Referenced by majority().

◆ interleave_high()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::interleave_high ( const SIMD_2x64 & a,
const SIMD_2x64 & b )
inlinestatic

Definition at line 428 of file simd_2x64.h.

428 {
429#if defined(BOTAN_SIMD_USE_SSSE3)
430 return SIMD_2x64(_mm_unpackhi_epi64(a.m_simd, b.m_simd));
431#elif defined(BOTAN_SIMD_USE_NEON)
432 return SIMD_2x64(vzip2q_u64(a.m_simd, b.m_simd));
433#elif defined(BOTAN_SIMD_USE_SIMD128)
434 return SIMD_2x64(wasm_u64x2_extract_lane(a.m_simd, 1), wasm_u64x2_extract_lane(b.m_simd, 1));
435#elif defined(BOTAN_SIMD_USE_VSX)
436 const __vector unsigned char mask = {8, 9, 10, 11, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31};
437 return SIMD_2x64(vec_perm(a.m_simd, b.m_simd, mask));
438#endif
439 }

References SIMD_2x64(), and SIMD_2x64().

◆ interleave_low()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::interleave_low ( const SIMD_2x64 & a,
const SIMD_2x64 & b )
inlinestatic

Definition at line 415 of file simd_2x64.h.

415 {
416#if defined(BOTAN_SIMD_USE_SSSE3)
417 return SIMD_2x64(_mm_unpacklo_epi64(a.m_simd, b.m_simd));
418#elif defined(BOTAN_SIMD_USE_NEON)
419 return SIMD_2x64(vzip1q_u64(a.m_simd, b.m_simd));
420#elif defined(BOTAN_SIMD_USE_SIMD128)
421 return SIMD_2x64(wasm_u64x2_extract_lane(a.m_simd, 0), wasm_u64x2_extract_lane(b.m_simd, 0));
422#elif defined(BOTAN_SIMD_USE_VSX)
423 const __vector unsigned char mask = {0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 23};
424 return SIMD_2x64(vec_perm(a.m_simd, b.m_simd, mask));
425#endif
426 }

References SIMD_2x64(), and SIMD_2x64().

◆ load_be() [1/2]

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::load_be ( const void * in)
inlinestatic

Definition at line 132 of file simd_2x64.h.

132 {
133 if constexpr(std::endian::native == std::endian::big) {
134 return SIMD_2x64::load_native(in);
135 } else {
136 return SIMD_2x64::load_native(in).bswap();
137 }
138 }
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 load_native(const void *in)
Definition simd_2x64.h:112
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 bswap() const
Definition simd_2x64.h:148

References bswap(), load_native(), and SIMD_2x64().

Referenced by load_be().

◆ load_be() [2/2]

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::load_be ( std::span< const uint8_t, 16 > in)
inlinestatic

Definition at line 144 of file simd_2x64.h.

144 {
145 return SIMD_2x64::load_be(in.data());
146 }
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 load_be(const void *in)
Definition simd_2x64.h:132

References load_be(), and SIMD_2x64().

◆ load_le() [1/2]

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::load_le ( const void * in)
inlinestatic

Definition at line 124 of file simd_2x64.h.

124 {
125 if constexpr(std::endian::native == std::endian::little) {
126 return SIMD_2x64::load_native(in);
127 } else {
128 return SIMD_2x64::load_native(in).bswap();
129 }
130 }

References bswap(), load_native(), and SIMD_2x64().

Referenced by load_le().

◆ load_le() [2/2]

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::load_le ( std::span< const uint8_t, 16 > in)
inlinestatic

Definition at line 140 of file simd_2x64.h.

140 {
141 return SIMD_2x64::load_le(in.data());
142 }
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 load_le(const void *in)
Definition simd_2x64.h:124

References load_le(), and SIMD_2x64().

◆ load_native()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::load_native ( const void * in)
inlinestatic

Load two 64-bit words stored in native byte order

Definition at line 112 of file simd_2x64.h.

112 {
113#if defined(BOTAN_SIMD_USE_SSSE3)
114 return SIMD_2x64(_mm_loadu_si128(reinterpret_cast<const __m128i*>(in)));
115#elif defined(BOTAN_SIMD_USE_NEON)
116 return SIMD_2x64(vld1q_u64(static_cast<const uint64_t*>(in)));
117#elif defined(BOTAN_SIMD_USE_SIMD128)
118 return SIMD_2x64(wasm_v128_load(in));
119#elif defined(BOTAN_SIMD_USE_VSX)
120 return SIMD_2x64(reinterpret_cast<native_simd_type>(vec_xl(0, static_cast<const unsigned char*>(in))));
121#endif
122 }

References SIMD_2x64(), and SIMD_2x64().

Referenced by load_be(), and load_le().

◆ majority()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::majority ( const SIMD_2x64 & x,
const SIMD_2x64 & y,
const SIMD_2x64 & z )
inlinestatic

Definition at line 366 of file simd_2x64.h.

366 {
367#if defined(BOTAN_SIMD_USE_VSX) && defined(_ARCH_PWR10)
368 // vec_ternarylogic is a _Generic macro in Clang, which warns in C++
369 return SIMD_2x64(__builtin_vsx_xxeval(x.m_simd, y.m_simd, z.m_simd, 0x17));
370#else
371 return SIMD_2x64::choose(x ^ y, z, y);
372#endif
373 }
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 choose(const SIMD_2x64 &mask, const SIMD_2x64 &a, const SIMD_2x64 &b)
Definition simd_2x64.h:358

References choose(), SIMD_2x64(), and SIMD_2x64().

◆ mul2_32()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::mul2_32 ( const SIMD_2x64 & x,
const SIMD_2x64 & y )
inlinestatic

Definition at line 478 of file simd_2x64.h.

478 {
479#if defined(BOTAN_SIMD_USE_SSSE3)
480 const __m128i m = _mm_mul_epu32(x.m_simd, y.m_simd);
481 return SIMD_2x64(_mm_add_epi64(m, m));
482#elif defined(BOTAN_SIMD_USE_NEON)
483 const uint64x2_t m = vmull_u32(vmovn_u64(x.m_simd), vmovn_u64(y.m_simd));
484 return SIMD_2x64(vaddq_u64(m, m));
485#elif defined(BOTAN_SIMD_USE_SIMD128)
486 const auto m = wasm_u64x2_extmul_low_u32x4(wasm_i32x4_shuffle(x.m_simd, x.m_simd, 0, 2, 0, 2),
487 wasm_i32x4_shuffle(y.m_simd, y.m_simd, 0, 2, 0, 2));
488
489 return SIMD_2x64(wasm_i64x2_add(m, m));
490#elif defined(BOTAN_SIMD_USE_VSX)
491 // Multiply the low 32 bits of each 64-bit lane; which 32-bit elements those are depends on endianness
492 const auto x32 = reinterpret_cast<__vector unsigned int>(x.m_simd);
493 const auto y32 = reinterpret_cast<__vector unsigned int>(y.m_simd);
494 #if defined(__clang__)
495 // Clang only declares the 32-bit vec_mule/vec_mulo if POWER8 is enabled for the whole TU;
496 // in big-endian element numbering the low halves are the odd elements
497 const auto m = __builtin_altivec_vmulouw(x32, y32);
498 #else
499 const auto m = (std::endian::native == std::endian::little) ? vec_mule(x32, y32) : vec_mulo(x32, y32);
500 #endif
501 return SIMD_2x64(vec_add(m, m));
502#endif
503 }

References SIMD_2x64(), and SIMD_2x64().

◆ operator&()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::operator& ( const SIMD_2x64 & other) const
inline

Definition at line 236 of file simd_2x64.h.

236 {
237 SIMD_2x64 retval(*this);
238 retval &= other;
239 return retval;
240 }
SIMD_2x64(const SIMD_2x64 &other)=default

References SIMD_2x64().

◆ operator&=()

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::operator&= ( const SIMD_2x64 & other)
inline

Definition at line 242 of file simd_2x64.h.

242 {
243#if defined(BOTAN_SIMD_USE_SSSE3)
244 m_simd = _mm_and_si128(m_simd, other.m_simd);
245#elif defined(BOTAN_SIMD_USE_NEON)
246 m_simd = vandq_u64(m_simd, other.m_simd);
247#elif defined(BOTAN_SIMD_USE_SIMD128)
248 m_simd = wasm_v128_and(m_simd, other.m_simd);
249#elif defined(BOTAN_SIMD_USE_VSX)
250 m_simd = vec_and(m_simd, other.m_simd);
251#endif
252 }

References SIMD_2x64().

◆ operator+()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::operator+ ( const SIMD_2x64 & other) const
inline

Definition at line 224 of file simd_2x64.h.

224 {
225 SIMD_2x64 retval(*this);
226 retval += other;
227 return retval;
228 }

References SIMD_2x64().

◆ operator+=()

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::operator+= ( const SIMD_2x64 & other)
inline

Definition at line 254 of file simd_2x64.h.

254 {
255#if defined(BOTAN_SIMD_USE_SSSE3)
256 m_simd = _mm_add_epi64(m_simd, other.m_simd);
257#elif defined(BOTAN_SIMD_USE_NEON)
258 m_simd = vaddq_u64(m_simd, other.m_simd);
259#elif defined(BOTAN_SIMD_USE_SIMD128)
260 m_simd = wasm_i64x2_add(m_simd, other.m_simd);
261#elif defined(BOTAN_SIMD_USE_VSX)
262 m_simd = vec_add(m_simd, other.m_simd);
263#endif
264 }

References SIMD_2x64().

◆ operator=() [1/2]

SIMD_2x64 & Botan::SIMD_2x64::operator= ( const SIMD_2x64 & other)
default

References SIMD_2x64().

◆ operator=() [2/2]

SIMD_2x64 & Botan::SIMD_2x64::operator= ( SIMD_2x64 && other)
default

References SIMD_2x64().

◆ operator^()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::operator^ ( const SIMD_2x64 & other) const
inline

Definition at line 230 of file simd_2x64.h.

230 {
231 SIMD_2x64 retval(*this);
232 retval ^= other;
233 return retval;
234 }

References SIMD_2x64().

◆ operator^=()

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::operator^= ( const SIMD_2x64 & other)
inline

Definition at line 266 of file simd_2x64.h.

266 {
267#if defined(BOTAN_SIMD_USE_SSSE3)
268 m_simd = _mm_xor_si128(m_simd, other.m_simd);
269#elif defined(BOTAN_SIMD_USE_NEON)
270 m_simd = veorq_u64(m_simd, other.m_simd);
271#elif defined(BOTAN_SIMD_USE_SIMD128)
272 m_simd = wasm_v128_xor(m_simd, other.m_simd);
273#elif defined(BOTAN_SIMD_USE_VSX)
274 m_simd = vec_xor(m_simd, other.m_simd);
275#endif
276 }

References SIMD_2x64().

◆ raw()

native_simd_type BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::raw ( ) const
inlinenoexcept

Definition at line 505 of file simd_2x64.h.

505{ return m_simd; }

◆ reverse_all_bytes()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::reverse_all_bytes ( ) const
inline

Definition at line 174 of file simd_2x64.h.

174 {
175#if defined(BOTAN_SIMD_USE_SSSE3)
176 const auto idx = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
177 return SIMD_2x64(_mm_shuffle_epi8(m_simd, idx));
178#elif defined(BOTAN_SIMD_USE_NEON) || defined(BOTAN_SIMD_USE_VSX)
179 return this->bswap().swap_lanes();
180#elif defined(BOTAN_SIMD_USE_SIMD128)
181 return SIMD_2x64(wasm_i8x16_shuffle(m_simd, m_simd, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0));
182#endif
183 }
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 swap_lanes() const
Definition simd_2x64.h:161

References bswap(), SIMD_2x64(), SIMD_2x64(), and swap_lanes().

◆ rotl()

template<size_t ROT>
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::rotl ( ) const
inline

Definition at line 340 of file simd_2x64.h.

340 {
341 return this->rotr<64 - ROT>();
342 }
BOTAN_FN_ISA_SIMD_2X64 SIMD_2x64 rotr() const
Definition simd_2x64.h:294

References rotr(), and SIMD_2x64().

◆ rotr()

template<size_t ROT>
requires (ROT > 0 && ROT < 64)
BOTAN_FN_ISA_SIMD_2X64 SIMD_2x64 Botan::SIMD_2x64::rotr ( ) const
inline

Definition at line 294 of file simd_2x64.h.

296 {
297#if defined(BOTAN_SIMD_USE_SSSE3)
298 if constexpr(ROT == 8) {
299 const auto tab = _mm_setr_epi8(1, 2, 3, 4, 5, 6, 7, 0, 9, 10, 11, 12, 13, 14, 15, 8);
300 return SIMD_2x64(_mm_shuffle_epi8(m_simd, tab));
301 } else if constexpr(ROT == 16) {
302 const auto tab = _mm_setr_epi8(2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9);
303 return SIMD_2x64(_mm_shuffle_epi8(m_simd, tab));
304 } else if constexpr(ROT == 24) {
305 const auto tab = _mm_setr_epi8(3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10);
306 return SIMD_2x64(_mm_shuffle_epi8(m_simd, tab));
307 } else if constexpr(ROT == 32) {
308 const auto tab = _mm_setr_epi8(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11);
309 return SIMD_2x64(_mm_shuffle_epi8(m_simd, tab));
310 } else {
311 return SIMD_2x64(_mm_or_si128(_mm_srli_epi64(m_simd, static_cast<int>(ROT)),
312 _mm_slli_epi64(m_simd, static_cast<int>(64 - ROT))));
313 }
314#elif defined(BOTAN_SIMD_USE_NEON)
315 return SIMD_2x64(vsriq_n_u64(vshlq_n_u64(m_simd, 64 - ROT), m_simd, ROT));
316#elif defined(BOTAN_SIMD_USE_SIMD128)
317 if constexpr(ROT == 8) {
318 return SIMD_2x64(wasm_i8x16_shuffle(m_simd, m_simd, 1, 2, 3, 4, 5, 6, 7, 0, 9, 10, 11, 12, 13, 14, 15, 8));
319 } else if constexpr(ROT == 16) {
320 return SIMD_2x64(wasm_i8x16_shuffle(m_simd, m_simd, 2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9));
321 } else if constexpr(ROT == 24) {
322 return SIMD_2x64(wasm_i8x16_shuffle(m_simd, m_simd, 3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10));
323 } else if constexpr(ROT == 32) {
324 return SIMD_2x64(wasm_i8x16_shuffle(m_simd, m_simd, 4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11));
325 } else {
326 return SIMD_2x64(wasm_v128_or(wasm_u64x2_shr(m_simd, ROT), wasm_i64x2_shl(m_simd, 64 - ROT)));
327 }
328#elif defined(BOTAN_SIMD_USE_VSX) && defined(__clang__)
329 // Clang only declares the 64-bit vec_rl if POWER8 is enabled for the whole TU
330 using s64x2 = __vector signed long long;
331 const auto rot = vec_splats(static_cast<unsigned long long>(64 - ROT));
332 const auto r = __builtin_altivec_vrld(reinterpret_cast<s64x2>(m_simd), rot);
333 return SIMD_2x64(reinterpret_cast<native_simd_type>(r));
334#elif defined(BOTAN_SIMD_USE_VSX)
335 return SIMD_2x64(vec_rl(m_simd, vec_splats(static_cast<unsigned long long>(64 - ROT))));
336#endif
337 }

References SIMD_2x64(), and SIMD_2x64().

Referenced by rotl(), sigma0(), and sigma1().

◆ shl()

template<int SHIFT>
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::shl ( ) const
inlinenoexcept

Definition at line 389 of file simd_2x64.h.

389 {
390#if defined(BOTAN_SIMD_USE_SSSE3)
391 return SIMD_2x64(_mm_slli_epi64(m_simd, SHIFT));
392#elif defined(BOTAN_SIMD_USE_NEON)
393 return SIMD_2x64(vshlq_n_u64(m_simd, SHIFT));
394#elif defined(BOTAN_SIMD_USE_SIMD128)
395 return SIMD_2x64(wasm_i64x2_shl(m_simd, SHIFT));
396#elif defined(BOTAN_SIMD_USE_VSX)
397 return SIMD_2x64(vec_sl(m_simd, vec_splats(static_cast<unsigned long long>(SHIFT))));
398#endif
399 }

References SIMD_2x64(), and SIMD_2x64().

◆ shr()

template<int SHIFT>
SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::shr ( ) const
inlinenoexcept

Definition at line 376 of file simd_2x64.h.

376 {
377#if defined(BOTAN_SIMD_USE_SSSE3)
378 return SIMD_2x64(_mm_srli_epi64(m_simd, SHIFT));
379#elif defined(BOTAN_SIMD_USE_NEON)
380 return SIMD_2x64(vshrq_n_u64(m_simd, SHIFT));
381#elif defined(BOTAN_SIMD_USE_SIMD128)
382 return SIMD_2x64(wasm_u64x2_shr(m_simd, SHIFT));
383#elif defined(BOTAN_SIMD_USE_VSX)
384 return SIMD_2x64(vec_sr(m_simd, vec_splats(static_cast<unsigned long long>(SHIFT))));
385#endif
386 }

References SIMD_2x64(), and SIMD_2x64().

◆ sigma0()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::sigma0 ( ) const
inline

Definition at line 344 of file simd_2x64.h.

344 {
345 const SIMD_2x64 r1 = this->rotr<28>();
346 const SIMD_2x64 r2 = this->rotr<34>();
347 const SIMD_2x64 r3 = this->rotr<39>();
348 return r1 ^ r2 ^ r3;
349 }

References rotr(), and SIMD_2x64().

◆ sigma1()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::sigma1 ( ) const
inline

Definition at line 351 of file simd_2x64.h.

351 {
352 const SIMD_2x64 r1 = this->rotr<14>();
353 const SIMD_2x64 r2 = this->rotr<18>();
354 const SIMD_2x64 r3 = this->rotr<41>();
355 return r1 ^ r2 ^ r3;
356 }

References rotr(), and SIMD_2x64().

◆ splat()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::splat ( uint64_t v)
inlinestatic

Definition at line 72 of file simd_2x64.h.

72 {
73#if defined(BOTAN_SIMD_USE_SSSE3)
74 return SIMD_2x64(_mm_set1_epi64x(v));
75#elif defined(BOTAN_SIMD_USE_NEON)
76 return SIMD_2x64(vdupq_n_u64(v));
77#elif defined(BOTAN_SIMD_USE_SIMD128)
78 return SIMD_2x64(wasm_u64x2_splat(v));
79#elif defined(BOTAN_SIMD_USE_VSX)
80 return SIMD_2x64(vec_splats(static_cast<unsigned long long>(v)));
81#endif
82 }

References SIMD_2x64(), and SIMD_2x64().

◆ store_be() [1/3]

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::store_be ( std::span< uint8_t, 16 > out) const
inline

Definition at line 220 of file simd_2x64.h.

220{ this->store_be(out.data()); }
void BOTAN_FN_ISA_SIMD_2X64 store_be(uint64_t out[2]) const
Definition simd_2x64.h:210

References store_be().

Referenced by store_be().

◆ store_be() [2/3]

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::store_be ( uint64_t out[2]) const
inline

Definition at line 210 of file simd_2x64.h.

210{ this->store_be(reinterpret_cast<uint8_t*>(out)); }

References store_be().

Referenced by store_be().

◆ store_be() [3/3]

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::store_be ( uint8_t out[]) const
inline

Definition at line 212 of file simd_2x64.h.

212 {
213 if constexpr(std::endian::native == std::endian::big) {
214 this->store_native(out);
215 } else {
216 this->bswap().store_native(out);
217 }
218 }
void BOTAN_FN_ISA_SIMD_2X64 store_native(void *out) const
Definition simd_2x64.h:188

References bswap(), and store_native().

◆ store_le() [1/3]

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::store_le ( std::span< uint8_t, 16 > out) const
inline

Definition at line 222 of file simd_2x64.h.

222{ this->store_le(out.data()); }
void BOTAN_FN_ISA_SIMD_2X64 store_le(uint64_t out[2]) const
Definition simd_2x64.h:200

References store_le().

Referenced by store_le().

◆ store_le() [2/3]

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::store_le ( uint64_t out[2]) const
inline

Definition at line 200 of file simd_2x64.h.

200{ this->store_le(reinterpret_cast<uint8_t*>(out)); }

References store_le().

Referenced by store_le().

◆ store_le() [3/3]

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::store_le ( uint8_t out[]) const
inline

Definition at line 202 of file simd_2x64.h.

202 {
203 if constexpr(std::endian::native == std::endian::little) {
204 this->store_native(out);
205 } else {
206 this->bswap().store_native(out);
207 }
208 }

References bswap(), and store_native().

◆ store_native()

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::store_native ( void * out) const
inline

Store two 64-bit words in native byte order

Definition at line 188 of file simd_2x64.h.

188 {
189#if defined(BOTAN_SIMD_USE_SSSE3)
190 _mm_storeu_si128(static_cast<__m128i*>(out), m_simd);
191#elif defined(BOTAN_SIMD_USE_NEON)
192 vst1q_u64(static_cast<uint64_t*>(out), m_simd);
193#elif defined(BOTAN_SIMD_USE_SIMD128)
194 wasm_v128_store(out, m_simd);
195#elif defined(BOTAN_SIMD_USE_VSX)
196 vec_xst(reinterpret_cast<__vector unsigned char>(m_simd), 0, static_cast<unsigned char*>(out));
197#endif
198 }

Referenced by store_be(), and store_le().

◆ swap_lanes()

SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::swap_lanes ( ) const
inline

Definition at line 161 of file simd_2x64.h.

161 {
162#if defined(BOTAN_SIMD_USE_SSSE3)
163 return SIMD_2x64(_mm_shuffle_epi32(m_simd, _MM_SHUFFLE(1, 0, 3, 2)));
164#elif defined(BOTAN_SIMD_USE_NEON)
165 return SIMD_2x64(vextq_u64(m_simd, m_simd, 1));
166#elif defined(BOTAN_SIMD_USE_SIMD128)
167 return SIMD_2x64(wasm_i64x2_shuffle(m_simd, m_simd, 1, 0));
168#elif defined(BOTAN_SIMD_USE_VSX)
169 const __vector unsigned char mask = {8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7};
170 return SIMD_2x64(vec_perm(m_simd, m_simd, mask));
171#endif
172 }

References SIMD_2x64(), and SIMD_2x64().

Referenced by reverse_all_bytes().

◆ twist()

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::twist ( SIMD_2x64 & B0,
SIMD_2x64 & B1,
SIMD_2x64 & C0,
SIMD_2x64 & C1,
SIMD_2x64 & D0,
SIMD_2x64 & D1 )
inlinestatic

Definition at line 443 of file simd_2x64.h.

443 {
444 auto T0 = SIMD_2x64::alignr8(B1, B0);
445 auto T1 = SIMD_2x64::alignr8(B0, B1);
446 B0 = T0;
447 B1 = T1;
448
449 T0 = C0;
450 C0 = C1;
451 C1 = T0;
452
453 T0 = SIMD_2x64::alignr8(D0, D1);
454 T1 = SIMD_2x64::alignr8(D1, D0);
455 D0 = T0;
456 D1 = T1;
457 }
static SIMD_2x64 BOTAN_FN_ISA_SIMD_2X64 alignr8(const SIMD_2x64 &a, const SIMD_2x64 &b)
Definition simd_2x64.h:401

References alignr8(), and SIMD_2x64().

◆ untwist()

void BOTAN_FN_ISA_SIMD_2X64 Botan::SIMD_2x64::untwist ( SIMD_2x64 & B0,
SIMD_2x64 & B1,
SIMD_2x64 & C0,
SIMD_2x64 & C1,
SIMD_2x64 & D0,
SIMD_2x64 & D1 )
inlinestatic

Definition at line 461 of file simd_2x64.h.

461 {
462 auto T0 = SIMD_2x64::alignr8(B0, B1);
463 auto T1 = SIMD_2x64::alignr8(B1, B0);
464 B0 = T0;
465 B1 = T1;
466
467 T0 = C0;
468 C0 = C1;
469 C1 = T0;
470
471 T0 = SIMD_2x64::alignr8(D1, D0);
472 T1 = SIMD_2x64::alignr8(D0, D1);
473 D0 = T0;
474 D1 = T1;
475 }

References alignr8(), and SIMD_2x64().


The documentation for this class was generated from the following file: