Botan  2.11.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<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
 
 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)
 
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 zero_registers ()
 

Detailed Description

Definition at line 15 of file simd_avx2.h.

Constructor & Destructor Documentation

◆ SIMD_8x32() [1/5]

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

◆ SIMD_8x32() [2/5]

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

◆ SIMD_8x32() [3/5]

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/5]

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/5]

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  }

Member Function Documentation

◆ andc()

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

Definition at line 191 of file simd_avx2.h.

References SIMD_8x32().

192  {
193  return SIMD_8x32(_mm256_andnot_si256(m_avx2, other.m_avx2));
194  }

◆ BOTAN_FUNC_ISA() [1/3]

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

Definition at line 173 of file simd_avx2.h.

References SIMD_8x32().

174  {
175  return SIMD_8x32(_mm256_slli_epi32(m_avx2, SHIFT));
176  }

◆ BOTAN_FUNC_ISA() [2/3]

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

Definition at line 178 of file simd_avx2.h.

References SIMD_8x32().

179  {
180  return SIMD_8x32(_mm256_srli_epi32(m_avx2, SHIFT));
181  }

◆ BOTAN_FUNC_ISA() [3/3]

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

Definition at line 242 of file simd_avx2.h.

242 { return m_avx2; }

◆ bswap()

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

Definition at line 197 of file simd_avx2.h.

References SIMD_8x32().

Referenced by load_be(), and store_be().

198  {
199  const uint8_t BSWAP_MASK[32] = { 3, 2, 1, 0,
200  7, 6, 5, 4,
201  11, 10, 9, 8,
202  15, 14, 13, 12,
203  19, 18, 17, 16,
204  23, 22, 21, 20,
205  27, 26, 25, 24,
206  31, 30, 29, 28 };
207 
208  const __m256i bswap = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(BSWAP_MASK));
209 
210  const __m256i output = _mm256_shuffle_epi8(m_avx2, bswap);
211 
212  return SIMD_8x32(output);
213  }
SIMD_8x32 bswap() const
Definition: simd_avx2.h:197

◆ 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:197

◆ 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  }

◆ operator &()

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

Definition at line 136 of file simd_avx2.h.

137  {
138  SIMD_8x32 retval(*this);
139  retval &= other;
140  return retval;
141  }

◆ operator &=()

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

Definition at line 168 of file simd_avx2.h.

169  {
170  m_avx2 = _mm256_and_si256(m_avx2, other.m_avx2);
171  }

◆ operator+()

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

Definition at line 108 of file simd_avx2.h.

109  {
110  SIMD_8x32 retval(*this);
111  retval += other;
112  return retval;
113  }

◆ operator+=()

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

Definition at line 144 of file simd_avx2.h.

145  {
146  m_avx2 = _mm256_add_epi32(m_avx2, other.m_avx2);
147  }

◆ operator-()

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

Definition at line 115 of file simd_avx2.h.

116  {
117  SIMD_8x32 retval(*this);
118  retval -= other;
119  return retval;
120  }

◆ operator-=()

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

Definition at line 150 of file simd_avx2.h.

151  {
152  m_avx2 = _mm256_sub_epi32(m_avx2, other.m_avx2);
153  }

◆ 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 122 of file simd_avx2.h.

123  {
124  SIMD_8x32 retval(*this);
125  retval ^= other;
126  return retval;
127  }

◆ operator^=()

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

Definition at line 156 of file simd_avx2.h.

157  {
158  m_avx2 = _mm256_xor_si256(m_avx2, other.m_avx2);
159  }

◆ operator|()

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

Definition at line 129 of file simd_avx2.h.

130  {
131  SIMD_8x32 retval(*this);
132  retval |= other;
133  return retval;
134  }

◆ operator|=()

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

Definition at line 162 of file simd_avx2.h.

163  {
164  m_avx2 = _mm256_or_si256(m_avx2, other.m_avx2);
165  }

◆ operator~()

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

Definition at line 184 of file simd_avx2.h.

References SIMD_8x32().

185  {
186  return SIMD_8x32(_mm256_xor_si256(m_avx2, _mm256_set1_epi32(0xFFFFFFFF)));
187  }

◆ reset_registers()

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

Definition at line 231 of file simd_avx2.h.

232  {
233  _mm256_zeroupper();
234  }

◆ 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  BOTAN_IF_CONSTEXPR(ROT == 8)
81  {
82  const __m256i shuf_rotl_8 = _mm256_set_epi8(14, 13, 12, 15, 10, 9, 8, 11, 6, 5, 4, 7, 2, 1, 0, 3,
83  14, 13, 12, 15, 10, 9, 8, 11, 6, 5, 4, 7, 2, 1, 0, 3);
84 
85  return SIMD_8x32(_mm256_shuffle_epi8(m_avx2, shuf_rotl_8));
86  }
87  else BOTAN_IF_CONSTEXPR(ROT == 16)
88  {
89  const __m256i shuf_rotl_16 = _mm256_set_epi8(13, 12, 15, 14, 9, 8, 11, 10, 5, 4, 7, 6, 1, 0, 3, 2,
90  13, 12, 15, 14, 9, 8, 11, 10, 5, 4, 7, 6, 1, 0, 3, 2);
91 
92  return SIMD_8x32(_mm256_shuffle_epi8(m_avx2, shuf_rotl_16));
93  }
94  else
95  {
96  return SIMD_8x32(_mm256_or_si256(_mm256_slli_epi32(m_avx2, static_cast<int>(ROT)),
97  _mm256_srli_epi32(m_avx2, static_cast<int>(32-ROT))));
98  }
99  }
#define BOTAN_IF_CONSTEXPR
Definition: compiler.h:161

◆ rotr()

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

Definition at line 103 of file simd_avx2.h.

References rotl().

104  {
105  return this->rotl<32-ROT>();
106  }
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  }

◆ 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:197

◆ 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()

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

Definition at line 216 of file simd_avx2.h.

218  {
219  const __m256i T0 = _mm256_unpacklo_epi32(B0.m_avx2, B1.m_avx2);
220  const __m256i T1 = _mm256_unpacklo_epi32(B2.m_avx2, B3.m_avx2);
221  const __m256i T2 = _mm256_unpackhi_epi32(B0.m_avx2, B1.m_avx2);
222  const __m256i T3 = _mm256_unpackhi_epi32(B2.m_avx2, B3.m_avx2);
223 
224  B0.m_avx2 = _mm256_unpacklo_epi64(T0, T1);
225  B1.m_avx2 = _mm256_unpackhi_epi64(T0, T1);
226  B2.m_avx2 = _mm256_unpacklo_epi64(T2, T3);
227  B3.m_avx2 = _mm256_unpackhi_epi64(T2, T3);
228  }

◆ zero_registers()

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

Definition at line 237 of file simd_avx2.h.

238  {
239  _mm256_zeroall();
240  }

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