native 0.0.1
Vectors, masks and wide register packs for C++26
Loading...
Searching...
No Matches
native.x86.vaes.ccm
1// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
2module;
3
4#include "native/isa_import.h"
5#include "native/x86/vaes.h"
6
7export module native.x86.vaes;
8export import native.x86.features;
9export import native.simd;
10
11// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
12
13#if NATIVE_HOST_X86 || defined(NATIVE_DOXYGEN)
14export namespace native {
24
26 template<isa<x86> Arch> requires(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx))
28 constexpr simd<std::uint8_t, 16, Arch> vaesenc(
29 simd<std::uint8_t, 16, Arch> state, simd<std::uint8_t, 16, Arch> key) noexcept {
30 if consteval {
31 return detail::x86_vaes_constant::round<false, false>(state, key);
32 } else {
34 detail::x86_vaes::vaesenc<Arch>(state.to_native(), key.to_native()));
35 }
36 }
37
39 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
40 requires { sizeof(simd<std::uint8_t, 16, Arch>); })
43 return detail::x86_vaes_constant::round<false, false>(state, key);
44 }
45
47 template<isa<x86> Arch> requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx))
51 if consteval {
52 return detail::x86_vaes_constant::round<false, false>(state, key);
53 } else {
55 detail::x86_vaes::vaesenc<Arch>(state.to_native(), key.to_native()));
56 }
57 }
58
60 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
61 requires { sizeof(simd<std::uint8_t, 32, Arch>); })
64 return detail::x86_vaes_constant::round<false, false>(state, key);
65 }
66
68 template<isa<x86> Arch> requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f))
72 if consteval {
73 return detail::x86_vaes_constant::round<false, false>(state, key);
74 } else {
76 detail::x86_vaes::vaesenc<Arch>(state.to_native(), key.to_native()));
77 }
78 }
79
81 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
82 requires { sizeof(simd<std::uint8_t, 64, Arch>); })
85 return detail::x86_vaes_constant::round<false, false>(state, key);
86 }
87
89 template<isa<x86> Arch, class... Args>
90 void vaesenc(Args...) = delete;
91
93 template<isa<x86> Arch> requires(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx))
95 constexpr simd<std::uint8_t, 16, Arch> vaesenclast(
96 simd<std::uint8_t, 16, Arch> state, simd<std::uint8_t, 16, Arch> key) noexcept {
97 if consteval {
98 return detail::x86_vaes_constant::round<false, true>(state, key);
99 } else {
101 detail::x86_vaes::vaesenclast<Arch>(state.to_native(), key.to_native()));
102 }
103 }
104
106 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
107 requires { sizeof(simd<std::uint8_t, 16, Arch>); })
110 return detail::x86_vaes_constant::round<false, true>(state, key);
111 }
112
114 template<isa<x86> Arch> requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx))
118 if consteval {
119 return detail::x86_vaes_constant::round<false, true>(state, key);
120 } else {
122 detail::x86_vaes::vaesenclast<Arch>(state.to_native(), key.to_native()));
123 }
124 }
125
127 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
128 requires { sizeof(simd<std::uint8_t, 32, Arch>); })
131 return detail::x86_vaes_constant::round<false, true>(state, key);
132 }
133
135 template<isa<x86> Arch> requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f))
139 if consteval {
140 return detail::x86_vaes_constant::round<false, true>(state, key);
141 } else {
143 detail::x86_vaes::vaesenclast<Arch>(state.to_native(), key.to_native()));
144 }
145 }
146
148 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
149 requires { sizeof(simd<std::uint8_t, 64, Arch>); })
152 return detail::x86_vaes_constant::round<false, true>(state, key);
153 }
154
156 template<isa<x86> Arch, class... Args>
157 void vaesenclast(Args...) = delete;
158
160 template<isa<x86> Arch> requires(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx))
162 constexpr simd<std::uint8_t, 16, Arch> vaesdec(
163 simd<std::uint8_t, 16, Arch> state, simd<std::uint8_t, 16, Arch> key) noexcept {
164 if consteval {
165 return detail::x86_vaes_constant::round<true, false>(state, key);
166 } else {
168 detail::x86_vaes::vaesdec<Arch>(state.to_native(), key.to_native()));
169 }
170 }
171
173 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
174 requires { sizeof(simd<std::uint8_t, 16, Arch>); })
177 return detail::x86_vaes_constant::round<true, false>(state, key);
178 }
179
181 template<isa<x86> Arch> requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx))
185 if consteval {
186 return detail::x86_vaes_constant::round<true, false>(state, key);
187 } else {
189 detail::x86_vaes::vaesdec<Arch>(state.to_native(), key.to_native()));
190 }
191 }
192
194 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
195 requires { sizeof(simd<std::uint8_t, 32, Arch>); })
198 return detail::x86_vaes_constant::round<true, false>(state, key);
199 }
200
202 template<isa<x86> Arch> requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f))
206 if consteval {
207 return detail::x86_vaes_constant::round<true, false>(state, key);
208 } else {
210 detail::x86_vaes::vaesdec<Arch>(state.to_native(), key.to_native()));
211 }
212 }
213
215 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
216 requires { sizeof(simd<std::uint8_t, 64, Arch>); })
219 return detail::x86_vaes_constant::round<true, false>(state, key);
220 }
221
223 template<isa<x86> Arch, class... Args>
224 void vaesdec(Args...) = delete;
225
227 template<isa<x86> Arch> requires(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx))
229 constexpr simd<std::uint8_t, 16, Arch> vaesdeclast(
230 simd<std::uint8_t, 16, Arch> state, simd<std::uint8_t, 16, Arch> key) noexcept {
231 if consteval {
232 return detail::x86_vaes_constant::round<true, true>(state, key);
233 } else {
235 detail::x86_vaes::vaesdeclast<Arch>(state.to_native(), key.to_native()));
236 }
237 }
238
240 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::aes) && Arch.has(x86_feature::avx)) &&
241 requires { sizeof(simd<std::uint8_t, 16, Arch>); })
244 return detail::x86_vaes_constant::round<true, true>(state, key);
245 }
246
248 template<isa<x86> Arch> requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx))
252 if consteval {
253 return detail::x86_vaes_constant::round<true, true>(state, key);
254 } else {
256 detail::x86_vaes::vaesdeclast<Arch>(state.to_native(), key.to_native()));
257 }
258 }
259
261 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx)) &&
262 requires { sizeof(simd<std::uint8_t, 32, Arch>); })
265 return detail::x86_vaes_constant::round<true, true>(state, key);
266 }
267
269 template<isa<x86> Arch> requires(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f))
273 if consteval {
274 return detail::x86_vaes_constant::round<true, true>(state, key);
275 } else {
277 detail::x86_vaes::vaesdeclast<Arch>(state.to_native(), key.to_native()));
278 }
279 }
280
282 template<isa<x86> Arch> requires(!(Arch.has(x86_feature::vaes) && Arch.has(x86_feature::avx512f)) &&
283 requires { sizeof(simd<std::uint8_t, 64, Arch>); })
286 return detail::x86_vaes_constant::round<true, true>(state, key);
287 }
288
290 template<isa<x86> Arch, class... Args>
291 void vaesdeclast(Args...) = delete;
292
294}
295#endif
#define native_inline
inline [[always_inline]]
Definition attributes.h:212
#define native_nodiscard
C++17 [[nodiscard]].
Definition attributes.h:189
#define native_const
[[const]] is not const
Definition attributes.h:108
#define native_target(x)
this indicates a required feature set for the current multiversioned function.
Definition attributes.h:476
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.