|
12 | 12 | #ifndef XSIMD_CPU_FEATURES_X86_HPP |
13 | 13 | #define XSIMD_CPU_FEATURES_X86_HPP |
14 | 14 |
|
| 15 | +#include "../utils/bits.hpp" |
| 16 | +#include "./xsimd_config.hpp" |
| 17 | + |
15 | 18 | #include <array> |
16 | 19 | #include <cassert> |
17 | 20 | #include <cstdint> |
18 | 21 | #include <cstring> |
19 | | -#include <type_traits> |
20 | 22 | #include <string_view> |
21 | | - |
22 | | -#include "../utils/bits.hpp" |
23 | | -#include "./xsimd_config.hpp" |
| 23 | +#include <type_traits> |
24 | 24 |
|
25 | 25 | #if XSIMD_TARGET_X86 && defined(_MSC_VER) |
26 | 26 | #include <intrin.h> // Contains the definition of __cpuidex |
@@ -122,75 +122,8 @@ namespace xsimd |
122 | 122 |
|
123 | 123 | constexpr x86_cpuid_regs() noexcept = default; |
124 | 124 |
|
125 | | - // TODO(C++17) compact version for which this was designed. |
126 | | - // The else clause contains a very verbose port. |
127 | | -#if 0 |
128 | 125 | using x86_reg32_bitset<typename reg_ids::bits>::all_bits_set...; |
129 | 126 | using x86_reg32_bitset<typename reg_ids::bits>::get_range...; |
130 | | -#else |
131 | | - |
132 | | - private: |
133 | | - template <int N> |
134 | | - struct m_empty_reg |
135 | | - { |
136 | | - enum class type {}; |
137 | | - }; |
138 | | - |
139 | | - using eax_or_empty = std::conditional_t<std::is_void_v<eax>, typename m_empty_reg<0>::type, eax>; |
140 | | - using ebx_or_empty = std::conditional_t<std::is_void_v<ebx>, typename m_empty_reg<1>::type, ebx>; |
141 | | - using ecx_or_empty = std::conditional_t<std::is_void_v<ecx>, typename m_empty_reg<2>::type, ecx>; |
142 | | - using edx_or_empty = std::conditional_t<std::is_void_v<edx>, typename m_empty_reg<3>::type, edx>; |
143 | | - |
144 | | - public: |
145 | | - template <eax_or_empty... bits, typename T = eax, std::enable_if_t<!std::is_void_v<T>, int> = 0> |
146 | | - constexpr bool all_bits_set() const noexcept |
147 | | - { |
148 | | - return x86_reg32_bitset<eax>::template all_bits_set<bits...>(); |
149 | | - } |
150 | | - |
151 | | - template <eax_or_empty start, eax_or_empty end, typename T = eax, std::enable_if_t<!std::is_void_v<T>, int> = 0> |
152 | | - constexpr x86_reg32_t get_range() const noexcept |
153 | | - { |
154 | | - return x86_reg32_bitset<eax>::template get_range<start, end>(); |
155 | | - } |
156 | | - |
157 | | - template <ebx_or_empty... bits, typename T = ebx, std::enable_if_t<!std::is_void_v<T>, int> = 0> |
158 | | - constexpr bool all_bits_set() const noexcept |
159 | | - { |
160 | | - return x86_reg32_bitset<ebx>::template all_bits_set<bits...>(); |
161 | | - } |
162 | | - |
163 | | - template <ebx_or_empty start, ebx_or_empty end, typename T = ebx, std::enable_if_t<!std::is_void_v<T>, int> = 0> |
164 | | - constexpr x86_reg32_t get_range() const noexcept |
165 | | - { |
166 | | - return x86_reg32_bitset<ebx>::template get_range<start, end>(); |
167 | | - } |
168 | | - |
169 | | - template <ecx_or_empty... bits, typename T = ecx, std::enable_if_t<!std::is_void_v<T>, int> = 0> |
170 | | - constexpr bool all_bits_set() const noexcept |
171 | | - { |
172 | | - return x86_reg32_bitset<ecx>::template all_bits_set<bits...>(); |
173 | | - } |
174 | | - |
175 | | - template <ecx_or_empty start, ecx_or_empty end, typename T = ecx, std::enable_if_t<!std::is_void_v<T>, int> = 0> |
176 | | - constexpr x86_reg32_t get_range() const noexcept |
177 | | - { |
178 | | - return x86_reg32_bitset<ecx>::template get_range<start, end>(); |
179 | | - } |
180 | | - |
181 | | - template <edx_or_empty... bits, typename T = edx, std::enable_if_t<!std::is_void_v<T>, int> = 0> |
182 | | - constexpr bool all_bits_set() const noexcept |
183 | | - { |
184 | | - return x86_reg32_bitset<edx>::template all_bits_set<bits...>(); |
185 | | - } |
186 | | - |
187 | | - template <edx_or_empty start, edx_or_empty end, typename T = edx, std::enable_if_t<!std::is_void_v<T>, int> = 0> |
188 | | - constexpr x86_reg32_t get_range() const noexcept |
189 | | - { |
190 | | - return x86_reg32_bitset<edx>::template get_range<start, end>(); |
191 | | - } |
192 | | - |
193 | | -#endif // C++17 |
194 | 127 | }; |
195 | 128 |
|
196 | 129 | template <bool extended> |
@@ -1044,8 +977,7 @@ namespace xsimd |
1044 | 977 |
|
1045 | 978 | // Check if it is safe to call CPUID with this value. |
1046 | 979 | // First we identify if the leaf is in the regular or extended range. |
1047 | | - // TODO(C++17): if constexpr |
1048 | | - if (L::leaf < extended_threshold) |
| 980 | + if constexpr (L::leaf < extended_threshold) |
1049 | 981 | { |
1050 | 982 | // Check leaf0 in regular range |
1051 | 983 | if (L::leaf <= leaf0().highest_leaf()) |
|
0 commit comments