| 1 |
/* SPDX-License-Identifier: MIT |
| 2 |
* |
| 3 |
* Permission is hereby granted, free of charge, to any person |
| 4 |
* obtaining a copy of this software and associated documentation |
| 5 |
* files (the "Software"), to deal in the Software without |
| 6 |
* restriction, including without limitation the rights to use, copy, |
| 7 |
* modify, merge, publish, distribute, sublicense, and/or sell copies |
| 8 |
* of the Software, and to permit persons to whom the Software is |
| 9 |
* furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be |
| 12 |
* included in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 15 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 16 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 17 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 18 |
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 19 |
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 20 |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 |
* SOFTWARE. |
| 22 |
* |
| 23 |
* Copyright: |
| 24 |
* 2017-2020 Evan Nemerson <[email protected]> |
| 25 |
*/ |
| 26 |
|
| 27 |
#if !defined(SIMDE_COMMON_H) |
| 28 |
#define SIMDE_COMMON_H |
| 29 |
|
| 30 |
#include "hedley.h" |
| 31 |
|
| 32 |
#define SIMDE_VERSION_MAJOR 0 |
| 33 |
#define SIMDE_VERSION_MINOR 7 |
| 34 |
#define SIMDE_VERSION_MICRO 3 |
| 35 |
#define SIMDE_VERSION HEDLEY_VERSION_ENCODE(SIMDE_VERSION_MAJOR, SIMDE_VERSION_MINOR, SIMDE_VERSION_MICRO) |
| 36 |
// Also update meson.build in the root directory of the repository |
| 37 |
|
| 38 |
#include <stddef.h> |
| 39 |
#include <stdint.h> |
| 40 |
|
| 41 |
#include "simde-detect-clang.h" |
| 42 |
#include "simde-arch.h" |
| 43 |
#include "simde-features.h" |
| 44 |
#include "simde-diagnostic.h" |
| 45 |
#include "simde-math.h" |
| 46 |
#include "simde-constify.h" |
| 47 |
#include "simde-align.h" |
| 48 |
|
| 49 |
/* In some situations, SIMDe has to make large performance sacrifices |
| 50 |
* for small increases in how faithfully it reproduces an API, but |
| 51 |
* only a relatively small number of users will actually need the API |
| 52 |
* to be completely accurate. The SIMDE_FAST_* options can be used to |
| 53 |
* disable these trade-offs. |
| 54 |
* |
| 55 |
* They can be enabled by passing -DSIMDE_FAST_MATH to the compiler, or |
| 56 |
* the individual defines (e.g., -DSIMDE_FAST_NANS) if you only want to |
| 57 |
* enable some optimizations. Using -ffast-math and/or |
| 58 |
* -ffinite-math-only will also enable the relevant options. If you |
| 59 |
* don't want that you can pass -DSIMDE_NO_FAST_* to disable them. */ |
| 60 |
|
| 61 |
/* Most programs avoid NaNs by never passing values which can result in |
| 62 |
* a NaN; for example, if you only pass non-negative values to the sqrt |
| 63 |
* functions, it won't generate a NaN. On some platforms, similar |
| 64 |
* functions handle NaNs differently; for example, the _mm_min_ps SSE |
| 65 |
* function will return 0.0 if you pass it (0.0, NaN), but the NEON |
| 66 |
* vminq_f32 function will return NaN. Making them behave like one |
| 67 |
* another is expensive; it requires generating a mask of all lanes |
| 68 |
* with NaNs, then performing the operation (e.g., vminq_f32), then |
| 69 |
* blending together the result with another vector using the mask. |
| 70 |
* |
| 71 |
* If you don't want SIMDe to worry about the differences between how |
| 72 |
* NaNs are handled on the two platforms, define this (or pass |
| 73 |
* -ffinite-math-only) */ |
| 74 |
#if !defined(SIMDE_FAST_MATH) && !defined(SIMDE_NO_FAST_MATH) && defined(__FAST_MATH__) |
| 75 |
#define SIMDE_FAST_MATH |
| 76 |
#endif |
| 77 |
|
| 78 |
#if !defined(SIMDE_FAST_NANS) && !defined(SIMDE_NO_FAST_NANS) |
| 79 |
#if defined(SIMDE_FAST_MATH) |
| 80 |
#define SIMDE_FAST_NANS |
| 81 |
#elif defined(__FINITE_MATH_ONLY__) |
| 82 |
#if __FINITE_MATH_ONLY__ |
| 83 |
#define SIMDE_FAST_NANS |
| 84 |
#endif |
| 85 |
#endif |
| 86 |
#endif |
| 87 |
|
| 88 |
/* Many functions are defined as using the current rounding mode |
| 89 |
* (i.e., the SIMD version of fegetround()) when converting to |
| 90 |
* an integer. For example, _mm_cvtpd_epi32. Unfortunately, |
| 91 |
* on some platforms (such as ARMv8+ where round-to-nearest is |
| 92 |
* always used, regardless of the FPSCR register) this means we |
| 93 |
* have to first query the current rounding mode, then choose |
| 94 |
* the proper function (rounnd |
| 95 |
, ceil, floor, etc.) */ |
| 96 |
#if !defined(SIMDE_FAST_ROUND_MODE) && !defined(SIMDE_NO_FAST_ROUND_MODE) && defined(SIMDE_FAST_MATH) |
| 97 |
#define SIMDE_FAST_ROUND_MODE |
| 98 |
#endif |
| 99 |
|
| 100 |
/* This controls how ties are rounded. For example, does 10.5 round to |
| 101 |
* 10 or 11? IEEE 754 specifies round-towards-even, but ARMv7 (for |
| 102 |
* example) doesn't support it and it must be emulated (which is rather |
| 103 |
* slow). If you're okay with just using the default for whatever arch |
| 104 |
* you're on, you should definitely define this. |
| 105 |
* |
| 106 |
* Note that we don't use this macro to avoid correct implementations |
| 107 |
* in functions which are explicitly about rounding (such as vrnd* on |
| 108 |
* NEON, _mm_round_* on x86, etc.); it is only used for code where |
| 109 |
* rounding is a component in another function, and even then it isn't |
| 110 |
* usually a problem since such functions will use the current rounding |
| 111 |
* mode. */ |
| 112 |
#if !defined(SIMDE_FAST_ROUND_TIES) && !defined(SIMDE_NO_FAST_ROUND_TIES) && defined(SIMDE_FAST_MATH) |
| 113 |
#define SIMDE_FAST_ROUND_TIES |
| 114 |
#endif |
| 115 |
|
| 116 |
/* For functions which convert from one type to another (mostly from |
| 117 |
* floating point to integer types), sometimes we need to do a range |
| 118 |
* check and potentially return a different result if the value |
| 119 |
* falls outside that range. Skipping this check can provide a |
| 120 |
* performance boost, at the expense of faithfulness to the API we're |
| 121 |
* emulating. */ |
| 122 |
#if !defined(SIMDE_FAST_CONVERSION_RANGE) && !defined(SIMDE_NO_FAST_CONVERSION_RANGE) && defined(SIMDE_FAST_MATH) |
| 123 |
#define SIMDE_FAST_CONVERSION_RANGE |
| 124 |
#endif |
| 125 |
|
| 126 |
/* Due to differences across platforms, sometimes it can be much |
| 127 |
* faster for us to allow spurious floating point exceptions, |
| 128 |
* or to no generate them when we should. */ |
| 129 |
#if !defined(SIMDE_FAST_EXCEPTIONS) && !defined(SIMDE_NO_FAST_EXCEPTIONS) && defined(SIMDE_FAST_MATH) |
| 130 |
#define SIMDE_FAST_EXCEPTIONS |
| 131 |
#endif |
| 132 |
|
| 133 |
#if \ |
| 134 |
HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ |
| 135 |
HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ |
| 136 |
HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
| 137 |
HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ |
| 138 |
HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
| 139 |
HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ |
| 140 |
HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ |
| 141 |
(HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ |
| 142 |
HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ |
| 143 |
HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
| 144 |
#define SIMDE_CHECK_CONSTANT_(expr) (__builtin_constant_p(expr)) |
| 145 |
#elif defined(__cplusplus) && (__cplusplus > 201703L) |
| 146 |
#include <type_traits> |
| 147 |
#define SIMDE_CHECK_CONSTANT_(expr) (std::is_constant_evaluated()) |
| 148 |
#endif |
| 149 |
|
| 150 |
#if !defined(SIMDE_NO_CHECK_IMMEDIATE_CONSTANT) |
| 151 |
#if defined(SIMDE_CHECK_CONSTANT_) && \ |
| 152 |
SIMDE_DETECT_CLANG_VERSION_CHECK(9,0,0) && \ |
| 153 |
(!defined(__apple_build_version__) || ((__apple_build_version__ < 11000000) || (__apple_build_version__ >= 12000000))) |
| 154 |
#define SIMDE_REQUIRE_CONSTANT(arg) HEDLEY_REQUIRE_MSG(SIMDE_CHECK_CONSTANT_(arg), "`" #arg "' must be constant") |
| 155 |
#else |
| 156 |
#define SIMDE_REQUIRE_CONSTANT(arg) |
| 157 |
#endif |
| 158 |
#else |
| 159 |
#define SIMDE_REQUIRE_CONSTANT(arg) |
| 160 |
#endif |
| 161 |
|
| 162 |
#define SIMDE_REQUIRE_RANGE(arg, min, max) \ |
| 163 |
HEDLEY_REQUIRE_MSG((((arg) >= (min)) && ((arg) <= (max))), "'" #arg "' must be in [" #min ", " #max "]") |
| 164 |
|
| 165 |
#define SIMDE_REQUIRE_CONSTANT_RANGE(arg, min, max) \ |
| 166 |
SIMDE_REQUIRE_CONSTANT(arg) \ |
| 167 |
SIMDE_REQUIRE_RANGE(arg, min, max) |
| 168 |
|
| 169 |
/* A copy of HEDLEY_STATIC_ASSERT, except we don't define an empty |
| 170 |
* fallback if we can't find an implementation; instead we have to |
| 171 |
* check if SIMDE_STATIC_ASSERT is defined before using it. */ |
| 172 |
#if \ |
| 173 |
!defined(__cplusplus) && ( \ |
| 174 |
(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ |
| 175 |
HEDLEY_HAS_FEATURE(c_static_assert) || \ |
| 176 |
HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ |
| 177 |
HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
| 178 |
defined(_Static_assert) \ |
| 179 |
) |
| 180 |
/* Sometimes _Static_assert is defined (in cdefs.h) using a symbol which |
| 181 |
* starts with a double-underscore. This is a system header so we have no |
| 182 |
* control over it, but since it's a macro it will emit a diagnostic which |
| 183 |
* prevents compilation with -Werror. */ |
| 184 |
#if HEDLEY_HAS_WARNING("-Wreserved-identifier") |
| 185 |
#define SIMDE_STATIC_ASSERT(expr, message) (__extension__({ \ |
| 186 |
HEDLEY_DIAGNOSTIC_PUSH \ |
| 187 |
_Pragma("clang diagnostic ignored \"-Wreserved-identifier\"") \ |
| 188 |
_Static_assert(expr, message); \ |
| 189 |
HEDLEY_DIAGNOSTIC_POP \ |
| 190 |
})) |
| 191 |
#else |
| 192 |
#define SIMDE_STATIC_ASSERT(expr, message) _Static_assert(expr, message) |
| 193 |
#endif |
| 194 |
#elif \ |
| 195 |
(defined(__cplusplus) && (__cplusplus >= 201103L)) || \ |
| 196 |
HEDLEY_MSVC_VERSION_CHECK(16,0,0) |
| 197 |
#define SIMDE_STATIC_ASSERT(expr, message) HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) |
| 198 |
#endif |
| 199 |
|
| 200 |
/* Statement exprs */ |
| 201 |
#if \ |
| 202 |
HEDLEY_GNUC_VERSION_CHECK(2,95,0) || \ |
| 203 |
HEDLEY_TINYC_VERSION_CHECK(0,9,26) || \ |
| 204 |
HEDLEY_INTEL_VERSION_CHECK(9,0,0) || \ |
| 205 |
HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ |
| 206 |
HEDLEY_SUNPRO_VERSION_CHECK(5,12,0) || \ |
| 207 |
HEDLEY_IBM_VERSION_CHECK(11,1,0) || \ |
| 208 |
HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
| 209 |
#define SIMDE_STATEMENT_EXPR_(expr) (__extension__ expr) |
| 210 |
#endif |
| 211 |
|
| 212 |
/* This is just a convenience macro to make it easy to call a single |
| 213 |
* function with a specific diagnostic disabled. */ |
| 214 |
#if defined(SIMDE_STATEMENT_EXPR_) |
| 215 |
#define SIMDE_DISABLE_DIAGNOSTIC_EXPR_(diagnostic, expr) \ |
| 216 |
SIMDE_STATEMENT_EXPR_(({ \ |
| 217 |
HEDLEY_DIAGNOSTIC_PUSH \ |
| 218 |
diagnostic \ |
| 219 |
(expr); \ |
| 220 |
HEDLEY_DIAGNOSTIC_POP \ |
| 221 |
})) |
| 222 |
#endif |
| 223 |
|
| 224 |
#if defined(SIMDE_CHECK_CONSTANT_) && defined(SIMDE_STATIC_ASSERT) |
| 225 |
#define SIMDE_ASSERT_CONSTANT_(v) SIMDE_STATIC_ASSERT(SIMDE_CHECK_CONSTANT_(v), #v " must be constant.") |
| 226 |
#endif |
| 227 |
|
| 228 |
#if \ |
| 229 |
(HEDLEY_HAS_ATTRIBUTE(may_alias) && !defined(HEDLEY_SUNPRO_VERSION)) || \ |
| 230 |
HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ |
| 231 |
HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
| 232 |
HEDLEY_IBM_VERSION_CHECK(13,1,0) |
| 233 |
# define SIMDE_MAY_ALIAS __attribute__((__may_alias__)) |
| 234 |
#else |
| 235 |
# define SIMDE_MAY_ALIAS |
| 236 |
#endif |
| 237 |
|
| 238 |
/* Lots of compilers support GCC-style vector extensions, but many |
| 239 |
don't support all the features. Define different macros depending |
| 240 |
on support for |
| 241 |
|
| 242 |
* SIMDE_VECTOR - Declaring a vector. |
| 243 |
* SIMDE_VECTOR_OPS - basic operations (binary and unary). |
| 244 |
* SIMDE_VECTOR_NEGATE - negating a vector |
| 245 |
* SIMDE_VECTOR_SCALAR - For binary operators, the second argument |
| 246 |
can be a scalar, in which case the result is as if that scalar |
| 247 |
had been broadcast to all lanes of a vector. |
| 248 |
* SIMDE_VECTOR_SUBSCRIPT - Supports array subscript notation for |
| 249 |
extracting/inserting a single element.= |
| 250 |
|
| 251 |
SIMDE_VECTOR can be assumed if any others are defined, the |
| 252 |
others are independent. */ |
| 253 |
#if !defined(SIMDE_NO_VECTOR) |
| 254 |
# if \ |
| 255 |
HEDLEY_GCC_VERSION_CHECK(4,8,0) |
| 256 |
# define SIMDE_VECTOR(size) __attribute__((__vector_size__(size))) |
| 257 |
# define SIMDE_VECTOR_OPS |
| 258 |
# define SIMDE_VECTOR_NEGATE |
| 259 |
# define SIMDE_VECTOR_SCALAR |
| 260 |
# define SIMDE_VECTOR_SUBSCRIPT |
| 261 |
# elif HEDLEY_INTEL_VERSION_CHECK(16,0,0) |
| 262 |
# define SIMDE_VECTOR(size) __attribute__((__vector_size__(size))) |
| 263 |
# define SIMDE_VECTOR_OPS |
| 264 |
# define SIMDE_VECTOR_NEGATE |
| 265 |
/* ICC only supports SIMDE_VECTOR_SCALAR for constants */ |
| 266 |
# define SIMDE_VECTOR_SUBSCRIPT |
| 267 |
# elif \ |
| 268 |
HEDLEY_GCC_VERSION_CHECK(4,1,0) || \ |
| 269 |
HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
| 270 |
HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
| 271 |
# define SIMDE_VECTOR(size) __attribute__((__vector_size__(size))) |
| 272 |
# define SIMDE_VECTOR_OPS |
| 273 |
# elif HEDLEY_SUNPRO_VERSION_CHECK(5,12,0) |
| 274 |
# define SIMDE_VECTOR(size) __attribute__((__vector_size__(size))) |
| 275 |
# elif HEDLEY_HAS_ATTRIBUTE(vector_size) |
| 276 |
# define SIMDE_VECTOR(size) __attribute__((__vector_size__(size))) |
| 277 |
# define SIMDE_VECTOR_OPS |
| 278 |
# define SIMDE_VECTOR_NEGATE |
| 279 |
# define SIMDE_VECTOR_SUBSCRIPT |
| 280 |
# if SIMDE_DETECT_CLANG_VERSION_CHECK(5,0,0) |
| 281 |
# define SIMDE_VECTOR_SCALAR |
| 282 |
# endif |
| 283 |
# endif |
| 284 |
|
| 285 |
/* GCC and clang have built-in functions to handle shuffling and |
| 286 |
converting of vectors, but the implementations are slightly |
| 287 |
different. This macro is just an abstraction over them. Note that |
| 288 |
elem_size is in bits but vec_size is in bytes. */ |
| 289 |
# if !defined(SIMDE_NO_SHUFFLE_VECTOR) && defined(SIMDE_VECTOR_SUBSCRIPT) |
| 290 |
HEDLEY_DIAGNOSTIC_PUSH |
| 291 |
/* We don't care about -Wvariadic-macros; all compilers that support |
| 292 |
* shufflevector/shuffle support them. */ |
| 293 |
# if HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") |
| 294 |
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic" |
| 295 |
# endif |
| 296 |
# if HEDLEY_HAS_WARNING("-Wvariadic-macros") || HEDLEY_GCC_VERSION_CHECK(4,0,0) |
| 297 |
# pragma GCC diagnostic ignored "-Wvariadic-macros" |
| 298 |
# endif |
| 299 |
|
| 300 |
# if HEDLEY_HAS_BUILTIN(__builtin_shufflevector) |
| 301 |
# define SIMDE_SHUFFLE_VECTOR_(elem_size, vec_size, a, b, ...) __builtin_shufflevector(a, b, __VA_ARGS__) |
| 302 |
# elif HEDLEY_GCC_HAS_BUILTIN(__builtin_shuffle,4,7,0) && !defined(__INTEL_COMPILER) |
| 303 |
# define SIMDE_SHUFFLE_VECTOR_(elem_size, vec_size, a, b, ...) (__extension__ ({ \ |
| 304 |
int##elem_size##_t SIMDE_VECTOR(vec_size) simde_shuffle_ = { __VA_ARGS__ }; \ |
| 305 |
__builtin_shuffle(a, b, simde_shuffle_); \ |
| 306 |
})) |
| 307 |
# endif |
| 308 |
HEDLEY_DIAGNOSTIC_POP |
| 309 |
# endif |
| 310 |
|
| 311 |
/* TODO: this actually works on XL C/C++ without SIMDE_VECTOR_SUBSCRIPT |
| 312 |
but the code needs to be refactored a bit to take advantage. */ |
| 313 |
# if !defined(SIMDE_NO_CONVERT_VECTOR) && defined(SIMDE_VECTOR_SUBSCRIPT) |
| 314 |
# if HEDLEY_HAS_BUILTIN(__builtin_convertvector) || HEDLEY_GCC_VERSION_CHECK(9,0,0) |
| 315 |
# if HEDLEY_GCC_VERSION_CHECK(9,0,0) && !HEDLEY_GCC_VERSION_CHECK(9,3,0) |
| 316 |
/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93557 */ |
| 317 |
# define SIMDE_CONVERT_VECTOR_(to, from) ((to) = (__extension__({ \ |
| 318 |
__typeof__(from) from_ = (from); \ |
| 319 |
((void) from_); \ |
| 320 |
__builtin_convertvector(from_, __typeof__(to)); \ |
| 321 |
}))) |
| 322 |
# else |
| 323 |
# define SIMDE_CONVERT_VECTOR_(to, from) ((to) = __builtin_convertvector((from), __typeof__(to))) |
| 324 |
# endif |
| 325 |
# endif |
| 326 |
# endif |
| 327 |
#endif |
| 328 |
|
| 329 |
/* Since we currently require SUBSCRIPT before using a vector in a |
| 330 |
union, we define these as dependencies of SUBSCRIPT. They are |
| 331 |
likely to disappear in the future, once SIMDe learns how to make |
| 332 |
use of vectors without using the union members. Do not use them |
| 333 |
in your code unless you're okay with it breaking when SIMDe |
| 334 |
changes. */ |
| 335 |
#if defined(SIMDE_VECTOR_SUBSCRIPT) |
| 336 |
# if defined(SIMDE_VECTOR_OPS) |
| 337 |
# define SIMDE_VECTOR_SUBSCRIPT_OPS |
| 338 |
# endif |
| 339 |
# if defined(SIMDE_VECTOR_SCALAR) |
| 340 |
# define SIMDE_VECTOR_SUBSCRIPT_SCALAR |
| 341 |
# endif |
| 342 |
#endif |
| 343 |
|
| 344 |
#if !defined(SIMDE_DISABLE_OPENMP) |
| 345 |
#if !defined(SIMDE_ENABLE_OPENMP) && ((defined(_OPENMP) && (_OPENMP >= 201307L)) || (defined(_OPENMP_SIMD) && (_OPENMP_SIMD >= 201307L))) || defined(HEDLEY_MCST_LCC_VERSION) |
| 346 |
#define SIMDE_ENABLE_OPENMP |
| 347 |
#endif |
| 348 |
#endif |
| 349 |
|
| 350 |
#if !defined(SIMDE_ENABLE_CILKPLUS) && (defined(__cilk) || defined(HEDLEY_INTEL_VERSION)) |
| 351 |
# define SIMDE_ENABLE_CILKPLUS |
| 352 |
#endif |
| 353 |
|
| 354 |
#if defined(SIMDE_ENABLE_OPENMP) |
| 355 |
# define SIMDE_VECTORIZE HEDLEY_PRAGMA(omp simd) |
| 356 |
# define SIMDE_VECTORIZE_SAFELEN(l) HEDLEY_PRAGMA(omp simd safelen(l)) |
| 357 |
# if defined(__clang__) |
| 358 |
# define SIMDE_VECTORIZE_REDUCTION(r) \ |
| 359 |
HEDLEY_DIAGNOSTIC_PUSH \ |
| 360 |
_Pragma("clang diagnostic ignored \"-Wsign-conversion\"") \ |
| 361 |
HEDLEY_PRAGMA(omp simd reduction(r)) \ |
| 362 |
HEDLEY_DIAGNOSTIC_POP |
| 363 |
# else |
| 364 |
# define SIMDE_VECTORIZE_REDUCTION(r) HEDLEY_PRAGMA(omp simd reduction(r)) |
| 365 |
# endif |
| 366 |
# if !defined(HEDLEY_MCST_LCC_VERSION) |
| 367 |
# define SIMDE_VECTORIZE_ALIGNED(a) HEDLEY_PRAGMA(omp simd aligned(a)) |
| 368 |
# else |
| 369 |
# define SIMDE_VECTORIZE_ALIGNED(a) HEDLEY_PRAGMA(omp simd) |
| 370 |
# endif |
| 371 |
#elif defined(SIMDE_ENABLE_CILKPLUS) |
| 372 |
# define SIMDE_VECTORIZE HEDLEY_PRAGMA(simd) |
| 373 |
# define SIMDE_VECTORIZE_SAFELEN(l) HEDLEY_PRAGMA(simd vectorlength(l)) |
| 374 |
# define SIMDE_VECTORIZE_REDUCTION(r) HEDLEY_PRAGMA(simd reduction(r)) |
| 375 |
# define SIMDE_VECTORIZE_ALIGNED(a) HEDLEY_PRAGMA(simd aligned(a)) |
| 376 |
#elif defined(__clang__) && !defined(HEDLEY_IBM_VERSION) |
| 377 |
# define SIMDE_VECTORIZE HEDLEY_PRAGMA(clang loop vectorize(enable)) |
| 378 |
# define SIMDE_VECTORIZE_SAFELEN(l) HEDLEY_PRAGMA(clang loop vectorize_width(l)) |
| 379 |
# define SIMDE_VECTORIZE_REDUCTION(r) SIMDE_VECTORIZE |
| 380 |
# define SIMDE_VECTORIZE_ALIGNED(a) |
| 381 |
#elif HEDLEY_GCC_VERSION_CHECK(4,9,0) |
| 382 |
# define SIMDE_VECTORIZE HEDLEY_PRAGMA(GCC ivdep) |
| 383 |
# define SIMDE_VECTORIZE_SAFELEN(l) SIMDE_VECTORIZE |
| 384 |
# define SIMDE_VECTORIZE_REDUCTION(r) SIMDE_VECTORIZE |
| 385 |
# define SIMDE_VECTORIZE_ALIGNED(a) |
| 386 |
#elif HEDLEY_CRAY_VERSION_CHECK(5,0,0) |
| 387 |
# define SIMDE_VECTORIZE HEDLEY_PRAGMA(_CRI ivdep) |
| 388 |
# define SIMDE_VECTORIZE_SAFELEN(l) SIMDE_VECTORIZE |
| 389 |
# define SIMDE_VECTORIZE_REDUCTION(r) SIMDE_VECTORIZE |
| 390 |
# define SIMDE_VECTORIZE_ALIGNED(a) |
| 391 |
#else |
| 392 |
# define SIMDE_VECTORIZE |
| 393 |
# define SIMDE_VECTORIZE_SAFELEN(l) |
| 394 |
# define SIMDE_VECTORIZE_REDUCTION(r) |
| 395 |
# define SIMDE_VECTORIZE_ALIGNED(a) |
| 396 |
#endif |
| 397 |
|
| 398 |
#define SIMDE_MASK_NZ_(v, mask) (((v) & (mask)) | !((v) & (mask))) |
| 399 |
|
| 400 |
/* Intended for checking coverage, you should never use this in |
| 401 |
production. */ |
| 402 |
#if defined(SIMDE_NO_INLINE) |
| 403 |
# define SIMDE_FUNCTION_ATTRIBUTES HEDLEY_NEVER_INLINE static |
| 404 |
#else |
| 405 |
# define SIMDE_FUNCTION_ATTRIBUTES HEDLEY_ALWAYS_INLINE static |
| 406 |
#endif |
| 407 |
|
| 408 |
#if defined(SIMDE_NO_INLINE) |
| 409 |
# define SIMDE_HUGE_FUNCTION_ATTRIBUTES HEDLEY_NEVER_INLINE static |
| 410 |
#elif defined(SIMDE_CONSTRAINED_COMPILATION) |
| 411 |
# define SIMDE_HUGE_FUNCTION_ATTRIBUTES static |
| 412 |
#else |
| 413 |
# define SIMDE_HUGE_FUNCTION_ATTRIBUTES HEDLEY_ALWAYS_INLINE static |
| 414 |
#endif |
| 415 |
|
| 416 |
#if \ |
| 417 |
HEDLEY_HAS_ATTRIBUTE(unused) || \ |
| 418 |
HEDLEY_GCC_VERSION_CHECK(2,95,0) |
| 419 |
# define SIMDE_FUNCTION_POSSIBLY_UNUSED_ __attribute__((__unused__)) |
| 420 |
#else |
| 421 |
# define SIMDE_FUNCTION_POSSIBLY_UNUSED_ |
| 422 |
#endif |
| 423 |
|
| 424 |
HEDLEY_DIAGNOSTIC_PUSH |
| 425 |
SIMDE_DIAGNOSTIC_DISABLE_USED_BUT_MARKED_UNUSED_ |
| 426 |
|
| 427 |
#if defined(_MSC_VER) |
| 428 |
# define SIMDE_BEGIN_DECLS_ HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(disable:4996 4204)) HEDLEY_BEGIN_C_DECLS |
| 429 |
# define SIMDE_END_DECLS_ HEDLEY_DIAGNOSTIC_POP HEDLEY_END_C_DECLS |
| 430 |
#else |
| 431 |
# define SIMDE_BEGIN_DECLS_ \ |
| 432 |
HEDLEY_DIAGNOSTIC_PUSH \ |
| 433 |
SIMDE_DIAGNOSTIC_DISABLE_USED_BUT_MARKED_UNUSED_ \ |
| 434 |
HEDLEY_BEGIN_C_DECLS |
| 435 |
# define SIMDE_END_DECLS_ \ |
| 436 |
HEDLEY_END_C_DECLS \ |
| 437 |
HEDLEY_DIAGNOSTIC_POP |
| 438 |
#endif |
| 439 |
|
| 440 |
#if defined(__SIZEOF_INT128__) |
| 441 |
# define SIMDE_HAVE_INT128_ |
| 442 |
HEDLEY_DIAGNOSTIC_PUSH |
| 443 |
SIMDE_DIAGNOSTIC_DISABLE_PEDANTIC_ |
| 444 |
typedef __int128 simde_int128; |
| 445 |
typedef unsigned __int128 simde_uint128; |
| 446 |
HEDLEY_DIAGNOSTIC_POP |
| 447 |
#endif |
| 448 |
|
| 449 |
#if !defined(SIMDE_ENDIAN_LITTLE) |
| 450 |
# define SIMDE_ENDIAN_LITTLE 1234 |
| 451 |
#endif |
| 452 |
#if !defined(SIMDE_ENDIAN_BIG) |
| 453 |
# define SIMDE_ENDIAN_BIG 4321 |
| 454 |
#endif |
| 455 |
|
| 456 |
#if !defined(SIMDE_ENDIAN_ORDER) |
| 457 |
/* GCC (and compilers masquerading as GCC) define __BYTE_ORDER__. */ |
| 458 |
# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) |
| 459 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_LITTLE |
| 460 |
# elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) |
| 461 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_BIG |
| 462 |
/* TI defines _BIG_ENDIAN or _LITTLE_ENDIAN */ |
| 463 |
# elif defined(_BIG_ENDIAN) |
| 464 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_BIG |
| 465 |
# elif defined(_LITTLE_ENDIAN) |
| 466 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_LITTLE |
| 467 |
/* We know the endianness of some common architectures. Common |
| 468 |
* architectures not listed (ARM, POWER, MIPS, etc.) here are |
| 469 |
* bi-endian. */ |
| 470 |
# elif defined(__amd64) || defined(_M_X64) || defined(__i386) || defined(_M_IX86) |
| 471 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_LITTLE |
| 472 |
# elif defined(__s390x__) || defined(__zarch__) |
| 473 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_BIG |
| 474 |
/* Looks like we'll have to rely on the platform. If we're missing a |
| 475 |
* platform, please let us know. */ |
| 476 |
# elif defined(_WIN32) |
| 477 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_LITTLE |
| 478 |
# elif defined(sun) || defined(__sun) /* Solaris */ |
| 479 |
# include <sys/byteorder.h> |
| 480 |
# if defined(_LITTLE_ENDIAN) |
| 481 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_LITTLE |
| 482 |
# elif defined(_BIG_ENDIAN) |
| 483 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_BIG |
| 484 |
# endif |
| 485 |
# elif defined(__APPLE__) |
| 486 |
# include <libkern/OSByteOrder.h> |
| 487 |
# if defined(__LITTLE_ENDIAN__) |
| 488 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_LITTLE |
| 489 |
# elif defined(__BIG_ENDIAN__) |
| 490 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_BIG |
| 491 |
# endif |
| 492 |
# elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(BSD) |
| 493 |
# include <machine/endian.h> |
| 494 |
# if defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN) |
| 495 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_LITTLE |
| 496 |
# elif defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN) |
| 497 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_BIG |
| 498 |
# endif |
| 499 |
# elif defined(__linux__) || defined(__linux) || defined(__gnu_linux__) |
| 500 |
# include <endian.h> |
| 501 |
# if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN) |
| 502 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_LITTLE |
| 503 |
# elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN) |
| 504 |
# define SIMDE_ENDIAN_ORDER SIMDE_ENDIAN_BIG |
| 505 |
# endif |
| 506 |
# endif |
| 507 |
#endif |
| 508 |
|
| 509 |
#if \ |
| 510 |
HEDLEY_HAS_BUILTIN(__builtin_bswap64) || \ |
| 511 |
HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ |
| 512 |
HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ |
| 513 |
HEDLEY_INTEL_VERSION_CHECK(13,0,0) |
| 514 |
#define simde_bswap64(v) __builtin_bswap64(v) |
| 515 |
#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) |
| 516 |
#define simde_bswap64(v) _byteswap_uint64(v) |
| 517 |
#else |
| 518 |
SIMDE_FUNCTION_ATTRIBUTES |
| 519 |
uint64_t |
| 520 |
simde_bswap64(uint64_t v) { |
| 521 |
return |
| 522 |
((v & (((uint64_t) 0xff) << 56)) >> 56) | |
| 523 |
((v & (((uint64_t) 0xff) << 48)) >> 40) | |
| 524 |
((v & (((uint64_t) 0xff) << 40)) >> 24) | |
| 525 |
((v & (((uint64_t) 0xff) << 32)) >> 8) | |
| 526 |
((v & (((uint64_t) 0xff) << 24)) << 8) | |
| 527 |
((v & (((uint64_t) 0xff) << 16)) << 24) | |
| 528 |
((v & (((uint64_t) 0xff) << 8)) << 40) | |
| 529 |
((v & (((uint64_t) 0xff) )) << 56); |
| 530 |
} |
| 531 |
#endif |
| 532 |
|
| 533 |
#if !defined(SIMDE_ENDIAN_ORDER) |
| 534 |
# error Unknown byte order; please file a bug |
| 535 |
#else |
| 536 |
# if SIMDE_ENDIAN_ORDER == SIMDE_ENDIAN_LITTLE |
| 537 |
# define simde_endian_bswap64_be(value) simde_bswap64(value) |
| 538 |
# define simde_endian_bswap64_le(value) (value) |
| 539 |
# elif SIMDE_ENDIAN_ORDER == SIMDE_ENDIAN_BIG |
| 540 |
# define simde_endian_bswap64_be(value) (value) |
| 541 |
# define simde_endian_bswap64_le(value) simde_bswap64(value) |
| 542 |
# endif |
| 543 |
#endif |
| 544 |
|
| 545 |
/* TODO: we should at least make an attempt to detect the correct |
| 546 |
types for simde_float32/float64 instead of just assuming float and |
| 547 |
double. */ |
| 548 |
|
| 549 |
#if !defined(SIMDE_FLOAT32_TYPE) |
| 550 |
# define SIMDE_FLOAT32_TYPE float |
| 551 |
# define SIMDE_FLOAT32_C(value) value##f |
| 552 |
#else |
| 553 |
# define SIMDE_FLOAT32_C(value) ((SIMDE_FLOAT32_TYPE) value) |
| 554 |
#endif |
| 555 |
typedef SIMDE_FLOAT32_TYPE simde_float32; |
| 556 |
|
| 557 |
#if !defined(SIMDE_FLOAT64_TYPE) |
| 558 |
# define SIMDE_FLOAT64_TYPE double |
| 559 |
# define SIMDE_FLOAT64_C(value) value |
| 560 |
#else |
| 561 |
# define SIMDE_FLOAT64_C(value) ((SIMDE_FLOAT64_TYPE) value) |
| 562 |
#endif |
| 563 |
typedef SIMDE_FLOAT64_TYPE simde_float64; |
| 564 |
|
| 565 |
#if defined(__cplusplus) |
| 566 |
typedef bool simde_bool; |
| 567 |
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) |
| 568 |
typedef _Bool simde_bool; |
| 569 |
#elif defined(bool) |
| 570 |
typedef bool simde_bool; |
| 571 |
#else |
| 572 |
#include <stdbool.h> |
| 573 |
typedef bool simde_bool; |
| 574 |
#endif |
| 575 |
|
| 576 |
#if HEDLEY_HAS_WARNING("-Wbad-function-cast") |
| 577 |
# define SIMDE_CONVERT_FTOI(T,v) \ |
| 578 |
HEDLEY_DIAGNOSTIC_PUSH \ |
| 579 |
_Pragma("clang diagnostic ignored \"-Wbad-function-cast\"") \ |
| 580 |
HEDLEY_STATIC_CAST(T, (v)) \ |
| 581 |
HEDLEY_DIAGNOSTIC_POP |
| 582 |
#else |
| 583 |
# define SIMDE_CONVERT_FTOI(T,v) ((T) (v)) |
| 584 |
#endif |
| 585 |
|
| 586 |
/* TODO: detect compilers which support this outside of C11 mode */ |
| 587 |
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) |
| 588 |
#define SIMDE_CHECKED_REINTERPRET_CAST(to, from, value) _Generic((value), to: (value), default: (_Generic((value), from: ((to) (value))))) |
| 589 |
#define SIMDE_CHECKED_STATIC_CAST(to, from, value) _Generic((value), to: (value), default: (_Generic((value), from: ((to) (value))))) |
| 590 |
#else |
| 591 |
#define SIMDE_CHECKED_REINTERPRET_CAST(to, from, value) HEDLEY_REINTERPRET_CAST(to, value) |
| 592 |
#define SIMDE_CHECKED_STATIC_CAST(to, from, value) HEDLEY_STATIC_CAST(to, value) |
| 593 |
#endif |
| 594 |
|
| 595 |
#if HEDLEY_HAS_WARNING("-Wfloat-equal") |
| 596 |
# define SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL _Pragma("clang diagnostic ignored \"-Wfloat-equal\"") |
| 597 |
#elif HEDLEY_GCC_VERSION_CHECK(3,0,0) |
| 598 |
# define SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"") |
| 599 |
#else |
| 600 |
# define SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL |
| 601 |
#endif |
| 602 |
|
| 603 |
/* Some functions can trade accuracy for speed. For those functions |
| 604 |
you can control the trade-off using this macro. Possible values: |
| 605 |
|
| 606 |
0: prefer speed |
| 607 |
1: reasonable trade-offs |
| 608 |
2: prefer accuracy */ |
| 609 |
#if !defined(SIMDE_ACCURACY_PREFERENCE) |
| 610 |
# define SIMDE_ACCURACY_PREFERENCE 1 |
| 611 |
#endif |
| 612 |
|
| 613 |
#if defined(__STDC_HOSTED__) |
| 614 |
# define SIMDE_STDC_HOSTED __STDC_HOSTED__ |
| 615 |
#else |
| 616 |
# if \ |
| 617 |
defined(HEDLEY_PGI_VERSION) || \ |
| 618 |
defined(HEDLEY_MSVC_VERSION) |
| 619 |
# define SIMDE_STDC_HOSTED 1 |
| 620 |
# else |
| 621 |
# define SIMDE_STDC_HOSTED 0 |
| 622 |
# endif |
| 623 |
#endif |
| 624 |
|
| 625 |
/* Try to deal with environments without a standard library. */ |
| 626 |
#if !defined(simde_memcpy) |
| 627 |
#if HEDLEY_HAS_BUILTIN(__builtin_memcpy) |
| 628 |
#define simde_memcpy(dest, src, n) __builtin_memcpy(dest, src, n) |
| 629 |
#endif |
| 630 |
#endif |
| 631 |
#if !defined(simde_memset) |
| 632 |
#if HEDLEY_HAS_BUILTIN(__builtin_memset) |
| 633 |
#define simde_memset(s, c, n) __builtin_memset(s, c, n) |
| 634 |
#endif |
| 635 |
#endif |
| 636 |
#if !defined(simde_memcmp) |
| 637 |
#if HEDLEY_HAS_BUILTIN(__builtin_memcmp) |
| 638 |
#define simde_memcmp(s1, s2, n) __builtin_memcmp(s1, s2, n) |
| 639 |
#endif |
| 640 |
#endif |
| 641 |
|
| 642 |
#if !defined(simde_memcpy) || !defined(simde_memset) || !defined(simde_memcmp) |
| 643 |
#if !defined(SIMDE_NO_STRING_H) |
| 644 |
#if defined(__has_include) |
| 645 |
#if !__has_include(<string.h>) |
| 646 |
#define SIMDE_NO_STRING_H |
| 647 |
#endif |
| 648 |
#elif (SIMDE_STDC_HOSTED == 0) |
| 649 |
#define SIMDE_NO_STRING_H |
| 650 |
#endif |
| 651 |
#endif |
| 652 |
|
| 653 |
#if !defined(SIMDE_NO_STRING_H) |
| 654 |
#include <string.h> |
| 655 |
#if !defined(simde_memcpy) |
| 656 |
#define simde_memcpy(dest, src, n) memcpy(dest, src, n) |
| 657 |
#endif |
| 658 |
#if !defined(simde_memset) |
| 659 |
#define simde_memset(s, c, n) memset(s, c, n) |
| 660 |
#endif |
| 661 |
#if !defined(simde_memcmp) |
| 662 |
#define simde_memcmp(s1, s2, n) memcmp(s1, s2, n) |
| 663 |
#endif |
| 664 |
#else |
| 665 |
/* These are meant to be portable, not fast. If you're hitting them you |
| 666 |
* should think about providing your own (by defining the simde_memcpy |
| 667 |
* macro prior to including any SIMDe files) or submitting a patch to |
| 668 |
* SIMDe so we can detect your system-provided memcpy/memset, like by |
| 669 |
* adding your compiler to the checks for __builtin_memcpy and/or |
| 670 |
* __builtin_memset. */ |
| 671 |
#if !defined(simde_memcpy) |
| 672 |
SIMDE_FUNCTION_ATTRIBUTES |
| 673 |
void |
| 674 |
simde_memcpy_(void* dest, const void* src, size_t len) { |
| 675 |
char* dest_ = HEDLEY_STATIC_CAST(char*, dest); |
| 676 |
char* src_ = HEDLEY_STATIC_CAST(const char*, src); |
| 677 |
for (size_t i = 0 ; i < len ; i++) { |
| 678 |
dest_[i] = src_[i]; |
| 679 |
} |
| 680 |
} |
| 681 |
#define simde_memcpy(dest, src, n) simde_memcpy_(dest, src, n) |
| 682 |
#endif |
| 683 |
|
| 684 |
#if !defined(simde_memset) |
| 685 |
SIMDE_FUNCTION_ATTRIBUTES |
| 686 |
void |
| 687 |
simde_memset_(void* s, int c, size_t len) { |
| 688 |
char* s_ = HEDLEY_STATIC_CAST(char*, s); |
| 689 |
char c_ = HEDLEY_STATIC_CAST(char, c); |
| 690 |
for (size_t i = 0 ; i < len ; i++) { |
| 691 |
s_[i] = c_[i]; |
| 692 |
} |
| 693 |
} |
| 694 |
#define simde_memset(s, c, n) simde_memset_(s, c, n) |
| 695 |
#endif |
| 696 |
|
| 697 |
#if !defined(simde_memcmp) |
| 698 |
SIMDE_FUCTION_ATTRIBUTES |
| 699 |
int |
| 700 |
simde_memcmp_(const void *s1, const void *s2, size_t n) { |
| 701 |
unsigned char* s1_ = HEDLEY_STATIC_CAST(unsigned char*, s1); |
| 702 |
unsigned char* s2_ = HEDLEY_STATIC_CAST(unsigned char*, s2); |
| 703 |
for (size_t i = 0 ; i < len ; i++) { |
| 704 |
if (s1_[i] != s2_[i]) { |
| 705 |
return (int) (s1_[i] - s2_[i]); |
| 706 |
} |
| 707 |
} |
| 708 |
return 0; |
| 709 |
} |
| 710 |
#define simde_memcmp(s1, s2, n) simde_memcmp_(s1, s2, n) |
| 711 |
#endif |
| 712 |
#endif |
| 713 |
#endif |
| 714 |
|
| 715 |
#if defined(FE_ALL_EXCEPT) |
| 716 |
#define SIMDE_HAVE_FENV_H |
| 717 |
#elif defined(__has_include) |
| 718 |
#if __has_include(<fenv.h>) |
| 719 |
#include <fenv.h> |
| 720 |
#define SIMDE_HAVE_FENV_H |
| 721 |
#endif |
| 722 |
#elif SIMDE_STDC_HOSTED == 1 |
| 723 |
#include <fenv.h> |
| 724 |
#define SIMDE_HAVE_FENV_H |
| 725 |
#endif |
| 726 |
|
| 727 |
#if defined(EXIT_FAILURE) |
| 728 |
#define SIMDE_HAVE_STDLIB_H |
| 729 |
#elif defined(__has_include) |
| 730 |
#if __has_include(<stdlib.h>) |
| 731 |
#include <stdlib.h> |
| 732 |
#define SIMDE_HAVE_STDLIB_H |
| 733 |
#endif |
| 734 |
#elif SIMDE_STDC_HOSTED == 1 |
| 735 |
#include <stdlib.h> |
| 736 |
#define SIMDE_HAVE_STDLIB_H |
| 737 |
#endif |
| 738 |
|
| 739 |
#if defined(__has_include) |
| 740 |
# if defined(__cplusplus) && (__cplusplus >= 201103L) && __has_include(<cfenv>) |
| 741 |
# include <cfenv> |
| 742 |
# elif __has_include(<fenv.h>) |
| 743 |
# include <fenv.h> |
| 744 |
# endif |
| 745 |
# if __has_include(<stdlib.h>) |
| 746 |
# include <stdlib.h> |
| 747 |
# endif |
| 748 |
#elif SIMDE_STDC_HOSTED == 1 |
| 749 |
# include <stdlib.h> |
| 750 |
# include <fenv.h> |
| 751 |
#endif |
| 752 |
|
| 753 |
#define SIMDE_DEFINE_CONVERSION_FUNCTION_(Name, T_To, T_From) \ |
| 754 |
static HEDLEY_ALWAYS_INLINE HEDLEY_CONST SIMDE_FUNCTION_POSSIBLY_UNUSED_ \ |
| 755 |
T_To \ |
| 756 |
Name (T_From value) { \ |
| 757 |
T_To r; \ |
| 758 |
simde_memcpy(&r, &value, sizeof(r)); \ |
| 759 |
return r; \ |
| 760 |
} |
| 761 |
|
| 762 |
SIMDE_DEFINE_CONVERSION_FUNCTION_(simde_float32_as_uint32, uint32_t, simde_float32) |
| 763 |
SIMDE_DEFINE_CONVERSION_FUNCTION_(simde_uint32_as_float32, simde_float32, uint32_t) |
| 764 |
SIMDE_DEFINE_CONVERSION_FUNCTION_(simde_float64_as_uint64, uint64_t, simde_float64) |
| 765 |
SIMDE_DEFINE_CONVERSION_FUNCTION_(simde_uint64_as_float64, simde_float64, uint64_t) |
| 766 |
|
| 767 |
#include "check.h" |
| 768 |
|
| 769 |
/* GCC/clang have a bunch of functionality in builtins which we would |
| 770 |
* like to access, but the suffixes indicate whether the operate on |
| 771 |
* int, long, or long long, not fixed width types (e.g., int32_t). |
| 772 |
* we use these macros to attempt to map from fixed-width to the |
| 773 |
* names GCC uses. Note that you should still cast the input(s) and |
| 774 |
* return values (to/from SIMDE_BUILTIN_TYPE_*_) since often even if |
| 775 |
* types are the same size they may not be compatible according to the |
| 776 |
* compiler. For example, on x86 long and long lonsg are generally |
| 777 |
* both 64 bits, but platforms vary on whether an int64_t is mapped |
| 778 |
* to a long or long long. */ |
| 779 |
|
| 780 |
#include <limits.h> |
| 781 |
|
| 782 |
HEDLEY_DIAGNOSTIC_PUSH |
| 783 |
SIMDE_DIAGNOSTIC_DISABLE_CPP98_COMPAT_PEDANTIC_ |
| 784 |
|
| 785 |
#if (INT8_MAX == INT_MAX) && (INT8_MIN == INT_MIN) |
| 786 |
#define SIMDE_BUILTIN_SUFFIX_8_ |
| 787 |
#define SIMDE_BUILTIN_TYPE_8_ int |
| 788 |
#elif (INT8_MAX == LONG_MAX) && (INT8_MIN == LONG_MIN) |
| 789 |
#define SIMDE_BUILTIN_SUFFIX_8_ l |
| 790 |
#define SIMDE_BUILTIN_TYPE_8_ long |
| 791 |
#elif (INT8_MAX == LLONG_MAX) && (INT8_MIN == LLONG_MIN) |
| 792 |
#define SIMDE_BUILTIN_SUFFIX_8_ ll |
| 793 |
#define SIMDE_BUILTIN_TYPE_8_ long long |
| 794 |
#endif |
| 795 |
|
| 796 |
#if (INT16_MAX == INT_MAX) && (INT16_MIN == INT_MIN) |
| 797 |
#define SIMDE_BUILTIN_SUFFIX_16_ |
| 798 |
#define SIMDE_BUILTIN_TYPE_16_ int |
| 799 |
#elif (INT16_MAX == LONG_MAX) && (INT16_MIN == LONG_MIN) |
| 800 |
#define SIMDE_BUILTIN_SUFFIX_16_ l |
| 801 |
#define SIMDE_BUILTIN_TYPE_16_ long |
| 802 |
#elif (INT16_MAX == LLONG_MAX) && (INT16_MIN == LLONG_MIN) |
| 803 |
#define SIMDE_BUILTIN_SUFFIX_16_ ll |
| 804 |
#define SIMDE_BUILTIN_TYPE_16_ long long |
| 805 |
#endif |
| 806 |
|
| 807 |
#if (INT32_MAX == INT_MAX) && (INT32_MIN == INT_MIN) |
| 808 |
#define SIMDE_BUILTIN_SUFFIX_32_ |
| 809 |
#define SIMDE_BUILTIN_TYPE_32_ int |
| 810 |
#elif (INT32_MAX == LONG_MAX) && (INT32_MIN == LONG_MIN) |
| 811 |
#define SIMDE_BUILTIN_SUFFIX_32_ l |
| 812 |
#define SIMDE_BUILTIN_TYPE_32_ long |
| 813 |
#elif (INT32_MAX == LLONG_MAX) && (INT32_MIN == LLONG_MIN) |
| 814 |
#define SIMDE_BUILTIN_SUFFIX_32_ ll |
| 815 |
#define SIMDE_BUILTIN_TYPE_32_ long long |
| 816 |
#endif |
| 817 |
|
| 818 |
#if (INT64_MAX == INT_MAX) && (INT64_MIN == INT_MIN) |
| 819 |
#define SIMDE_BUILTIN_SUFFIX_64_ |
| 820 |
#define SIMDE_BUILTIN_TYPE_64_ int |
| 821 |
#elif (INT64_MAX == LONG_MAX) && (INT64_MIN == LONG_MIN) |
| 822 |
#define SIMDE_BUILTIN_SUFFIX_64_ l |
| 823 |
#define SIMDE_BUILTIN_TYPE_64_ long |
| 824 |
#elif (INT64_MAX == LLONG_MAX) && (INT64_MIN == LLONG_MIN) |
| 825 |
#define SIMDE_BUILTIN_SUFFIX_64_ ll |
| 826 |
#define SIMDE_BUILTIN_TYPE_64_ long long |
| 827 |
#endif |
| 828 |
|
| 829 |
#if defined(SIMDE_BUILTIN_SUFFIX_8_) |
| 830 |
#define SIMDE_BUILTIN_8_(name) HEDLEY_CONCAT3(__builtin_, name, SIMDE_BUILTIN_SUFFIX_8_) |
| 831 |
#define SIMDE_BUILTIN_HAS_8_(name) HEDLEY_HAS_BUILTIN(HEDLEY_CONCAT3(__builtin_, name, SIMDE_BUILTIN_SUFFIX_8_)) |
| 832 |
#else |
| 833 |
#define SIMDE_BUILTIN_HAS_8_(name) 0 |
| 834 |
#endif |
| 835 |
#if defined(SIMDE_BUILTIN_SUFFIX_16_) |
| 836 |
#define SIMDE_BUILTIN_16_(name) HEDLEY_CONCAT3(__builtin_, name, SIMDE_BUILTIN_SUFFIX_16_) |
| 837 |
#define SIMDE_BUILTIN_HAS_16_(name) HEDLEY_HAS_BUILTIN(HEDLEY_CONCAT3(__builtin_, name, SIMDE_BUILTIN_SUFFIX_16_)) |
| 838 |
#else |
| 839 |
#define SIMDE_BUILTIN_HAS_16_(name) 0 |
| 840 |
#endif |
| 841 |
#if defined(SIMDE_BUILTIN_SUFFIX_32_) |
| 842 |
#define SIMDE_BUILTIN_32_(name) HEDLEY_CONCAT3(__builtin_, name, SIMDE_BUILTIN_SUFFIX_32_) |
| 843 |
#define SIMDE_BUILTIN_HAS_32_(name) HEDLEY_HAS_BUILTIN(HEDLEY_CONCAT3(__builtin_, name, SIMDE_BUILTIN_SUFFIX_32_)) |
| 844 |
#else |
| 845 |
#define SIMDE_BUILTIN_HAS_32_(name) 0 |
| 846 |
#endif |
| 847 |
#if defined(SIMDE_BUILTIN_SUFFIX_64_) |
| 848 |
#define SIMDE_BUILTIN_64_(name) HEDLEY_CONCAT3(__builtin_, name, SIMDE_BUILTIN_SUFFIX_64_) |
| 849 |
#define SIMDE_BUILTIN_HAS_64_(name) HEDLEY_HAS_BUILTIN(HEDLEY_CONCAT3(__builtin_, name, SIMDE_BUILTIN_SUFFIX_64_)) |
| 850 |
#else |
| 851 |
#define SIMDE_BUILTIN_HAS_64_(name) 0 |
| 852 |
#endif |
| 853 |
|
| 854 |
#if !defined(__cplusplus) |
| 855 |
#if defined(__clang__) |
| 856 |
#if HEDLEY_HAS_WARNING("-Wc11-extensions") |
| 857 |
#define SIMDE_GENERIC_(...) (__extension__ ({ \ |
| 858 |
HEDLEY_DIAGNOSTIC_PUSH \ |
| 859 |
_Pragma("clang diagnostic ignored \"-Wc11-extensions\"") \ |
| 860 |
_Generic(__VA_ARGS__); \ |
| 861 |
HEDLEY_DIAGNOSTIC_POP \ |
| 862 |
})) |
| 863 |
#elif HEDLEY_HAS_WARNING("-Wc1x-extensions") |
| 864 |
#define SIMDE_GENERIC_(...) (__extension__ ({ \ |
| 865 |
HEDLEY_DIAGNOSTIC_PUSH \ |
| 866 |
_Pragma("clang diagnostic ignored \"-Wc1x-extensions\"") \ |
| 867 |
_Generic(__VA_ARGS__); \ |
| 868 |
HEDLEY_DIAGNOSTIC_POP \ |
| 869 |
})) |
| 870 |
#endif |
| 871 |
#elif \ |
| 872 |
defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) || \ |
| 873 |
HEDLEY_HAS_EXTENSION(c_generic_selections) || \ |
| 874 |
HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ |
| 875 |
HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ |
| 876 |
HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ |
| 877 |
HEDLEY_ARM_VERSION_CHECK(5,3,0) |
| 878 |
#define SIMDE_GENERIC_(...) _Generic(__VA_ARGS__) |
| 879 |
#endif |
| 880 |
#endif |
| 881 |
|
| 882 |
/* Sometimes we run into problems with specific versions of compilers |
| 883 |
which make the native versions unusable for us. Often this is due |
| 884 |
to missing functions, sometimes buggy implementations, etc. These |
| 885 |
macros are how we check for specific bugs. As they are fixed we'll |
| 886 |
start only defining them for problematic compiler versions. */ |
| 887 |
|
| 888 |
#if !defined(SIMDE_IGNORE_COMPILER_BUGS) |
| 889 |
# if defined(HEDLEY_GCC_VERSION) |
| 890 |
# if !HEDLEY_GCC_VERSION_CHECK(4,9,0) |
| 891 |
# define SIMDE_BUG_GCC_REV_208793 |
| 892 |
# endif |
| 893 |
# if !HEDLEY_GCC_VERSION_CHECK(5,0,0) |
| 894 |
# define SIMDE_BUG_GCC_BAD_MM_SRA_EPI32 /* TODO: find relevant bug or commit */ |
| 895 |
# endif |
| 896 |
# if !HEDLEY_GCC_VERSION_CHECK(6,0,0) |
| 897 |
# define SIMDE_BUG_GCC_SIZEOF_IMMEDIATE |
| 898 |
# endif |
| 899 |
# if !HEDLEY_GCC_VERSION_CHECK(4,6,0) |
| 900 |
# define SIMDE_BUG_GCC_BAD_MM_EXTRACT_EPI8 /* TODO: find relevant bug or commit */ |
| 901 |
# endif |
| 902 |
# if !HEDLEY_GCC_VERSION_CHECK(8,0,0) |
| 903 |
# define SIMDE_BUG_GCC_REV_247851 |
| 904 |
# endif |
| 905 |
# if !HEDLEY_GCC_VERSION_CHECK(10,0,0) |
| 906 |
# define SIMDE_BUG_GCC_REV_274313 |
| 907 |
# define SIMDE_BUG_GCC_91341 |
| 908 |
# define SIMDE_BUG_GCC_92035 |
| 909 |
# endif |
| 910 |
# if !HEDLEY_GCC_VERSION_CHECK(9,0,0) && defined(SIMDE_ARCH_AARCH64) |
| 911 |
# define SIMDE_BUG_GCC_ARM_SHIFT_SCALAR |
| 912 |
# endif |
| 913 |
# if !HEDLEY_GCC_VERSION_CHECK(9,0,0) && defined(SIMDE_ARCH_AARCH64) |
| 914 |
# define SIMDE_BUG_GCC_BAD_VEXT_REV32 |
| 915 |
# endif |
| 916 |
# if defined(SIMDE_ARCH_X86) && !defined(SIMDE_ARCH_AMD64) |
| 917 |
# define SIMDE_BUG_GCC_94482 |
| 918 |
# endif |
| 919 |
# if (defined(SIMDE_ARCH_X86) && !defined(SIMDE_ARCH_AMD64)) || defined(SIMDE_ARCH_ZARCH) |
| 920 |
# define SIMDE_BUG_GCC_53784 |
| 921 |
# endif |
| 922 |
# if defined(SIMDE_ARCH_X86) || defined(SIMDE_ARCH_AMD64) |
| 923 |
# if HEDLEY_GCC_VERSION_CHECK(4,3,0) /* -Wsign-conversion */ |
| 924 |
# define SIMDE_BUG_GCC_95144 |
| 925 |
# endif |
| 926 |
# if !HEDLEY_GCC_VERSION_CHECK(11,2,0) |
| 927 |
# define SIMDE_BUG_GCC_95483 |
| 928 |
# endif |
| 929 |
# if defined(__OPTIMIZE__) |
| 930 |
# define SIMDE_BUG_GCC_100927 |
| 931 |
# endif |
| 932 |
# define SIMDE_BUG_GCC_98521 |
| 933 |
# endif |
| 934 |
# if !HEDLEY_GCC_VERSION_CHECK(9,4,0) && defined(SIMDE_ARCH_AARCH64) |
| 935 |
# define SIMDE_BUG_GCC_94488 |
| 936 |
# endif |
| 937 |
# if !HEDLEY_GCC_VERSION_CHECK(9,1,0) && defined(SIMDE_ARCH_AARCH64) |
| 938 |
# define SIMDE_BUG_GCC_REV_264019 |
| 939 |
# endif |
| 940 |
# if defined(SIMDE_ARCH_ARM) |
| 941 |
# define SIMDE_BUG_GCC_95399 |
| 942 |
# define SIMDE_BUG_GCC_95471 |
| 943 |
# elif defined(SIMDE_ARCH_POWER) |
| 944 |
# define SIMDE_BUG_GCC_95227 |
| 945 |
# define SIMDE_BUG_GCC_95782 |
| 946 |
# define SIMDE_BUG_VEC_CPSGN_REVERSED_ARGS |
| 947 |
# elif defined(SIMDE_ARCH_X86) || defined(SIMDE_ARCH_AMD64) |
| 948 |
# if !HEDLEY_GCC_VERSION_CHECK(10,2,0) && !defined(__OPTIMIZE__) |
| 949 |
# define SIMDE_BUG_GCC_96174 |
| 950 |
# endif |
| 951 |
# elif defined(SIMDE_ARCH_ZARCH) |
| 952 |
# define SIMDE_BUG_GCC_95782 |
| 953 |
# if HEDLEY_GCC_VERSION_CHECK(10,0,0) |
| 954 |
# define SIMDE_BUG_GCC_101614 |
| 955 |
# endif |
| 956 |
# endif |
| 957 |
# if defined(SIMDE_ARCH_MIPS_MSA) |
| 958 |
# define SIMDE_BUG_GCC_97248 |
| 959 |
# define SIMDE_BUG_GCC_100760 |
| 960 |
# define SIMDE_BUG_GCC_100761 |
| 961 |
# define SIMDE_BUG_GCC_100762 |
| 962 |
# endif |
| 963 |
# define SIMDE_BUG_GCC_95399 |
| 964 |
# if !defined(__OPTIMIZE__) |
| 965 |
# define SIMDE_BUG_GCC_105339 |
| 966 |
# endif |
| 967 |
# elif defined(__clang__) |
| 968 |
# if defined(SIMDE_ARCH_AARCH64) |
| 969 |
# define SIMDE_BUG_CLANG_45541 |
| 970 |
# define SIMDE_BUG_CLANG_46844 |
| 971 |
# define SIMDE_BUG_CLANG_48257 |
| 972 |
# if !SIMDE_DETECT_CLANG_VERSION_CHECK(12,0,0) |
| 973 |
# define SIMDE_BUG_CLANG_46840 |
| 974 |
# endif |
| 975 |
# if SIMDE_DETECT_CLANG_VERSION_CHECK(10,0,0) && SIMDE_DETECT_CLANG_VERSION_NOT(11,0,0) |
| 976 |
# define SIMDE_BUG_CLANG_BAD_VI64_OPS |
| 977 |
# endif |
| 978 |
# if SIMDE_DETECT_CLANG_VERSION_NOT(9,0,0) |
| 979 |
# define SIMDE_BUG_CLANG_GIT_4EC445B8 |
| 980 |
# define SIMDE_BUG_CLANG_REV_365298 /* 0464e07c8f6e3310c28eb210a4513bc2243c2a7e */ |
| 981 |
# endif |
| 982 |
# endif |
| 983 |
# if defined(SIMDE_ARCH_ARM) |
| 984 |
# if !SIMDE_DETECT_CLANG_VERSION_CHECK(11,0,0) |
| 985 |
# define SIMDE_BUG_CLANG_BAD_VGET_SET_LANE_TYPES |
| 986 |
# endif |
| 987 |
# endif |
| 988 |
# if defined(SIMDE_ARCH_POWER) && !SIMDE_DETECT_CLANG_VERSION_CHECK(12,0,0) |
| 989 |
# define SIMDE_BUG_CLANG_46770 |
| 990 |
# endif |
| 991 |
# if defined(SIMDE_ARCH_POWER) && (SIMDE_ARCH_POWER == 700) && (SIMDE_DETECT_CLANG_VERSION_CHECK(11,0,0)) |
| 992 |
# define SIMDE_BUG_CLANG_50893 |
| 993 |
# define SIMDE_BUG_CLANG_50901 |
| 994 |
# endif |
| 995 |
# if defined(_ARCH_PWR9) && !SIMDE_DETECT_CLANG_VERSION_CHECK(12,0,0) && !defined(__OPTIMIZE__) |
| 996 |
# define SIMDE_BUG_CLANG_POWER9_16x4_BAD_SHIFT |
| 997 |
# endif |
| 998 |
# if defined(SIMDE_ARCH_POWER) |
| 999 |
# define SIMDE_BUG_CLANG_50932 |
| 1000 |
# if !SIMDE_DETECT_CLANG_VERSION_CHECK(12,0,0) |
| 1001 |
# define SIMDE_BUG_VEC_CPSGN_REVERSED_ARGS |
| 1002 |
# endif |
| 1003 |
# endif |
| 1004 |
# if defined(SIMDE_ARCH_X86) || defined(SIMDE_ARCH_AMD64) |
| 1005 |
# if SIMDE_DETECT_CLANG_VERSION_NOT(5,0,0) |
| 1006 |
# define SIMDE_BUG_CLANG_REV_298042 /* 6afc436a7817a52e78ae7bcdc3faafd460124cac */ |
| 1007 |
# endif |
| 1008 |
# if SIMDE_DETECT_CLANG_VERSION_NOT(3,7,0) |
| 1009 |
# define SIMDE_BUG_CLANG_REV_234560 /* b929ad7b1726a32650a8051f69a747fb6836c540 */ |
| 1010 |
# endif |
| 1011 |
# if SIMDE_DETECT_CLANG_VERSION_CHECK(3,8,0) && SIMDE_DETECT_CLANG_VERSION_NOT(5,0,0) |
| 1012 |
# define SIMDE_BUG_CLANG_BAD_MADD |
| 1013 |
# endif |
| 1014 |
# if SIMDE_DETECT_CLANG_VERSION_CHECK(4,0,0) && SIMDE_DETECT_CLANG_VERSION_NOT(5,0,0) |
| 1015 |
# define SIMDE_BUG_CLANG_REV_299346 /* ac9959eb533a58482ea4da6c4db1e635a98de384 */ |
| 1016 |
# endif |
| 1017 |
# if SIMDE_DETECT_CLANG_VERSION_NOT(8,0,0) |
| 1018 |
# define SIMDE_BUG_CLANG_REV_344862 /* eae26bf73715994c2bd145f9b6dc3836aa4ffd4f */ |
| 1019 |
# endif |
| 1020 |
# if HEDLEY_HAS_WARNING("-Wsign-conversion") && SIMDE_DETECT_CLANG_VERSION_NOT(11,0,0) |
| 1021 |
# define SIMDE_BUG_CLANG_45931 |
| 1022 |
# endif |
| 1023 |
# if HEDLEY_HAS_WARNING("-Wvector-conversion") && SIMDE_DETECT_CLANG_VERSION_NOT(11,0,0) |
| 1024 |
# define SIMDE_BUG_CLANG_44589 |
| 1025 |
# endif |
| 1026 |
# define SIMDE_BUG_CLANG_48673 |
| 1027 |
# endif |
| 1028 |
# define SIMDE_BUG_CLANG_45959 |
| 1029 |
# elif defined(HEDLEY_MSVC_VERSION) |
| 1030 |
# if defined(SIMDE_ARCH_X86) |
| 1031 |
# define SIMDE_BUG_MSVC_ROUND_EXTRACT |
| 1032 |
# endif |
| 1033 |
# elif defined(HEDLEY_INTEL_VERSION) |
| 1034 |
# define SIMDE_BUG_INTEL_857088 |
| 1035 |
# elif defined(HEDLEY_MCST_LCC_VERSION) |
| 1036 |
# define SIMDE_BUG_MCST_LCC_MISSING_AVX_LOAD_STORE_M128_FUNCS |
| 1037 |
# define SIMDE_BUG_MCST_LCC_MISSING_CMOV_M256 |
| 1038 |
# define SIMDE_BUG_MCST_LCC_FMA_WRONG_RESULT |
| 1039 |
# elif defined(HEDLEY_PGI_VERSION) |
| 1040 |
# define SIMDE_BUG_PGI_30104 |
| 1041 |
# define SIMDE_BUG_PGI_30107 |
| 1042 |
# define SIMDE_BUG_PGI_30106 |
| 1043 |
# endif |
| 1044 |
#endif |
| 1045 |
|
| 1046 |
/* GCC and Clang both have the same issue: |
| 1047 |
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95144 |
| 1048 |
* https://bugs.llvm.org/show_bug.cgi?id=45931 |
| 1049 |
* This is just an easy way to work around it. |
| 1050 |
*/ |
| 1051 |
#if \ |
| 1052 |
(HEDLEY_HAS_WARNING("-Wsign-conversion") && SIMDE_DETECT_CLANG_VERSION_NOT(11,0,0)) || \ |
| 1053 |
HEDLEY_GCC_VERSION_CHECK(4,3,0) |
| 1054 |
# define SIMDE_BUG_IGNORE_SIGN_CONVERSION(expr) (__extension__ ({ \ |
| 1055 |
HEDLEY_DIAGNOSTIC_PUSH \ |
| 1056 |
HEDLEY_DIAGNOSTIC_POP \ |
| 1057 |
_Pragma("GCC diagnostic ignored \"-Wsign-conversion\"") \ |
| 1058 |
__typeof__(expr) simde_bug_ignore_sign_conversion_v_= (expr); \ |
| 1059 |
HEDLEY_DIAGNOSTIC_PUSH \ |
| 1060 |
simde_bug_ignore_sign_conversion_v_; \ |
| 1061 |
})) |
| 1062 |
#else |
| 1063 |
# define SIMDE_BUG_IGNORE_SIGN_CONVERSION(expr) (expr) |
| 1064 |
#endif |
| 1065 |
|
| 1066 |
/* Usually the shift count is signed (for example, NEON or SSE). |
| 1067 |
* OTOH, unsigned is good for PPC (vec_srl uses unsigned), and the only option for E2K. |
| 1068 |
* Further info: https://github.com/simd-everywhere/simde/pull/700 |
| 1069 |
*/ |
| 1070 |
#if defined(SIMDE_ARCH_E2K) || defined(SIMDE_ARCH_POWER) |
| 1071 |
#define SIMDE_CAST_VECTOR_SHIFT_COUNT(width, value) HEDLEY_STATIC_CAST(uint##width##_t, (value)) |
| 1072 |
#else |
| 1073 |
#define SIMDE_CAST_VECTOR_SHIFT_COUNT(width, value) HEDLEY_STATIC_CAST(int##width##_t, (value)) |
| 1074 |
#endif |
| 1075 |
|
| 1076 |
/* SIMDE_DIAGNOSTIC_DISABLE_USED_BUT_MARKED_UNUSED_ */ |
| 1077 |
HEDLEY_DIAGNOSTIC_POP |
| 1078 |
|
| 1079 |
#endif /* !defined(SIMDE_COMMON_H) */ |