X86TargetParser.def 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. //===- X86TargetParser.def - X86 target parsing defines ---------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file provides defines to build up the X86 target parser's logic.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. // NOTE: NO INCLUDE GUARD DESIRED!
  13. #ifndef X86_VENDOR
  14. #define X86_VENDOR(ENUM, STR)
  15. #endif
  16. X86_VENDOR(VENDOR_INTEL, "intel")
  17. X86_VENDOR(VENDOR_AMD, "amd")
  18. #undef X86_VENDOR
  19. // This macro is used for cpu types present in compiler-rt/libgcc.
  20. #ifndef X86_CPU_TYPE
  21. #define X86_CPU_TYPE(ENUM, STR)
  22. #endif
  23. #ifndef X86_CPU_TYPE_ALIAS
  24. #define X86_CPU_TYPE_ALIAS(ENUM, STR)
  25. #endif
  26. // This list must match what is implemented in libgcc and compilert-rt. Clang
  27. // uses this to know how to implement __builtin_cpu_is.
  28. X86_CPU_TYPE(INTEL_BONNELL, "bonnell")
  29. X86_CPU_TYPE(INTEL_CORE2, "core2")
  30. X86_CPU_TYPE(INTEL_COREI7, "corei7")
  31. X86_CPU_TYPE(AMDFAM10H, "amdfam10h")
  32. X86_CPU_TYPE(AMDFAM15H, "amdfam15h")
  33. X86_CPU_TYPE(INTEL_SILVERMONT, "silvermont")
  34. X86_CPU_TYPE(INTEL_KNL, "knl")
  35. X86_CPU_TYPE(AMD_BTVER1, "btver1")
  36. X86_CPU_TYPE(AMD_BTVER2, "btver2")
  37. X86_CPU_TYPE(AMDFAM17H, "amdfam17h")
  38. X86_CPU_TYPE(INTEL_KNM, "knm")
  39. X86_CPU_TYPE(INTEL_GOLDMONT, "goldmont")
  40. X86_CPU_TYPE(INTEL_GOLDMONT_PLUS, "goldmont-plus")
  41. X86_CPU_TYPE(INTEL_TREMONT, "tremont")
  42. X86_CPU_TYPE(AMDFAM19H, "amdfam19h")
  43. // Alternate names supported by __builtin_cpu_is and target multiversioning.
  44. X86_CPU_TYPE_ALIAS(INTEL_BONNELL, "atom")
  45. X86_CPU_TYPE_ALIAS(AMDFAM10H, "amdfam10")
  46. X86_CPU_TYPE_ALIAS(AMDFAM15H, "amdfam15")
  47. X86_CPU_TYPE_ALIAS(INTEL_SILVERMONT, "slm")
  48. #undef X86_CPU_TYPE_ALIAS
  49. #undef X86_CPU_TYPE
  50. // This macro is used for cpu subtypes present in compiler-rt/libgcc.
  51. #ifndef X86_CPU_SUBTYPE
  52. #define X86_CPU_SUBTYPE(ENUM, STR)
  53. #endif
  54. // This list must match what is implemented in libgcc and compilert-rt. Clang
  55. // uses this to know how to implement __builtin_cpu_is.
  56. X86_CPU_SUBTYPE(INTEL_COREI7_NEHALEM, "nehalem")
  57. X86_CPU_SUBTYPE(INTEL_COREI7_WESTMERE, "westmere")
  58. X86_CPU_SUBTYPE(INTEL_COREI7_SANDYBRIDGE, "sandybridge")
  59. X86_CPU_SUBTYPE(AMDFAM10H_BARCELONA, "barcelona")
  60. X86_CPU_SUBTYPE(AMDFAM10H_SHANGHAI, "shanghai")
  61. X86_CPU_SUBTYPE(AMDFAM10H_ISTANBUL, "istanbul")
  62. X86_CPU_SUBTYPE(AMDFAM15H_BDVER1, "bdver1")
  63. X86_CPU_SUBTYPE(AMDFAM15H_BDVER2, "bdver2")
  64. X86_CPU_SUBTYPE(AMDFAM15H_BDVER3, "bdver3")
  65. X86_CPU_SUBTYPE(AMDFAM15H_BDVER4, "bdver4")
  66. X86_CPU_SUBTYPE(AMDFAM17H_ZNVER1, "znver1")
  67. X86_CPU_SUBTYPE(INTEL_COREI7_IVYBRIDGE, "ivybridge")
  68. X86_CPU_SUBTYPE(INTEL_COREI7_HASWELL, "haswell")
  69. X86_CPU_SUBTYPE(INTEL_COREI7_BROADWELL, "broadwell")
  70. X86_CPU_SUBTYPE(INTEL_COREI7_SKYLAKE, "skylake")
  71. X86_CPU_SUBTYPE(INTEL_COREI7_SKYLAKE_AVX512, "skylake-avx512")
  72. X86_CPU_SUBTYPE(INTEL_COREI7_CANNONLAKE, "cannonlake")
  73. X86_CPU_SUBTYPE(INTEL_COREI7_ICELAKE_CLIENT, "icelake-client")
  74. X86_CPU_SUBTYPE(INTEL_COREI7_ICELAKE_SERVER, "icelake-server")
  75. X86_CPU_SUBTYPE(AMDFAM17H_ZNVER2, "znver2")
  76. X86_CPU_SUBTYPE(INTEL_COREI7_CASCADELAKE, "cascadelake")
  77. X86_CPU_SUBTYPE(INTEL_COREI7_TIGERLAKE, "tigerlake")
  78. X86_CPU_SUBTYPE(INTEL_COREI7_COOPERLAKE, "cooperlake")
  79. X86_CPU_SUBTYPE(INTEL_COREI7_SAPPHIRERAPIDS, "sapphirerapids")
  80. X86_CPU_SUBTYPE(INTEL_COREI7_ALDERLAKE, "alderlake")
  81. X86_CPU_SUBTYPE(AMDFAM19H_ZNVER3, "znver3")
  82. X86_CPU_SUBTYPE(INTEL_COREI7_ROCKETLAKE, "rocketlake")
  83. #undef X86_CPU_SUBTYPE
  84. // This macro is used for cpu types present in compiler-rt/libgcc. The third
  85. // parameter PRIORITY is as required by the attribute 'target' checking. Note
  86. // that not all are supported/prioritized by GCC, so synchronization with GCC's
  87. // implementation may require changing some existing values.
  88. //
  89. // We cannot just re-sort the list though because its order is dictated by the
  90. // order of bits in CodeGenFunction::GetX86CpuSupportsMask.
  91. #ifndef X86_FEATURE_COMPAT
  92. #define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) X86_FEATURE(ENUM, STR)
  93. #endif
  94. #ifndef X86_FEATURE
  95. #define X86_FEATURE(ENUM, STR)
  96. #endif
  97. X86_FEATURE_COMPAT(CMOV, "cmov", 0)
  98. X86_FEATURE_COMPAT(MMX, "mmx", 1)
  99. X86_FEATURE_COMPAT(POPCNT, "popcnt", 9)
  100. X86_FEATURE_COMPAT(SSE, "sse", 2)
  101. X86_FEATURE_COMPAT(SSE2, "sse2", 3)
  102. X86_FEATURE_COMPAT(SSE3, "sse3", 4)
  103. X86_FEATURE_COMPAT(SSSE3, "ssse3", 5)
  104. X86_FEATURE_COMPAT(SSE4_1, "sse4.1", 7)
  105. X86_FEATURE_COMPAT(SSE4_2, "sse4.2", 8)
  106. X86_FEATURE_COMPAT(AVX, "avx", 12)
  107. X86_FEATURE_COMPAT(AVX2, "avx2", 18)
  108. X86_FEATURE_COMPAT(SSE4_A, "sse4a", 6)
  109. X86_FEATURE_COMPAT(FMA4, "fma4", 14)
  110. X86_FEATURE_COMPAT(XOP, "xop", 15)
  111. X86_FEATURE_COMPAT(FMA, "fma", 16)
  112. X86_FEATURE_COMPAT(AVX512F, "avx512f", 19)
  113. X86_FEATURE_COMPAT(BMI, "bmi", 13)
  114. X86_FEATURE_COMPAT(BMI2, "bmi2", 17)
  115. X86_FEATURE_COMPAT(AES, "aes", 10)
  116. X86_FEATURE_COMPAT(PCLMUL, "pclmul", 11)
  117. X86_FEATURE_COMPAT(AVX512VL, "avx512vl", 20)
  118. X86_FEATURE_COMPAT(AVX512BW, "avx512bw", 21)
  119. X86_FEATURE_COMPAT(AVX512DQ, "avx512dq", 22)
  120. X86_FEATURE_COMPAT(AVX512CD, "avx512cd", 23)
  121. X86_FEATURE_COMPAT(AVX512ER, "avx512er", 24)
  122. X86_FEATURE_COMPAT(AVX512PF, "avx512pf", 25)
  123. X86_FEATURE_COMPAT(AVX512VBMI, "avx512vbmi", 26)
  124. X86_FEATURE_COMPAT(AVX512IFMA, "avx512ifma", 27)
  125. X86_FEATURE_COMPAT(AVX5124VNNIW, "avx5124vnniw", 28)
  126. X86_FEATURE_COMPAT(AVX5124FMAPS, "avx5124fmaps", 29)
  127. X86_FEATURE_COMPAT(AVX512VPOPCNTDQ, "avx512vpopcntdq", 30)
  128. X86_FEATURE_COMPAT(AVX512VBMI2, "avx512vbmi2", 31)
  129. X86_FEATURE_COMPAT(GFNI, "gfni", 32)
  130. X86_FEATURE_COMPAT(VPCLMULQDQ, "vpclmulqdq", 33)
  131. X86_FEATURE_COMPAT(AVX512VNNI, "avx512vnni", 34)
  132. X86_FEATURE_COMPAT(AVX512BITALG, "avx512bitalg", 35)
  133. X86_FEATURE_COMPAT(AVX512BF16, "avx512bf16", 36)
  134. X86_FEATURE_COMPAT(AVX512VP2INTERSECT, "avx512vp2intersect", 37)
  135. // Features below here are not in libgcc/compiler-rt.
  136. X86_FEATURE (3DNOW, "3dnow")
  137. X86_FEATURE (3DNOWA, "3dnowa")
  138. X86_FEATURE (64BIT, "64bit")
  139. X86_FEATURE (ADX, "adx")
  140. X86_FEATURE (AMX_BF16, "amx-bf16")
  141. X86_FEATURE (AMX_INT8, "amx-int8")
  142. X86_FEATURE (AMX_TILE, "amx-tile")
  143. X86_FEATURE (CLDEMOTE, "cldemote")
  144. X86_FEATURE (CLFLUSHOPT, "clflushopt")
  145. X86_FEATURE (CLWB, "clwb")
  146. X86_FEATURE (CLZERO, "clzero")
  147. X86_FEATURE (CMPXCHG16B, "cx16")
  148. X86_FEATURE (CMPXCHG8B, "cx8")
  149. X86_FEATURE (CRC32, "crc32")
  150. X86_FEATURE (ENQCMD, "enqcmd")
  151. X86_FEATURE (F16C, "f16c")
  152. X86_FEATURE (FSGSBASE, "fsgsbase")
  153. X86_FEATURE (FXSR, "fxsr")
  154. X86_FEATURE (INVPCID, "invpcid")
  155. X86_FEATURE (KL, "kl")
  156. X86_FEATURE (WIDEKL, "widekl")
  157. X86_FEATURE (LWP, "lwp")
  158. X86_FEATURE (LZCNT, "lzcnt")
  159. X86_FEATURE (MOVBE, "movbe")
  160. X86_FEATURE (MOVDIR64B, "movdir64b")
  161. X86_FEATURE (MOVDIRI, "movdiri")
  162. X86_FEATURE (MWAITX, "mwaitx")
  163. X86_FEATURE (PCONFIG, "pconfig")
  164. X86_FEATURE (PKU, "pku")
  165. X86_FEATURE (PREFETCHWT1, "prefetchwt1")
  166. X86_FEATURE (PRFCHW, "prfchw")
  167. X86_FEATURE (PTWRITE, "ptwrite")
  168. X86_FEATURE (RDPID, "rdpid")
  169. X86_FEATURE (RDRND, "rdrnd")
  170. X86_FEATURE (RDSEED, "rdseed")
  171. X86_FEATURE (RTM, "rtm")
  172. X86_FEATURE (SAHF, "sahf")
  173. X86_FEATURE (SERIALIZE, "serialize")
  174. X86_FEATURE (SGX, "sgx")
  175. X86_FEATURE (SHA, "sha")
  176. X86_FEATURE (SHSTK, "shstk")
  177. X86_FEATURE (TBM, "tbm")
  178. X86_FEATURE (TSXLDTRK, "tsxldtrk")
  179. X86_FEATURE (UINTR, "uintr")
  180. X86_FEATURE (VAES, "vaes")
  181. X86_FEATURE (VZEROUPPER, "vzeroupper")
  182. X86_FEATURE (WAITPKG, "waitpkg")
  183. X86_FEATURE (WBNOINVD, "wbnoinvd")
  184. X86_FEATURE (X87, "x87")
  185. X86_FEATURE (XSAVE, "xsave")
  186. X86_FEATURE (XSAVEC, "xsavec")
  187. X86_FEATURE (XSAVEOPT, "xsaveopt")
  188. X86_FEATURE (XSAVES, "xsaves")
  189. X86_FEATURE (HRESET, "hreset")
  190. X86_FEATURE (AVX512FP16, "avx512fp16")
  191. X86_FEATURE (AVXVNNI, "avxvnni")
  192. // These features aren't really CPU features, but the frontend can set them.
  193. X86_FEATURE (RETPOLINE_EXTERNAL_THUNK, "retpoline-external-thunk")
  194. X86_FEATURE (RETPOLINE_INDIRECT_BRANCHES, "retpoline-indirect-branches")
  195. X86_FEATURE (RETPOLINE_INDIRECT_CALLS, "retpoline-indirect-calls")
  196. X86_FEATURE (LVI_CFI, "lvi-cfi")
  197. X86_FEATURE (LVI_LOAD_HARDENING, "lvi-load-hardening")
  198. #undef X86_FEATURE_COMPAT
  199. #undef X86_FEATURE
  200. #ifndef CPU_SPECIFIC
  201. #define CPU_SPECIFIC(NAME, MANGLING, FEATURES)
  202. #endif
  203. #ifndef CPU_SPECIFIC_ALIAS
  204. #define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME)
  205. #endif
  206. CPU_SPECIFIC("generic", 'A', "")
  207. CPU_SPECIFIC("pentium", 'B', "")
  208. CPU_SPECIFIC("pentium_pro", 'C', "+cmov")
  209. CPU_SPECIFIC("pentium_mmx", 'D', "+mmx")
  210. CPU_SPECIFIC("pentium_ii", 'E', "+cmov,+mmx")
  211. CPU_SPECIFIC("pentium_iii", 'H', "+cmov,+mmx,+sse")
  212. CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium_iii")
  213. CPU_SPECIFIC("pentium_4", 'J', "+cmov,+mmx,+sse,+sse2")
  214. CPU_SPECIFIC("pentium_m", 'K', "+cmov,+mmx,+sse,+sse2")
  215. CPU_SPECIFIC("pentium_4_sse3", 'L', "+cmov,+mmx,+sse,+sse2,+sse3")
  216. CPU_SPECIFIC("core_2_duo_ssse3", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3")
  217. CPU_SPECIFIC("core_2_duo_sse4_1", 'N', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1")
  218. CPU_SPECIFIC("atom", 'O', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+movbe")
  219. CPU_SPECIFIC("atom_sse4_2", 'c', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
  220. CPU_SPECIFIC("core_i7_sse4_2", 'P', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
  221. CPU_SPECIFIC("core_aes_pclmulqdq", 'Q', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
  222. CPU_SPECIFIC("atom_sse4_2_movbe", 'd', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
  223. CPU_SPECIFIC("goldmont", 'i', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
  224. CPU_SPECIFIC("sandybridge", 'R', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx")
  225. CPU_SPECIFIC_ALIAS("core_2nd_gen_avx", "sandybridge")
  226. CPU_SPECIFIC("ivybridge", 'S', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+f16c,+avx")
  227. CPU_SPECIFIC_ALIAS("core_3rd_gen_avx", "ivybridge")
  228. CPU_SPECIFIC("haswell", 'V', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
  229. CPU_SPECIFIC_ALIAS("core_4th_gen_avx", "haswell")
  230. CPU_SPECIFIC("core_4th_gen_avx_tsx", 'W', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
  231. CPU_SPECIFIC("broadwell", 'X', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
  232. CPU_SPECIFIC_ALIAS("core_5th_gen_avx", "broadwell")
  233. CPU_SPECIFIC("core_5th_gen_avx_tsx", 'Y', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
  234. CPU_SPECIFIC("knl", 'Z', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd")
  235. CPU_SPECIFIC_ALIAS("mic_avx512", "knl")
  236. CPU_SPECIFIC("skylake", 'b', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx,+mpx")
  237. CPU_SPECIFIC( "skylake_avx512", 'a', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512cd,+avx512bw,+avx512vl,+clwb")
  238. CPU_SPECIFIC("cannonlake", 'e', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512ifma,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi")
  239. CPU_SPECIFIC("knm", 'j', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd,+avx5124fmaps,+avx5124vnniw,+avx512vpopcntdq")
  240. #undef CPU_SPECIFIC_ALIAS
  241. #undef CPU_SPECIFIC