3#include "native/x86/instruction_storage.h"
5#include "native/isa_import.h"
6#include "native/x86/aes.h"
7#include "native/x86/aes_constant.h"
13#if NATIVE_HOST_X86 || defined(NATIVE_DOXYGEN)
29 template<isa<x86> Arch>
requires(Arch.has(x86_feature::aes))
30 [[nodiscard]] hint_inline hint_const hint_target(
"aes")
32 simd<
std::uint8_t, 16, Arch> state,
simd<
std::uint8_t, 16, Arch> round_key) noexcept {
34 return detail::x86_aes_constant::round<false, false>(state, round_key);
36 return detail::x86_instruction_result<simd<std::uint8_t, 16, Arch>>(
37 detail::x86_aes::aesenc<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(round_key)));
42 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::aes) &&
43 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && !Arch.has(
polyfill))
46 return detail::x86_aes_constant::round<false, false>(state, round_key);
50 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::aes) &&
51 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && Arch.has(
polyfill))
54 return detail::x86_aes_constant::round<false, false>(state, round_key);
58 template<isa<x86> Arch>
requires(Arch.has(x86_feature::aes))
59 [[nodiscard]] hint_inline hint_const hint_target(
"aes")
63 return detail::x86_aes_constant::round<false, true>(state, round_key);
65 return detail::x86_instruction_result<simd<std::uint8_t, 16, Arch>>(
66 detail::x86_aes::aesenclast<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(round_key)));
71 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::aes) &&
72 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && !Arch.has(
polyfill))
75 return detail::x86_aes_constant::round<false, true>(state, round_key);
79 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::aes) &&
80 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && Arch.has(
polyfill))
83 return detail::x86_aes_constant::round<false, true>(state, round_key);
87 template<isa<x86> Arch>
requires(Arch.has(x86_feature::aes))
88 [[nodiscard]] hint_inline hint_const hint_target(
"aes")
92 return detail::x86_aes_constant::round<true, false>(state, round_key);
94 return detail::x86_instruction_result<simd<std::uint8_t, 16, Arch>>(
95 detail::x86_aes::aesdec<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(round_key)));
100 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::aes) &&
101 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && !Arch.has(
polyfill))
104 return detail::x86_aes_constant::round<true, false>(state, round_key);
108 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::aes) &&
109 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && Arch.has(
polyfill))
112 return detail::x86_aes_constant::round<true, false>(state, round_key);
116 template<isa<x86> Arch>
requires(Arch.has(x86_feature::aes))
117 [[nodiscard]] hint_inline hint_const hint_target(
"aes")
121 return detail::x86_aes_constant::round<true, true>(state, round_key);
123 return detail::x86_instruction_result<simd<std::uint8_t, 16, Arch>>(
124 detail::x86_aes::aesdeclast<Arch>(detail::x86_integer_register(state), detail::x86_integer_register(round_key)));
129 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::aes) &&
130 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && !Arch.has(
polyfill))
133 return detail::x86_aes_constant::round<true, true>(state, round_key);
137 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::aes) &&
138 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && Arch.has(
polyfill))
141 return detail::x86_aes_constant::round<true, true>(state, round_key);
145 template<isa<x86> Arch>
requires(Arch.has(x86_feature::aes))
146 [[nodiscard]] hint_inline hint_const hint_target(
"aes")
149 return detail::x86_aes_constant::inverse_mix(state);
151 return detail::x86_instruction_result<simd<std::uint8_t, 16, Arch>>(detail::x86_aes::aesimc<Arch>(detail::x86_integer_register(state)));
156 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::aes) &&
157 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && !Arch.has(
polyfill))
159 return detail::x86_aes_constant::inverse_mix(state);
163 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::aes) &&
164 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && Arch.has(
polyfill))
166 return detail::x86_aes_constant::inverse_mix(state);
172 template<isa<x86> Arch,
unsigned Imm8>
requires(Arch.has(x86_feature::aes) && Imm8 <= 255)
173 [[nodiscard]] hint_inline hint_const hint_target(
"aes")
176 return detail::x86_aes_constant::keygen<Imm8>(state);
178 return detail::x86_instruction_result<simd<std::uint8_t, 16, Arch>>(
179 detail::x86_aes::aeskeygenassist<Arch, Imm8>(detail::x86_integer_register(state)));
184 template<isa<x86> Arch,
unsigned Imm8>
requires(!Arch.has(x86_feature::aes) && Imm8 <= 255 &&
185 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && !Arch.has(
polyfill))
187 return detail::x86_aes_constant::keygen<Imm8>(state);
191 template<isa<x86> Arch,
unsigned Imm8>
requires(!Arch.has(x86_feature::aes) && Imm8 <= 255 &&
192 requires {
sizeof(simd<std::uint8_t, 16, Arch>); } && Arch.has(
polyfill))
194 return detail::x86_aes_constant::keygen<Imm8>(state);
198 template<isa<x86> Arch,
class... Args>
202 template<isa<x86> Arch,
class... Args>
206 template<isa<x86> Arch,
class... Args>
210 template<isa<x86> Arch,
class... Args>
214 template<isa<x86> Arch,
class... Args>
218 template<isa<x86> Arch,
unsigned Imm8,
class... Args>
constexpr simd< std::uint8_t, 16, Arch > aesimc(simd< std::uint8_t, 16, Arch > state) noexcept
Apply inverse AES MixColumns independently to the four state columns.
constexpr simd< std::uint8_t, 16, Arch > aesdeclast(simd< std::uint8_t, 16, Arch > state, simd< std::uint8_t, 16, Arch > round_key) noexcept
Apply inverse ShiftRows, inverse SubBytes and then AddRoundKey for the final decryption round.
constexpr simd< std::uint8_t, 16, Arch > aesenclast(simd< std::uint8_t, 16, Arch > state, simd< std::uint8_t, 16, Arch > round_key) noexcept
Apply ShiftRows, SubBytes and then AddRoundKey for the final encryption round.
constexpr simd< std::uint8_t, 16, Arch > aesdec(simd< std::uint8_t, 16, Arch > state, simd< std::uint8_t, 16, Arch > round_key) noexcept
Apply inverse ShiftRows, inverse SubBytes, inverse MixColumns and then AddRoundKey.
constexpr simd< std::uint8_t, 16, Arch > aeskeygenassist(simd< std::uint8_t, 16, Arch > state) noexcept
constexpr simd< std::uint8_t, 16, Arch > aesenc(simd< std::uint8_t, 16, Arch > state, simd< std::uint8_t, 16, Arch > round_key) noexcept
Apply ShiftRows, SubBytes, MixColumns and then AddRoundKey.
Architecture-tagged vectors, register packs and supporting value types. Native arithmetic follows its...
constexpr polyfill_t polyfill
Compose this permission with an ISA using A | polyfill. Used alone, it selects scalar emulation in th...
Standard-library adaptations documented here for SIMD value types.
Omitted architecture arguments use the native.simd provider's baseline.