Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:25:47

0001 /*  This file is part of the Vc library. {{{
0002 Copyright © 2010-2015 Matthias Kretz <kretz@kde.org>
0003 
0004 Redistribution and use in source and binary forms, with or without
0005 modification, are permitted provided that the following conditions are met:
0006     * Redistributions of source code must retain the above copyright
0007       notice, this list of conditions and the following disclaimer.
0008     * Redistributions in binary form must reproduce the above copyright
0009       notice, this list of conditions and the following disclaimer in the
0010       documentation and/or other materials provided with the distribution.
0011     * Neither the names of contributing organizations nor the
0012       names of its contributors may be used to endorse or promote products
0013       derived from this software without specific prior written permission.
0014 
0015 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
0016 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
0017 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0018 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
0019 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0020 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
0021 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0022 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0023 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0024 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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  // the following is actually ill-formed according to C++1[14]
0041 #define Vc_ALIGNED_TYPEDEF(n_, type_, new_type_)                                      \
0042     using new_type_ alignas(sizeof(n_)) = type_
0043 #endif
0044 
0045 // On Windows (WIN32) we might see macros called min and max. Just undefine them and hope
0046 // noone (re)defines them (NOMINMAX should help).
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  // WIN32
0056 
0057 #if defined Vc_GCC && Vc_GCC >= 0x60000
0058 // GCC 6 drops all attributes on types passed as template arguments. This is important
0059 // if a may_alias gets lost and therefore needs to be readded in the implementation of
0060 // the class template.
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 // ICC miscompiles if there are functions marked as pure or const
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 /*Vc_CONST*/
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 }  // namespace detail
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     /**\name new/delete overloads for correct alignment */                               \
0185     /**@{*/                                                                              \
0186     /*!\brief Allocates correctly aligned memory */                                      \
0187     Vc_ALWAYS_INLINE void *operator new(size_t size)                                     \
0188     {                                                                                    \
0189         return Vc::Common::aligned_malloc<align_>(size);                                 \
0190     }                                                                                    \
0191     /*!\brief Returns \p p. */                                                           \
0192     Vc_ALWAYS_INLINE void *operator new(size_t, void *p) { return p; }                   \
0193     /*!\brief Allocates correctly aligned memory */                                      \
0194     Vc_ALWAYS_INLINE void *operator new[](size_t size)                                   \
0195     {                                                                                    \
0196         return Vc::Common::aligned_malloc<align_>(size);                                 \
0197     }                                                                                    \
0198     /*!\brief Returns \p p. */                                                           \
0199     Vc_ALWAYS_INLINE void *operator new[](size_t, void *p) { return p; }                 \
0200     /*!\brief Frees aligned memory. */                                                   \
0201     Vc_ALWAYS_INLINE void operator delete(void *ptr, size_t) { Vc::Common::free(ptr); }  \
0202     /*!\brief Does nothing. */                                                           \
0203     Vc_ALWAYS_INLINE void operator delete(void *, void *) {}                             \
0204     /*!\brief Frees aligned memory. */                                                   \
0205     Vc_ALWAYS_INLINE void operator delete[](void *ptr, size_t)                           \
0206     {                                                                                    \
0207         Vc::Common::free(ptr);                                                           \
0208     }                                                                                    \
0209     /*!\brief Does nothing. */                                                           \
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 // VC_COMMON_MACROS_H_