Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 5 additions & 79 deletions include/xsimd/config/xsimd_cpu_features_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
#ifndef XSIMD_CPU_FEATURES_X86_HPP
#define XSIMD_CPU_FEATURES_X86_HPP

#include "../utils/bits.hpp"
#include "./xsimd_config.hpp"

#include <array>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <type_traits>
#if XSIMD_CPP_VERSION >= 201703L
#include <string_view>
#endif

#include "../utils/bits.hpp"
#include "./xsimd_config.hpp"
#include <type_traits>

#if XSIMD_TARGET_X86 && defined(_MSC_VER)
#include <intrin.h> // Contains the definition of __cpuidex
Expand Down Expand Up @@ -124,75 +122,8 @@ namespace xsimd

constexpr x86_cpuid_regs() noexcept = default;

// TODO(C++17) compact version for which this was designed.
// The else clause contains a very verbose port.
#if 0
using x86_reg32_bitset<typename reg_ids::bits>::all_bits_set...;
using x86_reg32_bitset<typename reg_ids::bits>::get_range...;
#else

private:
template <int N>
struct m_empty_reg
{
enum class type {};
};

using eax_or_empty = std::conditional_t<std::is_void_v<eax>, typename m_empty_reg<0>::type, eax>;
using ebx_or_empty = std::conditional_t<std::is_void_v<ebx>, typename m_empty_reg<1>::type, ebx>;
using ecx_or_empty = std::conditional_t<std::is_void_v<ecx>, typename m_empty_reg<2>::type, ecx>;
using edx_or_empty = std::conditional_t<std::is_void_v<edx>, typename m_empty_reg<3>::type, edx>;

public:
template <eax_or_empty... bits, typename T = eax, std::enable_if_t<!std::is_void_v<T>, int> = 0>
constexpr bool all_bits_set() const noexcept
{
return x86_reg32_bitset<eax>::template all_bits_set<bits...>();
}

template <eax_or_empty start, eax_or_empty end, typename T = eax, std::enable_if_t<!std::is_void_v<T>, int> = 0>
constexpr x86_reg32_t get_range() const noexcept
{
return x86_reg32_bitset<eax>::template get_range<start, end>();
}

template <ebx_or_empty... bits, typename T = ebx, std::enable_if_t<!std::is_void_v<T>, int> = 0>
constexpr bool all_bits_set() const noexcept
{
return x86_reg32_bitset<ebx>::template all_bits_set<bits...>();
}

template <ebx_or_empty start, ebx_or_empty end, typename T = ebx, std::enable_if_t<!std::is_void_v<T>, int> = 0>
constexpr x86_reg32_t get_range() const noexcept
{
return x86_reg32_bitset<ebx>::template get_range<start, end>();
}

template <ecx_or_empty... bits, typename T = ecx, std::enable_if_t<!std::is_void_v<T>, int> = 0>
constexpr bool all_bits_set() const noexcept
{
return x86_reg32_bitset<ecx>::template all_bits_set<bits...>();
}

template <ecx_or_empty start, ecx_or_empty end, typename T = ecx, std::enable_if_t<!std::is_void_v<T>, int> = 0>
constexpr x86_reg32_t get_range() const noexcept
{
return x86_reg32_bitset<ecx>::template get_range<start, end>();
}

template <edx_or_empty... bits, typename T = edx, std::enable_if_t<!std::is_void_v<T>, int> = 0>
constexpr bool all_bits_set() const noexcept
{
return x86_reg32_bitset<edx>::template all_bits_set<bits...>();
}

template <edx_or_empty start, edx_or_empty end, typename T = edx, std::enable_if_t<!std::is_void_v<T>, int> = 0>
constexpr x86_reg32_t get_range() const noexcept
{
return x86_reg32_bitset<edx>::template get_range<start, end>();
}

#endif // C++17
};

template <bool extended>
Expand Down Expand Up @@ -249,12 +180,10 @@ namespace xsimd
return m_manufacturer_id;
}

#if XSIMD_CPP_VERSION >= 201703L
constexpr std::string_view manufacturer_id() const noexcept
{
return { m_manufacturer_id.data(), m_manufacturer_id.size() };
}
#endif

private:
manufacturer_str m_manufacturer_id {};
Expand Down Expand Up @@ -835,12 +764,10 @@ namespace xsimd
return leaf0().manufacturer_id_raw();
}

#if XSIMD_CPP_VERSION >= 201703L
inline std::string_view manufacturer_id() const noexcept
{
return leaf0().manufacturer_id();
}
#endif

/** The manufacturer ID string parsed into known common vendors. */
inline x86_manufacturer known_manufacturer() const noexcept
Expand Down Expand Up @@ -1050,8 +977,7 @@ namespace xsimd

// Check if it is safe to call CPUID with this value.
// First we identify if the leaf is in the regular or extended range.
// TODO(C++17): if constexpr
if (L::leaf < extended_threshold)
if constexpr (L::leaf < extended_threshold)
{
// Check leaf0 in regular range
if (L::leaf <= leaf0().highest_leaf())
Expand Down
15 changes: 0 additions & 15 deletions include/xsimd/types/xsimd_batch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,6 @@ namespace xsimd
XSIMD_INLINE batch logical_or(batch const& other) const noexcept;
};

#if XSIMD_CPP_VERSION < 201703L
template <class T, class A>
constexpr std::size_t batch<T, A>::size;
#endif

/**
* @brief batch of predicate over scalar or complex values.
*
Expand Down Expand Up @@ -497,11 +492,6 @@ namespace xsimd
static XSIMD_INLINE register_type make_register(std::index_sequence<>, V... v) noexcept;
};

#if XSIMD_CPP_VERSION < 201703L
template <class T, class A>
constexpr std::size_t batch_bool<T, A>::size;
#endif

/**
* @brief batch of complex values.
*
Expand Down Expand Up @@ -643,11 +633,6 @@ namespace xsimd
real_batch m_imag;
};

#if XSIMD_CPP_VERSION < 201703L
template <class T, class A>
constexpr std::size_t batch<std::complex<T>, A>::size;
#endif

#ifdef XSIMD_ENABLE_XTL_COMPLEX
template <typename T, bool i3ec, typename A>
struct batch<xtl::xcomplex<T, T, i3ec>, A>
Expand Down
53 changes: 0 additions & 53 deletions include/xsimd/types/xsimd_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ namespace xsimd
static constexpr size_t size = 1;
};

#if XSIMD_CPP_VERSION < 201703L
template <class T>
constexpr size_t simd_traits_impl<T, false>::size;
#endif

template <class T>
struct simd_traits_impl<T, true>
{
Expand All @@ -77,11 +72,6 @@ namespace xsimd
static constexpr size_t size = type::size;
};

#if XSIMD_CPP_VERSION < 201703L
template <class T>
constexpr size_t simd_traits_impl<T, true>::size;
#endif

template <class T, class A>
struct static_check_supported_config_emitter
{
Expand Down Expand Up @@ -143,23 +133,13 @@ namespace xsimd
static constexpr size_t size = simd_traits<type>::size;
};

#if XSIMD_CPP_VERSION < 201703L
template <class T>
constexpr size_t revert_simd_traits<T>::size;
#endif

template <class T>
struct revert_simd_traits<batch<T>>
{
using type = T;
static constexpr size_t size = batch<T>::size;
};

#if XSIMD_CPP_VERSION < 201703L
template <class T>
constexpr size_t revert_simd_traits<batch<T>>::size;
#endif

template <class T>
using simd_type = typename simd_traits<T>::type;

Expand Down Expand Up @@ -264,17 +244,6 @@ namespace xsimd
static constexpr bool is_complex = detail::is_complex_v<T>; ///< True if T is complex or a batch of complex values.
};

#if XSIMD_CPP_VERSION < 201703L
template <class T>
constexpr bool batch_traits<T>::is_batch;
template <class T>
constexpr bool batch_traits<T>::is_batch_bool;
template <class T>
constexpr bool batch_traits<T>::is_any_batch;
template <class T>
constexpr bool batch_traits<T>::is_complex;
#endif

template <class T, class A>
struct batch_traits<batch<T, A>>
{
Expand All @@ -287,17 +256,6 @@ namespace xsimd
static constexpr bool is_complex = detail::is_complex_v<T>;
};

#if XSIMD_CPP_VERSION < 201703L
template <class T, class A>
constexpr bool batch_traits<batch<T, A>>::is_batch;
template <class T, class A>
constexpr bool batch_traits<batch<T, A>>::is_batch_bool;
template <class T, class A>
constexpr bool batch_traits<batch<T, A>>::is_any_batch;
template <class T, class A>
constexpr bool batch_traits<batch<T, A>>::is_complex;
#endif

template <class T, class A>
struct batch_traits<batch_bool<T, A>>
{
Expand All @@ -310,17 +268,6 @@ namespace xsimd
static constexpr bool is_complex = false;
};

#if XSIMD_CPP_VERSION < 201703L
template <class T, class A>
constexpr bool batch_traits<batch_bool<T, A>>::is_batch;
template <class T, class A>
constexpr bool batch_traits<batch_bool<T, A>>::is_batch_bool;
template <class T, class A>
constexpr bool batch_traits<batch_bool<T, A>>::is_any_batch;
template <class T, class A>
constexpr bool batch_traits<batch_bool<T, A>>::is_complex;
#endif

/**
* @ingroup batch_traits
*
Expand Down
Loading