3#include "native/x86/instruction_storage.h"
5#include "native/isa_import.h"
6#include "native/x86/vaes.h"
12#if NATIVE_HOST_X86 || defined(NATIVE_DOXYGEN)
25 template<isa<x86> Arch>
requires(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx))
26 [[nodiscard]] hint_inline hint_const hint_target(
"avx,aes")
28 simd<
std::uint8_t, 16, Arch> state,
simd<
std::uint8_t, 16, Arch> key) noexcept {
30 return detail::x86_vaes_constant::round<false, false>(state, key);
32 return detail::x86_instruction_result<simd<std::uint8_t, 16, Arch>>(
33 detail::x86_vaes::vaesenc<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
38 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
39 requires { sizeof(simd<std::uint8_t, 16, Arch>); } && !Arch.has(polyfill))
42 return detail::x86_vaes_constant::round<false, false>(state, key);
46 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
47 requires { sizeof(simd<std::uint8_t, 16, Arch>); } && Arch.has(polyfill))
50 return detail::x86_vaes_constant::round<false, false>(state, key);
54 template<isa<x86> Arch>
requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx))
55 [[nodiscard]] hint_inline hint_const hint_target(
"avx,vaes")
59 return detail::x86_vaes_constant::round<false, false>(state, key);
61 return detail::x86_instruction_result<simd<std::uint8_t, 32, Arch>>(
62 detail::x86_vaes::vaesenc<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
67 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
68 requires { sizeof(simd<std::uint8_t, 32, Arch>); } && !Arch.has(polyfill))
71 return detail::x86_vaes_constant::round<false, false>(state, key);
75 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
76 requires { sizeof(simd<std::uint8_t, 32, Arch>); } && Arch.has(polyfill))
79 return detail::x86_vaes_constant::round<false, false>(state, key);
83 template<isa<x86> Arch>
requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f))
84 [[nodiscard]] hint_inline hint_const hint_target(
"avx512f,vaes")
88 return detail::x86_vaes_constant::round<false, false>(state, key);
90 return detail::x86_instruction_result<simd<std::uint8_t, 64, Arch>>(
91 detail::x86_vaes::vaesenc<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
96 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
97 requires { sizeof(simd<std::uint8_t, 64, Arch>); } && !Arch.has(polyfill))
100 return detail::x86_vaes_constant::round<false, false>(state, key);
104 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
105 requires { sizeof(simd<std::uint8_t, 64, Arch>); } && Arch.has(polyfill))
108 return detail::x86_vaes_constant::round<false, false>(state, key);
112 template<isa<x86> Arch,
class... Args>
116 template<isa<x86> Arch>
requires(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx))
117 [[nodiscard]] hint_inline hint_const hint_target(
"avx,aes")
119 simd<
std::uint8_t, 16, Arch> state,
simd<
std::uint8_t, 16, Arch> key) noexcept {
121 return detail::x86_vaes_constant::round<false, true>(state, key);
123 return detail::x86_instruction_result<simd<std::uint8_t, 16, Arch>>(
124 detail::x86_vaes::vaesenclast<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
129 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
130 requires { sizeof(simd<std::uint8_t, 16, Arch>); } && !Arch.has(polyfill))
133 return detail::x86_vaes_constant::round<false, true>(state, key);
137 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
138 requires { sizeof(simd<std::uint8_t, 16, Arch>); } && Arch.has(polyfill))
141 return detail::x86_vaes_constant::round<false, true>(state, key);
145 template<isa<x86> Arch>
requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx))
146 [[nodiscard]] hint_inline hint_const hint_target(
"avx,vaes")
150 return detail::x86_vaes_constant::round<false, true>(state, key);
152 return detail::x86_instruction_result<simd<std::uint8_t, 32, Arch>>(
153 detail::x86_vaes::vaesenclast<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
158 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
159 requires { sizeof(simd<std::uint8_t, 32, Arch>); } && !Arch.has(polyfill))
162 return detail::x86_vaes_constant::round<false, true>(state, key);
166 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
167 requires { sizeof(simd<std::uint8_t, 32, Arch>); } && Arch.has(polyfill))
170 return detail::x86_vaes_constant::round<false, true>(state, key);
174 template<isa<x86> Arch>
requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f))
175 [[nodiscard]] hint_inline hint_const hint_target(
"avx512f,vaes")
179 return detail::x86_vaes_constant::round<false, true>(state, key);
181 return detail::x86_instruction_result<simd<std::uint8_t, 64, Arch>>(
182 detail::x86_vaes::vaesenclast<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
187 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
188 requires { sizeof(simd<std::uint8_t, 64, Arch>); } && !Arch.has(polyfill))
191 return detail::x86_vaes_constant::round<false, true>(state, key);
195 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
196 requires { sizeof(simd<std::uint8_t, 64, Arch>); } && Arch.has(polyfill))
199 return detail::x86_vaes_constant::round<false, true>(state, key);
203 template<isa<x86> Arch,
class... Args>
207 template<isa<x86> Arch>
requires(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx))
208 [[nodiscard]] hint_inline hint_const hint_target(
"avx,aes")
210 simd<
std::uint8_t, 16, Arch> state,
simd<
std::uint8_t, 16, Arch> key) noexcept {
212 return detail::x86_vaes_constant::round<true, false>(state, key);
214 return detail::x86_instruction_result<simd<std::uint8_t, 16, Arch>>(
215 detail::x86_vaes::vaesdec<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
220 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
221 requires { sizeof(simd<std::uint8_t, 16, Arch>); } && !Arch.has(polyfill))
224 return detail::x86_vaes_constant::round<true, false>(state, key);
228 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
229 requires { sizeof(simd<std::uint8_t, 16, Arch>); } && Arch.has(polyfill))
232 return detail::x86_vaes_constant::round<true, false>(state, key);
236 template<isa<x86> Arch>
requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx))
237 [[nodiscard]] hint_inline hint_const hint_target(
"avx,vaes")
241 return detail::x86_vaes_constant::round<true, false>(state, key);
243 return detail::x86_instruction_result<simd<std::uint8_t, 32, Arch>>(
244 detail::x86_vaes::vaesdec<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
249 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
250 requires { sizeof(simd<std::uint8_t, 32, Arch>); } && !Arch.has(polyfill))
253 return detail::x86_vaes_constant::round<true, false>(state, key);
257 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
258 requires { sizeof(simd<std::uint8_t, 32, Arch>); } && Arch.has(polyfill))
261 return detail::x86_vaes_constant::round<true, false>(state, key);
265 template<isa<x86> Arch>
requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f))
266 [[nodiscard]] hint_inline hint_const hint_target(
"avx512f,vaes")
270 return detail::x86_vaes_constant::round<true, false>(state, key);
272 return detail::x86_instruction_result<simd<std::uint8_t, 64, Arch>>(
273 detail::x86_vaes::vaesdec<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
278 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
279 requires { sizeof(simd<std::uint8_t, 64, Arch>); } && !Arch.has(polyfill))
282 return detail::x86_vaes_constant::round<true, false>(state, key);
286 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
287 requires { sizeof(simd<std::uint8_t, 64, Arch>); } && Arch.has(polyfill))
290 return detail::x86_vaes_constant::round<true, false>(state, key);
294 template<isa<x86> Arch,
class... Args>
298 template<isa<x86> Arch>
requires(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx))
299 [[nodiscard]] hint_inline hint_const hint_target(
"avx,aes")
301 simd<
std::uint8_t, 16, Arch> state,
simd<
std::uint8_t, 16, Arch> key) noexcept {
303 return detail::x86_vaes_constant::round<true, true>(state, key);
305 return detail::x86_instruction_result<simd<std::uint8_t, 16, Arch>>(
306 detail::x86_vaes::vaesdeclast<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
311 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
312 requires { sizeof(simd<std::uint8_t, 16, Arch>); } && !Arch.has(polyfill))
315 return detail::x86_vaes_constant::round<true, true>(state, key);
319 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
320 requires { sizeof(simd<std::uint8_t, 16, Arch>); } && Arch.has(polyfill))
323 return detail::x86_vaes_constant::round<true, true>(state, key);
327 template<isa<x86> Arch>
requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx))
328 [[nodiscard]] hint_inline hint_const hint_target(
"avx,vaes")
332 return detail::x86_vaes_constant::round<true, true>(state, key);
334 return detail::x86_instruction_result<simd<std::uint8_t, 32, Arch>>(
335 detail::x86_vaes::vaesdeclast<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
340 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
341 requires { sizeof(simd<std::uint8_t, 32, Arch>); } && !Arch.has(polyfill))
344 return detail::x86_vaes_constant::round<true, true>(state, key);
348 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
349 requires { sizeof(simd<std::uint8_t, 32, Arch>); } && Arch.has(polyfill))
352 return detail::x86_vaes_constant::round<true, true>(state, key);
356 template<isa<x86> Arch>
requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f))
357 [[nodiscard]] hint_inline hint_const hint_target(
"avx512f,vaes")
361 return detail::x86_vaes_constant::round<true, true>(state, key);
363 return detail::x86_instruction_result<simd<std::uint8_t, 64, Arch>>(
364 detail::x86_vaes::vaesdeclast<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(key)));
369 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
370 requires { sizeof(simd<std::uint8_t, 64, Arch>); } && !Arch.has(polyfill))
373 return detail::x86_vaes_constant::round<true, true>(state, key);
377 template<isa<x86> Arch>
requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
378 requires { sizeof(simd<std::uint8_t, 64, Arch>); } && Arch.has(polyfill))
381 return detail::x86_vaes_constant::round<true, true>(state, key);
385 template<isa<x86> Arch,
class... Args>
constexpr simd< std::uint8_t, 16, Arch > vaesenc(simd< std::uint8_t, 16, Arch > state, simd< std::uint8_t, 16, Arch > key) noexcept
One AES encryption round.
constexpr simd< std::uint8_t, 16, Arch > vaesenclast(simd< std::uint8_t, 16, Arch > state, simd< std::uint8_t, 16, Arch > key) noexcept
One final AES encryption round.
constexpr simd< std::uint8_t, 16, Arch > vaesdec(simd< std::uint8_t, 16, Arch > state, simd< std::uint8_t, 16, Arch > key) noexcept
One AES decryption round.
constexpr simd< std::uint8_t, 16, Arch > vaesdeclast(simd< std::uint8_t, 16, Arch > state, simd< std::uint8_t, 16, Arch > key) noexcept
One final AES decryption round.
Architecture-tagged vectors, register packs and supporting value types. Native arithmetic follows its...
Standard-library adaptations documented here for SIMD value types.
Omitted architecture arguments use the native.simd provider's baseline.