native 0.0.1
Vectors, masks and wide register packs for C++26
Loading...
Searching...
No Matches
vpclmul.h
1// SPDX-FileCopyrightText: 2026 Edward Kmett <ekmett@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
3#pragma once
4#include "native/config.h"
5#include <hint.h>
6#include "native/isa.h"
7#if NATIVE_HOST_X86
8#include <immintrin.h>
9#endif
10
11#if NATIVE_HOST_X86 || defined(NATIVE_DOXYGEN)
12namespace native::detail::x86_vpclmul {
13// Internal register helpers for the native.x86.vpclmul module.
14
15
17 template<isa<x86> Arch, unsigned Imm8> requires(Arch.has(x86_feature::pclmul) &&
18 Arch.has(x86_feature::avx) && Imm8 <= 255)
19 [[nodiscard]] hint_inline hint_const hint_target("avx,pclmul")
20 __m128i vpclmulqdq(__m128i a, __m128i b) noexcept {
21 return _mm_clmulepi64_si128(a, b, Imm8);
22 }
23
25 template<isa<x86> Arch, unsigned Imm8> requires(Arch.has(x86_feature::vpclmulqdq) &&
26 Arch.has(x86_feature::avx) && Imm8 <= 255)
27 [[nodiscard]] hint_inline hint_const hint_target("avx,vpclmulqdq")
28 __m256i vpclmulqdq(__m256i a, __m256i b) noexcept {
29 return _mm256_clmulepi64_epi128(a, b, Imm8);
30 }
31
33 template<isa<x86> Arch, unsigned Imm8> requires(Arch.has(x86_feature::vpclmulqdq) &&
34 Arch.has(x86_feature::avx512f) && Imm8 <= 255)
35 [[nodiscard]] hint_inline hint_const hint_target("avx512f,vpclmulqdq")
36 __m512i vpclmulqdq(__m512i a, __m512i b) noexcept {
37 return _mm512_clmulepi64_epi128(a, b, Imm8);
38 }
39
41 template<isa<x86> Arch, unsigned Imm8, class A, class B>
42 void vpclmulqdq(A, B) = delete;
43
44
45}
46#endif