2 * Copyright (C) 2024 Mikulas Patocka
4 * This file is part of Ajla.
6 * Ajla is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
11 * Ajla is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * Ajla. If not, see <https://www.gnu.org/licenses/>.
19 #define feature_name bswap
20 #define static_test_bswap ((__i486__) || (__i586__) || (__i686__) || (__MMX__) || (__x86_64__))
21 #define dynamic_test (eflags_bits & (1 << 18U))
24 #define feature_name cmov
25 #define static_test_cmov ((__i686__) || (__athlon__) || (__SSE__) || (__x86_64__))
26 #define dynamic_test (cpuid_1[3] & (1U << 15))
29 #define feature_name popcnt
30 #define static_test_popcnt (__POPCNT__)
31 #define dynamic_test (cpuid_1[2] & (1U << 23))
34 #define feature_name lzcnt
35 #define static_test_lzcnt (__LZCNT__)
36 #define dynamic_test (cpuid_8_1[2] & (1U << 5))
39 #define feature_name sse
40 #define static_test_sse ((__SSE__) || (__x86_64__))
41 #define dynamic_test (likely(cpuid_1[3] & (1U << 25)) && likely(test_fxsave()))
44 #define feature_name sse2
45 #define static_test_sse2 ((__SSE2__) || (__x86_64__))
46 #define dynamic_test (likely(cpu_test_feature(CPU_FEATURE_sse)) && likely(cpuid_1[3] & (1U << 26)))
49 #define feature_name sse3
50 #define static_test_sse3 (__SSE3__)
51 #define dynamic_test (likely(cpu_test_feature(CPU_FEATURE_sse2)) && likely(cpuid_1[2] & (1U << 0)))
54 #define feature_name sse41
55 #define static_test_sse41 (__SSE4_1__)
56 #define dynamic_test (likely(cpu_test_feature(CPU_FEATURE_sse2)) && likely(cpuid_1[2] & (1U << 19)))
59 #define feature_name avx
60 #define static_test_avx (__AVX__)
61 #define dynamic_test (likely(cpu_test_feature(CPU_FEATURE_sse2)) && likely((cpuid_1[2] & (7U << 26)) == (7U << 26)) && likely(test_xcr0(6)))
64 #define feature_name f16c
65 #define static_test_f16c (__F16C__)
66 #define dynamic_test (likely(cpu_test_feature(CPU_FEATURE_avx)) && likely(cpuid_1[2] & (1U << 29)))
69 #define feature_name bmi2
70 #define static_test_bmi2 (__BMI2__)
71 #define dynamic_test (cpuid_7[1] & (1U << 8))
74 #define feature_name erms
75 #define static_test_erms 0
76 #define dynamic_test (cpuid_7[1] & (1U << 9))