File indexing completed on 2025-01-30 10:25:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifndef VC_COMMON_MACROS_H_
0029 #define VC_COMMON_MACROS_H_
0030
0031 #include "../global.h"
0032
0033
0034 #ifdef Vc_MSVC
0035 #define Vc_ALIGNED_TYPEDEF(n_, type_, new_type_) \
0036 typedef __declspec(align(n_)) type_ new_type_
0037 #elif __GNUC__
0038 #define Vc_ALIGNED_TYPEDEF(n_, type_, new_type_) \
0039 typedef type_ new_type_[[gnu::aligned(n_)]]
0040 #else
0041 #define Vc_ALIGNED_TYPEDEF(n_, type_, new_type_) \
0042 using new_type_ alignas(sizeof(n_)) = type_
0043 #endif
0044
0045
0046
0047 #ifdef WIN32
0048 #define NOMINMAX 1
0049 #if defined min
0050 #undef min
0051 #endif
0052 #if defined max
0053 #undef max
0054 #endif
0055 #endif
0056
0057 #if defined Vc_GCC && Vc_GCC >= 0x60000
0058
0059
0060
0061 #define Vc_TEMPLATES_DROP_ATTRIBUTES 1
0062 #endif
0063
0064 #if defined Vc_CLANG || defined Vc_APPLECLANG
0065 # define Vc_UNREACHABLE __builtin_unreachable
0066 # define Vc_NEVER_INLINE [[gnu::noinline]]
0067 # define Vc_INTRINSIC_L inline
0068 # define Vc_INTRINSIC_R __attribute__((always_inline))
0069 # define Vc_INTRINSIC Vc_INTRINSIC_L Vc_INTRINSIC_R
0070 # define Vc_FLATTEN
0071 # define Vc_CONST __attribute__((const))
0072 # define Vc_CONST_L
0073 # define Vc_CONST_R Vc_CONST
0074 # define Vc_PURE __attribute__((pure))
0075 # define Vc_PURE_L
0076 # define Vc_PURE_R Vc_PURE
0077 # define Vc_MAY_ALIAS __attribute__((may_alias))
0078 # define Vc_ALWAYS_INLINE_L inline
0079 # define Vc_ALWAYS_INLINE_R __attribute__((always_inline))
0080 # define Vc_ALWAYS_INLINE Vc_ALWAYS_INLINE_L Vc_ALWAYS_INLINE_R
0081 # define Vc_IS_UNLIKELY(x) __builtin_expect(x, 0)
0082 # define Vc_IS_LIKELY(x) __builtin_expect(x, 1)
0083 # define Vc_RESTRICT __restrict__
0084 # define Vc_DEPRECATED(msg)
0085 # define Vc_DEPRECATED_ALIAS(msg)
0086 # define Vc_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
0087 #elif defined(__GNUC__)
0088 # define Vc_UNREACHABLE __builtin_unreachable
0089 # if defined Vc_GCC && !defined __OPTIMIZE__
0090 # define Vc_MAY_ALIAS
0091 # else
0092 # define Vc_MAY_ALIAS __attribute__((__may_alias__))
0093 # endif
0094 # define Vc_INTRINSIC_R __attribute__((__always_inline__, __artificial__))
0095 # define Vc_INTRINSIC_L inline
0096 # define Vc_INTRINSIC Vc_INTRINSIC_L Vc_INTRINSIC_R
0097 # define Vc_FLATTEN __attribute__((__flatten__))
0098 # define Vc_ALWAYS_INLINE_L inline
0099 # define Vc_ALWAYS_INLINE_R __attribute__((__always_inline__))
0100 # define Vc_ALWAYS_INLINE Vc_ALWAYS_INLINE_L Vc_ALWAYS_INLINE_R
0101 # ifdef Vc_ICC
0102
0103 # define Vc_PURE
0104 # define Vc_CONST
0105 # define Vc_NEVER_INLINE
0106 # else
0107 # define Vc_NEVER_INLINE [[gnu::noinline]]
0108 # define Vc_PURE __attribute__((__pure__))
0109 # define Vc_CONST __attribute__((__const__))
0110 # endif
0111 # define Vc_CONST_L
0112 # define Vc_CONST_R Vc_CONST
0113 # define Vc_PURE_L
0114 # define Vc_PURE_R Vc_PURE
0115 # define Vc_IS_UNLIKELY(x) __builtin_expect(x, 0)
0116 # define Vc_IS_LIKELY(x) __builtin_expect(x, 1)
0117 # define Vc_RESTRICT __restrict__
0118 # ifdef Vc_ICC
0119 # define Vc_DEPRECATED(msg)
0120 # define Vc_DEPRECATED_ALIAS(msg)
0121 # else
0122 # define Vc_DEPRECATED(msg) __attribute__((__deprecated__(msg)))
0123 # define Vc_DEPRECATED_ALIAS(msg) __attribute__((__deprecated__(msg)))
0124 # endif
0125 # define Vc_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
0126 #else
0127 # define Vc_NEVER_INLINE
0128 # define Vc_FLATTEN
0129 # ifdef Vc_PURE
0130 # undef Vc_PURE
0131 # endif
0132 # define Vc_MAY_ALIAS
0133 # ifdef Vc_MSVC
0134 # define Vc_ALWAYS_INLINE inline __forceinline
0135 # define Vc_ALWAYS_INLINE_L Vc_ALWAYS_INLINE
0136 # define Vc_ALWAYS_INLINE_R
0137 # define Vc_CONST __declspec(noalias)
0138 # define Vc_CONST_L Vc_CONST
0139 # define Vc_CONST_R
0140 # define Vc_PURE
0141 # define Vc_PURE_L Vc_PURE
0142 # define Vc_PURE_R
0143 # define Vc_INTRINSIC inline __forceinline
0144 # define Vc_INTRINSIC_L Vc_INTRINSIC
0145 # define Vc_INTRINSIC_R
0146 namespace Vc_VERSIONED_NAMESPACE {
0147 namespace detail
0148 {
0149 static Vc_INTRINSIC void unreachable() { __assume(0); }
0150 }
0151 }
0152 # define Vc_UNREACHABLE Vc::detail::unreachable
0153 # else
0154 # define Vc_ALWAYS_INLINE
0155 # define Vc_ALWAYS_INLINE_L
0156 # define Vc_ALWAYS_INLINE_R
0157 # define Vc_CONST
0158 # define Vc_CONST_L
0159 # define Vc_CONST_R
0160 # define Vc_PURE
0161 # define Vc_PURE_L
0162 # define Vc_PURE_R
0163 # define Vc_INTRINSIC
0164 # define Vc_INTRINSIC_L
0165 # define Vc_INTRINSIC_R
0166 # define Vc_UNREACHABLE std::abort
0167 # endif
0168 # define Vc_IS_UNLIKELY(x) x
0169 # define Vc_IS_LIKELY(x) x
0170 # define Vc_RESTRICT __restrict
0171 # define Vc_DEPRECATED(msg) __declspec(deprecated(msg))
0172 # define Vc_DEPRECATED_ALIAS(msg)
0173 # define Vc_WARN_UNUSED_RESULT
0174 #endif
0175
0176 #ifdef Vc_CXX14
0177 #undef Vc_DEPRECATED
0178 #define Vc_DEPRECATED(msg_) [[deprecated(msg_)]]
0179 #endif
0180
0181 #define Vc_NOTHING_EXPECTING_SEMICOLON static_assert(true, "")
0182
0183 #define Vc_FREE_STORE_OPERATORS_ALIGNED(align_) \
0184 \
0185 \
0186 \
0187 Vc_ALWAYS_INLINE void *operator new(size_t size) \
0188 { \
0189 return Vc::Common::aligned_malloc<align_>(size); \
0190 } \
0191 \
0192 Vc_ALWAYS_INLINE void *operator new(size_t, void *p) { return p; } \
0193 \
0194 Vc_ALWAYS_INLINE void *operator new[](size_t size) \
0195 { \
0196 return Vc::Common::aligned_malloc<align_>(size); \
0197 } \
0198 \
0199 Vc_ALWAYS_INLINE void *operator new[](size_t, void *p) { return p; } \
0200 \
0201 Vc_ALWAYS_INLINE void operator delete(void *ptr, size_t) { Vc::Common::free(ptr); } \
0202 \
0203 Vc_ALWAYS_INLINE void operator delete(void *, void *) {} \
0204 \
0205 Vc_ALWAYS_INLINE void operator delete[](void *ptr, size_t) \
0206 { \
0207 Vc::Common::free(ptr); \
0208 } \
0209 \
0210 Vc_ALWAYS_INLINE void operator delete[](void *, void *) {} \
0211 \
0212 Vc_NOTHING_EXPECTING_SEMICOLON
0213
0214 #ifdef Vc_ASSERT
0215 #define Vc_EXTERNAL_ASSERT 1
0216 #else
0217 #ifdef NDEBUG
0218 #define Vc_ASSERT(x)
0219 #else
0220 #include <assert.h>
0221 #define Vc_ASSERT(x) assert(x);
0222 #endif
0223 #endif
0224
0225 #if defined Vc_CLANG || defined Vc_APPLECLANG
0226 #define Vc_HAS_BUILTIN(x) __has_builtin(x)
0227 #else
0228 #define Vc_HAS_BUILTIN(x) 0
0229 #endif
0230
0231 #define Vc_CAT_HELPER_(a, b, c, d) a##b##c##d
0232 #define Vc_CAT(a, b, c, d) Vc_CAT_HELPER_(a, b, c, d)
0233
0234 #define Vc_CAT_IMPL(a, b) a##b
0235 #define Vc_CAT2(a, b) Vc_CAT_IMPL(a, b)
0236
0237 #define Vc_APPLY_IMPL_1_(macro, a, b, c, d, e) macro(a)
0238 #define Vc_APPLY_IMPL_2_(macro, a, b, c, d, e) macro(a, b)
0239 #define Vc_APPLY_IMPL_3_(macro, a, b, c, d, e) macro(a, b, c)
0240 #define Vc_APPLY_IMPL_4_(macro, a, b, c, d, e) macro(a, b, c, d)
0241 #define Vc_APPLY_IMPL_5_(macro, a, b, c, d, e) macro(a, b, c, d, e)
0242
0243 #define Vc_LIST_FLOAT_VECTOR_TYPES(size, macro, a, b, c, d) \
0244 size(macro, double_v, a, b, c, d) \
0245 size(macro, float_v, a, b, c, d)
0246 #define Vc_LIST_INT_VECTOR_TYPES(size, macro, a, b, c, d) \
0247 size(macro, int_v, a, b, c, d) \
0248 size(macro, uint_v, a, b, c, d) \
0249 size(macro, short_v, a, b, c, d) \
0250 size(macro, ushort_v, a, b, c, d)
0251 #define Vc_LIST_VECTOR_TYPES(size, macro, a, b, c, d) \
0252 Vc_LIST_FLOAT_VECTOR_TYPES(size, macro, a, b, c, d) \
0253 Vc_LIST_INT_VECTOR_TYPES(size, macro, a, b, c, d)
0254 #define Vc_LIST_COMPARES(size, macro, a, b, c, d) \
0255 size(macro, ==, a, b, c, d) \
0256 size(macro, !=, a, b, c, d) \
0257 size(macro, <=, a, b, c, d) \
0258 size(macro, >=, a, b, c, d) \
0259 size(macro, < , a, b, c, d) \
0260 size(macro, > , a, b, c, d)
0261 #define Vc_LIST_LOGICAL(size, macro, a, b, c, d) \
0262 size(macro, &&, a, b, c, d) \
0263 size(macro, ||, a, b, c, d)
0264 #define Vc_LIST_BINARY(size, macro, a, b, c, d) \
0265 size(macro, |, a, b, c, d) \
0266 size(macro, &, a, b, c, d) \
0267 size(macro, ^, a, b, c, d)
0268 #define Vc_LIST_SHIFTS(size, macro, a, b, c, d) \
0269 size(macro, <<, a, b, c, d) \
0270 size(macro, >>, a, b, c, d)
0271 #define Vc_LIST_ARITHMETICS(size, macro, a, b, c, d) \
0272 size(macro, +, a, b, c, d) \
0273 size(macro, -, a, b, c, d) \
0274 size(macro, *, a, b, c, d) \
0275 size(macro, /, a, b, c, d) \
0276 size(macro, %, a, b, c, d)
0277
0278 #define Vc_APPLY_0(_list, macro) _list(Vc_APPLY_IMPL_1_, macro, 0, 0, 0, 0) Vc_NOTHING_EXPECTING_SEMICOLON
0279 #define Vc_APPLY_1(_list, macro, a) _list(Vc_APPLY_IMPL_2_, macro, a, 0, 0, 0) Vc_NOTHING_EXPECTING_SEMICOLON
0280 #define Vc_APPLY_2(_list, macro, a, b) _list(Vc_APPLY_IMPL_3_, macro, a, b, 0, 0) Vc_NOTHING_EXPECTING_SEMICOLON
0281 #define Vc_APPLY_3(_list, macro, a, b, c) _list(Vc_APPLY_IMPL_4_, macro, a, b, c, 0) Vc_NOTHING_EXPECTING_SEMICOLON
0282 #define Vc_APPLY_4(_list, macro, a, b, c, d) _list(Vc_APPLY_IMPL_5_, macro, a, b, c, d) Vc_NOTHING_EXPECTING_SEMICOLON
0283
0284 #define Vc_ALL_COMPARES(macro) Vc_APPLY_0(Vc_LIST_COMPARES, macro)
0285 #define Vc_ALL_LOGICAL(macro) Vc_APPLY_0(Vc_LIST_LOGICAL, macro)
0286 #define Vc_ALL_BINARY(macro) Vc_APPLY_0(Vc_LIST_BINARY, macro)
0287 #define Vc_ALL_SHIFTS(macro) Vc_APPLY_0(Vc_LIST_SHIFTS, macro)
0288 #define Vc_ALL_ARITHMETICS(macro) Vc_APPLY_0(Vc_LIST_ARITHMETICS, macro)
0289 #define Vc_ALL_FLOAT_VECTOR_TYPES(macro) Vc_APPLY_0(Vc_LIST_FLOAT_VECTOR_TYPES, macro)
0290 #define Vc_ALL_VECTOR_TYPES(macro) Vc_APPLY_0(Vc_LIST_VECTOR_TYPES, macro)
0291
0292 #define Vc_EXACT_TYPE(_test, _reference, _type) \
0293 typename std::enable_if<std::is_same<_test, _reference>::value, _type>::type
0294
0295 #define Vc_make_unique(name) Vc_CAT(Vc_,name,_,__LINE__)
0296
0297 #if defined(Vc_NO_NOEXCEPT)
0298 #define Vc_NOEXCEPT throw()
0299 #else
0300 #define Vc_NOEXCEPT noexcept
0301 #endif
0302
0303 #ifdef Vc_NO_ALWAYS_INLINE
0304 #undef Vc_ALWAYS_INLINE
0305 #undef Vc_ALWAYS_INLINE_L
0306 #undef Vc_ALWAYS_INLINE_R
0307 #define Vc_ALWAYS_INLINE inline
0308 #define Vc_ALWAYS_INLINE_L inline
0309 #define Vc_ALWAYS_INLINE_R
0310 #undef Vc_INTRINSIC
0311 #undef Vc_INTRINSIC_L
0312 #undef Vc_INTRINSIC_R
0313 #define Vc_INTRINSIC inline
0314 #define Vc_INTRINSIC_L inline
0315 #define Vc_INTRINSIC_R
0316 #endif
0317
0318 #endif