simde-features.h 11 KB

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