Botan  2.15.0
Crypto and TLS for C++11
Public Member Functions | Static Public Member Functions | List of all members
Botan::SIMD_8x32 Class Referencefinal

#include <simd_avx2.h>

Public Member Functions

SIMD_8x32 andc (const SIMD_8x32 &other) const
 
template<size_t ROT1, size_t ROT2, size_t ROT3>
SIMD_8x32 BOTAN_FUNC_ISA ("avx2") rho() const
 
template<int SHIFT>
 BOTAN_FUNC_ISA ("avx2") SIMD_8x32 shl() const
 
template<int SHIFT>
 BOTAN_FUNC_ISA ("avx2") SIMD_8x32 shr() const
 
__m256i BOTAN_FUNC_ISA ("avx2") handle() const
 
SIMD_8x32 bswap () const
 
SIMD_8x32 operator & (const SIMD_8x32 &other) const
 
void operator &= (const SIMD_8x32 &other)
 
SIMD_8x32 operator+ (const SIMD_8x32 &other) const
 
void operator+= (const SIMD_8x32 &other)
 
SIMD_8x32 operator- (const SIMD_8x32 &other) const
 
void operator-= (const SIMD_8x32 &other)
 
SIMD_8x32operator= (const SIMD_8x32 &other)=default
 
SIMD_8x32operator= (SIMD_8x32 &&other)=default
 
SIMD_8x32 operator^ (const SIMD_8x32 &other) const
 
void operator^= (const SIMD_8x32 &other)
 
SIMD_8x32 operator| (const SIMD_8x32 &other) const
 
void operator|= (const SIMD_8x32 &other)
 
SIMD_8x32 operator~ () const
 
template<size_t ROT>
SIMD_8x32 rotl () const
 
template<size_t ROT>
SIMD_8x32 rotr () const
 
 SIMD_8x32 (const SIMD_8x32 &other)=default
 
 SIMD_8x32 (SIMD_8x32 &&other)=default
 
BOTAN_FORCE_INLINE SIMD_8x32 ()
 
 SIMD_8x32 (const uint32_t B[8])
 
 SIMD_8x32 (uint32_t B0, uint32_t B1, uint32_t B2, uint32_t B3, uint32_t B4, uint32_t B5, uint32_t B6, uint32_t B7)
 
 SIMD_8x32 (__m256i x)
 
void store_be (uint8_t out[]) const
 
void store_le (uint8_t out[]) const
 

Static Public Member Functions

static SIMD_8x32 load_be (const uint8_t *in)
 
static SIMD_8x32 load_le (const uint8_t *in)
 
static void reset_registers ()
 
static SIMD_8x32 splat (uint32_t B)
 
static void transpose (SIMD_8x32 &B0, SIMD_8x32 &B1, SIMD_8x32 &B2, SIMD_8x32 &B3)
 
static void transpose (SIMD_8x32 &B0, SIMD_8x32 &B1, SIMD_8x32 &B2, SIMD_8x32 &B3, SIMD_8x32 &B4, SIMD_8x32 &B5, SIMD_8x32 &B6, SIMD_8x32 &B7)
 
static void zero_registers ()
 

Detailed Description

Definition at line 15 of file simd_avx2.h.

Constructor & Destructor Documentation

◆ SIMD_8x32() [1/6]

Botan::SIMD_8x32::SIMD_8x32 ( const SIMD_8x32 other)
default

◆ SIMD_8x32() [2/6]

Botan::SIMD_8x32::SIMD_8x32 ( SIMD_8x32 &&  other)
default

◆ SIMD_8x32() [3/6]

BOTAN_FORCE_INLINE Botan::SIMD_8x32::SIMD_8x32 ( )
inline

Definition at line 26 of file simd_avx2.h.

Referenced by andc(), BOTAN_FUNC_ISA(), bswap(), load_le(), operator~(), rotl(), and splat().

27  {
28  m_avx2 = _mm256_setzero_si256();
29  }

◆ SIMD_8x32() [4/6]

Botan::SIMD_8x32::SIMD_8x32 ( const uint32_t  B[8])
inlineexplicit

Definition at line 32 of file simd_avx2.h.

33  {
34  m_avx2 = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(B));
35  }

◆ SIMD_8x32() [5/6]

Botan::SIMD_8x32::SIMD_8x32 ( uint32_t  B0,
uint32_t  B1,
uint32_t  B2,
uint32_t  B3,
uint32_t  B4,
uint32_t  B5,
uint32_t  B6,
uint32_t  B7 
)
inlineexplicit

Definition at line 38 of file simd_avx2.h.

40  {
41  m_avx2 = _mm256_set_epi32(B7, B6, B5, B4, B3, B2, B1, B0);
42  }

◆ SIMD_8x32() [6/6]

Botan::SIMD_8x32::SIMD_8x32 ( __m256i  x)
inline

Definition at line 281 of file simd_avx2.h.

281 : m_avx2(x) {}

Member Function Documentation

◆ andc()

SIMD_8x32 Botan::SIMD_8x32::andc ( const SIMD_8x32 other) const
inline

Definition at line 212 of file simd_avx2.h.

References SIMD_8x32().

213  {
214  return SIMD_8x32(_mm256_andnot_si256(m_avx2, other.m_avx2));
215  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ BOTAN_FUNC_ISA() [1/4]

template<size_t ROT1, size_t ROT2, size_t ROT3>
SIMD_8x32 Botan::SIMD_8x32::BOTAN_FUNC_ISA ( "avx2"  ) const
inline

Definition at line 113 of file simd_avx2.h.

114  {
115  SIMD_8x32 res;
116 
117  const SIMD_8x32 rot1 = this->rotr<ROT1>();
118  const SIMD_8x32 rot2 = this->rotr<ROT2>();
119  const SIMD_8x32 rot3 = this->rotr<ROT3>();
120 
121  return rot1 ^ rot2 ^ rot3;
122  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ BOTAN_FUNC_ISA() [2/4]

template<int SHIFT>
Botan::SIMD_8x32::BOTAN_FUNC_ISA ( "avx2"  ) const
inline

Definition at line 194 of file simd_avx2.h.

References SIMD_8x32().

195  {
196  return SIMD_8x32(_mm256_slli_epi32(m_avx2, SHIFT));
197  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ BOTAN_FUNC_ISA() [3/4]

template<int SHIFT>
Botan::SIMD_8x32::BOTAN_FUNC_ISA ( "avx2"  ) const
inline

Definition at line 199 of file simd_avx2.h.

References SIMD_8x32().

200  {
201  return SIMD_8x32(_mm256_srli_epi32(m_avx2, SHIFT));
202  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ BOTAN_FUNC_ISA() [4/4]

__m256i Botan::SIMD_8x32::BOTAN_FUNC_ISA ( "avx2"  ) const
inline

Definition at line 278 of file simd_avx2.h.

278 { return m_avx2; }

◆ bswap()

SIMD_8x32 Botan::SIMD_8x32::bswap ( ) const
inline

Definition at line 218 of file simd_avx2.h.

References SIMD_8x32().

Referenced by load_be(), and store_be().

219  {
220  const uint8_t BSWAP_MASK[32] = { 3, 2, 1, 0,
221  7, 6, 5, 4,
222  11, 10, 9, 8,
223  15, 14, 13, 12,
224  19, 18, 17, 16,
225  23, 22, 21, 20,
226  27, 26, 25, 24,
227  31, 30, 29, 28 };
228 
229  const __m256i bswap = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(BSWAP_MASK));
230 
231  const __m256i output = _mm256_shuffle_epi8(m_avx2, bswap);
232 
233  return SIMD_8x32(output);
234  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26
SIMD_8x32 bswap() const
Definition: simd_avx2.h:218

◆ load_be()

static SIMD_8x32 Botan::SIMD_8x32::load_be ( const uint8_t *  in)
inlinestatic

Definition at line 57 of file simd_avx2.h.

References bswap(), and load_le().

58  {
59  return load_le(in).bswap();
60  }
static SIMD_8x32 load_le(const uint8_t *in)
Definition: simd_avx2.h:51
SIMD_8x32 bswap() const
Definition: simd_avx2.h:218

◆ load_le()

static SIMD_8x32 Botan::SIMD_8x32::load_le ( const uint8_t *  in)
inlinestatic

Definition at line 51 of file simd_avx2.h.

References SIMD_8x32().

Referenced by load_be().

52  {
53  return SIMD_8x32(_mm256_loadu_si256(reinterpret_cast<const __m256i*>(in)));
54  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ operator &()

SIMD_8x32 Botan::SIMD_8x32::operator& ( const SIMD_8x32 other) const
inline

Definition at line 157 of file simd_avx2.h.

158  {
159  SIMD_8x32 retval(*this);
160  retval &= other;
161  return retval;
162  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ operator &=()

void Botan::SIMD_8x32::operator&= ( const SIMD_8x32 other)
inline

Definition at line 189 of file simd_avx2.h.

190  {
191  m_avx2 = _mm256_and_si256(m_avx2, other.m_avx2);
192  }

◆ operator+()

SIMD_8x32 Botan::SIMD_8x32::operator+ ( const SIMD_8x32 other) const
inline

Definition at line 125 of file simd_avx2.h.

126  {
127  SIMD_8x32 retval(*this);
128  retval += other;
129  return retval;
130  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ operator+=()

void Botan::SIMD_8x32::operator+= ( const SIMD_8x32 other)
inline

Definition at line 165 of file simd_avx2.h.

166  {
167  m_avx2 = _mm256_add_epi32(m_avx2, other.m_avx2);
168  }

◆ operator-()

SIMD_8x32 Botan::SIMD_8x32::operator- ( const SIMD_8x32 other) const
inline

Definition at line 133 of file simd_avx2.h.

134  {
135  SIMD_8x32 retval(*this);
136  retval -= other;
137  return retval;
138  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ operator-=()

void Botan::SIMD_8x32::operator-= ( const SIMD_8x32 other)
inline

Definition at line 171 of file simd_avx2.h.

172  {
173  m_avx2 = _mm256_sub_epi32(m_avx2, other.m_avx2);
174  }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator^()

SIMD_8x32 Botan::SIMD_8x32::operator^ ( const SIMD_8x32 other) const
inline

Definition at line 141 of file simd_avx2.h.

142  {
143  SIMD_8x32 retval(*this);
144  retval ^= other;
145  return retval;
146  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ operator^=()

void Botan::SIMD_8x32::operator^= ( const SIMD_8x32 other)
inline

Definition at line 177 of file simd_avx2.h.

178  {
179  m_avx2 = _mm256_xor_si256(m_avx2, other.m_avx2);
180  }

◆ operator|()

SIMD_8x32 Botan::SIMD_8x32::operator| ( const SIMD_8x32 other) const
inline

Definition at line 149 of file simd_avx2.h.

150  {
151  SIMD_8x32 retval(*this);
152  retval |= other;
153  return retval;
154  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ operator|=()

void Botan::SIMD_8x32::operator|= ( const SIMD_8x32 other)
inline

Definition at line 183 of file simd_avx2.h.

184  {
185  m_avx2 = _mm256_or_si256(m_avx2, other.m_avx2);
186  }

◆ operator~()

SIMD_8x32 Botan::SIMD_8x32::operator~ ( ) const
inline

Definition at line 205 of file simd_avx2.h.

References SIMD_8x32().

206  {
207  return SIMD_8x32(_mm256_xor_si256(m_avx2, _mm256_set1_epi32(0xFFFFFFFF)));
208  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ reset_registers()

static void Botan::SIMD_8x32::reset_registers ( )
inlinestatic

Definition at line 267 of file simd_avx2.h.

268  {
269  _mm256_zeroupper();
270  }

◆ rotl()

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

Definition at line 76 of file simd_avx2.h.

References BOTAN_IF_CONSTEXPR, and SIMD_8x32().

Referenced by rotr().

77  {
78  static_assert(ROT > 0 && ROT < 32, "Invalid rotation constant");
79 
80 #if defined(__AVX512VL__)
81  return SIMD_8x32(_mm256_rol_epi32(m_avx2, ROT));
82 #else
83  BOTAN_IF_CONSTEXPR(ROT == 8)
84  {
85  const __m256i shuf_rotl_8 = _mm256_set_epi8(14, 13, 12, 15, 10, 9, 8, 11, 6, 5, 4, 7, 2, 1, 0, 3,
86  14, 13, 12, 15, 10, 9, 8, 11, 6, 5, 4, 7, 2, 1, 0, 3);
87 
88  return SIMD_8x32(_mm256_shuffle_epi8(m_avx2, shuf_rotl_8));
89  }
90  else BOTAN_IF_CONSTEXPR(ROT == 16)
91  {
92  const __m256i shuf_rotl_16 = _mm256_set_epi8(13, 12, 15, 14, 9, 8, 11, 10, 5, 4, 7, 6, 1, 0, 3, 2,
93  13, 12, 15, 14, 9, 8, 11, 10, 5, 4, 7, 6, 1, 0, 3, 2);
94 
95  return SIMD_8x32(_mm256_shuffle_epi8(m_avx2, shuf_rotl_16));
96  }
97  else
98  {
99  return SIMD_8x32(_mm256_or_si256(_mm256_slli_epi32(m_avx2, static_cast<int>(ROT)),
100  _mm256_srli_epi32(m_avx2, static_cast<int>(32-ROT))));
101  }
102 #endif
103  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26
#define BOTAN_IF_CONSTEXPR
Definition: compiler.h:185

◆ rotr()

template<size_t ROT>
SIMD_8x32 Botan::SIMD_8x32::rotr ( ) const
inline

Definition at line 107 of file simd_avx2.h.

References rotl().

108  {
109  return this->rotl<32-ROT>();
110  }
SIMD_8x32 rotl() const
Definition: simd_avx2.h:76

◆ splat()

static SIMD_8x32 Botan::SIMD_8x32::splat ( uint32_t  B)
inlinestatic

Definition at line 45 of file simd_avx2.h.

References SIMD_8x32().

46  {
47  return SIMD_8x32(_mm256_set1_epi32(B));
48  }
BOTAN_FORCE_INLINE SIMD_8x32()
Definition: simd_avx2.h:26

◆ store_be()

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

Definition at line 69 of file simd_avx2.h.

References bswap(), and store_le().

70  {
71  bswap().store_le(out);
72  }
void store_le(uint8_t out[]) const
Definition: simd_avx2.h:63
SIMD_8x32 bswap() const
Definition: simd_avx2.h:218

◆ store_le()

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

Definition at line 63 of file simd_avx2.h.

Referenced by store_be().

64  {
65  _mm256_storeu_si256(reinterpret_cast<__m256i*>(out), m_avx2);
66  }

◆ transpose() [1/2]

static void Botan::SIMD_8x32::transpose ( SIMD_8x32 B0,
SIMD_8x32 B1,
SIMD_8x32 B2,
SIMD_8x32 B3 
)
inlinestatic

Definition at line 237 of file simd_avx2.h.

Referenced by transpose().

239  {
240  const __m256i T0 = _mm256_unpacklo_epi32(B0.m_avx2, B1.m_avx2);
241  const __m256i T1 = _mm256_unpacklo_epi32(B2.m_avx2, B3.m_avx2);
242  const __m256i T2 = _mm256_unpackhi_epi32(B0.m_avx2, B1.m_avx2);
243  const __m256i T3 = _mm256_unpackhi_epi32(B2.m_avx2, B3.m_avx2);
244 
245  B0.m_avx2 = _mm256_unpacklo_epi64(T0, T1);
246  B1.m_avx2 = _mm256_unpackhi_epi64(T0, T1);
247  B2.m_avx2 = _mm256_unpacklo_epi64(T2, T3);
248  B3.m_avx2 = _mm256_unpackhi_epi64(T2, T3);
249  }

◆ transpose() [2/2]

static void Botan::SIMD_8x32::transpose ( SIMD_8x32 B0,
SIMD_8x32 B1,
SIMD_8x32 B2,
SIMD_8x32 B3,
SIMD_8x32 B4,
SIMD_8x32 B5,
SIMD_8x32 B6,
SIMD_8x32 B7 
)
inlinestatic

Definition at line 252 of file simd_avx2.h.

References transpose().

256  {
257  transpose(B0, B1, B2, B3);
258  transpose(B4, B5, B6, B7);
259 
260  swap_tops(B0, B4);
261  swap_tops(B1, B5);
262  swap_tops(B2, B6);
263  swap_tops(B3, B7);
264  }
static void transpose(SIMD_8x32 &B0, SIMD_8x32 &B1, SIMD_8x32 &B2, SIMD_8x32 &B3)
Definition: simd_avx2.h:237

◆ zero_registers()

static void Botan::SIMD_8x32::zero_registers ( )
inlinestatic

Definition at line 273 of file simd_avx2.h.

274  {
275  _mm256_zeroall();
276  }

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