simde-arch.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. /* Architecture detection
  2. * Created by Evan Nemerson <[email protected]>
  3. *
  4. * To the extent possible under law, the authors have waived all
  5. * copyright and related or neighboring rights to this code. For
  6. * details, see the Creative Commons Zero 1.0 Universal license at
  7. * <https://creativecommons.org/publicdomain/zero/1.0/>
  8. *
  9. * Different compilers define different preprocessor macros for the
  10. * same architecture. This is an attempt to provide a single
  11. * interface which is usable on any compiler.
  12. *
  13. * In general, a macro named SIMDE_ARCH_* is defined for each
  14. * architecture the CPU supports. When there are multiple possible
  15. * versions, we try to define the macro to the target version. For
  16. * example, if you want to check for i586+, you could do something
  17. * like:
  18. *
  19. * #if defined(SIMDE_ARCH_X86) && (SIMDE_ARCH_X86 >= 5)
  20. * ...
  21. * #endif
  22. *
  23. * You could also just check that SIMDE_ARCH_X86 >= 5 without checking
  24. * if it's defined first, but some compilers may emit a warning about
  25. * an undefined macro being used (e.g., GCC with -Wundef).
  26. *
  27. * This was originally created for SIMDe
  28. * <https://github.com/nemequ/simde> (hence the prefix), but this
  29. * header has no dependencies and may be used anywhere. It is
  30. * originally based on information from
  31. * <https://sourceforge.net/p/predef/wiki/Architectures/>, though it
  32. * has been enhanced with additional information.
  33. *
  34. * If you improve this file, or find a bug, please file the issue at
  35. * <https://github.com/nemequ/simde/issues>. If you copy this into
  36. * your project, even if you change the prefix, please keep the links
  37. * to SIMDe intact so others know where to report issues, submit
  38. * enhancements, and find the latest version. */
  39. #if !defined(SIMDE_ARCH_H)
  40. #define SIMDE_ARCH_H
  41. /* Alpha
  42. <https://en.wikipedia.org/wiki/DEC_Alpha> */
  43. #if defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
  44. #if defined(__alpha_ev6__)
  45. #define SIMDE_ARCH_ALPHA 6
  46. #elif defined(__alpha_ev5__)
  47. #define SIMDE_ARCH_ALPHA 5
  48. #elif defined(__alpha_ev4__)
  49. #define SIMDE_ARCH_ALPHA 4
  50. #else
  51. #define SIMDE_ARCH_ALPHA 1
  52. #endif
  53. #endif
  54. /* Atmel AVR
  55. <https://en.wikipedia.org/wiki/Atmel_AVR> */
  56. #if defined(__AVR_ARCH__)
  57. #define SIMDE_ARCH_AVR __AVR_ARCH__
  58. #endif
  59. /* AMD64 / x86_64
  60. <https://en.wikipedia.org/wiki/X86-64> */
  61. #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || \
  62. defined(__x86_64) || defined(_M_X66) || defined(_M_AMD64)
  63. #define SIMDE_ARCH_AMD64 1
  64. #endif
  65. /* ARM
  66. <https://en.wikipedia.org/wiki/ARM_architecture> */
  67. #if defined(__ARM_ARCH_8A__)
  68. #define SIMDE_ARCH_ARM 82
  69. #elif defined(__ARM_ARCH_8R__)
  70. #define SIMDE_ARCH_ARM 81
  71. #elif defined(__ARM_ARCH_8__)
  72. #define SIMDE_ARCH_ARM 80
  73. #elif defined(__ARM_ARCH_7S__)
  74. #define SIMDE_ARCH_ARM 74
  75. #elif defined(__ARM_ARCH_7M__)
  76. #define SIMDE_ARCH_ARM 73
  77. #elif defined(__ARM_ARCH_7R__)
  78. #define SIMDE_ARCH_ARM 72
  79. #elif defined(__ARM_ARCH_7A__)
  80. #define SIMDE_ARCH_ARM 71
  81. #elif defined(__ARM_ARCH_7__)
  82. #define SIMDE_ARCH_ARM 70
  83. #elif defined(__ARM_ARCH)
  84. #define SIMDE_ARCH_ARM (__ARM_ARCH * 10)
  85. #elif defined(_M_ARM)
  86. #define SIMDE_ARCH_ARM (_M_ARM * 10)
  87. #elif defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) || \
  88. defined(_ARM) || defined(_M_ARM) || defined(_M_ARM)
  89. #define SIMDE_ARCH_ARM 1
  90. #endif
  91. /* AArch64
  92. <https://en.wikipedia.org/wiki/ARM_architecture> */
  93. #if defined(__aarch64__) || defined(_M_ARM64)
  94. #define SIMDE_ARCH_AARCH64 10
  95. #endif
  96. /* Blackfin
  97. <https://en.wikipedia.org/wiki/Blackfin> */
  98. #if defined(__bfin) || defined(__BFIN__) || defined(__bfin__)
  99. #define SIMDE_ARCH_BLACKFIN 1
  100. #endif
  101. /* CRIS
  102. <https://en.wikipedia.org/wiki/ETRAX_CRIS> */
  103. #if defined(__CRIS_arch_version)
  104. #define SIMDE_ARCH_CRIS __CRIS_arch_version
  105. #elif defined(__cris__) || defined(__cris) || defined(__CRIS) || \
  106. defined(__CRIS__)
  107. #define SIMDE_ARCH_CRIS 1
  108. #endif
  109. /* Convex
  110. <https://en.wikipedia.org/wiki/Convex_Computer> */
  111. #if defined(__convex_c38__)
  112. #define SIMDE_ARCH_CONVEX 38
  113. #elif defined(__convex_c34__)
  114. #define SIMDE_ARCH_CONVEX 34
  115. #elif defined(__convex_c32__)
  116. #define SIMDE_ARCH_CONVEX 32
  117. #elif defined(__convex_c2__)
  118. #define SIMDE_ARCH_CONVEX 2
  119. #elif defined(__convex__)
  120. #define SIMDE_ARCH_CONVEX 1
  121. #endif
  122. /* Adapteva Epiphany
  123. <https://en.wikipedia.org/wiki/Adapteva_Epiphany> */
  124. #if defined(__epiphany__)
  125. #define SIMDE_ARCH_EPIPHANY 1
  126. #endif
  127. /* Fujitsu FR-V
  128. <https://en.wikipedia.org/wiki/FR-V_(microprocessor)> */
  129. #if defined(__frv__)
  130. #define SIMDE_ARCH_FRV 1
  131. #endif
  132. /* H8/300
  133. <https://en.wikipedia.org/wiki/H8_Family> */
  134. #if defined(__H8300__)
  135. #define SIMDE_ARCH_H8300
  136. #endif
  137. /* HP/PA / PA-RISC
  138. <https://en.wikipedia.org/wiki/PA-RISC> */
  139. #if defined(__PA8000__) || defined(__HPPA20__) || defined(__RISC2_0__) || \
  140. defined(_PA_RISC2_0)
  141. #define SIMDE_ARCH_HPPA 20
  142. #elif defined(__PA7100__) || defined(__HPPA11__) || defined(_PA_RISC1_1)
  143. #define SIMDE_ARCH_HPPA 11
  144. #elif defined(_PA_RISC1_0)
  145. #define SIMDE_ARCH_HPPA 10
  146. #elif defined(__hppa__) || defined(__HPPA__) || defined(__hppa)
  147. #define SIMDE_ARCH_HPPA 1
  148. #endif
  149. /* x86
  150. <https://en.wikipedia.org/wiki/X86> */
  151. #if defined(_M_IX86)
  152. #define SIMDE_ARCH_X86 (_M_IX86 / 100)
  153. #elif defined(__I86__)
  154. #define SIMDE_ARCH_X86 __I86__
  155. #elif defined(i686) || defined(__i686) || defined(__i686__)
  156. #define SIMDE_ARCH_X86 6
  157. #elif defined(i586) || defined(__i586) || defined(__i586__)
  158. #define SIMDE_ARCH_X86 5
  159. #elif defined(i486) || defined(__i486) || defined(__i486__)
  160. #define SIMDE_ARCH_X86 4
  161. #elif defined(i386) || defined(__i386) || defined(__i386__)
  162. #define SIMDE_ARCH_X86 3
  163. #elif defined(_X86_) || defined(__X86__) || defined(__THW_INTEL__)
  164. #define SIMDE_ARCH_X86 3
  165. #endif
  166. /* Itanium
  167. <https://en.wikipedia.org/wiki/Itanium> */
  168. #if defined(__ia64__) || defined(_IA64) || defined(__IA64__) || \
  169. defined(__ia64) || defined(_M_IA64) || defined(__itanium__)
  170. #define SIMDE_ARCH_IA64 1
  171. #endif
  172. /* Renesas M32R
  173. <https://en.wikipedia.org/wiki/M32R> */
  174. #if defined(__m32r__) || defined(__M32R__)
  175. #define SIMDE_ARCH_M32R
  176. #endif
  177. /* Motorola 68000
  178. <https://en.wikipedia.org/wiki/Motorola_68000> */
  179. #if defined(__mc68060__) || defined(__MC68060__)
  180. #define SIMDE_ARCH_M68K 68060
  181. #elif defined(__mc68040__) || defined(__MC68040__)
  182. #define SIMDE_ARCH_M68K 68040
  183. #elif defined(__mc68030__) || defined(__MC68030__)
  184. #define SIMDE_ARCH_M68K 68030
  185. #elif defined(__mc68020__) || defined(__MC68020__)
  186. #define SIMDE_ARCH_M68K 68020
  187. #elif defined(__mc68010__) || defined(__MC68010__)
  188. #define SIMDE_ARCH_M68K 68010
  189. #elif defined(__mc68000__) || defined(__MC68000__)
  190. #define SIMDE_ARCH_M68K 68000
  191. #endif
  192. /* Xilinx MicroBlaze
  193. <https://en.wikipedia.org/wiki/MicroBlaze> */
  194. #if defined(__MICROBLAZE__) || defined(__microblaze__)
  195. #define SIMDE_ARCH_MICROBLAZE
  196. #endif
  197. /* MIPS
  198. <https://en.wikipedia.org/wiki/MIPS_architecture> */
  199. #if defined(_MIPS_ISA_MIPS64R2)
  200. #define SIMDE_ARCH_MIPS 642
  201. #elif defined(_MIPS_ISA_MIPS64)
  202. #define SIMDE_ARCH_MIPS 640
  203. #elif defined(_MIPS_ISA_MIPS32R2)
  204. #define SIMDE_ARCH_MIPS 322
  205. #elif defined(_MIPS_ISA_MIPS32)
  206. #define SIMDE_ARCH_MIPS 320
  207. #elif defined(_MIPS_ISA_MIPS4)
  208. #define SIMDE_ARCH_MIPS 4
  209. #elif defined(_MIPS_ISA_MIPS3)
  210. #define SIMDE_ARCH_MIPS 3
  211. #elif defined(_MIPS_ISA_MIPS2)
  212. #define SIMDE_ARCH_MIPS 2
  213. #elif defined(_MIPS_ISA_MIPS1)
  214. #define SIMDE_ARCH_MIPS 1
  215. #elif defined(_MIPS_ISA_MIPS) || defined(__mips) || defined(__MIPS__)
  216. #define SIMDE_ARCH_MIPS 1
  217. #endif
  218. /* Matsushita MN10300
  219. <https://en.wikipedia.org/wiki/MN103> */
  220. #if defined(__MN10300__) || defined(__mn10300__)
  221. #define SIMDE_ARCH_MN10300 1
  222. #endif
  223. /* POWER
  224. <https://en.wikipedia.org/wiki/IBM_POWER_Instruction_Set_Architecture> */
  225. #if defined(_M_PPC)
  226. #define SIMDE_ARCH_POWER _M_PPC
  227. #elif defined(_ARCH_PWR8)
  228. #define SIMDE_ARCH_POWER 800
  229. #elif defined(_ARCH_PWR7)
  230. #define SIMDE_ARCH_POWER 700
  231. #elif defined(_ARCH_PWR6)
  232. #define SIMDE_ARCH_POWER 600
  233. #elif defined(_ARCH_PWR5)
  234. #define SIMDE_ARCH_POWER 500
  235. #elif defined(_ARCH_PWR4)
  236. #define SIMDE_ARCH_POWER 400
  237. #elif defined(_ARCH_440) || defined(__ppc440__)
  238. #define SIMDE_ARCH_POWER 440
  239. #elif defined(_ARCH_450) || defined(__ppc450__)
  240. #define SIMDE_ARCH_POWER 450
  241. #elif defined(_ARCH_601) || defined(__ppc601__)
  242. #define SIMDE_ARCH_POWER 601
  243. #elif defined(_ARCH_603) || defined(__ppc603__)
  244. #define SIMDE_ARCH_POWER 603
  245. #elif defined(_ARCH_604) || defined(__ppc604__)
  246. #define SIMDE_ARCH_POWER 604
  247. #elif defined(_ARCH_605) || defined(__ppc605__)
  248. #define SIMDE_ARCH_POWER 605
  249. #elif defined(_ARCH_620) || defined(__ppc620__)
  250. #define SIMDE_ARCH_POWER 620
  251. #elif defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) || \
  252. defined(__ppc__) || defined(__PPC__) || defined(_ARCH_PPC) || \
  253. defined(__ppc)
  254. #define SIMDE_ARCH_POWER 1
  255. #endif
  256. /* SPARC
  257. <https://en.wikipedia.org/wiki/SPARC> */
  258. #if defined(__sparc_v9__) || defined(__sparcv9)
  259. #define SIMDE_ARCH_SPARC 9
  260. #elif defined(__sparc_v8__) || defined(__sparcv8)
  261. #define SIMDE_ARCH_SPARC 8
  262. #elif defined(__sparc_v7__) || defined(__sparcv7)
  263. #define SIMDE_ARCH_SPARC 7
  264. #elif defined(__sparc_v6__) || defined(__sparcv6)
  265. #define SIMDE_ARCH_SPARC 6
  266. #elif defined(__sparc_v5__) || defined(__sparcv5)
  267. #define SIMDE_ARCH_SPARC 5
  268. #elif defined(__sparc_v4__) || defined(__sparcv4)
  269. #define SIMDE_ARCH_SPARC 4
  270. #elif defined(__sparc_v3__) || defined(__sparcv3)
  271. #define SIMDE_ARCH_SPARC 3
  272. #elif defined(__sparc_v2__) || defined(__sparcv2)
  273. #define SIMDE_ARCH_SPARC 2
  274. #elif defined(__sparc_v1__) || defined(__sparcv1)
  275. #define SIMDE_ARCH_SPARC 1
  276. #elif defined(__sparc__) || defined(__sparc)
  277. #define SIMDE_ARCH_SPARC 1
  278. #endif
  279. /* SuperH
  280. <https://en.wikipedia.org/wiki/SuperH> */
  281. #if defined(__sh5__) || defined(__SH5__)
  282. #define SIMDE_ARCH_SUPERH 5
  283. #elif defined(__sh4__) || defined(__SH4__)
  284. #define SIMDE_ARCH_SUPERH 4
  285. #elif defined(__sh3__) || defined(__SH3__)
  286. #define SIMDE_ARCH_SUPERH 3
  287. #elif defined(__sh2__) || defined(__SH2__)
  288. #define SIMDE_ARCH_SUPERH 2
  289. #elif defined(__sh1__) || defined(__SH1__)
  290. #define SIMDE_ARCH_SUPERH 1
  291. #elif defined(__sh__) || defined(__SH__)
  292. #define SIMDE_ARCH_SUPERH 1
  293. #endif
  294. /* IBM System z
  295. <https://en.wikipedia.org/wiki/IBM_System_z> */
  296. #if defined(__370__) || defined(__THW_370__) || defined(__s390__) || \
  297. defined(__s390x__) || defined(__zarch__) || defined(__SYSC_ZARCH__)
  298. #define SIMDE_ARCH_SYSTEMZ
  299. #endif
  300. /* TMS320 DSP
  301. <https://en.wikipedia.org/wiki/Texas_Instruments_TMS320> */
  302. #if defined(_TMS320C6740) || defined(__TMS320C6740__)
  303. #define SIMDE_ARCH_TMS320 6740
  304. #elif defined(_TMS320C6700_PLUS) || defined(__TMS320C6700_PLUS__)
  305. #define SIMDE_ARCH_TMS320 6701
  306. #elif defined(_TMS320C6700) || defined(__TMS320C6700__)
  307. #define SIMDE_ARCH_TMS320 6700
  308. #elif defined(_TMS320C6600) || defined(__TMS320C6600__)
  309. #define SIMDE_ARCH_TMS320 6600
  310. #elif defined(_TMS320C6400_PLUS) || defined(__TMS320C6400_PLUS__)
  311. #define SIMDE_ARCH_TMS320 6401
  312. #elif defined(_TMS320C6400) || defined(__TMS320C6400__)
  313. #define SIMDE_ARCH_TMS320 6400
  314. #elif defined(_TMS320C6200) || defined(__TMS320C6200__)
  315. #define SIMDE_ARCH_TMS320 6200
  316. #elif defined(_TMS320C55X) || defined(__TMS320C55X__)
  317. #define SIMDE_ARCH_TMS320 550
  318. #elif defined(_TMS320C54X) || defined(__TMS320C54X__)
  319. #define SIMDE_ARCH_TMS320 540
  320. #elif defined(_TMS320C28X) || defined(__TMS320C28X__)
  321. #define SIMDE_ARCH_TMS320 280
  322. #endif
  323. /* Xtensa
  324. <https://en.wikipedia.org/wiki/> */
  325. #if defined(__xtensa__) || defined(__XTENSA__)
  326. #define SIMDE_ARCH_XTENSA 1
  327. #endif
  328. #endif /* !defined(SIMDE_ARCH_H) */