mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Avoid breaking the build on older compilers.
See merge request libeigen/eigen!2068 Co-authored-by: Rasmus Munk Larsen <rmlarsen@google.com>
This commit is contained in:
@@ -458,8 +458,8 @@ EIGEN_CLANG_PACKET_BITWISE_FLOAT(Packet8d, detail::pcast_double_to_long, detail:
|
|||||||
#undef EIGEN_CLANG_PACKET_BITWISE_FLOAT
|
#undef EIGEN_CLANG_PACKET_BITWISE_FLOAT
|
||||||
|
|
||||||
// --- Min/Max operations ---
|
// --- Min/Max operations ---
|
||||||
#if __has_builtin(__builtin_elementwise_min) && __has_builtin(__builtin_elementwise_max) && \
|
#if EIGEN_HAS_BUILTIN(__builtin_elementwise_min) && EIGEN_HAS_BUILTIN(__builtin_elementwise_max) && \
|
||||||
__has_builtin(__builtin_elementwise_abs)
|
EIGEN_HAS_BUILTIN(__builtin_elementwise_abs)
|
||||||
#define EIGEN_CLANG_PACKET_ELEMENTWISE(PACKET_TYPE) \
|
#define EIGEN_CLANG_PACKET_ELEMENTWISE(PACKET_TYPE) \
|
||||||
template <> \
|
template <> \
|
||||||
EIGEN_STRONG_INLINE PACKET_TYPE pmin<PACKET_TYPE>(const PACKET_TYPE& a, const PACKET_TYPE& b) { \
|
EIGEN_STRONG_INLINE PACKET_TYPE pmin<PACKET_TYPE>(const PACKET_TYPE& a, const PACKET_TYPE& b) { \
|
||||||
@@ -506,9 +506,9 @@ EIGEN_CLANG_PACKET_ELEMENTWISE(Packet8l)
|
|||||||
|
|
||||||
// --- Math functions (float/double only) ---
|
// --- Math functions (float/double only) ---
|
||||||
|
|
||||||
#if __has_builtin(__builtin_elementwise_floor) && __has_builtin(__builtin_elementwise_ceil) && \
|
#if EIGEN_HAS_BUILTIN(__builtin_elementwise_floor) && EIGEN_HAS_BUILTIN(__builtin_elementwise_ceil) && \
|
||||||
__has_builtin(__builtin_elementwise_round) && __has_builtin(__builtin_elementwise_roundeven) && \
|
EIGEN_HAS_BUILTIN(__builtin_elementwise_round) && EIGEN_HAS_BUILTIN(__builtin_elementwise_roundeven) && \
|
||||||
__has_builtin(__builtin_elementwise_trunc) && __has_builtin(__builtin_elementwise_sqrt)
|
EIGEN_HAS_BUILTIN(__builtin_elementwise_trunc) && EIGEN_HAS_BUILTIN(__builtin_elementwise_sqrt)
|
||||||
#define EIGEN_CLANG_PACKET_MATH_FLOAT(PACKET_TYPE) \
|
#define EIGEN_CLANG_PACKET_MATH_FLOAT(PACKET_TYPE) \
|
||||||
template <> \
|
template <> \
|
||||||
EIGEN_STRONG_INLINE PACKET_TYPE pfloor<PACKET_TYPE>(const PACKET_TYPE& a) { \
|
EIGEN_STRONG_INLINE PACKET_TYPE pfloor<PACKET_TYPE>(const PACKET_TYPE& a) { \
|
||||||
@@ -541,7 +541,7 @@ EIGEN_CLANG_PACKET_MATH_FLOAT(Packet8d)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// --- Fused Multiply-Add (MADD) ---
|
// --- Fused Multiply-Add (MADD) ---
|
||||||
#if defined(__FMA__) && __has_builtin(__builtin_elementwise_fma)
|
#if defined(__FMA__) && EIGEN_HAS_BUILTIN(__builtin_elementwise_fma)
|
||||||
#define EIGEN_CLANG_PACKET_MADD(PACKET_TYPE) \
|
#define EIGEN_CLANG_PACKET_MADD(PACKET_TYPE) \
|
||||||
template <> \
|
template <> \
|
||||||
EIGEN_STRONG_INLINE PACKET_TYPE pmadd<PACKET_TYPE>(const PACKET_TYPE& a, const PACKET_TYPE& b, \
|
EIGEN_STRONG_INLINE PACKET_TYPE pmadd<PACKET_TYPE>(const PACKET_TYPE& a, const PACKET_TYPE& b, \
|
||||||
@@ -603,7 +603,7 @@ EIGEN_CLANG_PACKET_SCATTER_GATHER(Packet8l)
|
|||||||
#undef EIGEN_CLANG_PACKET_SCATTER_GATHER
|
#undef EIGEN_CLANG_PACKET_SCATTER_GATHER
|
||||||
|
|
||||||
// ---- Various operations that depend on __builtin_shufflevector.
|
// ---- Various operations that depend on __builtin_shufflevector.
|
||||||
#if __has_builtin(__builtin_shufflevector)
|
#if EIGEN_HAS_BUILTIN(__builtin_shufflevector)
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template <typename Packet>
|
template <typename Packet>
|
||||||
EIGEN_STRONG_INLINE Packet preverse_impl_8(const Packet& a) {
|
EIGEN_STRONG_INLINE Packet preverse_impl_8(const Packet& a) {
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ namespace Eigen {
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// --- Reductions ---
|
// --- Reductions ---
|
||||||
#if __has_builtin(__builtin_reduce_min) && __has_builtin(__builtin_reduce_max) && __has_builtin(__builtin_reduce_or)
|
#if EIGEN_HAS_BUILTIN(__builtin_reduce_min) && EIGEN_HAS_BUILTIN(__builtin_reduce_max) && \
|
||||||
|
EIGEN_HAS_BUILTIN(__builtin_reduce_or)
|
||||||
#define EIGEN_CLANG_PACKET_REDUX_MINMAX(PACKET_TYPE) \
|
#define EIGEN_CLANG_PACKET_REDUX_MINMAX(PACKET_TYPE) \
|
||||||
template <> \
|
template <> \
|
||||||
EIGEN_STRONG_INLINE unpacket_traits<PACKET_TYPE>::type predux_min(const PACKET_TYPE& a) { \
|
EIGEN_STRONG_INLINE unpacket_traits<PACKET_TYPE>::type predux_min(const PACKET_TYPE& a) { \
|
||||||
@@ -36,7 +37,7 @@ EIGEN_CLANG_PACKET_REDUX_MINMAX(Packet8l)
|
|||||||
#undef EIGEN_CLANG_PACKET_REDUX_MINMAX
|
#undef EIGEN_CLANG_PACKET_REDUX_MINMAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __has_builtin(__builtin_reduce_add) && __has_builtin(__builtin_reduce_mul)
|
#if EIGEN_HAS_BUILTIN(__builtin_reduce_add) && EIGEN_HAS_BUILTIN(__builtin_reduce_mul)
|
||||||
#define EIGEN_CLANG_PACKET_REDUX_INT(PACKET_TYPE) \
|
#define EIGEN_CLANG_PACKET_REDUX_INT(PACKET_TYPE) \
|
||||||
template <> \
|
template <> \
|
||||||
EIGEN_STRONG_INLINE unpacket_traits<PACKET_TYPE>::type predux<PACKET_TYPE>(const PACKET_TYPE& a) { \
|
EIGEN_STRONG_INLINE unpacket_traits<PACKET_TYPE>::type predux<PACKET_TYPE>(const PACKET_TYPE& a) { \
|
||||||
@@ -53,7 +54,7 @@ EIGEN_CLANG_PACKET_REDUX_INT(Packet8l)
|
|||||||
#undef EIGEN_CLANG_PACKET_REDUX_INT
|
#undef EIGEN_CLANG_PACKET_REDUX_INT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __has_builtin(__builtin_shufflevector)
|
#if EIGEN_HAS_BUILTIN(__builtin_shufflevector)
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template <typename VectorT>
|
template <typename VectorT>
|
||||||
EIGEN_STRONG_INLINE scalar_type_of_vector_t<VectorT> ReduceAdd16(const VectorT& a) {
|
EIGEN_STRONG_INLINE scalar_type_of_vector_t<VectorT> ReduceAdd16(const VectorT& a) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ EIGEN_STRONG_INLINE Packet8l preinterpret<Packet8l, Packet8d>(const Packet8d& a)
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
// pcast
|
// pcast
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
#if __has_builtin(__builtin_convertvector)
|
#if EIGEN_HAS_BUILTIN(__builtin_convertvector)
|
||||||
template <>
|
template <>
|
||||||
EIGEN_STRONG_INLINE Packet16i pcast<Packet16f, Packet16i>(const Packet16f& a) {
|
EIGEN_STRONG_INLINE Packet16i pcast<Packet16f, Packet16i>(const Packet16f& a) {
|
||||||
return __builtin_convertvector(a, Packet16i);
|
return __builtin_convertvector(a, Packet16i);
|
||||||
|
|||||||
@@ -700,6 +700,13 @@
|
|||||||
#define EIGEN_HAS_BUILTIN(x) 0
|
#define EIGEN_HAS_BUILTIN(x) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Cross compiler wrapper around LLVM's __has_attribute
|
||||||
|
#ifdef __has_attribute
|
||||||
|
#define EIGEN_HAS_ATTRIBUTE(x) __has_attribute(x)
|
||||||
|
#else
|
||||||
|
#define EIGEN_HAS_ATTRIBUTE(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// A Clang feature extension to determine compiler features.
|
// A Clang feature extension to determine compiler features.
|
||||||
// We use it to determine 'cxx_rvalue_references'
|
// We use it to determine 'cxx_rvalue_references'
|
||||||
#ifndef __has_feature
|
#ifndef __has_feature
|
||||||
@@ -831,7 +838,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Does the compiler support vector types?
|
// Does the compiler support vector types?
|
||||||
#if __has_attribute(ext_vector_type) && __has_builtin(__builtin_vectorelements)
|
#if EIGEN_HAS_ATTRIBUTE(ext_vector_type) && EIGEN_HAS_BUILTIN(__builtin_vectorelements)
|
||||||
#define EIGEN_ARCH_VECTOR_EXTENSIONS 1
|
#define EIGEN_ARCH_VECTOR_EXTENSIONS 1
|
||||||
#else
|
#else
|
||||||
#define EIGEN_ARCH_VECTOR_EXTENSIONS 0
|
#define EIGEN_ARCH_VECTOR_EXTENSIONS 0
|
||||||
|
|||||||
Reference in New Issue
Block a user