X86.td 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593
  1. //===-- X86.td - Target definition file for the Intel X86 --*- tablegen -*-===//
  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 is a target description file for the Intel i386 architecture, referred
  10. // to here as the "X86" architecture.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. // Get the target-independent interfaces which we are implementing...
  14. //
  15. include "llvm/Target/Target.td"
  16. //===----------------------------------------------------------------------===//
  17. // X86 Subtarget state
  18. //
  19. def Mode64Bit : SubtargetFeature<"64bit-mode", "In64BitMode", "true",
  20. "64-bit mode (x86_64)">;
  21. def Mode32Bit : SubtargetFeature<"32bit-mode", "In32BitMode", "true",
  22. "32-bit mode (80386)">;
  23. def Mode16Bit : SubtargetFeature<"16bit-mode", "In16BitMode", "true",
  24. "16-bit mode (i8086)">;
  25. //===----------------------------------------------------------------------===//
  26. // X86 Subtarget ISA features
  27. //===----------------------------------------------------------------------===//
  28. def FeatureX87 : SubtargetFeature<"x87","HasX87", "true",
  29. "Enable X87 float instructions">;
  30. def FeatureNOPL : SubtargetFeature<"nopl", "HasNOPL", "true",
  31. "Enable NOPL instruction">;
  32. def FeatureCMOV : SubtargetFeature<"cmov","HasCMov", "true",
  33. "Enable conditional move instructions">;
  34. def FeatureCMPXCHG8B : SubtargetFeature<"cx8", "HasCmpxchg8b", "true",
  35. "Support CMPXCHG8B instructions">;
  36. def FeatureCRC32 : SubtargetFeature<"crc32", "HasCRC32", "true",
  37. "Enable SSE 4.2 CRC32 instruction">;
  38. def FeaturePOPCNT : SubtargetFeature<"popcnt", "HasPOPCNT", "true",
  39. "Support POPCNT instruction">;
  40. def FeatureFXSR : SubtargetFeature<"fxsr", "HasFXSR", "true",
  41. "Support fxsave/fxrestore instructions">;
  42. def FeatureXSAVE : SubtargetFeature<"xsave", "HasXSAVE", "true",
  43. "Support xsave instructions">;
  44. def FeatureXSAVEOPT: SubtargetFeature<"xsaveopt", "HasXSAVEOPT", "true",
  45. "Support xsaveopt instructions",
  46. [FeatureXSAVE]>;
  47. def FeatureXSAVEC : SubtargetFeature<"xsavec", "HasXSAVEC", "true",
  48. "Support xsavec instructions",
  49. [FeatureXSAVE]>;
  50. def FeatureXSAVES : SubtargetFeature<"xsaves", "HasXSAVES", "true",
  51. "Support xsaves instructions",
  52. [FeatureXSAVE]>;
  53. def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1",
  54. "Enable SSE instructions">;
  55. def FeatureSSE2 : SubtargetFeature<"sse2", "X86SSELevel", "SSE2",
  56. "Enable SSE2 instructions",
  57. [FeatureSSE1]>;
  58. def FeatureSSE3 : SubtargetFeature<"sse3", "X86SSELevel", "SSE3",
  59. "Enable SSE3 instructions",
  60. [FeatureSSE2]>;
  61. def FeatureSSSE3 : SubtargetFeature<"ssse3", "X86SSELevel", "SSSE3",
  62. "Enable SSSE3 instructions",
  63. [FeatureSSE3]>;
  64. def FeatureSSE41 : SubtargetFeature<"sse4.1", "X86SSELevel", "SSE41",
  65. "Enable SSE 4.1 instructions",
  66. [FeatureSSSE3]>;
  67. def FeatureSSE42 : SubtargetFeature<"sse4.2", "X86SSELevel", "SSE42",
  68. "Enable SSE 4.2 instructions",
  69. [FeatureSSE41]>;
  70. // The MMX subtarget feature is separate from the rest of the SSE features
  71. // because it's important (for odd compatibility reasons) to be able to
  72. // turn it off explicitly while allowing SSE+ to be on.
  73. def FeatureMMX : SubtargetFeature<"mmx","X863DNowLevel", "MMX",
  74. "Enable MMX instructions">;
  75. def Feature3DNow : SubtargetFeature<"3dnow", "X863DNowLevel", "ThreeDNow",
  76. "Enable 3DNow! instructions",
  77. [FeatureMMX]>;
  78. def Feature3DNowA : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA",
  79. "Enable 3DNow! Athlon instructions",
  80. [Feature3DNow]>;
  81. // All x86-64 hardware has SSE2, but we don't mark SSE2 as an implied
  82. // feature, because SSE2 can be disabled (e.g. for compiling OS kernels)
  83. // without disabling 64-bit mode. Nothing should imply this feature bit. It
  84. // is used to enforce that only 64-bit capable CPUs are used in 64-bit mode.
  85. def Feature64Bit : SubtargetFeature<"64bit", "HasX86_64", "true",
  86. "Support 64-bit instructions">;
  87. def FeatureCMPXCHG16B : SubtargetFeature<"cx16", "HasCmpxchg16b", "true",
  88. "64-bit with cmpxchg16b",
  89. [FeatureCMPXCHG8B]>;
  90. def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
  91. "Support SSE 4a instructions",
  92. [FeatureSSE3]>;
  93. def FeatureAVX : SubtargetFeature<"avx", "X86SSELevel", "AVX",
  94. "Enable AVX instructions",
  95. [FeatureSSE42]>;
  96. def FeatureAVX2 : SubtargetFeature<"avx2", "X86SSELevel", "AVX2",
  97. "Enable AVX2 instructions",
  98. [FeatureAVX]>;
  99. def FeatureFMA : SubtargetFeature<"fma", "HasFMA", "true",
  100. "Enable three-operand fused multiple-add",
  101. [FeatureAVX]>;
  102. def FeatureF16C : SubtargetFeature<"f16c", "HasF16C", "true",
  103. "Support 16-bit floating point conversion instructions",
  104. [FeatureAVX]>;
  105. def FeatureAVX512 : SubtargetFeature<"avx512f", "X86SSELevel", "AVX512F",
  106. "Enable AVX-512 instructions",
  107. [FeatureAVX2, FeatureFMA, FeatureF16C]>;
  108. def FeatureERI : SubtargetFeature<"avx512er", "HasERI", "true",
  109. "Enable AVX-512 Exponential and Reciprocal Instructions",
  110. [FeatureAVX512]>;
  111. def FeatureCDI : SubtargetFeature<"avx512cd", "HasCDI", "true",
  112. "Enable AVX-512 Conflict Detection Instructions",
  113. [FeatureAVX512]>;
  114. def FeatureVPOPCNTDQ : SubtargetFeature<"avx512vpopcntdq", "HasVPOPCNTDQ",
  115. "true", "Enable AVX-512 Population Count Instructions",
  116. [FeatureAVX512]>;
  117. def FeaturePFI : SubtargetFeature<"avx512pf", "HasPFI", "true",
  118. "Enable AVX-512 PreFetch Instructions",
  119. [FeatureAVX512]>;
  120. def FeaturePREFETCHWT1 : SubtargetFeature<"prefetchwt1", "HasPREFETCHWT1",
  121. "true",
  122. "Prefetch with Intent to Write and T1 Hint">;
  123. def FeatureDQI : SubtargetFeature<"avx512dq", "HasDQI", "true",
  124. "Enable AVX-512 Doubleword and Quadword Instructions",
  125. [FeatureAVX512]>;
  126. def FeatureBWI : SubtargetFeature<"avx512bw", "HasBWI", "true",
  127. "Enable AVX-512 Byte and Word Instructions",
  128. [FeatureAVX512]>;
  129. def FeatureVLX : SubtargetFeature<"avx512vl", "HasVLX", "true",
  130. "Enable AVX-512 Vector Length eXtensions",
  131. [FeatureAVX512]>;
  132. def FeatureVBMI : SubtargetFeature<"avx512vbmi", "HasVBMI", "true",
  133. "Enable AVX-512 Vector Byte Manipulation Instructions",
  134. [FeatureBWI]>;
  135. def FeatureVBMI2 : SubtargetFeature<"avx512vbmi2", "HasVBMI2", "true",
  136. "Enable AVX-512 further Vector Byte Manipulation Instructions",
  137. [FeatureBWI]>;
  138. def FeatureIFMA : SubtargetFeature<"avx512ifma", "HasIFMA", "true",
  139. "Enable AVX-512 Integer Fused Multiple-Add",
  140. [FeatureAVX512]>;
  141. def FeaturePKU : SubtargetFeature<"pku", "HasPKU", "true",
  142. "Enable protection keys">;
  143. def FeatureVNNI : SubtargetFeature<"avx512vnni", "HasVNNI", "true",
  144. "Enable AVX-512 Vector Neural Network Instructions",
  145. [FeatureAVX512]>;
  146. def FeatureAVXVNNI : SubtargetFeature<"avxvnni", "HasAVXVNNI", "true",
  147. "Support AVX_VNNI encoding",
  148. [FeatureAVX2]>;
  149. def FeatureBF16 : SubtargetFeature<"avx512bf16", "HasBF16", "true",
  150. "Support bfloat16 floating point",
  151. [FeatureBWI]>;
  152. def FeatureBITALG : SubtargetFeature<"avx512bitalg", "HasBITALG", "true",
  153. "Enable AVX-512 Bit Algorithms",
  154. [FeatureBWI]>;
  155. def FeatureVP2INTERSECT : SubtargetFeature<"avx512vp2intersect",
  156. "HasVP2INTERSECT", "true",
  157. "Enable AVX-512 vp2intersect",
  158. [FeatureAVX512]>;
  159. // FIXME: FP16 scalar intrinsics use the type v8f16, which is supposed to be
  160. // guarded under condition hasVLX. So we imply it in FeatureFP16 currently.
  161. // FIXME: FP16 conversion between f16 and i64 customize type v8i64, which is
  162. // supposed to be guarded under condition hasDQI. So we imply it in FeatureFP16
  163. // currently.
  164. def FeatureFP16 : SubtargetFeature<"avx512fp16", "HasFP16", "true",
  165. "Support 16-bit floating point",
  166. [FeatureBWI, FeatureVLX, FeatureDQI]>;
  167. def FeaturePCLMUL : SubtargetFeature<"pclmul", "HasPCLMUL", "true",
  168. "Enable packed carry-less multiplication instructions",
  169. [FeatureSSE2]>;
  170. def FeatureGFNI : SubtargetFeature<"gfni", "HasGFNI", "true",
  171. "Enable Galois Field Arithmetic Instructions",
  172. [FeatureSSE2]>;
  173. def FeatureVPCLMULQDQ : SubtargetFeature<"vpclmulqdq", "HasVPCLMULQDQ", "true",
  174. "Enable vpclmulqdq instructions",
  175. [FeatureAVX, FeaturePCLMUL]>;
  176. def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
  177. "Enable four-operand fused multiple-add",
  178. [FeatureAVX, FeatureSSE4A]>;
  179. def FeatureXOP : SubtargetFeature<"xop", "HasXOP", "true",
  180. "Enable XOP instructions",
  181. [FeatureFMA4]>;
  182. def FeatureSSEUnalignedMem : SubtargetFeature<"sse-unaligned-mem",
  183. "HasSSEUnalignedMem", "true",
  184. "Allow unaligned memory operands with SSE instructions">;
  185. def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
  186. "Enable AES instructions",
  187. [FeatureSSE2]>;
  188. def FeatureVAES : SubtargetFeature<"vaes", "HasVAES", "true",
  189. "Promote selected AES instructions to AVX512/AVX registers",
  190. [FeatureAVX, FeatureAES]>;
  191. def FeatureTBM : SubtargetFeature<"tbm", "HasTBM", "true",
  192. "Enable TBM instructions">;
  193. def FeatureLWP : SubtargetFeature<"lwp", "HasLWP", "true",
  194. "Enable LWP instructions">;
  195. def FeatureMOVBE : SubtargetFeature<"movbe", "HasMOVBE", "true",
  196. "Support MOVBE instruction">;
  197. def FeatureRDRAND : SubtargetFeature<"rdrnd", "HasRDRAND", "true",
  198. "Support RDRAND instruction">;
  199. def FeatureFSGSBase : SubtargetFeature<"fsgsbase", "HasFSGSBase", "true",
  200. "Support FS/GS Base instructions">;
  201. def FeatureLZCNT : SubtargetFeature<"lzcnt", "HasLZCNT", "true",
  202. "Support LZCNT instruction">;
  203. def FeatureBMI : SubtargetFeature<"bmi", "HasBMI", "true",
  204. "Support BMI instructions">;
  205. def FeatureBMI2 : SubtargetFeature<"bmi2", "HasBMI2", "true",
  206. "Support BMI2 instructions">;
  207. def FeatureRTM : SubtargetFeature<"rtm", "HasRTM", "true",
  208. "Support RTM instructions">;
  209. def FeatureADX : SubtargetFeature<"adx", "HasADX", "true",
  210. "Support ADX instructions">;
  211. def FeatureSHA : SubtargetFeature<"sha", "HasSHA", "true",
  212. "Enable SHA instructions",
  213. [FeatureSSE2]>;
  214. def FeatureSHSTK : SubtargetFeature<"shstk", "HasSHSTK", "true",
  215. "Support CET Shadow-Stack instructions">;
  216. def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
  217. "Support PRFCHW instructions">;
  218. def FeatureRDSEED : SubtargetFeature<"rdseed", "HasRDSEED", "true",
  219. "Support RDSEED instruction">;
  220. def FeatureLAHFSAHF : SubtargetFeature<"sahf", "HasLAHFSAHF64", "true",
  221. "Support LAHF and SAHF instructions in 64-bit mode">;
  222. def FeatureMWAITX : SubtargetFeature<"mwaitx", "HasMWAITX", "true",
  223. "Enable MONITORX/MWAITX timer functionality">;
  224. def FeatureCLZERO : SubtargetFeature<"clzero", "HasCLZERO", "true",
  225. "Enable Cache Line Zero">;
  226. def FeatureCLDEMOTE : SubtargetFeature<"cldemote", "HasCLDEMOTE", "true",
  227. "Enable Cache Demote">;
  228. def FeaturePTWRITE : SubtargetFeature<"ptwrite", "HasPTWRITE", "true",
  229. "Support ptwrite instruction">;
  230. def FeatureAMXTILE : SubtargetFeature<"amx-tile", "HasAMXTILE", "true",
  231. "Support AMX-TILE instructions">;
  232. def FeatureAMXINT8 : SubtargetFeature<"amx-int8", "HasAMXINT8", "true",
  233. "Support AMX-INT8 instructions",
  234. [FeatureAMXTILE]>;
  235. def FeatureAMXBF16 : SubtargetFeature<"amx-bf16", "HasAMXBF16", "true",
  236. "Support AMX-BF16 instructions",
  237. [FeatureAMXTILE]>;
  238. def FeatureINVPCID : SubtargetFeature<"invpcid", "HasINVPCID", "true",
  239. "Invalidate Process-Context Identifier">;
  240. def FeatureSGX : SubtargetFeature<"sgx", "HasSGX", "true",
  241. "Enable Software Guard Extensions">;
  242. def FeatureCLFLUSHOPT : SubtargetFeature<"clflushopt", "HasCLFLUSHOPT", "true",
  243. "Flush A Cache Line Optimized">;
  244. def FeatureCLWB : SubtargetFeature<"clwb", "HasCLWB", "true",
  245. "Cache Line Write Back">;
  246. def FeatureWBNOINVD : SubtargetFeature<"wbnoinvd", "HasWBNOINVD", "true",
  247. "Write Back No Invalidate">;
  248. def FeatureRDPID : SubtargetFeature<"rdpid", "HasRDPID", "true",
  249. "Support RDPID instructions">;
  250. def FeatureWAITPKG : SubtargetFeature<"waitpkg", "HasWAITPKG", "true",
  251. "Wait and pause enhancements">;
  252. def FeatureENQCMD : SubtargetFeature<"enqcmd", "HasENQCMD", "true",
  253. "Has ENQCMD instructions">;
  254. def FeatureKL : SubtargetFeature<"kl", "HasKL", "true",
  255. "Support Key Locker kl Instructions",
  256. [FeatureSSE2]>;
  257. def FeatureWIDEKL : SubtargetFeature<"widekl", "HasWIDEKL", "true",
  258. "Support Key Locker wide Instructions",
  259. [FeatureKL]>;
  260. def FeatureHRESET : SubtargetFeature<"hreset", "HasHRESET", "true",
  261. "Has hreset instruction">;
  262. def FeatureSERIALIZE : SubtargetFeature<"serialize", "HasSERIALIZE", "true",
  263. "Has serialize instruction">;
  264. def FeatureTSXLDTRK : SubtargetFeature<"tsxldtrk", "HasTSXLDTRK", "true",
  265. "Support TSXLDTRK instructions">;
  266. def FeatureUINTR : SubtargetFeature<"uintr", "HasUINTR", "true",
  267. "Has UINTR Instructions">;
  268. def FeaturePCONFIG : SubtargetFeature<"pconfig", "HasPCONFIG", "true",
  269. "platform configuration instruction">;
  270. def FeatureMOVDIRI : SubtargetFeature<"movdiri", "HasMOVDIRI", "true",
  271. "Support movdiri instruction">;
  272. def FeatureMOVDIR64B : SubtargetFeature<"movdir64b", "HasMOVDIR64B", "true",
  273. "Support movdir64b instruction">;
  274. // Ivy Bridge and newer processors have enhanced REP MOVSB and STOSB (aka
  275. // "string operations"). See "REP String Enhancement" in the Intel Software
  276. // Development Manual. This feature essentially means that REP MOVSB will copy
  277. // using the largest available size instead of copying bytes one by one, making
  278. // it at least as fast as REPMOVS{W,D,Q}.
  279. def FeatureERMSB
  280. : SubtargetFeature<
  281. "ermsb", "HasERMSB", "true",
  282. "REP MOVS/STOS are fast">;
  283. // Icelake and newer processors have Fast Short REP MOV.
  284. def FeatureFSRM
  285. : SubtargetFeature<
  286. "fsrm", "HasFSRM", "true",
  287. "REP MOVSB of short lengths is faster">;
  288. def FeatureSoftFloat
  289. : SubtargetFeature<"soft-float", "UseSoftFloat", "true",
  290. "Use software floating point features">;
  291. //===----------------------------------------------------------------------===//
  292. // X86 Subtarget Security Mitigation features
  293. //===----------------------------------------------------------------------===//
  294. // Lower indirect calls using a special construct called a `retpoline` to
  295. // mitigate potential Spectre v2 attacks against them.
  296. def FeatureRetpolineIndirectCalls
  297. : SubtargetFeature<
  298. "retpoline-indirect-calls", "UseRetpolineIndirectCalls", "true",
  299. "Remove speculation of indirect calls from the generated code">;
  300. // Lower indirect branches and switches either using conditional branch trees
  301. // or using a special construct called a `retpoline` to mitigate potential
  302. // Spectre v2 attacks against them.
  303. def FeatureRetpolineIndirectBranches
  304. : SubtargetFeature<
  305. "retpoline-indirect-branches", "UseRetpolineIndirectBranches", "true",
  306. "Remove speculation of indirect branches from the generated code">;
  307. // Deprecated umbrella feature for enabling both `retpoline-indirect-calls` and
  308. // `retpoline-indirect-branches` above.
  309. def FeatureRetpoline
  310. : SubtargetFeature<"retpoline", "DeprecatedUseRetpoline", "true",
  311. "Remove speculation of indirect branches from the "
  312. "generated code, either by avoiding them entirely or "
  313. "lowering them with a speculation blocking construct",
  314. [FeatureRetpolineIndirectCalls,
  315. FeatureRetpolineIndirectBranches]>;
  316. // Rely on external thunks for the emitted retpoline calls. This allows users
  317. // to provide their own custom thunk definitions in highly specialized
  318. // environments such as a kernel that does boot-time hot patching.
  319. def FeatureRetpolineExternalThunk
  320. : SubtargetFeature<
  321. "retpoline-external-thunk", "UseRetpolineExternalThunk", "true",
  322. "When lowering an indirect call or branch using a `retpoline`, rely "
  323. "on the specified user provided thunk rather than emitting one "
  324. "ourselves. Only has effect when combined with some other retpoline "
  325. "feature", [FeatureRetpolineIndirectCalls]>;
  326. // Mitigate LVI attacks against indirect calls/branches and call returns
  327. def FeatureLVIControlFlowIntegrity
  328. : SubtargetFeature<
  329. "lvi-cfi", "UseLVIControlFlowIntegrity", "true",
  330. "Prevent indirect calls/branches from using a memory operand, and "
  331. "precede all indirect calls/branches from a register with an "
  332. "LFENCE instruction to serialize control flow. Also decompose RET "
  333. "instructions into a POP+LFENCE+JMP sequence.">;
  334. // Enable SESES to mitigate speculative execution attacks
  335. def FeatureSpeculativeExecutionSideEffectSuppression
  336. : SubtargetFeature<
  337. "seses", "UseSpeculativeExecutionSideEffectSuppression", "true",
  338. "Prevent speculative execution side channel timing attacks by "
  339. "inserting a speculation barrier before memory reads, memory writes, "
  340. "and conditional branches. Implies LVI Control Flow integrity.",
  341. [FeatureLVIControlFlowIntegrity]>;
  342. // Mitigate LVI attacks against data loads
  343. def FeatureLVILoadHardening
  344. : SubtargetFeature<
  345. "lvi-load-hardening", "UseLVILoadHardening", "true",
  346. "Insert LFENCE instructions to prevent data speculatively injected "
  347. "into loads from being used maliciously.">;
  348. def FeatureTaggedGlobals
  349. : SubtargetFeature<
  350. "tagged-globals", "AllowTaggedGlobals", "true",
  351. "Use an instruction sequence for taking the address of a global "
  352. "that allows a memory tag in the upper address bits.">;
  353. //===----------------------------------------------------------------------===//
  354. // X86 Subtarget Tuning features
  355. //===----------------------------------------------------------------------===//
  356. def TuningSlowSHLD : SubtargetFeature<"slow-shld", "IsSHLDSlow", "true",
  357. "SHLD instruction is slow">;
  358. def TuningSlowPMULLD : SubtargetFeature<"slow-pmulld", "IsPMULLDSlow", "true",
  359. "PMULLD instruction is slow">;
  360. def TuningSlowPMADDWD : SubtargetFeature<"slow-pmaddwd", "IsPMADDWDSlow",
  361. "true",
  362. "PMADDWD is slower than PMULLD">;
  363. // FIXME: This should not apply to CPUs that do not have SSE.
  364. def TuningSlowUAMem16 : SubtargetFeature<"slow-unaligned-mem-16",
  365. "IsUAMem16Slow", "true",
  366. "Slow unaligned 16-byte memory access">;
  367. def TuningSlowUAMem32 : SubtargetFeature<"slow-unaligned-mem-32",
  368. "IsUAMem32Slow", "true",
  369. "Slow unaligned 32-byte memory access">;
  370. def TuningLEAForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true",
  371. "Use LEA for adjusting the stack pointer">;
  372. def TuningSlowDivide32 : SubtargetFeature<"idivl-to-divb",
  373. "HasSlowDivide32", "true",
  374. "Use 8-bit divide for positive values less than 256">;
  375. def TuningSlowDivide64 : SubtargetFeature<"idivq-to-divl",
  376. "HasSlowDivide64", "true",
  377. "Use 32-bit divide for positive values less than 2^32">;
  378. def TuningPadShortFunctions : SubtargetFeature<"pad-short-functions",
  379. "PadShortFunctions", "true",
  380. "Pad short functions">;
  381. // On some processors, instructions that implicitly take two memory operands are
  382. // slow. In practice, this means that CALL, PUSH, and POP with memory operands
  383. // should be avoided in favor of a MOV + register CALL/PUSH/POP.
  384. def TuningSlowTwoMemOps : SubtargetFeature<"slow-two-mem-ops",
  385. "SlowTwoMemOps", "true",
  386. "Two memory operand instructions are slow">;
  387. def TuningLEAUsesAG : SubtargetFeature<"lea-uses-ag", "LEAUsesAG", "true",
  388. "LEA instruction needs inputs at AG stage">;
  389. def TuningSlowLEA : SubtargetFeature<"slow-lea", "SlowLEA", "true",
  390. "LEA instruction with certain arguments is slow">;
  391. def TuningSlow3OpsLEA : SubtargetFeature<"slow-3ops-lea", "Slow3OpsLEA", "true",
  392. "LEA instruction with 3 ops or certain registers is slow">;
  393. def TuningSlowIncDec : SubtargetFeature<"slow-incdec", "SlowIncDec", "true",
  394. "INC and DEC instructions are slower than ADD and SUB">;
  395. def TuningPOPCNTFalseDeps : SubtargetFeature<"false-deps-popcnt",
  396. "HasPOPCNTFalseDeps", "true",
  397. "POPCNT has a false dependency on dest register">;
  398. def TuningLZCNTFalseDeps : SubtargetFeature<"false-deps-lzcnt-tzcnt",
  399. "HasLZCNTFalseDeps", "true",
  400. "LZCNT/TZCNT have a false dependency on dest register">;
  401. // On recent X86 (port bound) processors, its preferable to combine to a single shuffle
  402. // using a variable mask over multiple fixed shuffles.
  403. def TuningFastVariableCrossLaneShuffle
  404. : SubtargetFeature<"fast-variable-crosslane-shuffle",
  405. "HasFastVariableCrossLaneShuffle",
  406. "true", "Cross-lane shuffles with variable masks are fast">;
  407. def TuningFastVariablePerLaneShuffle
  408. : SubtargetFeature<"fast-variable-perlane-shuffle",
  409. "HasFastVariablePerLaneShuffle",
  410. "true", "Per-lane shuffles with variable masks are fast">;
  411. // On some X86 processors, a vzeroupper instruction should be inserted after
  412. // using ymm/zmm registers before executing code that may use SSE instructions.
  413. def TuningInsertVZEROUPPER
  414. : SubtargetFeature<"vzeroupper",
  415. "InsertVZEROUPPER",
  416. "true", "Should insert vzeroupper instructions">;
  417. // TuningFastScalarFSQRT should be enabled if scalar FSQRT has shorter latency
  418. // than the corresponding NR code. TuningFastVectorFSQRT should be enabled if
  419. // vector FSQRT has higher throughput than the corresponding NR code.
  420. // The idea is that throughput bound code is likely to be vectorized, so for
  421. // vectorized code we should care about the throughput of SQRT operations.
  422. // But if the code is scalar that probably means that the code has some kind of
  423. // dependency and we should care more about reducing the latency.
  424. def TuningFastScalarFSQRT
  425. : SubtargetFeature<"fast-scalar-fsqrt", "HasFastScalarFSQRT",
  426. "true", "Scalar SQRT is fast (disable Newton-Raphson)">;
  427. def TuningFastVectorFSQRT
  428. : SubtargetFeature<"fast-vector-fsqrt", "HasFastVectorFSQRT",
  429. "true", "Vector SQRT is fast (disable Newton-Raphson)">;
  430. // If lzcnt has equivalent latency/throughput to most simple integer ops, it can
  431. // be used to replace test/set sequences.
  432. def TuningFastLZCNT
  433. : SubtargetFeature<
  434. "fast-lzcnt", "HasFastLZCNT", "true",
  435. "LZCNT instructions are as fast as most simple integer ops">;
  436. // If the target can efficiently decode NOPs upto 7-bytes in length.
  437. def TuningFast7ByteNOP
  438. : SubtargetFeature<
  439. "fast-7bytenop", "HasFast7ByteNOP", "true",
  440. "Target can quickly decode up to 7 byte NOPs">;
  441. // If the target can efficiently decode NOPs upto 11-bytes in length.
  442. def TuningFast11ByteNOP
  443. : SubtargetFeature<
  444. "fast-11bytenop", "HasFast11ByteNOP", "true",
  445. "Target can quickly decode up to 11 byte NOPs">;
  446. // If the target can efficiently decode NOPs upto 15-bytes in length.
  447. def TuningFast15ByteNOP
  448. : SubtargetFeature<
  449. "fast-15bytenop", "HasFast15ByteNOP", "true",
  450. "Target can quickly decode up to 15 byte NOPs">;
  451. // Sandy Bridge and newer processors can use SHLD with the same source on both
  452. // inputs to implement rotate to avoid the partial flag update of the normal
  453. // rotate instructions.
  454. def TuningFastSHLDRotate
  455. : SubtargetFeature<
  456. "fast-shld-rotate", "HasFastSHLDRotate", "true",
  457. "SHLD can be used as a faster rotate">;
  458. // Bulldozer and newer processors can merge CMP/TEST (but not other
  459. // instructions) with conditional branches.
  460. def TuningBranchFusion
  461. : SubtargetFeature<"branchfusion", "HasBranchFusion", "true",
  462. "CMP/TEST can be fused with conditional branches">;
  463. // Sandy Bridge and newer processors have many instructions that can be
  464. // fused with conditional branches and pass through the CPU as a single
  465. // operation.
  466. def TuningMacroFusion
  467. : SubtargetFeature<"macrofusion", "HasMacroFusion", "true",
  468. "Various instructions can be fused with conditional branches">;
  469. // Gather is available since Haswell (AVX2 set). So technically, we can
  470. // generate Gathers on all AVX2 processors. But the overhead on HSW is high.
  471. // Skylake Client processor has faster Gathers than HSW and performance is
  472. // similar to Skylake Server (AVX-512).
  473. def TuningFastGather
  474. : SubtargetFeature<"fast-gather", "HasFastGather", "true",
  475. "Indicates if gather is reasonably fast">;
  476. def TuningPrefer128Bit
  477. : SubtargetFeature<"prefer-128-bit", "Prefer128Bit", "true",
  478. "Prefer 128-bit AVX instructions">;
  479. def TuningPrefer256Bit
  480. : SubtargetFeature<"prefer-256-bit", "Prefer256Bit", "true",
  481. "Prefer 256-bit AVX instructions">;
  482. def TuningPreferMaskRegisters
  483. : SubtargetFeature<"prefer-mask-registers", "PreferMaskRegisters", "true",
  484. "Prefer AVX512 mask registers over PTEST/MOVMSK">;
  485. def TuningFastBEXTR : SubtargetFeature<"fast-bextr", "HasFastBEXTR", "true",
  486. "Indicates that the BEXTR instruction is implemented as a single uop "
  487. "with good throughput">;
  488. // Combine vector math operations with shuffles into horizontal math
  489. // instructions if a CPU implements horizontal operations (introduced with
  490. // SSE3) with better latency/throughput than the alternative sequence.
  491. def TuningFastHorizontalOps
  492. : SubtargetFeature<
  493. "fast-hops", "HasFastHorizontalOps", "true",
  494. "Prefer horizontal vector math instructions (haddp, phsub, etc.) over "
  495. "normal vector instructions with shuffles">;
  496. def TuningFastScalarShiftMasks
  497. : SubtargetFeature<
  498. "fast-scalar-shift-masks", "HasFastScalarShiftMasks", "true",
  499. "Prefer a left/right scalar logical shift pair over a shift+and pair">;
  500. def TuningFastVectorShiftMasks
  501. : SubtargetFeature<
  502. "fast-vector-shift-masks", "HasFastVectorShiftMasks", "true",
  503. "Prefer a left/right vector logical shift pair over a shift+and pair">;
  504. def TuningFastMOVBE
  505. : SubtargetFeature<"fast-movbe", "HasFastMOVBE", "true",
  506. "Prefer a movbe over a single-use load + bswap / single-use bswap + store">;
  507. def TuningUseSLMArithCosts
  508. : SubtargetFeature<"use-slm-arith-costs", "UseSLMArithCosts", "true",
  509. "Use Silvermont specific arithmetic costs">;
  510. def TuningUseGLMDivSqrtCosts
  511. : SubtargetFeature<"use-glm-div-sqrt-costs", "UseGLMDivSqrtCosts", "true",
  512. "Use Goldmont specific floating point div/sqrt costs">;
  513. // Enable use of alias analysis during code generation.
  514. def FeatureUseAA : SubtargetFeature<"use-aa", "UseAA", "true",
  515. "Use alias analysis during codegen">;
  516. //===----------------------------------------------------------------------===//
  517. // X86 CPU Families
  518. // TODO: Remove these - use general tuning features to determine codegen.
  519. //===----------------------------------------------------------------------===//
  520. // Bonnell
  521. def ProcIntelAtom : SubtargetFeature<"", "X86ProcFamily", "IntelAtom", "">;
  522. //===----------------------------------------------------------------------===//
  523. // Register File Description
  524. //===----------------------------------------------------------------------===//
  525. include "X86RegisterInfo.td"
  526. include "X86RegisterBanks.td"
  527. //===----------------------------------------------------------------------===//
  528. // Instruction Descriptions
  529. //===----------------------------------------------------------------------===//
  530. include "X86Schedule.td"
  531. include "X86InstrInfo.td"
  532. include "X86SchedPredicates.td"
  533. def X86InstrInfo : InstrInfo;
  534. //===----------------------------------------------------------------------===//
  535. // X86 Scheduler Models
  536. //===----------------------------------------------------------------------===//
  537. include "X86ScheduleAtom.td"
  538. include "X86SchedSandyBridge.td"
  539. include "X86SchedHaswell.td"
  540. include "X86SchedBroadwell.td"
  541. include "X86ScheduleSLM.td"
  542. include "X86ScheduleZnver1.td"
  543. include "X86ScheduleZnver2.td"
  544. include "X86ScheduleZnver3.td"
  545. include "X86ScheduleBdVer2.td"
  546. include "X86ScheduleBtVer2.td"
  547. include "X86SchedSkylakeClient.td"
  548. include "X86SchedSkylakeServer.td"
  549. include "X86SchedIceLake.td"
  550. //===----------------------------------------------------------------------===//
  551. // X86 Processor Feature Lists
  552. //===----------------------------------------------------------------------===//
  553. def ProcessorFeatures {
  554. // x86-64 and x86-64-v[234]
  555. list<SubtargetFeature> X86_64V1Features = [
  556. FeatureX87, FeatureCMPXCHG8B, FeatureCMOV, FeatureMMX, FeatureSSE2,
  557. FeatureFXSR, FeatureNOPL, Feature64Bit
  558. ];
  559. list<SubtargetFeature> X86_64V2Features = !listconcat(X86_64V1Features, [
  560. FeatureCMPXCHG16B, FeatureLAHFSAHF, FeatureCRC32, FeaturePOPCNT,
  561. FeatureSSE42
  562. ]);
  563. list<SubtargetFeature> X86_64V3Features = !listconcat(X86_64V2Features, [
  564. FeatureAVX2, FeatureBMI, FeatureBMI2, FeatureF16C, FeatureFMA, FeatureLZCNT,
  565. FeatureMOVBE, FeatureXSAVE
  566. ]);
  567. list<SubtargetFeature> X86_64V4Features = !listconcat(X86_64V3Features, [
  568. FeatureBWI,
  569. FeatureCDI,
  570. FeatureDQI,
  571. FeatureVLX,
  572. ]);
  573. // Nehalem
  574. list<SubtargetFeature> NHMFeatures = X86_64V2Features;
  575. list<SubtargetFeature> NHMTuning = [TuningMacroFusion,
  576. TuningInsertVZEROUPPER];
  577. // Westmere
  578. list<SubtargetFeature> WSMAdditionalFeatures = [FeaturePCLMUL];
  579. list<SubtargetFeature> WSMTuning = NHMTuning;
  580. list<SubtargetFeature> WSMFeatures =
  581. !listconcat(NHMFeatures, WSMAdditionalFeatures);
  582. // Sandybridge
  583. list<SubtargetFeature> SNBAdditionalFeatures = [FeatureAVX,
  584. FeatureXSAVE,
  585. FeatureXSAVEOPT];
  586. list<SubtargetFeature> SNBTuning = [TuningMacroFusion,
  587. TuningSlow3OpsLEA,
  588. TuningSlowDivide64,
  589. TuningSlowUAMem32,
  590. TuningFastScalarFSQRT,
  591. TuningFastSHLDRotate,
  592. TuningFast15ByteNOP,
  593. TuningPOPCNTFalseDeps,
  594. TuningInsertVZEROUPPER];
  595. list<SubtargetFeature> SNBFeatures =
  596. !listconcat(WSMFeatures, SNBAdditionalFeatures);
  597. // Ivybridge
  598. list<SubtargetFeature> IVBAdditionalFeatures = [FeatureRDRAND,
  599. FeatureF16C,
  600. FeatureFSGSBase];
  601. list<SubtargetFeature> IVBTuning = SNBTuning;
  602. list<SubtargetFeature> IVBFeatures =
  603. !listconcat(SNBFeatures, IVBAdditionalFeatures);
  604. // Haswell
  605. list<SubtargetFeature> HSWAdditionalFeatures = [FeatureAVX2,
  606. FeatureBMI,
  607. FeatureBMI2,
  608. FeatureERMSB,
  609. FeatureFMA,
  610. FeatureINVPCID,
  611. FeatureLZCNT,
  612. FeatureMOVBE];
  613. list<SubtargetFeature> HSWTuning = [TuningMacroFusion,
  614. TuningSlow3OpsLEA,
  615. TuningSlowDivide64,
  616. TuningFastScalarFSQRT,
  617. TuningFastSHLDRotate,
  618. TuningFast15ByteNOP,
  619. TuningFastVariableCrossLaneShuffle,
  620. TuningFastVariablePerLaneShuffle,
  621. TuningPOPCNTFalseDeps,
  622. TuningLZCNTFalseDeps,
  623. TuningInsertVZEROUPPER];
  624. list<SubtargetFeature> HSWFeatures =
  625. !listconcat(IVBFeatures, HSWAdditionalFeatures);
  626. // Broadwell
  627. list<SubtargetFeature> BDWAdditionalFeatures = [FeatureADX,
  628. FeatureRDSEED,
  629. FeaturePRFCHW];
  630. list<SubtargetFeature> BDWTuning = HSWTuning;
  631. list<SubtargetFeature> BDWFeatures =
  632. !listconcat(HSWFeatures, BDWAdditionalFeatures);
  633. // Skylake
  634. list<SubtargetFeature> SKLAdditionalFeatures = [FeatureAES,
  635. FeatureXSAVEC,
  636. FeatureXSAVES,
  637. FeatureCLFLUSHOPT];
  638. list<SubtargetFeature> SKLTuning = [TuningFastGather,
  639. TuningMacroFusion,
  640. TuningSlow3OpsLEA,
  641. TuningSlowDivide64,
  642. TuningFastScalarFSQRT,
  643. TuningFastVectorFSQRT,
  644. TuningFastSHLDRotate,
  645. TuningFast15ByteNOP,
  646. TuningFastVariableCrossLaneShuffle,
  647. TuningFastVariablePerLaneShuffle,
  648. TuningPOPCNTFalseDeps,
  649. TuningInsertVZEROUPPER];
  650. list<SubtargetFeature> SKLFeatures =
  651. !listconcat(BDWFeatures, SKLAdditionalFeatures);
  652. // Skylake-AVX512
  653. list<SubtargetFeature> SKXAdditionalFeatures = [FeatureAES,
  654. FeatureXSAVEC,
  655. FeatureXSAVES,
  656. FeatureCLFLUSHOPT,
  657. FeatureAVX512,
  658. FeatureCDI,
  659. FeatureDQI,
  660. FeatureBWI,
  661. FeatureVLX,
  662. FeaturePKU,
  663. FeatureCLWB];
  664. list<SubtargetFeature> SKXTuning = [TuningFastGather,
  665. TuningMacroFusion,
  666. TuningSlow3OpsLEA,
  667. TuningSlowDivide64,
  668. TuningFastScalarFSQRT,
  669. TuningFastVectorFSQRT,
  670. TuningFastSHLDRotate,
  671. TuningFast15ByteNOP,
  672. TuningFastVariableCrossLaneShuffle,
  673. TuningFastVariablePerLaneShuffle,
  674. TuningPrefer256Bit,
  675. TuningPOPCNTFalseDeps,
  676. TuningInsertVZEROUPPER];
  677. list<SubtargetFeature> SKXFeatures =
  678. !listconcat(BDWFeatures, SKXAdditionalFeatures);
  679. // Cascadelake
  680. list<SubtargetFeature> CLXAdditionalFeatures = [FeatureVNNI];
  681. list<SubtargetFeature> CLXTuning = SKXTuning;
  682. list<SubtargetFeature> CLXFeatures =
  683. !listconcat(SKXFeatures, CLXAdditionalFeatures);
  684. // Cooperlake
  685. list<SubtargetFeature> CPXAdditionalFeatures = [FeatureBF16];
  686. list<SubtargetFeature> CPXTuning = SKXTuning;
  687. list<SubtargetFeature> CPXFeatures =
  688. !listconcat(CLXFeatures, CPXAdditionalFeatures);
  689. // Cannonlake
  690. list<SubtargetFeature> CNLAdditionalFeatures = [FeatureAVX512,
  691. FeatureCDI,
  692. FeatureDQI,
  693. FeatureBWI,
  694. FeatureVLX,
  695. FeaturePKU,
  696. FeatureVBMI,
  697. FeatureIFMA,
  698. FeatureSHA];
  699. list<SubtargetFeature> CNLTuning = [TuningFastGather,
  700. TuningMacroFusion,
  701. TuningSlow3OpsLEA,
  702. TuningSlowDivide64,
  703. TuningFastScalarFSQRT,
  704. TuningFastVectorFSQRT,
  705. TuningFastSHLDRotate,
  706. TuningFast15ByteNOP,
  707. TuningFastVariableCrossLaneShuffle,
  708. TuningFastVariablePerLaneShuffle,
  709. TuningPrefer256Bit,
  710. TuningInsertVZEROUPPER];
  711. list<SubtargetFeature> CNLFeatures =
  712. !listconcat(SKLFeatures, CNLAdditionalFeatures);
  713. // Icelake
  714. list<SubtargetFeature> ICLAdditionalFeatures = [FeatureBITALG,
  715. FeatureVAES,
  716. FeatureVBMI2,
  717. FeatureVNNI,
  718. FeatureVPCLMULQDQ,
  719. FeatureVPOPCNTDQ,
  720. FeatureGFNI,
  721. FeatureRDPID,
  722. FeatureFSRM];
  723. list<SubtargetFeature> ICLTuning = [TuningFastGather,
  724. TuningMacroFusion,
  725. TuningSlow3OpsLEA,
  726. TuningSlowDivide64,
  727. TuningFastScalarFSQRT,
  728. TuningFastVectorFSQRT,
  729. TuningFastSHLDRotate,
  730. TuningFast15ByteNOP,
  731. TuningFastVariableCrossLaneShuffle,
  732. TuningFastVariablePerLaneShuffle,
  733. TuningPrefer256Bit,
  734. TuningInsertVZEROUPPER];
  735. list<SubtargetFeature> ICLFeatures =
  736. !listconcat(CNLFeatures, ICLAdditionalFeatures);
  737. // Icelake Server
  738. list<SubtargetFeature> ICXAdditionalFeatures = [FeaturePCONFIG,
  739. FeatureCLWB,
  740. FeatureWBNOINVD];
  741. list<SubtargetFeature> ICXTuning = ICLTuning;
  742. list<SubtargetFeature> ICXFeatures =
  743. !listconcat(ICLFeatures, ICXAdditionalFeatures);
  744. // Tigerlake
  745. list<SubtargetFeature> TGLAdditionalFeatures = [FeatureVP2INTERSECT,
  746. FeatureCLWB,
  747. FeatureMOVDIRI,
  748. FeatureMOVDIR64B,
  749. FeatureSHSTK];
  750. list<SubtargetFeature> TGLTuning = ICLTuning;
  751. list<SubtargetFeature> TGLFeatures =
  752. !listconcat(ICLFeatures, TGLAdditionalFeatures );
  753. // Sapphirerapids
  754. list<SubtargetFeature> SPRAdditionalFeatures = [FeatureAMXTILE,
  755. FeatureAMXINT8,
  756. FeatureAMXBF16,
  757. FeatureBF16,
  758. FeatureSERIALIZE,
  759. FeatureCLDEMOTE,
  760. FeatureWAITPKG,
  761. FeaturePTWRITE,
  762. FeatureFP16,
  763. FeatureAVXVNNI,
  764. FeatureTSXLDTRK,
  765. FeatureENQCMD,
  766. FeatureSHSTK,
  767. FeatureVP2INTERSECT,
  768. FeatureMOVDIRI,
  769. FeatureMOVDIR64B,
  770. FeatureUINTR];
  771. list<SubtargetFeature> SPRTuning = ICXTuning;
  772. list<SubtargetFeature> SPRFeatures =
  773. !listconcat(ICXFeatures, SPRAdditionalFeatures);
  774. // Atom
  775. list<SubtargetFeature> AtomFeatures = [FeatureX87,
  776. FeatureCMPXCHG8B,
  777. FeatureCMOV,
  778. FeatureMMX,
  779. FeatureSSSE3,
  780. FeatureFXSR,
  781. FeatureNOPL,
  782. Feature64Bit,
  783. FeatureCMPXCHG16B,
  784. FeatureMOVBE,
  785. FeatureLAHFSAHF];
  786. list<SubtargetFeature> AtomTuning = [ProcIntelAtom,
  787. TuningSlowUAMem16,
  788. TuningLEAForSP,
  789. TuningSlowDivide32,
  790. TuningSlowDivide64,
  791. TuningSlowTwoMemOps,
  792. TuningLEAUsesAG,
  793. TuningPadShortFunctions,
  794. TuningInsertVZEROUPPER];
  795. // Silvermont
  796. list<SubtargetFeature> SLMAdditionalFeatures = [FeatureSSE42,
  797. FeatureCRC32,
  798. FeaturePOPCNT,
  799. FeaturePCLMUL,
  800. FeaturePRFCHW,
  801. FeatureRDRAND];
  802. list<SubtargetFeature> SLMTuning = [TuningUseSLMArithCosts,
  803. TuningSlowTwoMemOps,
  804. TuningSlowLEA,
  805. TuningSlowIncDec,
  806. TuningSlowDivide64,
  807. TuningSlowPMULLD,
  808. TuningFast7ByteNOP,
  809. TuningFastMOVBE,
  810. TuningPOPCNTFalseDeps,
  811. TuningInsertVZEROUPPER];
  812. list<SubtargetFeature> SLMFeatures =
  813. !listconcat(AtomFeatures, SLMAdditionalFeatures);
  814. // Goldmont
  815. list<SubtargetFeature> GLMAdditionalFeatures = [FeatureAES,
  816. FeatureSHA,
  817. FeatureRDSEED,
  818. FeatureXSAVE,
  819. FeatureXSAVEOPT,
  820. FeatureXSAVEC,
  821. FeatureXSAVES,
  822. FeatureCLFLUSHOPT,
  823. FeatureFSGSBase];
  824. list<SubtargetFeature> GLMTuning = [TuningUseGLMDivSqrtCosts,
  825. TuningSlowTwoMemOps,
  826. TuningSlowLEA,
  827. TuningSlowIncDec,
  828. TuningFastMOVBE,
  829. TuningPOPCNTFalseDeps,
  830. TuningInsertVZEROUPPER];
  831. list<SubtargetFeature> GLMFeatures =
  832. !listconcat(SLMFeatures, GLMAdditionalFeatures);
  833. // Goldmont Plus
  834. list<SubtargetFeature> GLPAdditionalFeatures = [FeaturePTWRITE,
  835. FeatureRDPID];
  836. list<SubtargetFeature> GLPTuning = [TuningUseGLMDivSqrtCosts,
  837. TuningSlowTwoMemOps,
  838. TuningSlowLEA,
  839. TuningSlowIncDec,
  840. TuningFastMOVBE,
  841. TuningInsertVZEROUPPER];
  842. list<SubtargetFeature> GLPFeatures =
  843. !listconcat(GLMFeatures, GLPAdditionalFeatures);
  844. // Tremont
  845. list<SubtargetFeature> TRMAdditionalFeatures = [FeatureCLWB,
  846. FeatureGFNI];
  847. list<SubtargetFeature> TRMTuning = GLPTuning;
  848. list<SubtargetFeature> TRMFeatures =
  849. !listconcat(GLPFeatures, TRMAdditionalFeatures);
  850. // Alderlake
  851. list<SubtargetFeature> ADLAdditionalFeatures = [FeatureSERIALIZE,
  852. FeaturePCONFIG,
  853. FeatureSHSTK,
  854. FeatureWIDEKL,
  855. FeatureINVPCID,
  856. FeatureADX,
  857. FeatureFMA,
  858. FeatureVAES,
  859. FeatureVPCLMULQDQ,
  860. FeatureF16C,
  861. FeatureBMI,
  862. FeatureBMI2,
  863. FeatureLZCNT,
  864. FeatureAVXVNNI,
  865. FeaturePKU,
  866. FeatureHRESET,
  867. FeatureCLDEMOTE,
  868. FeatureMOVDIRI,
  869. FeatureMOVDIR64B,
  870. FeatureWAITPKG];
  871. list<SubtargetFeature> ADLTuning = SKLTuning;
  872. list<SubtargetFeature> ADLFeatures =
  873. !listconcat(TRMFeatures, ADLAdditionalFeatures);
  874. // Knights Landing
  875. list<SubtargetFeature> KNLFeatures = [FeatureX87,
  876. FeatureCMPXCHG8B,
  877. FeatureCMOV,
  878. FeatureMMX,
  879. FeatureFXSR,
  880. FeatureNOPL,
  881. Feature64Bit,
  882. FeatureCMPXCHG16B,
  883. FeatureCRC32,
  884. FeaturePOPCNT,
  885. FeaturePCLMUL,
  886. FeatureXSAVE,
  887. FeatureXSAVEOPT,
  888. FeatureLAHFSAHF,
  889. FeatureAES,
  890. FeatureRDRAND,
  891. FeatureF16C,
  892. FeatureFSGSBase,
  893. FeatureAVX512,
  894. FeatureERI,
  895. FeatureCDI,
  896. FeaturePFI,
  897. FeaturePREFETCHWT1,
  898. FeatureADX,
  899. FeatureRDSEED,
  900. FeatureMOVBE,
  901. FeatureLZCNT,
  902. FeatureBMI,
  903. FeatureBMI2,
  904. FeatureFMA,
  905. FeaturePRFCHW];
  906. list<SubtargetFeature> KNLTuning = [TuningSlowDivide64,
  907. TuningSlow3OpsLEA,
  908. TuningSlowIncDec,
  909. TuningSlowTwoMemOps,
  910. TuningPreferMaskRegisters,
  911. TuningFastGather,
  912. TuningFastMOVBE,
  913. TuningSlowPMADDWD];
  914. // TODO Add AVX5124FMAPS/AVX5124VNNIW features
  915. list<SubtargetFeature> KNMFeatures =
  916. !listconcat(KNLFeatures, [FeatureVPOPCNTDQ]);
  917. // Barcelona
  918. list<SubtargetFeature> BarcelonaFeatures = [FeatureX87,
  919. FeatureCMPXCHG8B,
  920. FeatureSSE4A,
  921. Feature3DNowA,
  922. FeatureFXSR,
  923. FeatureNOPL,
  924. FeatureCMPXCHG16B,
  925. FeaturePRFCHW,
  926. FeatureLZCNT,
  927. FeaturePOPCNT,
  928. FeatureLAHFSAHF,
  929. FeatureCMOV,
  930. Feature64Bit];
  931. list<SubtargetFeature> BarcelonaTuning = [TuningFastScalarShiftMasks,
  932. TuningSlowSHLD,
  933. TuningInsertVZEROUPPER];
  934. // Bobcat
  935. list<SubtargetFeature> BtVer1Features = [FeatureX87,
  936. FeatureCMPXCHG8B,
  937. FeatureCMOV,
  938. FeatureMMX,
  939. FeatureSSSE3,
  940. FeatureSSE4A,
  941. FeatureFXSR,
  942. FeatureNOPL,
  943. Feature64Bit,
  944. FeatureCMPXCHG16B,
  945. FeaturePRFCHW,
  946. FeatureLZCNT,
  947. FeaturePOPCNT,
  948. FeatureLAHFSAHF];
  949. list<SubtargetFeature> BtVer1Tuning = [TuningFast15ByteNOP,
  950. TuningFastScalarShiftMasks,
  951. TuningFastVectorShiftMasks,
  952. TuningSlowSHLD,
  953. TuningInsertVZEROUPPER];
  954. // Jaguar
  955. list<SubtargetFeature> BtVer2AdditionalFeatures = [FeatureAVX,
  956. FeatureAES,
  957. FeatureCRC32,
  958. FeaturePCLMUL,
  959. FeatureBMI,
  960. FeatureF16C,
  961. FeatureMOVBE,
  962. FeatureXSAVE,
  963. FeatureXSAVEOPT];
  964. list<SubtargetFeature> BtVer2Tuning = [TuningFastLZCNT,
  965. TuningFastBEXTR,
  966. TuningFastHorizontalOps,
  967. TuningFast15ByteNOP,
  968. TuningFastScalarShiftMasks,
  969. TuningFastVectorShiftMasks,
  970. TuningFastMOVBE,
  971. TuningSlowSHLD];
  972. list<SubtargetFeature> BtVer2Features =
  973. !listconcat(BtVer1Features, BtVer2AdditionalFeatures);
  974. // Bulldozer
  975. list<SubtargetFeature> BdVer1Features = [FeatureX87,
  976. FeatureCMPXCHG8B,
  977. FeatureCMOV,
  978. FeatureXOP,
  979. Feature64Bit,
  980. FeatureCMPXCHG16B,
  981. FeatureAES,
  982. FeatureCRC32,
  983. FeaturePRFCHW,
  984. FeaturePCLMUL,
  985. FeatureMMX,
  986. FeatureFXSR,
  987. FeatureNOPL,
  988. FeatureLZCNT,
  989. FeaturePOPCNT,
  990. FeatureXSAVE,
  991. FeatureLWP,
  992. FeatureLAHFSAHF];
  993. list<SubtargetFeature> BdVer1Tuning = [TuningSlowSHLD,
  994. TuningFast11ByteNOP,
  995. TuningFastScalarShiftMasks,
  996. TuningBranchFusion,
  997. TuningInsertVZEROUPPER];
  998. // PileDriver
  999. list<SubtargetFeature> BdVer2AdditionalFeatures = [FeatureF16C,
  1000. FeatureBMI,
  1001. FeatureTBM,
  1002. FeatureFMA];
  1003. list<SubtargetFeature> BdVer2AdditionalTuning = [TuningFastBEXTR,
  1004. TuningFastMOVBE];
  1005. list<SubtargetFeature> BdVer2Tuning =
  1006. !listconcat(BdVer1Tuning, BdVer2AdditionalTuning);
  1007. list<SubtargetFeature> BdVer2Features =
  1008. !listconcat(BdVer1Features, BdVer2AdditionalFeatures);
  1009. // Steamroller
  1010. list<SubtargetFeature> BdVer3AdditionalFeatures = [FeatureXSAVEOPT,
  1011. FeatureFSGSBase];
  1012. list<SubtargetFeature> BdVer3Tuning = BdVer2Tuning;
  1013. list<SubtargetFeature> BdVer3Features =
  1014. !listconcat(BdVer2Features, BdVer3AdditionalFeatures);
  1015. // Excavator
  1016. list<SubtargetFeature> BdVer4AdditionalFeatures = [FeatureAVX2,
  1017. FeatureBMI2,
  1018. FeatureMOVBE,
  1019. FeatureRDRAND,
  1020. FeatureMWAITX];
  1021. list<SubtargetFeature> BdVer4Tuning = BdVer3Tuning;
  1022. list<SubtargetFeature> BdVer4Features =
  1023. !listconcat(BdVer3Features, BdVer4AdditionalFeatures);
  1024. // AMD Zen Processors common ISAs
  1025. list<SubtargetFeature> ZNFeatures = [FeatureADX,
  1026. FeatureAES,
  1027. FeatureAVX2,
  1028. FeatureBMI,
  1029. FeatureBMI2,
  1030. FeatureCLFLUSHOPT,
  1031. FeatureCLZERO,
  1032. FeatureCMOV,
  1033. Feature64Bit,
  1034. FeatureCMPXCHG16B,
  1035. FeatureCRC32,
  1036. FeatureF16C,
  1037. FeatureFMA,
  1038. FeatureFSGSBase,
  1039. FeatureFXSR,
  1040. FeatureNOPL,
  1041. FeatureLAHFSAHF,
  1042. FeatureLZCNT,
  1043. FeatureMMX,
  1044. FeatureMOVBE,
  1045. FeatureMWAITX,
  1046. FeaturePCLMUL,
  1047. FeaturePOPCNT,
  1048. FeaturePRFCHW,
  1049. FeatureRDRAND,
  1050. FeatureRDSEED,
  1051. FeatureSHA,
  1052. FeatureSSE4A,
  1053. FeatureX87,
  1054. FeatureXSAVE,
  1055. FeatureXSAVEC,
  1056. FeatureXSAVEOPT,
  1057. FeatureXSAVES];
  1058. list<SubtargetFeature> ZNTuning = [TuningFastLZCNT,
  1059. TuningFastBEXTR,
  1060. TuningFast15ByteNOP,
  1061. TuningBranchFusion,
  1062. TuningFastScalarFSQRT,
  1063. TuningFastVectorFSQRT,
  1064. TuningFastScalarShiftMasks,
  1065. TuningFastMOVBE,
  1066. TuningSlowSHLD,
  1067. TuningInsertVZEROUPPER];
  1068. list<SubtargetFeature> ZN2AdditionalFeatures = [FeatureCLWB,
  1069. FeatureRDPID,
  1070. FeatureWBNOINVD];
  1071. list<SubtargetFeature> ZN2Tuning = ZNTuning;
  1072. list<SubtargetFeature> ZN2Features =
  1073. !listconcat(ZNFeatures, ZN2AdditionalFeatures);
  1074. list<SubtargetFeature> ZN3AdditionalFeatures = [FeatureFSRM,
  1075. FeatureINVPCID,
  1076. FeaturePKU,
  1077. FeatureVAES,
  1078. FeatureVPCLMULQDQ];
  1079. list<SubtargetFeature> ZN3AdditionalTuning =
  1080. [TuningMacroFusion,
  1081. TuningFastVariablePerLaneShuffle];
  1082. list<SubtargetFeature> ZN3Tuning =
  1083. !listconcat(ZNTuning, ZN3AdditionalTuning);
  1084. list<SubtargetFeature> ZN3Features =
  1085. !listconcat(ZN2Features, ZN3AdditionalFeatures);
  1086. }
  1087. //===----------------------------------------------------------------------===//
  1088. // X86 processors supported.
  1089. //===----------------------------------------------------------------------===//
  1090. class Proc<string Name, list<SubtargetFeature> Features,
  1091. list<SubtargetFeature> TuneFeatures>
  1092. : ProcessorModel<Name, GenericModel, Features, TuneFeatures>;
  1093. class ProcModel<string Name, SchedMachineModel Model,
  1094. list<SubtargetFeature> Features,
  1095. list<SubtargetFeature> TuneFeatures>
  1096. : ProcessorModel<Name, Model, Features, TuneFeatures>;
  1097. // NOTE: CMPXCHG8B is here for legacy compatibility so that it is only disabled
  1098. // if i386/i486 is specifically requested.
  1099. // NOTE: 64Bit is here as "generic" is the default llc CPU. The X86Subtarget
  1100. // constructor checks that any CPU used in 64-bit mode has Feature64Bit enabled.
  1101. // It has no effect on code generation.
  1102. def : ProcModel<"generic", SandyBridgeModel,
  1103. [FeatureX87, FeatureCMPXCHG8B, Feature64Bit],
  1104. [TuningSlow3OpsLEA,
  1105. TuningSlowDivide64,
  1106. TuningSlowIncDec,
  1107. TuningMacroFusion,
  1108. TuningInsertVZEROUPPER]>;
  1109. def : Proc<"i386", [FeatureX87],
  1110. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1111. def : Proc<"i486", [FeatureX87],
  1112. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1113. def : Proc<"i586", [FeatureX87, FeatureCMPXCHG8B],
  1114. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1115. def : Proc<"pentium", [FeatureX87, FeatureCMPXCHG8B],
  1116. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1117. def : Proc<"pentium-mmx", [FeatureX87, FeatureCMPXCHG8B, FeatureMMX],
  1118. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1119. def : Proc<"i686", [FeatureX87, FeatureCMPXCHG8B, FeatureCMOV],
  1120. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1121. def : Proc<"pentiumpro", [FeatureX87, FeatureCMPXCHG8B, FeatureCMOV,
  1122. FeatureNOPL],
  1123. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1124. def : Proc<"pentium2", [FeatureX87, FeatureCMPXCHG8B, FeatureMMX, FeatureCMOV,
  1125. FeatureFXSR, FeatureNOPL],
  1126. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1127. foreach P = ["pentium3", "pentium3m"] in {
  1128. def : Proc<P, [FeatureX87, FeatureCMPXCHG8B, FeatureMMX,
  1129. FeatureSSE1, FeatureFXSR, FeatureNOPL, FeatureCMOV],
  1130. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1131. }
  1132. // Enable the PostRAScheduler for SSE2 and SSE3 class cpus.
  1133. // The intent is to enable it for pentium4 which is the current default
  1134. // processor in a vanilla 32-bit clang compilation when no specific
  1135. // architecture is specified. This generally gives a nice performance
  1136. // increase on silvermont, with largely neutral behavior on other
  1137. // contemporary large core processors.
  1138. // pentium-m, pentium4m, prescott and nocona are included as a preventative
  1139. // measure to avoid performance surprises, in case clang's default cpu
  1140. // changes slightly.
  1141. def : ProcModel<"pentium-m", GenericPostRAModel,
  1142. [FeatureX87, FeatureCMPXCHG8B, FeatureMMX, FeatureSSE2,
  1143. FeatureFXSR, FeatureNOPL, FeatureCMOV],
  1144. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1145. foreach P = ["pentium4", "pentium4m"] in {
  1146. def : ProcModel<P, GenericPostRAModel,
  1147. [FeatureX87, FeatureCMPXCHG8B, FeatureMMX, FeatureSSE2,
  1148. FeatureFXSR, FeatureNOPL, FeatureCMOV],
  1149. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1150. }
  1151. // Intel Quark.
  1152. def : Proc<"lakemont", [FeatureCMPXCHG8B],
  1153. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1154. // Intel Core Duo.
  1155. def : ProcModel<"yonah", SandyBridgeModel,
  1156. [FeatureX87, FeatureCMPXCHG8B, FeatureMMX, FeatureSSE3,
  1157. FeatureFXSR, FeatureNOPL, FeatureCMOV],
  1158. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1159. // NetBurst.
  1160. def : ProcModel<"prescott", GenericPostRAModel,
  1161. [FeatureX87, FeatureCMPXCHG8B, FeatureMMX, FeatureSSE3,
  1162. FeatureFXSR, FeatureNOPL, FeatureCMOV],
  1163. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1164. def : ProcModel<"nocona", GenericPostRAModel, [
  1165. FeatureX87,
  1166. FeatureCMPXCHG8B,
  1167. FeatureCMOV,
  1168. FeatureMMX,
  1169. FeatureSSE3,
  1170. FeatureFXSR,
  1171. FeatureNOPL,
  1172. Feature64Bit,
  1173. FeatureCMPXCHG16B,
  1174. ],
  1175. [
  1176. TuningSlowUAMem16,
  1177. TuningInsertVZEROUPPER
  1178. ]>;
  1179. // Intel Core 2 Solo/Duo.
  1180. def : ProcModel<"core2", SandyBridgeModel, [
  1181. FeatureX87,
  1182. FeatureCMPXCHG8B,
  1183. FeatureCMOV,
  1184. FeatureMMX,
  1185. FeatureSSSE3,
  1186. FeatureFXSR,
  1187. FeatureNOPL,
  1188. Feature64Bit,
  1189. FeatureCMPXCHG16B,
  1190. FeatureLAHFSAHF
  1191. ],
  1192. [
  1193. TuningMacroFusion,
  1194. TuningSlowUAMem16,
  1195. TuningInsertVZEROUPPER
  1196. ]>;
  1197. def : ProcModel<"penryn", SandyBridgeModel, [
  1198. FeatureX87,
  1199. FeatureCMPXCHG8B,
  1200. FeatureCMOV,
  1201. FeatureMMX,
  1202. FeatureSSE41,
  1203. FeatureFXSR,
  1204. FeatureNOPL,
  1205. Feature64Bit,
  1206. FeatureCMPXCHG16B,
  1207. FeatureLAHFSAHF
  1208. ],
  1209. [
  1210. TuningMacroFusion,
  1211. TuningSlowUAMem16,
  1212. TuningInsertVZEROUPPER
  1213. ]>;
  1214. // Atom CPUs.
  1215. foreach P = ["bonnell", "atom"] in {
  1216. def : ProcModel<P, AtomModel, ProcessorFeatures.AtomFeatures,
  1217. ProcessorFeatures.AtomTuning>;
  1218. }
  1219. foreach P = ["silvermont", "slm"] in {
  1220. def : ProcModel<P, SLMModel, ProcessorFeatures.SLMFeatures,
  1221. ProcessorFeatures.SLMTuning>;
  1222. }
  1223. def : ProcModel<"goldmont", SLMModel, ProcessorFeatures.GLMFeatures,
  1224. ProcessorFeatures.GLMTuning>;
  1225. def : ProcModel<"goldmont-plus", SLMModel, ProcessorFeatures.GLPFeatures,
  1226. ProcessorFeatures.GLPTuning>;
  1227. def : ProcModel<"tremont", SLMModel, ProcessorFeatures.TRMFeatures,
  1228. ProcessorFeatures.TRMTuning>;
  1229. // "Arrandale" along with corei3 and corei5
  1230. foreach P = ["nehalem", "corei7"] in {
  1231. def : ProcModel<P, SandyBridgeModel, ProcessorFeatures.NHMFeatures,
  1232. ProcessorFeatures.NHMTuning>;
  1233. }
  1234. // Westmere is the corei3/i5/i7 path from nehalem to sandybridge
  1235. def : ProcModel<"westmere", SandyBridgeModel, ProcessorFeatures.WSMFeatures,
  1236. ProcessorFeatures.WSMTuning>;
  1237. foreach P = ["sandybridge", "corei7-avx"] in {
  1238. def : ProcModel<P, SandyBridgeModel, ProcessorFeatures.SNBFeatures,
  1239. ProcessorFeatures.SNBTuning>;
  1240. }
  1241. foreach P = ["ivybridge", "core-avx-i"] in {
  1242. def : ProcModel<P, SandyBridgeModel, ProcessorFeatures.IVBFeatures,
  1243. ProcessorFeatures.IVBTuning>;
  1244. }
  1245. foreach P = ["haswell", "core-avx2"] in {
  1246. def : ProcModel<P, HaswellModel, ProcessorFeatures.HSWFeatures,
  1247. ProcessorFeatures.HSWTuning>;
  1248. }
  1249. def : ProcModel<"broadwell", BroadwellModel, ProcessorFeatures.BDWFeatures,
  1250. ProcessorFeatures.BDWTuning>;
  1251. def : ProcModel<"skylake", SkylakeClientModel, ProcessorFeatures.SKLFeatures,
  1252. ProcessorFeatures.SKLTuning>;
  1253. // FIXME: define KNL scheduler model
  1254. def : ProcModel<"knl", HaswellModel, ProcessorFeatures.KNLFeatures,
  1255. ProcessorFeatures.KNLTuning>;
  1256. def : ProcModel<"knm", HaswellModel, ProcessorFeatures.KNMFeatures,
  1257. ProcessorFeatures.KNLTuning>;
  1258. foreach P = ["skylake-avx512", "skx"] in {
  1259. def : ProcModel<P, SkylakeServerModel, ProcessorFeatures.SKXFeatures,
  1260. ProcessorFeatures.SKXTuning>;
  1261. }
  1262. def : ProcModel<"cascadelake", SkylakeServerModel,
  1263. ProcessorFeatures.CLXFeatures, ProcessorFeatures.CLXTuning>;
  1264. def : ProcModel<"cooperlake", SkylakeServerModel,
  1265. ProcessorFeatures.CPXFeatures, ProcessorFeatures.CPXTuning>;
  1266. def : ProcModel<"cannonlake", SkylakeServerModel,
  1267. ProcessorFeatures.CNLFeatures, ProcessorFeatures.CNLTuning>;
  1268. def : ProcModel<"icelake-client", IceLakeModel,
  1269. ProcessorFeatures.ICLFeatures, ProcessorFeatures.ICLTuning>;
  1270. def : ProcModel<"rocketlake", IceLakeModel,
  1271. ProcessorFeatures.ICLFeatures, ProcessorFeatures.ICLTuning>;
  1272. def : ProcModel<"icelake-server", IceLakeModel,
  1273. ProcessorFeatures.ICXFeatures, ProcessorFeatures.ICXTuning>;
  1274. def : ProcModel<"tigerlake", IceLakeModel,
  1275. ProcessorFeatures.TGLFeatures, ProcessorFeatures.TGLTuning>;
  1276. def : ProcModel<"sapphirerapids", SkylakeServerModel,
  1277. ProcessorFeatures.SPRFeatures, ProcessorFeatures.SPRTuning>;
  1278. def : ProcModel<"alderlake", SkylakeClientModel,
  1279. ProcessorFeatures.ADLFeatures, ProcessorFeatures.ADLTuning>;
  1280. // AMD CPUs.
  1281. def : Proc<"k6", [FeatureX87, FeatureCMPXCHG8B, FeatureMMX],
  1282. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1283. def : Proc<"k6-2", [FeatureX87, FeatureCMPXCHG8B, Feature3DNow],
  1284. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1285. def : Proc<"k6-3", [FeatureX87, FeatureCMPXCHG8B, Feature3DNow],
  1286. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1287. foreach P = ["athlon", "athlon-tbird"] in {
  1288. def : Proc<P, [FeatureX87, FeatureCMPXCHG8B, FeatureCMOV, Feature3DNowA,
  1289. FeatureNOPL],
  1290. [TuningSlowSHLD, TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1291. }
  1292. foreach P = ["athlon-4", "athlon-xp", "athlon-mp"] in {
  1293. def : Proc<P, [FeatureX87, FeatureCMPXCHG8B, FeatureCMOV,
  1294. FeatureSSE1, Feature3DNowA, FeatureFXSR, FeatureNOPL],
  1295. [TuningSlowSHLD, TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1296. }
  1297. foreach P = ["k8", "opteron", "athlon64", "athlon-fx"] in {
  1298. def : Proc<P, [FeatureX87, FeatureCMPXCHG8B, FeatureSSE2, Feature3DNowA,
  1299. FeatureFXSR, FeatureNOPL, Feature64Bit, FeatureCMOV],
  1300. [TuningFastScalarShiftMasks, TuningSlowSHLD, TuningSlowUAMem16,
  1301. TuningInsertVZEROUPPER]>;
  1302. }
  1303. foreach P = ["k8-sse3", "opteron-sse3", "athlon64-sse3"] in {
  1304. def : Proc<P, [FeatureX87, FeatureCMPXCHG8B, FeatureSSE3, Feature3DNowA,
  1305. FeatureFXSR, FeatureNOPL, FeatureCMPXCHG16B, FeatureCMOV,
  1306. Feature64Bit],
  1307. [TuningFastScalarShiftMasks, TuningSlowSHLD, TuningSlowUAMem16,
  1308. TuningInsertVZEROUPPER]>;
  1309. }
  1310. foreach P = ["amdfam10", "barcelona"] in {
  1311. def : Proc<P, ProcessorFeatures.BarcelonaFeatures,
  1312. ProcessorFeatures.BarcelonaTuning>;
  1313. }
  1314. // Bobcat
  1315. def : Proc<"btver1", ProcessorFeatures.BtVer1Features,
  1316. ProcessorFeatures.BtVer1Tuning>;
  1317. // Jaguar
  1318. def : ProcModel<"btver2", BtVer2Model, ProcessorFeatures.BtVer2Features,
  1319. ProcessorFeatures.BtVer2Tuning>;
  1320. // Bulldozer
  1321. def : ProcModel<"bdver1", BdVer2Model, ProcessorFeatures.BdVer1Features,
  1322. ProcessorFeatures.BdVer1Tuning>;
  1323. // Piledriver
  1324. def : ProcModel<"bdver2", BdVer2Model, ProcessorFeatures.BdVer2Features,
  1325. ProcessorFeatures.BdVer2Tuning>;
  1326. // Steamroller
  1327. def : Proc<"bdver3", ProcessorFeatures.BdVer3Features,
  1328. ProcessorFeatures.BdVer3Tuning>;
  1329. // Excavator
  1330. def : Proc<"bdver4", ProcessorFeatures.BdVer4Features,
  1331. ProcessorFeatures.BdVer4Tuning>;
  1332. def : ProcModel<"znver1", Znver1Model, ProcessorFeatures.ZNFeatures,
  1333. ProcessorFeatures.ZNTuning>;
  1334. def : ProcModel<"znver2", Znver2Model, ProcessorFeatures.ZN2Features,
  1335. ProcessorFeatures.ZN2Tuning>;
  1336. def : ProcModel<"znver3", Znver3Model, ProcessorFeatures.ZN3Features,
  1337. ProcessorFeatures.ZN3Tuning>;
  1338. def : Proc<"geode", [FeatureX87, FeatureCMPXCHG8B, Feature3DNowA],
  1339. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1340. def : Proc<"winchip-c6", [FeatureX87, FeatureMMX],
  1341. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1342. def : Proc<"winchip2", [FeatureX87, Feature3DNow],
  1343. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1344. def : Proc<"c3", [FeatureX87, Feature3DNow],
  1345. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1346. def : Proc<"c3-2", [FeatureX87, FeatureCMPXCHG8B, FeatureMMX,
  1347. FeatureSSE1, FeatureFXSR, FeatureCMOV],
  1348. [TuningSlowUAMem16, TuningInsertVZEROUPPER]>;
  1349. // We also provide a generic 64-bit specific x86 processor model which tries to
  1350. // be good for modern chips without enabling instruction set encodings past the
  1351. // basic SSE2 and 64-bit ones. It disables slow things from any mainstream and
  1352. // modern 64-bit x86 chip, and enables features that are generally beneficial.
  1353. //
  1354. // We currently use the Sandy Bridge model as the default scheduling model as
  1355. // we use it across Nehalem, Westmere, Sandy Bridge, and Ivy Bridge which
  1356. // covers a huge swath of x86 processors. If there are specific scheduling
  1357. // knobs which need to be tuned differently for AMD chips, we might consider
  1358. // forming a common base for them.
  1359. def : ProcModel<"x86-64", SandyBridgeModel, ProcessorFeatures.X86_64V1Features,
  1360. [
  1361. TuningSlow3OpsLEA,
  1362. TuningSlowDivide64,
  1363. TuningSlowIncDec,
  1364. TuningMacroFusion,
  1365. TuningInsertVZEROUPPER
  1366. ]>;
  1367. // x86-64 micro-architecture levels.
  1368. def : ProcModel<"x86-64-v2", SandyBridgeModel, ProcessorFeatures.X86_64V2Features,
  1369. ProcessorFeatures.SNBTuning>;
  1370. // Close to Haswell.
  1371. def : ProcModel<"x86-64-v3", HaswellModel, ProcessorFeatures.X86_64V3Features,
  1372. ProcessorFeatures.HSWTuning>;
  1373. // Close to the AVX-512 level implemented by Xeon Scalable Processors.
  1374. def : ProcModel<"x86-64-v4", SkylakeServerModel, ProcessorFeatures.X86_64V4Features,
  1375. ProcessorFeatures.SKXTuning>;
  1376. //===----------------------------------------------------------------------===//
  1377. // Calling Conventions
  1378. //===----------------------------------------------------------------------===//
  1379. include "X86CallingConv.td"
  1380. //===----------------------------------------------------------------------===//
  1381. // Assembly Parser
  1382. //===----------------------------------------------------------------------===//
  1383. def ATTAsmParserVariant : AsmParserVariant {
  1384. int Variant = 0;
  1385. // Variant name.
  1386. string Name = "att";
  1387. // Discard comments in assembly strings.
  1388. string CommentDelimiter = "#";
  1389. // Recognize hard coded registers.
  1390. string RegisterPrefix = "%";
  1391. }
  1392. def IntelAsmParserVariant : AsmParserVariant {
  1393. int Variant = 1;
  1394. // Variant name.
  1395. string Name = "intel";
  1396. // Discard comments in assembly strings.
  1397. string CommentDelimiter = ";";
  1398. // Recognize hard coded registers.
  1399. string RegisterPrefix = "";
  1400. }
  1401. //===----------------------------------------------------------------------===//
  1402. // Assembly Printers
  1403. //===----------------------------------------------------------------------===//
  1404. // The X86 target supports two different syntaxes for emitting machine code.
  1405. // This is controlled by the -x86-asm-syntax={att|intel}
  1406. def ATTAsmWriter : AsmWriter {
  1407. string AsmWriterClassName = "ATTInstPrinter";
  1408. int Variant = 0;
  1409. }
  1410. def IntelAsmWriter : AsmWriter {
  1411. string AsmWriterClassName = "IntelInstPrinter";
  1412. int Variant = 1;
  1413. }
  1414. def X86 : Target {
  1415. // Information about the instructions...
  1416. let InstructionSet = X86InstrInfo;
  1417. let AssemblyParserVariants = [ATTAsmParserVariant, IntelAsmParserVariant];
  1418. let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];
  1419. let AllowRegisterRenaming = 1;
  1420. }
  1421. //===----------------------------------------------------------------------===//
  1422. // Pfm Counters
  1423. //===----------------------------------------------------------------------===//
  1424. include "X86PfmCounters.td"