X86.td 85 KB

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