Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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_8x32 & | operator= (const SIMD_8x32 &other)=default
SIMD_8x32 & | operator= (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 ROT1, size_t ROT2, size_t ROT3>
SIMD_8x32 | rho () 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)
| 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

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

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

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 }

Botan::SIMD_8x32::SIMD_8x32 | ( | const uint32_t | B[8] | ) |
| inline explicit

Definition at line 32 of file simd_avx2.h.

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

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
| ) |  |
| inline explicit

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 }

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

Definition at line 272 of file simd_avx2.h.

272 : m_avx2(x) {}

## Member Function Documentation

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

Definition at line 203 of file simd_avx2.h.

References SIMD_8x32().

204 {
205 return SIMD_8x32(_mm256_andnot_si256(m_avx2, other.m_avx2));
206 }
Botan::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26
template<int SHIFT>

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

Definition at line 185 of file simd_avx2.h.

References SIMD_8x32().

186 {
187 return SIMD_8x32(_mm256_slli_epi32(m_avx2, SHIFT));
188 }
Botan::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26
template<int SHIFT>

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

Definition at line 190 of file simd_avx2.h.

References SIMD_8x32().

191 {
192 return SIMD_8x32(_mm256_srli_epi32(m_avx2, SHIFT));
193 }
Botan::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26

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

Definition at line 269 of file simd_avx2.h.

269 { return m_avx2; }

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

Definition at line 209 of file simd_avx2.h.

References SIMD_8x32().

Referenced by load_be(), and store_be().

210 {
211 const uint8_t BSWAP_MASK[32] = { 3, 2, 1, 0,
212 7, 6, 5, 4,
213 11, 10, 9, 8,
214 15, 14, 13, 12,
215 19, 18, 17, 16,
216 23, 22, 21, 20,
217 27, 26, 25, 24,
218 31, 30, 29, 28 };
219
220 const __m256i bswap = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(BSWAP_MASK));
221
222 const __m256i output = _mm256_shuffle_epi8(m_avx2, bswap);
223
224 return SIMD_8x32(output);
225 }
Botan::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26
Botan::SIMD_8x32::bswap
SIMD_8x32 bswap() const
Definition: simd_avx2.h:209

static SIMD_8x32 Botan::SIMD_8x32::load_be | ( | const uint8_t * | in | ) |
| inline static

Definition at line 57 of file simd_avx2.h.

References bswap(), and load_le().

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

static SIMD_8x32 Botan::SIMD_8x32::load_le | ( | const uint8_t * | in | ) |
| inline static

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::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26

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

Definition at line 148 of file simd_avx2.h.

149 {
150 SIMD_8x32 retval(*this);
151 retval &= other;
152 return retval;
153 }
Botan::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26

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

Definition at line 180 of file simd_avx2.h.

181 {
182 m_avx2 = _mm256_and_si256(m_avx2, other.m_avx2);
183 }

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

Definition at line 120 of file simd_avx2.h.

121 {
122 SIMD_8x32 retval(*this);
123 retval += other;
124 return retval;
125 }
Botan::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26

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

Definition at line 156 of file simd_avx2.h.

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

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

Definition at line 127 of file simd_avx2.h.

128 {
129 SIMD_8x32 retval(*this);
130 retval -= other;
131 return retval;
132 }
Botan::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26

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

Definition at line 162 of file simd_avx2.h.

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

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

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

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

Definition at line 134 of file simd_avx2.h.

135 {
136 SIMD_8x32 retval(*this);
137 retval ^= other;
138 return retval;
139 }
Botan::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26

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

Definition at line 168 of file simd_avx2.h.

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

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::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26

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

Definition at line 174 of file simd_avx2.h.

175 {
176 m_avx2 = _mm256_or_si256(m_avx2, other.m_avx2);
177 }

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

Definition at line 196 of file simd_avx2.h.

References SIMD_8x32().

197 {
198 return SIMD_8x32(_mm256_xor_si256(m_avx2, _mm256_set1_epi32(0xFFFFFFFF)));
199 }
Botan::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26

static void Botan::SIMD_8x32::reset_registers | ( |  | ) |
| inline static

Definition at line 258 of file simd_avx2.h.

259 {
260 _mm256_zeroupper();
261 }
template<size_t ROT1, size_t ROT2, size_t ROT3>

SIMD_8x32 Botan::SIMD_8x32::rho | ( |  | ) | const
| inline

Definition at line 109 of file simd_avx2.h.

110 {
111 SIMD_8x32 res;
112
113 const SIMD_8x32 rot1 = this->rotr<ROT1>();
114 const SIMD_8x32 rot2 = this->rotr<ROT2>();
115 const SIMD_8x32 rot3 = this->rotr<ROT3>();
116
117 return rot1 ^ rot2 ^ rot3;
118 }
Botan::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26
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 }
BOTAN_IF_CONSTEXPR
#define BOTAN_IF_CONSTEXPR
Definition: compiler.h:179
Botan::SIMD_8x32::SIMD_8x32
SIMD_8x32()
Definition: simd_avx2.h:26
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 }
Botan::SIMD_8x32::rotl
SIMD_8x32 rotl() const
Definition: simd_avx2.h:76

static SIMD_8x32 Botan::SIMD_8x32::splat | ( | uint32_t | B | ) |
| inline static

Definition at line 45 of file simd_avx2.h.

References SIMD_8x32().

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

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 }
Botan::SIMD_8x32::store_le
void store_le(uint8_t out[]) const
Definition: simd_avx2.h:63
Botan::SIMD_8x32::bswap
SIMD_8x32 bswap() const
Definition: simd_avx2.h:209

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 }

static void Botan::SIMD_8x32::transpose | ( | SIMD_8x32 & | B0,
|  | SIMD_8x32 & | B1,
|  | SIMD_8x32 & | B2,
|  | SIMD_8x32 & | B3
| ) |  |
| inline static

Definition at line 228 of file simd_avx2.h.

Referenced by transpose().

230 {
231 const __m256i T0 = _mm256_unpacklo_epi32(B0.m_avx2, B1.m_avx2);
232 const __m256i T1 = _mm256_unpacklo_epi32(B2.m_avx2, B3.m_avx2);
233 const __m256i T2 = _mm256_unpackhi_epi32(B0.m_avx2, B1.m_avx2);
234 const __m256i T3 = _mm256_unpackhi_epi32(B2.m_avx2, B3.m_avx2);
235
236 B0.m_avx2 = _mm256_unpacklo_epi64(T0, T1);
237 B1.m_avx2 = _mm256_unpackhi_epi64(T0, T1);
238 B2.m_avx2 = _mm256_unpacklo_epi64(T2, T3);
239 B3.m_avx2 = _mm256_unpackhi_epi64(T2, T3);
240 }

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
| ) |  |
| inline static

Definition at line 243 of file simd_avx2.h.

References transpose().

247 {
248 transpose(B0, B1, B2, B3);
249 transpose(B4, B5, B6, B7);
250
251 swap_tops(B0, B4);
252 swap_tops(B1, B5);
253 swap_tops(B2, B6);
254 swap_tops(B3, B7);
255 }
Botan::SIMD_8x32::transpose
static void transpose(SIMD_8x32 &B0, SIMD_8x32 &B1, SIMD_8x32 &B2, SIMD_8x32 &B3)
Definition: simd_avx2.h:228

static void Botan::SIMD_8x32::zero_registers | ( |  | ) |
| inline static

Definition at line 264 of file simd_avx2.h.

265 {
266 _mm256_zeroall();
267 }

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

- src/lib/utils/simd/simd_avx2/simd_avx2.h