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 * 2020 Evan Nemerson <evan@nemerson.com> 25 */ 26 27 /* simde-arch.h is used to determine which features are available according 28 to the compiler. However, we want to make it possible to forcibly enable 29 or disable APIs */ 30 31 #if !defined(SIMDE_FEATURES_H) 32 #define SIMDE_FEATURES_H 33 34 #include "simde-arch.h" 35 #include "simde-diagnostic.h" 36 37 #if !defined(SIMDE_X86_SVML_NATIVE) && !defined(SIMDE_X86_SVML_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 38 #if defined(SIMDE_ARCH_X86_SVML) 39 #define SIMDE_X86_SVML_NATIVE 40 #endif 41 #endif 42 #if defined(SIMDE_X86_SVML_NATIVE) && !defined(SIMDE_X86_AVX512F_NATIVE) 43 #define SIMDE_X86_AVX512F_NATIVE 44 #endif 45 46 #if !defined(SIMDE_X86_AVX512CD_NATIVE) && !defined(SIMDE_X86_AVX512CD_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 47 #if defined(SIMDE_ARCH_X86_AVX512CD) 48 #define SIMDE_X86_AVX512CD_NATIVE 49 #endif 50 #endif 51 #if defined(SIMDE_X86_AVX512CD_NATIVE) && !defined(SIMDE_X86_AVX512F_NATIVE) 52 #define SIMDE_X86_AVX512F_NATIVE 53 #endif 54 55 #if !defined(SIMDE_X86_AVX512DQ_NATIVE) && !defined(SIMDE_X86_AVX512DQ_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 56 #if defined(SIMDE_ARCH_X86_AVX512DQ) 57 #define SIMDE_X86_AVX512DQ_NATIVE 58 #endif 59 #endif 60 #if defined(SIMDE_X86_AVX512DQ_NATIVE) && !defined(SIMDE_X86_AVX512F_NATIVE) 61 #define SIMDE_X86_AVX512F_NATIVE 62 #endif 63 64 #if !defined(SIMDE_X86_AVX512VL_NATIVE) && !defined(SIMDE_X86_AVX512VL_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 65 #if defined(SIMDE_ARCH_X86_AVX512VL) 66 #define SIMDE_X86_AVX512VL_NATIVE 67 #endif 68 #endif 69 #if defined(SIMDE_X86_AVX512VL_NATIVE) && !defined(SIMDE_X86_AVX512F_NATIVE) 70 #define SIMDE_X86_AVX512F_NATIVE 71 #endif 72 73 #if !defined(SIMDE_X86_AVX512BW_NATIVE) && !defined(SIMDE_X86_AVX512BW_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 74 #if defined(SIMDE_ARCH_X86_AVX512BW) 75 #define SIMDE_X86_AVX512BW_NATIVE 76 #endif 77 #endif 78 #if defined(SIMDE_X86_AVX512BW_NATIVE) && !defined(SIMDE_X86_AVX512F_NATIVE) 79 #define SIMDE_X86_AVX512F_NATIVE 80 #endif 81 82 #if !defined(SIMDE_X86_AVX512F_NATIVE) && !defined(SIMDE_X86_AVX512F_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 83 #if defined(SIMDE_ARCH_X86_AVX512F) 84 #define SIMDE_X86_AVX512F_NATIVE 85 #endif 86 #endif 87 #if defined(SIMDE_X86_AVX512F_NATIVE) && !defined(SIMDE_X86_AVX2_NATIVE) 88 #define SIMDE_X86_AVX2_NATIVE 89 #endif 90 91 #if !defined(SIMDE_X86_FMA_NATIVE) && !defined(SIMDE_X86_FMA_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 92 #if defined(SIMDE_ARCH_X86_FMA) 93 #define SIMDE_X86_FMA_NATIVE 94 #endif 95 #endif 96 #if defined(SIMDE_X86_FMA_NATIVE) && !defined(SIMDE_X86_AVX_NATIVE) 97 #define SIMDE_X86_AVX_NATIVE 98 #endif 99 100 #if !defined(SIMDE_X86_AVX2_NATIVE) && !defined(SIMDE_X86_AVX2_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 101 #if defined(SIMDE_ARCH_X86_AVX2) 102 #define SIMDE_X86_AVX2_NATIVE 103 #endif 104 #endif 105 #if defined(SIMDE_X86_AVX2_NATIVE) && !defined(SIMDE_X86_AVX_NATIVE) 106 #define SIMDE_X86_AVX_NATIVE 107 #endif 108 109 #if !defined(SIMDE_X86_AVX_NATIVE) && !defined(SIMDE_X86_AVX_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 110 #if defined(SIMDE_ARCH_X86_AVX) 111 #define SIMDE_X86_AVX_NATIVE 112 #endif 113 #endif 114 #if defined(SIMDE_X86_AVX_NATIVE) && !defined(SIMDE_X86_SSE4_1_NATIVE) 115 #define SIMDE_X86_SSE4_2_NATIVE 116 #endif 117 118 #if !defined(SIMDE_X86_SSE4_2_NATIVE) && !defined(SIMDE_X86_SSE4_2_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 119 #if defined(SIMDE_ARCH_X86_SSE4_2) 120 #define SIMDE_X86_SSE4_2_NATIVE 121 #endif 122 #endif 123 #if defined(SIMDE_X86_SSE4_2_NATIVE) && !defined(SIMDE_X86_SSE4_1_NATIVE) 124 #define SIMDE_X86_SSE4_1_NATIVE 125 #endif 126 127 #if !defined(SIMDE_X86_SSE4_1_NATIVE) && !defined(SIMDE_X86_SSE4_1_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 128 #if defined(SIMDE_ARCH_X86_SSE4_1) 129 #define SIMDE_X86_SSE4_1_NATIVE 130 #endif 131 #endif 132 #if defined(SIMDE_X86_SSE4_1_NATIVE) && !defined(SIMDE_X86_SSSE3_NATIVE) 133 #define SIMDE_X86_SSSE3_NATIVE 134 #endif 135 136 #if !defined(SIMDE_X86_SSSE3_NATIVE) && !defined(SIMDE_X86_SSSE3_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 137 #if defined(SIMDE_ARCH_X86_SSSE3) 138 #define SIMDE_X86_SSSE3_NATIVE 139 #endif 140 #endif 141 #if defined(SIMDE_X86_SSSE3_NATIVE) && !defined(SIMDE_X86_SSE3_NATIVE) 142 #define SIMDE_X86_SSE3_NATIVE 143 #endif 144 145 #if !defined(SIMDE_X86_SSE3_NATIVE) && !defined(SIMDE_X86_SSE3_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 146 #if defined(SIMDE_ARCH_X86_SSE3) 147 #define SIMDE_X86_SSE3_NATIVE 148 #endif 149 #endif 150 #if defined(SIMDE_X86_SSE3_NATIVE) && !defined(SIMDE_X86_SSE2_NATIVE) 151 #define SIMDE_X86_SSE2_NATIVE 152 #endif 153 154 #if !defined(SIMDE_X86_SSE2_NATIVE) && !defined(SIMDE_X86_SSE2_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 155 #if defined(SIMDE_ARCH_X86_SSE2) 156 #define SIMDE_X86_SSE2_NATIVE 157 #endif 158 #endif 159 #if defined(SIMDE_X86_SSE2_NATIVE) && !defined(SIMDE_X86_SSE_NATIVE) 160 #define SIMDE_X86_SSE_NATIVE 161 #endif 162 163 #if !defined(SIMDE_X86_SSE_NATIVE) && !defined(SIMDE_X86_SSE_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 164 #if defined(SIMDE_ARCH_X86_SSE) 165 #define SIMDE_X86_SSE_NATIVE 166 #endif 167 #endif 168 169 #if !defined(SIMDE_X86_MMX_NATIVE) && !defined(SIMDE_X86_MMX_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 170 #if defined(SIMDE_ARCH_X86_MMX) 171 #define SIMDE_X86_MMX_NATIVE 172 #endif 173 #endif 174 175 #if !defined(SIMDE_X86_GFNI_NATIVE) && !defined(SIMDE_X86_GFNI_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 176 #if defined(SIMDE_ARCH_X86_GFNI) 177 #define SIMDE_X86_GFNI_NATIVE 178 #endif 179 #endif 180 181 #if !defined(SIMDE_X86_SVML_NATIVE) && !defined(SIMDE_X86_SVML_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 182 #if defined(__INTEL_COMPILER) 183 #define SIMDE_X86_SVML_NATIVE 184 #endif 185 #endif 186 187 #if defined(HEDLEY_MSVC_VERSION) 188 #pragma warning(push) 189 #pragma warning(disable:4799) 190 #endif 191 192 #if \ 193 defined(SIMDE_X86_AVX_NATIVE) || \ 194 defined(SIMDE_X86_GFNI_NATIVE) || \ 195 defined(SIMDE_X86_SVML_NATIVE) 196 #include <immintrin.h> 197 #elif defined(SIMDE_X86_SSE4_2_NATIVE) 198 #include <nmmintrin.h> 199 #elif defined(SIMDE_X86_SSE4_1_NATIVE) 200 #include <smmintrin.h> 201 #elif defined(SIMDE_X86_SSSE3_NATIVE) 202 #include <tmmintrin.h> 203 #elif defined(SIMDE_X86_SSE3_NATIVE) 204 #include <pmmintrin.h> 205 #elif defined(SIMDE_X86_SSE2_NATIVE) 206 #include <emmintrin.h> 207 #elif defined(SIMDE_X86_SSE_NATIVE) 208 #include <xmmintrin.h> 209 #elif defined(SIMDE_X86_MMX_NATIVE) 210 #include <mmintrin.h> 211 #endif 212 213 #if defined(HEDLEY_MSVC_VERSION) 214 #pragma warning(pop) 215 #endif 216 217 #if !defined(SIMDE_ARM_NEON_A64V8_NATIVE) && !defined(SIMDE_ARM_NEON_A64V8_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 218 #if defined(SIMDE_ARCH_ARM_NEON) && defined(SIMDE_ARCH_AARCH64) && SIMDE_ARCH_ARM_CHECK(80) 219 #define SIMDE_ARM_NEON_A64V8_NATIVE 220 #endif 221 #endif 222 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && !defined(SIMDE_ARM_NEON_A32V8_NATIVE) 223 #define SIMDE_ARM_NEON_A32V8_NATIVE 224 #endif 225 226 #if !defined(SIMDE_ARM_NEON_A32V8_NATIVE) && !defined(SIMDE_ARM_NEON_A32V8_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 227 #if defined(SIMDE_ARCH_ARM_NEON) && SIMDE_ARCH_ARM_CHECK(80) 228 #define SIMDE_ARM_NEON_A32V8_NATIVE 229 #endif 230 #endif 231 #if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && !defined(SIMDE_ARM_NEON_A32V7_NATIVE) 232 #define SIMDE_ARM_NEON_A32V7_NATIVE 233 #endif 234 235 #if !defined(SIMDE_ARM_NEON_A32V7_NATIVE) && !defined(SIMDE_ARM_NEON_A32V7_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 236 #if defined(SIMDE_ARCH_ARM_NEON) && SIMDE_ARCH_ARM_CHECK(70) 237 #define SIMDE_ARM_NEON_A32V7_NATIVE 238 #endif 239 #endif 240 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE) 241 #include <arm_neon.h> 242 #endif 243 244 #if !defined(SIMDE_WASM_SIMD128_NATIVE) && !defined(SIMDE_WASM_SIMD128_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 245 #if defined(SIMDE_ARCH_WASM_SIMD128) 246 #define SIMDE_WASM_SIMD128_NATIVE 247 #endif 248 #endif 249 #if defined(SIMDE_WASM_SIMD128_NATIVE) 250 #if !defined(__wasm_unimplemented_simd128__) 251 HEDLEY_DIAGNOSTIC_PUSH 252 SIMDE_DIAGNOSTIC_DISABLE_RESERVED_ID_MACRO_ 253 #define __wasm_unimplemented_simd128__ 254 HEDLEY_DIAGNOSTIC_POP 255 #endif 256 #include <wasm_simd128.h> 257 #endif 258 259 #if !defined(SIMDE_POWER_ALTIVEC_P9_NATIVE) && !defined(SIMDE_POWER_ALTIVEC_P9_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 260 #if SIMDE_ARCH_POWER_ALTIVEC_CHECK(900) 261 #define SIMDE_POWER_ALTIVEC_P9_NATIVE 262 #endif 263 #endif 264 #if defined(SIMDE_POWER_ALTIVEC_P9_NATIVE) && !defined(SIMDE_POWER_ALTIVEC_P8) 265 #define SIMDE_POWER_ALTIVEC_P8_NATIVE 266 #endif 267 268 #if !defined(SIMDE_POWER_ALTIVEC_P8_NATIVE) && !defined(SIMDE_POWER_ALTIVEC_P8_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 269 #if SIMDE_ARCH_POWER_ALTIVEC_CHECK(800) 270 #define SIMDE_POWER_ALTIVEC_P8_NATIVE 271 #endif 272 #endif 273 #if defined(SIMDE_POWER_ALTIVEC_P8_NATIVE) && !defined(SIMDE_POWER_ALTIVEC_P7) 274 #define SIMDE_POWER_ALTIVEC_P7_NATIVE 275 #endif 276 277 #if !defined(SIMDE_POWER_ALTIVEC_P7_NATIVE) && !defined(SIMDE_POWER_ALTIVEC_P7_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 278 #if SIMDE_ARCH_POWER_ALTIVEC_CHECK(700) 279 #define SIMDE_POWER_ALTIVEC_P7_NATIVE 280 #endif 281 #endif 282 #if defined(SIMDE_POWER_ALTIVEC_P7_NATIVE) && !defined(SIMDE_POWER_ALTIVEC_P6) 283 #define SIMDE_POWER_ALTIVEC_P6_NATIVE 284 #endif 285 286 #if !defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) && !defined(SIMDE_POWER_ALTIVEC_P6_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 287 #if SIMDE_ARCH_POWER_ALTIVEC_CHECK(600) 288 #define SIMDE_POWER_ALTIVEC_P6_NATIVE 289 #endif 290 #endif 291 #if defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) && !defined(SIMDE_POWER_ALTIVEC_P5) 292 #define SIMDE_POWER_ALTIVEC_P5_NATIVE 293 #endif 294 295 #if !defined(SIMDE_POWER_ALTIVEC_P5_NATIVE) && !defined(SIMDE_POWER_ALTIVEC_P5_NO_NATIVE) && !defined(SIMDE_NO_NATIVE) 296 #if SIMDE_ARCH_POWER_ALTIVEC_CHECK(500) 297 #define SIMDE_POWER_ALTIVEC_P5_NATIVE 298 #endif 299 #endif 300 #if defined(SIMDE_POWER_ALTIVEC_P5_NATIVE) 301 /* stdbool.h conflicts with the bool in altivec.h */ 302 #if defined(bool) && !defined(SIMDE_POWER_ALTIVEC_NO_UNDEF_BOOL_) 303 #undef bool 304 #endif 305 #include <altivec.h> 306 /* GCC allows you to undefine these macros to prevent conflicts with 307 * standard types as they become context-sensitive keywords. */ 308 #if defined(__cplusplus) 309 #if defined(vector) 310 #undef vector 311 #endif 312 #if defined(pixel) 313 #undef pixel 314 #endif 315 #if defined(bool) 316 #undef bool 317 #endif 318 #define SIMDE_POWER_ALTIVEC_VECTOR(T) __vector T 319 #define SIMDE_POWER_ALTIVEC_PIXEL __pixel 320 #define SIMDE_POWER_ALTIVEC_BOOL __bool 321 #else 322 #define SIMDE_POWER_ALTIVEC_VECTOR(T) __vector T 323 #define SIMDE_POWER_ALTIVEC_PIXEL __pixel 324 #define SIMDE_POWER_ALTIVEC_BOOL __bool 325 #endif /* defined(__cplusplus) */ 326 #endif 327 328 /* Native aliases */ 329 #if defined(SIMDE_ENABLE_NATIVE_ALIASES) 330 #if !defined(SIMDE_X86_MMX_NATIVE) 331 #define SIMDE_X86_MMX_ENABLE_NATIVE_ALIASES 332 #endif 333 #if !defined(SIMDE_X86_SSE_NATIVE) 334 #define SIMDE_X86_SSE_ENABLE_NATIVE_ALIASES 335 #endif 336 #if !defined(SIMDE_X86_SSE2_NATIVE) 337 #define SIMDE_X86_SSE2_ENABLE_NATIVE_ALIASES 338 #endif 339 #if !defined(SIMDE_X86_SSE3_NATIVE) 340 #define SIMDE_X86_SSE3_ENABLE_NATIVE_ALIASES 341 #endif 342 #if !defined(SIMDE_X86_SSSE3_NATIVE) 343 #define SIMDE_X86_SSSE3_ENABLE_NATIVE_ALIASES 344 #endif 345 #if !defined(SIMDE_X86_SSE4_1_NATIVE) 346 #define SIMDE_X86_SSE4_1_ENABLE_NATIVE_ALIASES 347 #endif 348 #if !defined(SIMDE_X86_SSE4_2_NATIVE) 349 #define SIMDE_X86_SSE4_2_ENABLE_NATIVE_ALIASES 350 #endif 351 #if !defined(SIMDE_X86_AVX_NATIVE) 352 #define SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES 353 #endif 354 #if !defined(SIMDE_X86_AVX2_NATIVE) 355 #define SIMDE_X86_AVX2_ENABLE_NATIVE_ALIASES 356 #endif 357 #if !defined(SIMDE_X86_FMA_NATIVE) 358 #define SIMDE_X86_FMA_ENABLE_NATIVE_ALIASES 359 #endif 360 #if !defined(SIMDE_X86_AVX512F_NATIVE) 361 #define SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES 362 #endif 363 #if !defined(SIMDE_X86_AVX512VL_NATIVE) 364 #define SIMDE_X86_AVX512VL_ENABLE_NATIVE_ALIASES 365 #endif 366 #if !defined(SIMDE_X86_AVX512BW_NATIVE) 367 #define SIMDE_X86_AVX512BW_ENABLE_NATIVE_ALIASES 368 #endif 369 #if !defined(SIMDE_X86_AVX512DQ_NATIVE) 370 #define SIMDE_X86_AVX512DQ_ENABLE_NATIVE_ALIASES 371 #endif 372 #if !defined(SIMDE_X86_AVX512CD_NATIVE) 373 #define SIMDE_X86_AVX512CD_ENABLE_NATIVE_ALIASES 374 #endif 375 #if !defined(SIMDE_X86_GFNI_NATIVE) 376 #define SIMDE_X86_GFNI_ENABLE_NATIVE_ALIASES 377 #endif 378 379 #if !defined(SIMDE_ARM_NEON_A32V7_NATIVE) 380 #define SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES 381 #endif 382 #if !defined(SIMDE_ARM_NEON_A32V8_NATIVE) 383 #define SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES 384 #endif 385 #if !defined(SIMDE_ARM_NEON_A64V8_NATIVE) 386 #define SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES 387 #endif 388 #endif 389 390 #endif /* !defined(SIMDE_FEATURES_H) */ 391