X86ScheduleZnver2.td 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406
  1. //=- X86ScheduleZnver2.td - X86 Znver2 Scheduling -------------*- 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 file defines the machine model for Znver2 to support instruction
  10. // scheduling and other instruction cost heuristics.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. def Znver2Model : SchedMachineModel {
  14. // Zen can decode 4 instructions per cycle.
  15. let IssueWidth = 4;
  16. // Based on the reorder buffer we define MicroOpBufferSize
  17. let MicroOpBufferSize = 224;
  18. let LoadLatency = 4;
  19. let MispredictPenalty = 17;
  20. let HighLatency = 25;
  21. let PostRAScheduler = 1;
  22. // FIXME: This variable is required for incomplete model.
  23. // We haven't catered all instructions.
  24. // So, we reset the value of this variable so as to
  25. // say that the model is incomplete.
  26. let CompleteModel = 0;
  27. }
  28. let SchedModel = Znver2Model in {
  29. // Zen can issue micro-ops to 10 different units in one cycle.
  30. // These are
  31. // * Four integer ALU units (ZALU0, ZALU1, ZALU2, ZALU3)
  32. // * Three AGU units (ZAGU0, ZAGU1, ZAGU2)
  33. // * Four FPU units (ZFPU0, ZFPU1, ZFPU2, ZFPU3)
  34. // AGUs feed load store queues @two loads and 1 store per cycle.
  35. // Four ALU units are defined below
  36. def Zn2ALU0 : ProcResource<1>;
  37. def Zn2ALU1 : ProcResource<1>;
  38. def Zn2ALU2 : ProcResource<1>;
  39. def Zn2ALU3 : ProcResource<1>;
  40. // Three AGU units are defined below
  41. def Zn2AGU0 : ProcResource<1>;
  42. def Zn2AGU1 : ProcResource<1>;
  43. def Zn2AGU2 : ProcResource<1>;
  44. // Four FPU units are defined below
  45. def Zn2FPU0 : ProcResource<1>;
  46. def Zn2FPU1 : ProcResource<1>;
  47. def Zn2FPU2 : ProcResource<1>;
  48. def Zn2FPU3 : ProcResource<1>;
  49. // FPU grouping
  50. def Zn2FPU013 : ProcResGroup<[Zn2FPU0, Zn2FPU1, Zn2FPU3]>;
  51. def Zn2FPU01 : ProcResGroup<[Zn2FPU0, Zn2FPU1]>;
  52. def Zn2FPU12 : ProcResGroup<[Zn2FPU1, Zn2FPU2]>;
  53. def Zn2FPU13 : ProcResGroup<[Zn2FPU1, Zn2FPU3]>;
  54. def Zn2FPU23 : ProcResGroup<[Zn2FPU2, Zn2FPU3]>;
  55. def Zn2FPU02 : ProcResGroup<[Zn2FPU0, Zn2FPU2]>;
  56. def Zn2FPU03 : ProcResGroup<[Zn2FPU0, Zn2FPU3]>;
  57. // Below are the grouping of the units.
  58. // Micro-ops to be issued to multiple units are tackled this way.
  59. // ALU grouping
  60. // Zn2ALU03 - 0,3 grouping
  61. def Zn2ALU03: ProcResGroup<[Zn2ALU0, Zn2ALU3]>;
  62. // 64 Entry (16x4 entries) Int Scheduler
  63. def Zn2ALU : ProcResGroup<[Zn2ALU0, Zn2ALU1, Zn2ALU2, Zn2ALU3]> {
  64. let BufferSize=64;
  65. }
  66. // 28 Entry (14x2) AGU group. AGUs can't be used for all ALU operations
  67. // but are relevant for some instructions
  68. def Zn2AGU : ProcResGroup<[Zn2AGU0, Zn2AGU1, Zn2AGU2]> {
  69. let BufferSize=28;
  70. }
  71. // Integer Multiplication issued on ALU1.
  72. def Zn2Multiplier : ProcResource<1>;
  73. // Integer division issued on ALU2.
  74. def Zn2Divider : ProcResource<1>;
  75. // 4 Cycles load-to use Latency is captured
  76. def : ReadAdvance<ReadAfterLd, 4>;
  77. // 7 Cycles vector load-to use Latency is captured
  78. def : ReadAdvance<ReadAfterVecLd, 7>;
  79. def : ReadAdvance<ReadAfterVecXLd, 7>;
  80. def : ReadAdvance<ReadAfterVecYLd, 7>;
  81. def : ReadAdvance<ReadInt2Fpu, 0>;
  82. // The Integer PRF for Zen is 168 entries, and it holds the architectural and
  83. // speculative version of the 64-bit integer registers.
  84. // Reference: "Software Optimization Guide for AMD Family 17h Processors"
  85. def Zn2IntegerPRF : RegisterFile<168, [GR64, CCR]>;
  86. // 36 Entry (9x4 entries) floating-point Scheduler
  87. def Zn2FPU : ProcResGroup<[Zn2FPU0, Zn2FPU1, Zn2FPU2, Zn2FPU3]> {
  88. let BufferSize=36;
  89. }
  90. // The Zen FP Retire Queue renames SIMD and FP uOps onto a pool of 160 128-bit
  91. // registers. Operations on 256-bit data types are cracked into two COPs.
  92. // Reference: "Software Optimization Guide for AMD Family 17h Processors"
  93. def Zn2FpuPRF: RegisterFile<160, [VR64, VR128, VR256], [1, 1, 2]>;
  94. // The unit can track up to 192 macro ops in-flight.
  95. // The retire unit handles in-order commit of up to 8 macro ops per cycle.
  96. // Reference: "Software Optimization Guide for AMD Family 17h Processors"
  97. // To be noted, the retire unit is shared between integer and FP ops.
  98. // In SMT mode it is 96 entry per thread. But, we do not use the conservative
  99. // value here because there is currently no way to fully mode the SMT mode,
  100. // so there is no point in trying.
  101. def Zn2RCU : RetireControlUnit<192, 8>;
  102. // (a folded load is an instruction that loads and does some operation)
  103. // Ex: ADDPD xmm,[mem]-> This instruction has two micro-ops
  104. // Instructions with folded loads are usually micro-fused, so they only appear
  105. // as two micro-ops.
  106. // a. load and
  107. // b. addpd
  108. // This multiclass is for folded loads for integer units.
  109. multiclass Zn2WriteResPair<X86FoldableSchedWrite SchedRW,
  110. list<ProcResourceKind> ExePorts,
  111. int Lat, list<int> Res = [], int UOps = 1,
  112. int LoadLat = 4, int LoadUOps = 1> {
  113. // Register variant takes 1-cycle on Execution Port.
  114. def : WriteRes<SchedRW, ExePorts> {
  115. let Latency = Lat;
  116. let ResourceCycles = Res;
  117. let NumMicroOps = UOps;
  118. }
  119. // Memory variant also uses a cycle on Zn2AGU
  120. // adds LoadLat cycles to the latency (default = 4).
  121. def : WriteRes<SchedRW.Folded, !listconcat([Zn2AGU], ExePorts)> {
  122. let Latency = !add(Lat, LoadLat);
  123. let ResourceCycles = !if(!empty(Res), [], !listconcat([1], Res));
  124. let NumMicroOps = !add(UOps, LoadUOps);
  125. }
  126. }
  127. // This multiclass is for folded loads for floating point units.
  128. multiclass Zn2WriteResFpuPair<X86FoldableSchedWrite SchedRW,
  129. list<ProcResourceKind> ExePorts,
  130. int Lat, list<int> Res = [], int UOps = 1,
  131. int LoadLat = 7, int LoadUOps = 0> {
  132. // Register variant takes 1-cycle on Execution Port.
  133. def : WriteRes<SchedRW, ExePorts> {
  134. let Latency = Lat;
  135. let ResourceCycles = Res;
  136. let NumMicroOps = UOps;
  137. }
  138. // Memory variant also uses a cycle on Zn2AGU
  139. // adds LoadLat cycles to the latency (default = 7).
  140. def : WriteRes<SchedRW.Folded, !listconcat([Zn2AGU], ExePorts)> {
  141. let Latency = !add(Lat, LoadLat);
  142. let ResourceCycles = !if(!empty(Res), [], !listconcat([1], Res));
  143. let NumMicroOps = !add(UOps, LoadUOps);
  144. }
  145. }
  146. // WriteRMW is set for instructions with Memory write
  147. // operation in codegen
  148. def : WriteRes<WriteRMW, [Zn2AGU]>;
  149. def : WriteRes<WriteStore, [Zn2AGU]>;
  150. def : WriteRes<WriteStoreNT, [Zn2AGU]>;
  151. def : WriteRes<WriteMove, [Zn2ALU]>;
  152. def : WriteRes<WriteLoad, [Zn2AGU]> { let Latency = 4; }
  153. // Model the effect of clobbering the read-write mask operand of the GATHER operation.
  154. // Does not cost anything by itself, only has latency, matching that of the WriteLoad,
  155. def : WriteRes<WriteVecMaskedGatherWriteback, []> { let Latency = 8; let NumMicroOps = 0; }
  156. def : WriteRes<WriteZero, []>;
  157. def : WriteRes<WriteLEA, [Zn2ALU]>;
  158. defm : Zn2WriteResPair<WriteALU, [Zn2ALU], 1>;
  159. defm : Zn2WriteResPair<WriteADC, [Zn2ALU], 1>;
  160. defm : Zn2WriteResPair<WriteIMul8, [Zn2ALU1, Zn2Multiplier], 4>;
  161. defm : X86WriteRes<WriteBSWAP32, [Zn2ALU], 1, [4], 1>;
  162. defm : X86WriteRes<WriteBSWAP64, [Zn2ALU], 1, [4], 1>;
  163. defm : X86WriteRes<WriteCMPXCHG, [Zn2ALU], 3, [1], 1>;
  164. defm : X86WriteRes<WriteCMPXCHGRMW,[Zn2ALU,Zn2AGU], 8, [1,1], 5>;
  165. defm : X86WriteRes<WriteXCHG, [Zn2ALU], 1, [2], 2>;
  166. defm : Zn2WriteResPair<WriteShift, [Zn2ALU], 1>;
  167. defm : Zn2WriteResPair<WriteShiftCL, [Zn2ALU], 1>;
  168. defm : Zn2WriteResPair<WriteRotate, [Zn2ALU], 1>;
  169. defm : Zn2WriteResPair<WriteRotateCL, [Zn2ALU], 1>;
  170. defm : X86WriteRes<WriteSHDrri, [Zn2ALU], 1, [1], 1>;
  171. defm : X86WriteResUnsupported<WriteSHDrrcl>;
  172. defm : X86WriteResUnsupported<WriteSHDmri>;
  173. defm : X86WriteResUnsupported<WriteSHDmrcl>;
  174. defm : Zn2WriteResPair<WriteJump, [Zn2ALU], 1>;
  175. defm : Zn2WriteResFpuPair<WriteCRC32, [Zn2FPU0], 3>;
  176. defm : Zn2WriteResPair<WriteCMOV, [Zn2ALU], 1>;
  177. def : WriteRes<WriteSETCC, [Zn2ALU]>;
  178. def : WriteRes<WriteSETCCStore, [Zn2ALU, Zn2AGU]>;
  179. defm : X86WriteRes<WriteLAHFSAHF, [Zn2ALU], 2, [1], 2>;
  180. defm : X86WriteRes<WriteBitTest, [Zn2ALU], 1, [1], 1>;
  181. defm : X86WriteRes<WriteBitTestImmLd, [Zn2ALU,Zn2AGU], 5, [1,1], 2>;
  182. defm : X86WriteRes<WriteBitTestRegLd, [Zn2ALU,Zn2AGU], 5, [1,1], 2>;
  183. defm : X86WriteRes<WriteBitTestSet, [Zn2ALU], 2, [1], 2>;
  184. // Bit counts.
  185. defm : Zn2WriteResPair<WriteBSF, [Zn2ALU], 3, [12], 6, 4, 2>;
  186. defm : Zn2WriteResPair<WriteBSR, [Zn2ALU], 4, [16], 6, 4, 2>;
  187. defm : Zn2WriteResPair<WriteLZCNT, [Zn2ALU], 1>;
  188. defm : Zn2WriteResPair<WriteTZCNT, [Zn2ALU], 2, [2], 2, 4, 0>;
  189. defm : Zn2WriteResPair<WritePOPCNT, [Zn2ALU], 1>;
  190. // Treat misc copies as a move.
  191. def : InstRW<[WriteMove], (instrs COPY)>;
  192. // BMI1 BEXTR, BMI2 BZHI
  193. defm : Zn2WriteResPair<WriteBEXTR, [Zn2ALU], 1, [1], 1, 4, 1>;
  194. defm : Zn2WriteResPair<WriteBLS, [Zn2ALU], 2, [2], 2, 4, 1>;
  195. defm : Zn2WriteResPair<WriteBZHI, [Zn2ALU], 1>;
  196. // IDIV
  197. defm : Zn2WriteResPair<WriteDiv8, [Zn2ALU2, Zn2Divider], 15, [1,15], 1>;
  198. defm : Zn2WriteResPair<WriteDiv16, [Zn2ALU2, Zn2Divider], 17, [1,17], 2>;
  199. defm : Zn2WriteResPair<WriteDiv32, [Zn2ALU2, Zn2Divider], 25, [1,25], 2>;
  200. defm : Zn2WriteResPair<WriteDiv64, [Zn2ALU2, Zn2Divider], 41, [1,41], 2>;
  201. defm : Zn2WriteResPair<WriteIDiv8, [Zn2ALU2, Zn2Divider], 15, [1,15], 1>;
  202. defm : Zn2WriteResPair<WriteIDiv16, [Zn2ALU2, Zn2Divider], 17, [1,17], 2>;
  203. defm : Zn2WriteResPair<WriteIDiv32, [Zn2ALU2, Zn2Divider], 25, [1,25], 2>;
  204. defm : Zn2WriteResPair<WriteIDiv64, [Zn2ALU2, Zn2Divider], 41, [1,41], 2>;
  205. // IMULH
  206. def Zn2WriteIMulH : WriteRes<WriteIMulH, [Zn2Multiplier]>{
  207. let Latency = 3;
  208. let NumMicroOps = 0;
  209. }
  210. def : WriteRes<WriteIMulHLd, [Zn2Multiplier]>{
  211. let Latency = !add(Zn2WriteIMulH.Latency, Znver2Model.LoadLatency);
  212. let NumMicroOps = Zn2WriteIMulH.NumMicroOps;
  213. }
  214. // Floating point operations
  215. defm : X86WriteRes<WriteFLoad, [Zn2AGU], 8, [1], 1>;
  216. defm : X86WriteRes<WriteFLoadX, [Zn2AGU], 8, [1], 1>;
  217. defm : X86WriteRes<WriteFLoadY, [Zn2AGU], 8, [1], 1>;
  218. defm : X86WriteRes<WriteFMaskedLoad, [Zn2AGU,Zn2FPU01], 8, [1,1], 1>;
  219. defm : X86WriteRes<WriteFMaskedLoadY, [Zn2AGU,Zn2FPU01], 8, [1,1], 2>;
  220. defm : X86WriteRes<WriteFStore, [Zn2AGU], 1, [1], 1>;
  221. defm : X86WriteRes<WriteFStoreX, [Zn2AGU], 1, [1], 1>;
  222. defm : X86WriteRes<WriteFStoreY, [Zn2AGU], 1, [1], 1>;
  223. defm : X86WriteRes<WriteFStoreNT, [Zn2AGU,Zn2FPU2], 8, [1,1], 1>;
  224. defm : X86WriteRes<WriteFStoreNTX, [Zn2AGU], 1, [1], 1>;
  225. defm : X86WriteRes<WriteFStoreNTY, [Zn2AGU], 1, [1], 1>;
  226. defm : X86WriteRes<WriteFMaskedStore32, [Zn2AGU,Zn2FPU01], 4, [1,1], 1>;
  227. defm : X86WriteRes<WriteFMaskedStore32Y, [Zn2AGU,Zn2FPU01], 5, [1,2], 2>;
  228. defm : X86WriteRes<WriteFMaskedStore64, [Zn2AGU,Zn2FPU01], 4, [1,1], 1>;
  229. defm : X86WriteRes<WriteFMaskedStore64Y, [Zn2AGU,Zn2FPU01], 5, [1,2], 2>;
  230. defm : X86WriteRes<WriteFMove, [Zn2FPU], 1, [1], 1>;
  231. defm : X86WriteRes<WriteFMoveX, [Zn2FPU], 1, [1], 1>;
  232. defm : X86WriteRes<WriteFMoveY, [Zn2FPU], 1, [1], 1>;
  233. defm : X86WriteResUnsupported<WriteFMoveZ>;
  234. defm : Zn2WriteResFpuPair<WriteFAdd, [Zn2FPU23], 3>;
  235. defm : Zn2WriteResFpuPair<WriteFAddX, [Zn2FPU23], 3>;
  236. defm : Zn2WriteResFpuPair<WriteFAddY, [Zn2FPU23], 3>;
  237. defm : X86WriteResPairUnsupported<WriteFAddZ>;
  238. defm : Zn2WriteResFpuPair<WriteFAdd64, [Zn2FPU23], 3>;
  239. defm : Zn2WriteResFpuPair<WriteFAdd64X, [Zn2FPU23], 3>;
  240. defm : Zn2WriteResFpuPair<WriteFAdd64Y, [Zn2FPU23], 3>;
  241. defm : X86WriteResPairUnsupported<WriteFAdd64Z>;
  242. defm : Zn2WriteResFpuPair<WriteFCmp, [Zn2FPU01], 1>;
  243. defm : Zn2WriteResFpuPair<WriteFCmpX, [Zn2FPU01], 1>;
  244. defm : Zn2WriteResFpuPair<WriteFCmpY, [Zn2FPU01], 1>;
  245. defm : X86WriteResPairUnsupported<WriteFCmpZ>;
  246. defm : Zn2WriteResFpuPair<WriteFCmp64, [Zn2FPU01], 1>;
  247. defm : Zn2WriteResFpuPair<WriteFCmp64X, [Zn2FPU01], 1>;
  248. defm : Zn2WriteResFpuPair<WriteFCmp64Y, [Zn2FPU01], 1>;
  249. defm : X86WriteResPairUnsupported<WriteFCmp64Z>;
  250. defm : Zn2WriteResFpuPair<WriteFCom, [Zn2FPU01,Zn2FPU2], 3, [1,1], 2>;
  251. defm : Zn2WriteResFpuPair<WriteFComX, [Zn2FPU01,Zn2FPU2], 3, [1,1], 2>;
  252. defm : Zn2WriteResFpuPair<WriteFBlend, [Zn2FPU01], 1>;
  253. defm : Zn2WriteResFpuPair<WriteFBlendY, [Zn2FPU01], 1>;
  254. defm : X86WriteResPairUnsupported<WriteFBlendZ>;
  255. defm : Zn2WriteResFpuPair<WriteFVarBlend, [Zn2FPU01], 1>;
  256. defm : Zn2WriteResFpuPair<WriteFVarBlendY,[Zn2FPU01], 1>;
  257. defm : X86WriteResPairUnsupported<WriteFVarBlendZ>;
  258. defm : Zn2WriteResFpuPair<WriteCvtSS2I, [Zn2FPU3], 5>;
  259. defm : Zn2WriteResFpuPair<WriteCvtPS2I, [Zn2FPU3], 5>;
  260. defm : Zn2WriteResFpuPair<WriteCvtPS2IY, [Zn2FPU3], 5>;
  261. defm : X86WriteResPairUnsupported<WriteCvtPS2IZ>;
  262. defm : Zn2WriteResFpuPair<WriteCvtSD2I, [Zn2FPU3], 5>;
  263. defm : Zn2WriteResFpuPair<WriteCvtPD2I, [Zn2FPU3], 5>;
  264. defm : Zn2WriteResFpuPair<WriteCvtPD2IY, [Zn2FPU3], 5>;
  265. defm : X86WriteResPairUnsupported<WriteCvtPD2IZ>;
  266. defm : Zn2WriteResFpuPair<WriteCvtI2SS, [Zn2FPU3], 5>;
  267. defm : Zn2WriteResFpuPair<WriteCvtI2PS, [Zn2FPU3], 5>;
  268. defm : Zn2WriteResFpuPair<WriteCvtI2PSY, [Zn2FPU3], 5>;
  269. defm : X86WriteResPairUnsupported<WriteCvtI2PSZ>;
  270. defm : Zn2WriteResFpuPair<WriteCvtI2SD, [Zn2FPU3], 5>;
  271. defm : Zn2WriteResFpuPair<WriteCvtI2PD, [Zn2FPU3], 5>;
  272. defm : Zn2WriteResFpuPair<WriteCvtI2PDY, [Zn2FPU3], 5>;
  273. defm : X86WriteResPairUnsupported<WriteCvtI2PDZ>;
  274. defm : Zn2WriteResFpuPair<WriteFDiv, [Zn2FPU3], 10, [5]>;
  275. defm : Zn2WriteResFpuPair<WriteFDivX, [Zn2FPU3], 10, [5]>;
  276. defm : Zn2WriteResFpuPair<WriteFDivY, [Zn2FPU3], 10, [5]>;
  277. defm : X86WriteResPairUnsupported<WriteFDivZ>;
  278. defm : Zn2WriteResFpuPair<WriteFDiv64, [Zn2FPU3], 13, [6]>;
  279. defm : Zn2WriteResFpuPair<WriteFDiv64X, [Zn2FPU3], 13, [6]>;
  280. defm : Zn2WriteResFpuPair<WriteFDiv64Y, [Zn2FPU3], 13, [6]>;
  281. defm : X86WriteResPairUnsupported<WriteFDiv64Z>;
  282. defm : Zn2WriteResFpuPair<WriteFSign, [Zn2FPU3], 2>;
  283. defm : Zn2WriteResFpuPair<WriteFRnd, [Zn2FPU3], 3, [1], 1, 7, 0>;
  284. defm : Zn2WriteResFpuPair<WriteFRndY, [Zn2FPU3], 3, [1], 1, 7, 0>;
  285. defm : X86WriteResPairUnsupported<WriteFRndZ>;
  286. defm : Zn2WriteResFpuPair<WriteFLogic, [Zn2FPU], 1>;
  287. defm : Zn2WriteResFpuPair<WriteFLogicY, [Zn2FPU], 1>;
  288. defm : X86WriteResPairUnsupported<WriteFLogicZ>;
  289. defm : Zn2WriteResFpuPair<WriteFTest, [Zn2FPU12], 3, [2], 1, 7, 1>;
  290. defm : Zn2WriteResFpuPair<WriteFTestY, [Zn2FPU12], 3, [2], 1, 7, 1>;
  291. defm : X86WriteResPairUnsupported<WriteFTestZ>;
  292. defm : Zn2WriteResFpuPair<WriteFShuffle, [Zn2FPU12], 1>;
  293. defm : Zn2WriteResFpuPair<WriteFShuffleY, [Zn2FPU12], 1>;
  294. defm : X86WriteResPairUnsupported<WriteFShuffleZ>;
  295. defm : Zn2WriteResFpuPair<WriteFVarShuffle, [Zn2FPU12], 3>;
  296. defm : Zn2WriteResFpuPair<WriteFVarShuffleY,[Zn2FPU12], 3>;
  297. defm : X86WriteResPairUnsupported<WriteFVarShuffleZ>;
  298. defm : Zn2WriteResFpuPair<WriteFMul, [Zn2FPU01], 3>;
  299. defm : Zn2WriteResFpuPair<WriteFMulX, [Zn2FPU01], 3>;
  300. defm : Zn2WriteResFpuPair<WriteFMulY, [Zn2FPU01], 3>;
  301. defm : X86WriteResPairUnsupported<WriteFMulZ>;
  302. defm : Zn2WriteResFpuPair<WriteFMul64, [Zn2FPU01], 3>;
  303. defm : Zn2WriteResFpuPair<WriteFMul64X, [Zn2FPU01], 3>;
  304. defm : Zn2WriteResFpuPair<WriteFMul64Y, [Zn2FPU01], 3>;
  305. defm : X86WriteResPairUnsupported<WriteFMul64Z>;
  306. defm : Zn2WriteResFpuPair<WriteFMA, [Zn2FPU01], 5>;
  307. defm : Zn2WriteResFpuPair<WriteFMAX, [Zn2FPU01], 5>;
  308. defm : Zn2WriteResFpuPair<WriteFMAY, [Zn2FPU01], 5>;
  309. defm : X86WriteResPairUnsupported<WriteFMAZ>;
  310. defm : Zn2WriteResFpuPair<WriteFRcp, [Zn2FPU01], 5>;
  311. defm : Zn2WriteResFpuPair<WriteFRcpX, [Zn2FPU01], 5>;
  312. defm : Zn2WriteResFpuPair<WriteFRcpY, [Zn2FPU01], 5>;
  313. defm : X86WriteResPairUnsupported<WriteFRcpZ>;
  314. defm : Zn2WriteResFpuPair<WriteFRsqrt, [Zn2FPU01], 5>;
  315. defm : Zn2WriteResFpuPair<WriteFRsqrtX, [Zn2FPU01], 5>;
  316. defm : Zn2WriteResFpuPair<WriteFRsqrtY, [Zn2FPU01], 5>;
  317. defm : X86WriteResPairUnsupported<WriteFRsqrtZ>;
  318. defm : Zn2WriteResFpuPair<WriteFSqrt, [Zn2FPU3], 14, [7]>;
  319. defm : Zn2WriteResFpuPair<WriteFSqrtX, [Zn2FPU3], 14, [7]>;
  320. defm : Zn2WriteResFpuPair<WriteFSqrtY, [Zn2FPU3], 14, [7]>;
  321. defm : X86WriteResPairUnsupported<WriteFSqrtZ>;
  322. defm : Zn2WriteResFpuPair<WriteFSqrt64, [Zn2FPU3], 20, [10]>;
  323. defm : Zn2WriteResFpuPair<WriteFSqrt64X, [Zn2FPU3], 20, [10]>;
  324. defm : Zn2WriteResFpuPair<WriteFSqrt64Y, [Zn2FPU3], 20, [10]>;
  325. defm : X86WriteResPairUnsupported<WriteFSqrt64Z>;
  326. defm : Zn2WriteResFpuPair<WriteFSqrt80, [Zn2FPU3], 20, [20]>;
  327. defm : Zn2WriteResFpuPair<WriteFShuffle256, [Zn2FPU12], 2>;
  328. defm : Zn2WriteResFpuPair<WriteFVarShuffle256, [Zn2FPU12], 2>;
  329. // Vector integer operations which uses FPU units
  330. defm : X86WriteRes<WriteVecLoad, [Zn2AGU], 8, [1], 1>;
  331. defm : X86WriteRes<WriteVecLoadX, [Zn2AGU], 8, [1], 1>;
  332. defm : X86WriteRes<WriteVecLoadY, [Zn2AGU], 8, [1], 1>;
  333. defm : X86WriteRes<WriteVecLoadNT, [Zn2AGU], 8, [1], 1>;
  334. defm : X86WriteRes<WriteVecLoadNTY, [Zn2AGU], 8, [1], 1>;
  335. defm : X86WriteRes<WriteVecMaskedLoad, [Zn2AGU,Zn2FPU01], 8, [1,2], 2>;
  336. defm : X86WriteRes<WriteVecMaskedLoadY, [Zn2AGU,Zn2FPU01], 8, [1,2], 2>;
  337. defm : X86WriteRes<WriteVecStore, [Zn2AGU], 1, [1], 1>;
  338. defm : X86WriteRes<WriteVecStoreX, [Zn2AGU], 1, [1], 1>;
  339. defm : X86WriteRes<WriteVecStoreY, [Zn2AGU], 1, [1], 1>;
  340. defm : X86WriteRes<WriteVecStoreNT, [Zn2AGU], 1, [1], 1>;
  341. defm : X86WriteRes<WriteVecStoreNTY, [Zn2AGU], 1, [1], 1>;
  342. defm : X86WriteRes<WriteVecMaskedStore32, [Zn2AGU,Zn2FPU01], 4, [1,1], 1>;
  343. defm : X86WriteRes<WriteVecMaskedStore32Y, [Zn2AGU,Zn2FPU01], 5, [1,2], 2>;
  344. defm : X86WriteRes<WriteVecMaskedStore64, [Zn2AGU,Zn2FPU01], 4, [1,1], 1>;
  345. defm : X86WriteRes<WriteVecMaskedStore64Y, [Zn2AGU,Zn2FPU01], 5, [1,2], 2>;
  346. defm : X86WriteRes<WriteVecMove, [Zn2FPU], 1, [1], 1>;
  347. defm : X86WriteRes<WriteVecMoveX, [Zn2FPU], 1, [1], 1>;
  348. defm : X86WriteRes<WriteVecMoveY, [Zn2FPU], 2, [1], 2>;
  349. defm : X86WriteResUnsupported<WriteVecMoveZ>;
  350. defm : X86WriteRes<WriteVecMoveToGpr, [Zn2FPU2], 2, [1], 1>;
  351. defm : X86WriteRes<WriteVecMoveFromGpr, [Zn2FPU2], 3, [1], 1>;
  352. defm : X86WriteRes<WriteEMMS, [Zn2FPU], 2, [1], 1>;
  353. defm : Zn2WriteResFpuPair<WriteVecShift, [Zn2FPU2], 1>;
  354. defm : Zn2WriteResFpuPair<WriteVecShiftX, [Zn2FPU2], 1>;
  355. defm : Zn2WriteResFpuPair<WriteVecShiftY, [Zn2FPU2], 1>;
  356. defm : X86WriteResPairUnsupported<WriteVecShiftZ>;
  357. defm : Zn2WriteResFpuPair<WriteVecShiftImm, [Zn2FPU2], 1>;
  358. defm : Zn2WriteResFpuPair<WriteVecShiftImmX, [Zn2FPU2], 1>;
  359. defm : Zn2WriteResFpuPair<WriteVecShiftImmY, [Zn2FPU2], 1>;
  360. defm : X86WriteResPairUnsupported<WriteVecShiftImmZ>;
  361. defm : Zn2WriteResFpuPair<WriteVarVecShift, [Zn2FPU1], 3, [2], 1>;
  362. defm : Zn2WriteResFpuPair<WriteVarVecShiftY, [Zn2FPU1], 3, [2], 1>;
  363. defm : X86WriteResPairUnsupported<WriteVarVecShiftZ>;
  364. defm : Zn2WriteResFpuPair<WriteVecLogic, [Zn2FPU], 1>;
  365. defm : Zn2WriteResFpuPair<WriteVecLogicX, [Zn2FPU], 1>;
  366. defm : Zn2WriteResFpuPair<WriteVecLogicY, [Zn2FPU], 1>;
  367. defm : X86WriteResPairUnsupported<WriteVecLogicZ>;
  368. defm : Zn2WriteResFpuPair<WriteVecTest, [Zn2FPU12], 3, [2], 1, 7, 1>;
  369. defm : Zn2WriteResFpuPair<WriteVecTestY, [Zn2FPU12], 3, [2], 1, 7, 1>;
  370. defm : X86WriteResPairUnsupported<WriteVecTestZ>;
  371. defm : Zn2WriteResFpuPair<WriteVecALU, [Zn2FPU013], 1>;
  372. defm : Zn2WriteResFpuPair<WriteVecALUX, [Zn2FPU013], 1>;
  373. defm : Zn2WriteResFpuPair<WriteVecALUY, [Zn2FPU013], 1>;
  374. defm : X86WriteResPairUnsupported<WriteVecALUZ>;
  375. defm : Zn2WriteResFpuPair<WriteVecIMul, [Zn2FPU0], 4>;
  376. defm : Zn2WriteResFpuPair<WriteVecIMulX, [Zn2FPU0], 4>;
  377. defm : Zn2WriteResFpuPair<WriteVecIMulY, [Zn2FPU0], 4>;
  378. defm : X86WriteResPairUnsupported<WriteVecIMulZ>;
  379. defm : Zn2WriteResFpuPair<WritePMULLD, [Zn2FPU0], 4, [2]>;
  380. defm : Zn2WriteResFpuPair<WritePMULLDY, [Zn2FPU0], 4, [2]>;
  381. defm : X86WriteResPairUnsupported<WritePMULLDZ>;
  382. defm : Zn2WriteResFpuPair<WriteShuffle, [Zn2FPU12], 1>;
  383. defm : Zn2WriteResFpuPair<WriteShuffleX, [Zn2FPU12], 1>;
  384. defm : Zn2WriteResFpuPair<WriteShuffleY, [Zn2FPU12], 1>;
  385. defm : X86WriteResPairUnsupported<WriteShuffleZ>;
  386. defm : Zn2WriteResFpuPair<WriteVarShuffle, [Zn2FPU12], 1>;
  387. defm : Zn2WriteResFpuPair<WriteVarShuffleX,[Zn2FPU12], 1>;
  388. defm : Zn2WriteResFpuPair<WriteVarShuffleY,[Zn2FPU12], 1>;
  389. defm : X86WriteResPairUnsupported<WriteVarShuffleZ>;
  390. defm : Zn2WriteResFpuPair<WriteBlend, [Zn2FPU013], 1>;
  391. defm : Zn2WriteResFpuPair<WriteBlendY, [Zn2FPU013], 1>;
  392. defm : X86WriteResPairUnsupported<WriteBlendZ>;
  393. defm : Zn2WriteResFpuPair<WriteVarBlend, [Zn2FPU0], 1>;
  394. defm : Zn2WriteResFpuPair<WriteVarBlendY, [Zn2FPU0], 1>;
  395. defm : X86WriteResPairUnsupported<WriteVarBlendZ>;
  396. defm : Zn2WriteResFpuPair<WriteShuffle256, [Zn2FPU12], 2>;
  397. defm : Zn2WriteResFpuPair<WriteVPMOV256, [Zn2FPU12], 4, [1], 2, 4>;
  398. defm : Zn2WriteResFpuPair<WriteVarShuffle256, [Zn2FPU12], 2>;
  399. defm : Zn2WriteResFpuPair<WritePSADBW, [Zn2FPU0], 3>;
  400. defm : Zn2WriteResFpuPair<WritePSADBWX, [Zn2FPU0], 3>;
  401. defm : Zn2WriteResFpuPair<WritePSADBWY, [Zn2FPU0], 3>;
  402. defm : X86WriteResPairUnsupported<WritePSADBWZ>;
  403. defm : Zn2WriteResFpuPair<WritePHMINPOS, [Zn2FPU0], 4>;
  404. // Vector insert/extract operations.
  405. defm : Zn2WriteResFpuPair<WriteVecInsert, [Zn2FPU], 1>;
  406. def : WriteRes<WriteVecExtract, [Zn2FPU12, Zn2FPU2]> {
  407. let Latency = 2;
  408. let ResourceCycles = [1, 2];
  409. }
  410. def : WriteRes<WriteVecExtractSt, [Zn2AGU, Zn2FPU12, Zn2FPU2]> {
  411. let Latency = 5;
  412. let NumMicroOps = 2;
  413. let ResourceCycles = [1, 2, 3];
  414. }
  415. // MOVMSK Instructions.
  416. def : WriteRes<WriteFMOVMSK, [Zn2FPU2]>;
  417. def : WriteRes<WriteMMXMOVMSK, [Zn2FPU2]>;
  418. def : WriteRes<WriteVecMOVMSK, [Zn2FPU2]>;
  419. def : WriteRes<WriteVecMOVMSKY, [Zn2FPU2]> {
  420. let NumMicroOps = 2;
  421. let Latency = 2;
  422. let ResourceCycles = [2];
  423. }
  424. // AES Instructions.
  425. defm : Zn2WriteResFpuPair<WriteAESDecEnc, [Zn2FPU01], 4>;
  426. defm : Zn2WriteResFpuPair<WriteAESIMC, [Zn2FPU01], 4>;
  427. defm : Zn2WriteResFpuPair<WriteAESKeyGen, [Zn2FPU01], 4>;
  428. def : WriteRes<WriteFence, [Zn2AGU]>;
  429. def : WriteRes<WriteNop, []>;
  430. // Microcoded Instructions
  431. def Zn2WriteMicrocoded : SchedWriteRes<[]> {
  432. let Latency = 100;
  433. }
  434. def : SchedAlias<WriteMicrocoded, Zn2WriteMicrocoded>;
  435. def : SchedAlias<WriteFCMOV, Zn2WriteMicrocoded>;
  436. def : SchedAlias<WriteSystem, Zn2WriteMicrocoded>;
  437. def : SchedAlias<WriteMPSAD, Zn2WriteMicrocoded>;
  438. def : SchedAlias<WriteMPSADY, Zn2WriteMicrocoded>;
  439. def : SchedAlias<WriteMPSADLd, Zn2WriteMicrocoded>;
  440. def : SchedAlias<WriteMPSADYLd, Zn2WriteMicrocoded>;
  441. def : SchedAlias<WriteCLMul, Zn2WriteMicrocoded>;
  442. def : SchedAlias<WriteCLMulLd, Zn2WriteMicrocoded>;
  443. def : SchedAlias<WritePCmpIStrM, Zn2WriteMicrocoded>;
  444. def : SchedAlias<WritePCmpIStrMLd, Zn2WriteMicrocoded>;
  445. def : SchedAlias<WritePCmpEStrI, Zn2WriteMicrocoded>;
  446. def : SchedAlias<WritePCmpEStrILd, Zn2WriteMicrocoded>;
  447. def : SchedAlias<WritePCmpEStrM, Zn2WriteMicrocoded>;
  448. def : SchedAlias<WritePCmpEStrMLd, Zn2WriteMicrocoded>;
  449. def : SchedAlias<WritePCmpIStrI, Zn2WriteMicrocoded>;
  450. def : SchedAlias<WritePCmpIStrILd, Zn2WriteMicrocoded>;
  451. def : SchedAlias<WriteLDMXCSR, Zn2WriteMicrocoded>;
  452. def : SchedAlias<WriteSTMXCSR, Zn2WriteMicrocoded>;
  453. //=== Regex based InstRW ===//
  454. // Notation:
  455. // - r: register.
  456. // - m = memory.
  457. // - i = immediate
  458. // - mm: 64 bit mmx register.
  459. // - x = 128 bit xmm register.
  460. // - (x)mm = mmx or xmm register.
  461. // - y = 256 bit ymm register.
  462. // - v = any vector register.
  463. //=== Integer Instructions ===//
  464. //-- Move instructions --//
  465. // MOV.
  466. // r16,m.
  467. def : InstRW<[WriteALULd, ReadAfterLd], (instrs MOV16rm)>;
  468. // XCHG.
  469. // r,r.
  470. def Zn2WriteXCHG : SchedWriteRes<[Zn2ALU]> {
  471. let NumMicroOps = 2;
  472. }
  473. def : InstRW<[Zn2WriteXCHG], (instregex "^XCHG(8|16|32|64)rr", "^XCHG(16|32|64)ar")>;
  474. // r,m.
  475. def Zn2WriteXCHGrm : SchedWriteRes<[Zn2AGU, Zn2ALU]> {
  476. let Latency = 5;
  477. let NumMicroOps = 2;
  478. }
  479. def : InstRW<[Zn2WriteXCHGrm, ReadAfterLd], (instregex "^XCHG(8|16|32|64)rm")>;
  480. def : InstRW<[WriteMicrocoded], (instrs XLAT)>;
  481. // POP16.
  482. // r.
  483. def Zn2WritePop16r : SchedWriteRes<[Zn2AGU]>{
  484. let Latency = 5;
  485. let NumMicroOps = 2;
  486. }
  487. def : InstRW<[Zn2WritePop16r], (instrs POP16rmm)>;
  488. def : InstRW<[WriteMicrocoded], (instregex "POPF(16|32)")>;
  489. def : InstRW<[WriteMicrocoded], (instregex "POPA(16|32)")>;
  490. // PUSH.
  491. // r. Has default values.
  492. // m.
  493. def Zn2WritePUSH : SchedWriteRes<[Zn2AGU]>{
  494. let Latency = 4;
  495. }
  496. def : InstRW<[Zn2WritePUSH], (instregex "PUSH(16|32)rmm")>;
  497. // PUSHF
  498. def : InstRW<[WriteMicrocoded], (instregex "PUSHF(16|32)")>;
  499. // PUSHA.
  500. def Zn2WritePushA : SchedWriteRes<[Zn2AGU]> {
  501. let Latency = 8;
  502. }
  503. def : InstRW<[Zn2WritePushA], (instregex "PUSHA(16|32)")>;
  504. //LAHF
  505. def : InstRW<[WriteMicrocoded], (instrs LAHF)>;
  506. // MOVBE.
  507. // r,m.
  508. def Zn2WriteMOVBE : SchedWriteRes<[Zn2AGU, Zn2ALU]> {
  509. let Latency = 5;
  510. }
  511. def : InstRW<[Zn2WriteMOVBE, ReadAfterLd], (instregex "MOVBE(16|32|64)rm")>;
  512. // m16,r16.
  513. def : InstRW<[Zn2WriteMOVBE], (instregex "MOVBE(16|32|64)mr")>;
  514. //-- Arithmetic instructions --//
  515. // ADD SUB.
  516. // m,r/i.
  517. def : InstRW<[WriteALULd], (instregex "(ADD|SUB)(8|16|32|64)m(r|i)",
  518. "(ADD|SUB)(8|16|32|64)mi8",
  519. "(ADD|SUB)64mi32")>;
  520. // ADC SBB.
  521. // m,r/i.
  522. def : InstRW<[WriteALULd],
  523. (instregex "(ADC|SBB)(8|16|32|64)m(r|i)",
  524. "(ADC|SBB)(16|32|64)mi8",
  525. "(ADC|SBB)64mi32")>;
  526. // INC DEC NOT NEG.
  527. // m.
  528. def : InstRW<[WriteALULd],
  529. (instregex "(INC|DEC|NOT|NEG)(8|16|32|64)m")>;
  530. // MUL IMUL.
  531. // r16.
  532. def Zn2WriteMul16 : SchedWriteRes<[Zn2ALU1, Zn2Multiplier]> {
  533. let Latency = 3;
  534. }
  535. def Zn2WriteMul16Imm : SchedWriteRes<[Zn2ALU1, Zn2Multiplier]> {
  536. let Latency = 4;
  537. }
  538. def : SchedAlias<WriteIMul16, Zn2WriteMul16>;
  539. def : SchedAlias<WriteIMul16Imm, Zn2WriteMul16Imm>;
  540. def : SchedAlias<WriteIMul16Reg, Zn2WriteMul16>;
  541. // m16.
  542. def Zn2WriteMul16Ld : SchedWriteRes<[Zn2AGU, Zn2ALU1, Zn2Multiplier]> {
  543. let Latency = 7;
  544. }
  545. def : SchedAlias<WriteIMul16Ld, Zn2WriteMul16Ld>;
  546. def : SchedAlias<WriteIMul16ImmLd, Zn2WriteMul16Ld>;
  547. def : SchedAlias<WriteIMul16RegLd, Zn2WriteMul16Ld>;
  548. // r32.
  549. def Zn2WriteMul32 : SchedWriteRes<[Zn2ALU1, Zn2Multiplier]> {
  550. let Latency = 3;
  551. }
  552. def : SchedAlias<WriteIMul32, Zn2WriteMul32>;
  553. def : SchedAlias<WriteIMul32Imm, Zn2WriteMul32>;
  554. def : SchedAlias<WriteIMul32Reg, Zn2WriteMul32>;
  555. // m32.
  556. def Zn2WriteMul32Ld : SchedWriteRes<[Zn2AGU, Zn2ALU1, Zn2Multiplier]> {
  557. let Latency = 7;
  558. }
  559. def : SchedAlias<WriteIMul32Ld, Zn2WriteMul32Ld>;
  560. def : SchedAlias<WriteIMul32ImmLd, Zn2WriteMul32Ld>;
  561. def : SchedAlias<WriteIMul32RegLd, Zn2WriteMul32Ld>;
  562. // r64.
  563. def Zn2WriteMul64 : SchedWriteRes<[Zn2ALU1, Zn2Multiplier]> {
  564. let Latency = 4;
  565. let NumMicroOps = 2;
  566. }
  567. def : SchedAlias<WriteIMul64, Zn2WriteMul64>;
  568. def : SchedAlias<WriteIMul64Imm, Zn2WriteMul64>;
  569. def : SchedAlias<WriteIMul64Reg, Zn2WriteMul64>;
  570. // m64.
  571. def Zn2WriteMul64Ld : SchedWriteRes<[Zn2AGU, Zn2ALU1, Zn2Multiplier]> {
  572. let Latency = 8;
  573. let NumMicroOps = 2;
  574. }
  575. def : SchedAlias<WriteIMul64Ld, Zn2WriteMul64Ld>;
  576. def : SchedAlias<WriteIMul64ImmLd, Zn2WriteMul64Ld>;
  577. def : SchedAlias<WriteIMul64RegLd, Zn2WriteMul64Ld>;
  578. // MULX.
  579. // Numbers are based on the AMD SOG for Family 17h - Instruction Latencies.
  580. defm : Zn2WriteResPair<WriteMULX32, [Zn2ALU1, Zn2Multiplier], 3, [1, 1], 1, 4, 0>;
  581. defm : Zn2WriteResPair<WriteMULX64, [Zn2ALU1, Zn2Multiplier], 3, [1, 1], 1, 4, 0>;
  582. //-- Control transfer instructions --//
  583. // J(E|R)CXZ.
  584. def Zn2WriteJCXZ : SchedWriteRes<[Zn2ALU03]>;
  585. def : InstRW<[Zn2WriteJCXZ], (instrs JCXZ, JECXZ, JRCXZ)>;
  586. // LOOP.
  587. def Zn2WriteLOOP : SchedWriteRes<[Zn2ALU03]>;
  588. def : InstRW<[Zn2WriteLOOP], (instrs LOOP)>;
  589. // LOOP(N)E, LOOP(N)Z
  590. def Zn2WriteLOOPE : SchedWriteRes<[Zn2ALU03]>;
  591. def : InstRW<[Zn2WriteLOOPE], (instrs LOOPE, LOOPNE)>;
  592. // CALL.
  593. // r.
  594. def Zn2WriteCALLr : SchedWriteRes<[Zn2AGU, Zn2ALU03]>;
  595. def : InstRW<[Zn2WriteCALLr], (instregex "CALL(16|32)r")>;
  596. def : InstRW<[WriteMicrocoded], (instregex "CALL(16|32)m")>;
  597. // RET.
  598. def Zn2WriteRET : SchedWriteRes<[Zn2ALU03]> {
  599. let NumMicroOps = 2;
  600. }
  601. def : InstRW<[Zn2WriteRET], (instregex "RET(16|32|64)", "LRET(16|32|64)",
  602. "IRET(16|32|64)")>;
  603. //-- Logic instructions --//
  604. // AND OR XOR.
  605. // m,r/i.
  606. def : InstRW<[WriteALULd],
  607. (instregex "(AND|OR|XOR)(8|16|32|64)m(r|i)",
  608. "(AND|OR|XOR)(8|16|32|64)mi8", "(AND|OR|XOR)64mi32")>;
  609. // Define ALU latency variants
  610. def Zn2WriteALULat2 : SchedWriteRes<[Zn2ALU]> {
  611. let Latency = 2;
  612. }
  613. def Zn2WriteALULat2Ld : SchedWriteRes<[Zn2AGU, Zn2ALU]> {
  614. let Latency = 6;
  615. }
  616. // BTR BTS BTC.
  617. // m,r,i.
  618. def Zn2WriteBTRSCm : SchedWriteRes<[Zn2AGU, Zn2ALU]> {
  619. let Latency = 6;
  620. let NumMicroOps = 2;
  621. }
  622. // m,r,i.
  623. def : SchedAlias<WriteBitTestSetImmRMW, Zn2WriteBTRSCm>;
  624. def : SchedAlias<WriteBitTestSetRegRMW, Zn2WriteBTRSCm>;
  625. // PDEP PEXT.
  626. // r,r,r.
  627. def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rr", "PEXT(32|64)rr")>;
  628. // r,r,m.
  629. def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rm", "PEXT(32|64)rm")>;
  630. // RCR RCL.
  631. // m,i.
  632. def : InstRW<[WriteMicrocoded], (instregex "RC(R|L)(8|16|32|64)m(1|i|CL)")>;
  633. // SHR SHL SAR.
  634. // m,i.
  635. def : InstRW<[WriteShiftLd], (instregex "S(A|H)(R|L)(8|16|32|64)m(i|1)")>;
  636. // SHRD SHLD.
  637. // m,r
  638. def : InstRW<[WriteShiftLd], (instregex "SH(R|L)D(16|32|64)mri8")>;
  639. // r,r,cl.
  640. def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)rrCL")>;
  641. // m,r,cl.
  642. def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)mrCL")>;
  643. //-- Misc instructions --//
  644. // CMPXCHG8B.
  645. def Zn2WriteCMPXCHG8B : SchedWriteRes<[Zn2AGU, Zn2ALU]> {
  646. let NumMicroOps = 18;
  647. }
  648. def : InstRW<[Zn2WriteCMPXCHG8B], (instrs CMPXCHG8B)>;
  649. def : InstRW<[WriteMicrocoded], (instrs CMPXCHG16B)>;
  650. // LEAVE
  651. def Zn2WriteLEAVE : SchedWriteRes<[Zn2ALU, Zn2AGU]> {
  652. let Latency = 8;
  653. let NumMicroOps = 2;
  654. }
  655. def : InstRW<[Zn2WriteLEAVE], (instregex "LEAVE")>;
  656. // PAUSE.
  657. def : InstRW<[WriteMicrocoded], (instrs PAUSE)>;
  658. // XADD.
  659. def Zn2XADD : SchedWriteRes<[Zn2ALU]>;
  660. def : InstRW<[Zn2XADD], (instregex "XADD(8|16|32|64)rr")>;
  661. def : InstRW<[WriteMicrocoded], (instregex "XADD(8|16|32|64)rm")>;
  662. //=== Floating Point x87 Instructions ===//
  663. //-- Move instructions --//
  664. def Zn2WriteFLDr : SchedWriteRes<[Zn2FPU13]> ;
  665. def Zn2WriteSTr: SchedWriteRes<[Zn2FPU23]> {
  666. let Latency = 5;
  667. let NumMicroOps = 2;
  668. }
  669. // LD_F.
  670. // r.
  671. def : InstRW<[Zn2WriteFLDr], (instrs LD_Frr)>;
  672. // m.
  673. def Zn2WriteLD_F80m : SchedWriteRes<[Zn2AGU, Zn2FPU13]> {
  674. let NumMicroOps = 2;
  675. }
  676. def : InstRW<[Zn2WriteLD_F80m], (instrs LD_F80m)>;
  677. // FST(P).
  678. // r.
  679. def : InstRW<[Zn2WriteSTr], (instregex "ST_(F|FP)rr")>;
  680. // m80.
  681. def Zn2WriteST_FP80m : SchedWriteRes<[Zn2AGU, Zn2FPU23]> {
  682. let Latency = 5;
  683. }
  684. def : InstRW<[Zn2WriteST_FP80m], (instrs ST_FP80m)>;
  685. def Zn2WriteFXCH : SchedWriteRes<[Zn2FPU]>;
  686. // FXCHG.
  687. def : InstRW<[Zn2WriteFXCH], (instrs XCH_F)>;
  688. // FILD.
  689. def Zn2WriteFILD : SchedWriteRes<[Zn2AGU, Zn2FPU3]> {
  690. let Latency = 11;
  691. let NumMicroOps = 2;
  692. }
  693. def : InstRW<[Zn2WriteFILD], (instregex "ILD_F(16|32|64)m")>;
  694. // FIST(P) FISTTP.
  695. def Zn2WriteFIST : SchedWriteRes<[Zn2AGU, Zn2FPU23]> {
  696. let Latency = 12;
  697. }
  698. def : InstRW<[Zn2WriteFIST], (instregex "IS(T|TT)_(F|FP)(16|32|64)m")>;
  699. def Zn2WriteFPU13 : SchedWriteRes<[Zn2AGU, Zn2FPU13]> {
  700. let Latency = 8;
  701. }
  702. def Zn2WriteFPU3 : SchedWriteRes<[Zn2AGU, Zn2FPU3]> {
  703. let Latency = 11;
  704. }
  705. // FLDZ.
  706. def : SchedAlias<WriteFLD0, Zn2WriteFPU13>;
  707. // FLD1.
  708. def : SchedAlias<WriteFLD1, Zn2WriteFPU3>;
  709. // FLDPI FLDL2E etc.
  710. def : SchedAlias<WriteFLDC, Zn2WriteFPU3>;
  711. // FNSTSW.
  712. // AX.
  713. def : InstRW<[WriteMicrocoded], (instrs FNSTSW16r)>;
  714. // FLDCW.
  715. def : InstRW<[WriteMicrocoded], (instrs FLDCW16m)>;
  716. // FNSTCW.
  717. def : InstRW<[WriteMicrocoded], (instrs FNSTCW16m)>;
  718. // FINCSTP FDECSTP.
  719. def : InstRW<[Zn2WriteFPU3], (instrs FINCSTP, FDECSTP)>;
  720. // FFREE.
  721. def : InstRW<[Zn2WriteFPU3], (instregex "FFREE")>;
  722. //-- Arithmetic instructions --//
  723. def Zn2WriteFPU3Lat1 : SchedWriteRes<[Zn2FPU3]> ;
  724. def Zn2WriteFPU0Lat1 : SchedWriteRes<[Zn2FPU0]> ;
  725. def Zn2WriteFPU0Lat1Ld : SchedWriteRes<[Zn2AGU, Zn2FPU0]> {
  726. let Latency = 8;
  727. }
  728. // FCHS.
  729. def : InstRW<[Zn2WriteFPU3Lat1], (instregex "CHS_F")>;
  730. // FCOM(P) FUCOM(P).
  731. // r.
  732. def : InstRW<[Zn2WriteFPU0Lat1], (instregex "COM(P?)_FST0r", "UCOM_F(P?)r")>;
  733. // m.
  734. def : InstRW<[Zn2WriteFPU0Lat1Ld], (instregex "FCOM(P?)(32|64)m")>;
  735. // FCOMPP FUCOMPP.
  736. // r.
  737. def : InstRW<[Zn2WriteFPU0Lat1], (instrs FCOMPP, UCOM_FPPr)>;
  738. def Zn2WriteFPU02 : SchedWriteRes<[Zn2AGU, Zn2FPU02]>
  739. {
  740. let Latency = 9;
  741. }
  742. // FCOMI(P) FUCOMI(P).
  743. // m.
  744. def : InstRW<[Zn2WriteFPU02], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>;
  745. def Zn2WriteFPU03 : SchedWriteRes<[Zn2AGU, Zn2FPU03]>
  746. {
  747. let Latency = 12;
  748. let NumMicroOps = 2;
  749. let ResourceCycles = [1,3];
  750. }
  751. // FICOM(P).
  752. def : InstRW<[Zn2WriteFPU03], (instregex "FICOM(P?)(16|32)m")>;
  753. // FTST.
  754. def : InstRW<[Zn2WriteFPU0Lat1], (instregex "TST_F")>;
  755. // FXAM.
  756. def : InstRW<[Zn2WriteFPU3Lat1], (instrs XAM_F)>;
  757. // FNOP.
  758. def : InstRW<[Zn2WriteFPU0Lat1], (instrs FNOP)>;
  759. // WAIT.
  760. def : InstRW<[Zn2WriteFPU0Lat1], (instrs WAIT)>;
  761. //=== Integer MMX and XMM Instructions ===//
  762. def Zn2WriteFPU013 : SchedWriteRes<[Zn2FPU013]> ;
  763. def Zn2WriteFPU013m : SchedWriteRes<[Zn2AGU, Zn2FPU013]> {
  764. let Latency = 8;
  765. let NumMicroOps = 2;
  766. }
  767. def Zn2WriteFPU01 : SchedWriteRes<[Zn2FPU01]> ;
  768. def Zn2WriteFPU01Y : SchedWriteRes<[Zn2FPU01]> {
  769. let NumMicroOps = 2;
  770. }
  771. // VPBLENDD.
  772. // v,v,v,i.
  773. def : InstRW<[Zn2WriteFPU01], (instrs VPBLENDDrri)>;
  774. // ymm
  775. def : InstRW<[Zn2WriteFPU01Y], (instrs VPBLENDDYrri)>;
  776. // v,v,m,i
  777. def Zn2WriteFPU01Op2 : SchedWriteRes<[Zn2AGU, Zn2FPU01]> {
  778. let NumMicroOps = 2;
  779. let Latency = 8;
  780. let ResourceCycles = [1, 2];
  781. }
  782. def Zn2WriteFPU01Op2Y : SchedWriteRes<[Zn2AGU, Zn2FPU01]> {
  783. let NumMicroOps = 2;
  784. let Latency = 9;
  785. let ResourceCycles = [1, 3];
  786. }
  787. def : InstRW<[Zn2WriteFPU01Op2], (instrs VPBLENDDrmi)>;
  788. def : InstRW<[Zn2WriteFPU01Op2Y], (instrs VPBLENDDYrmi)>;
  789. // MASKMOVQ.
  790. def : InstRW<[WriteMicrocoded], (instregex "MMX_MASKMOVQ(64)?")>;
  791. // MASKMOVDQU.
  792. def : InstRW<[WriteMicrocoded], (instregex "(V?)MASKMOVDQU(64)?")>;
  793. // VPMASKMOVD.
  794. // ymm
  795. def : InstRW<[WriteMicrocoded],
  796. (instregex "VPMASKMOVD(Y?)rm")>;
  797. // m, v,v.
  798. def : InstRW<[WriteMicrocoded], (instregex "VPMASKMOV(D|Q)(Y?)mr")>;
  799. // VPBROADCAST B/W.
  800. // x, m8/16.
  801. def Zn2WriteVPBROADCAST128Ld : SchedWriteRes<[Zn2AGU, Zn2FPU12]> {
  802. let Latency = 8;
  803. let NumMicroOps = 2;
  804. let ResourceCycles = [1, 2];
  805. }
  806. def : InstRW<[Zn2WriteVPBROADCAST128Ld],
  807. (instregex "VPBROADCAST(B|W)rm")>;
  808. // y, m8/16
  809. def Zn2WriteVPBROADCAST256Ld : SchedWriteRes<[Zn2AGU, Zn2FPU1]> {
  810. let Latency = 8;
  811. let NumMicroOps = 2;
  812. let ResourceCycles = [1, 2];
  813. }
  814. def : InstRW<[Zn2WriteVPBROADCAST256Ld],
  815. (instregex "VPBROADCAST(B|W)Yrm")>;
  816. // VPGATHER.
  817. def : InstRW<[WriteMicrocoded], (instregex "VPGATHER(Q|D)(Q|D)(Y?)rm")>;
  818. //-- Arithmetic instructions --//
  819. // HADD, HSUB PS/PD
  820. // PHADD|PHSUB (S) W/D.
  821. defm : Zn2WriteResFpuPair<WriteFHAdd, [], 7>;
  822. defm : Zn2WriteResFpuPair<WriteFHAddY, [], 7>;
  823. defm : Zn2WriteResFpuPair<WritePHAdd, [], 3>;
  824. defm : Zn2WriteResFpuPair<WritePHAddX, [], 3>;
  825. defm : Zn2WriteResFpuPair<WritePHAddY, [], 3>;
  826. // PCMPGTQ.
  827. def Zn2WritePCMPGTQr : SchedWriteRes<[Zn2FPU03]>;
  828. def : InstRW<[Zn2WritePCMPGTQr], (instregex "(V?)PCMPGTQ(Y?)rr")>;
  829. // x <- x,m.
  830. def Zn2WritePCMPGTQm : SchedWriteRes<[Zn2AGU, Zn2FPU03]> {
  831. let Latency = 8;
  832. }
  833. // ymm.
  834. def Zn2WritePCMPGTQYm : SchedWriteRes<[Zn2AGU, Zn2FPU03]> {
  835. let Latency = 8;
  836. }
  837. def : InstRW<[Zn2WritePCMPGTQm], (instregex "(V?)PCMPGTQrm")>;
  838. def : InstRW<[Zn2WritePCMPGTQYm], (instrs VPCMPGTQYrm)>;
  839. //=== Floating Point XMM and YMM Instructions ===//
  840. //-- Move instructions --//
  841. // VPERM2F128 / VPERM2I128.
  842. def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rr,
  843. VPERM2I128rr)>;
  844. def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rm,
  845. VPERM2I128rm)>;
  846. def Zn2WriteBROADCAST : SchedWriteRes<[Zn2AGU, Zn2FPU13]> {
  847. let NumMicroOps = 2;
  848. let Latency = 8;
  849. }
  850. // VBROADCASTF128 / VBROADCASTI128.
  851. def : InstRW<[Zn2WriteBROADCAST], (instrs VBROADCASTF128,
  852. VBROADCASTI128)>;
  853. // EXTRACTPS.
  854. // r32,x,i.
  855. def Zn2WriteEXTRACTPSr : SchedWriteRes<[Zn2FPU12, Zn2FPU2]> {
  856. let Latency = 2;
  857. let NumMicroOps = 2;
  858. let ResourceCycles = [1, 2];
  859. }
  860. def : InstRW<[Zn2WriteEXTRACTPSr], (instregex "(V?)EXTRACTPSrr")>;
  861. def Zn2WriteEXTRACTPSm : SchedWriteRes<[Zn2AGU,Zn2FPU12, Zn2FPU2]> {
  862. let Latency = 5;
  863. let NumMicroOps = 2;
  864. let ResourceCycles = [5, 1, 2];
  865. }
  866. // m32,x,i.
  867. def : InstRW<[Zn2WriteEXTRACTPSm], (instregex "(V?)EXTRACTPSmr")>;
  868. // VEXTRACTF128 / VEXTRACTI128.
  869. // x,y,i.
  870. def : InstRW<[Zn2WriteFPU013], (instrs VEXTRACTF128rr,
  871. VEXTRACTI128rr)>;
  872. // m128,y,i.
  873. def : InstRW<[Zn2WriteFPU013m], (instrs VEXTRACTF128mr,
  874. VEXTRACTI128mr)>;
  875. def Zn2WriteVINSERT128r: SchedWriteRes<[Zn2FPU013]> {
  876. let Latency = 2;
  877. // let ResourceCycles = [2];
  878. }
  879. def Zn2WriteVINSERT128Ld: SchedWriteRes<[Zn2AGU,Zn2FPU013]> {
  880. let Latency = 9;
  881. let NumMicroOps = 2;
  882. }
  883. // VINSERTF128 / VINSERTI128.
  884. // y,y,x,i.
  885. def : InstRW<[Zn2WriteVINSERT128r], (instrs VINSERTF128rr,
  886. VINSERTI128rr)>;
  887. def : InstRW<[Zn2WriteVINSERT128Ld], (instrs VINSERTF128rm,
  888. VINSERTI128rm)>;
  889. // VGATHER.
  890. def : InstRW<[WriteMicrocoded], (instregex "VGATHER(Q|D)(PD|PS)(Y?)rm")>;
  891. //-- Conversion instructions --//
  892. def Zn2WriteCVTPD2PSr: SchedWriteRes<[Zn2FPU3]> {
  893. let Latency = 3;
  894. }
  895. def Zn2WriteCVTPD2PSYr: SchedWriteRes<[Zn2FPU3]> {
  896. let Latency = 3;
  897. }
  898. // CVTPD2PS.
  899. // x,x.
  900. def : SchedAlias<WriteCvtPD2PS, Zn2WriteCVTPD2PSr>;
  901. // y,y.
  902. def : SchedAlias<WriteCvtPD2PSY, Zn2WriteCVTPD2PSYr>;
  903. // z,z.
  904. defm : X86WriteResUnsupported<WriteCvtPD2PSZ>;
  905. def Zn2WriteCVTPD2PSLd: SchedWriteRes<[Zn2AGU,Zn2FPU3]> {
  906. let Latency = 10;
  907. }
  908. // x,m128.
  909. def : SchedAlias<WriteCvtPD2PSLd, Zn2WriteCVTPD2PSLd>;
  910. // x,m256.
  911. def Zn2WriteCVTPD2PSYLd : SchedWriteRes<[Zn2AGU, Zn2FPU3]> {
  912. let Latency = 10;
  913. }
  914. def : SchedAlias<WriteCvtPD2PSYLd, Zn2WriteCVTPD2PSYLd>;
  915. // z,m512
  916. defm : X86WriteResUnsupported<WriteCvtPD2PSZLd>;
  917. // CVTSD2SS.
  918. // x,x.
  919. // Same as WriteCVTPD2PSr
  920. def : SchedAlias<WriteCvtSD2SS, Zn2WriteCVTPD2PSr>;
  921. // x,m64.
  922. def : SchedAlias<WriteCvtSD2SSLd, Zn2WriteCVTPD2PSLd>;
  923. // CVTPS2PD.
  924. // x,x.
  925. def Zn2WriteCVTPS2PDr : SchedWriteRes<[Zn2FPU3]> {
  926. let Latency = 3;
  927. }
  928. def : SchedAlias<WriteCvtPS2PD, Zn2WriteCVTPS2PDr>;
  929. // x,m64.
  930. // y,m128.
  931. def Zn2WriteCVTPS2PDLd : SchedWriteRes<[Zn2AGU, Zn2FPU3]> {
  932. let Latency = 10;
  933. let NumMicroOps = 2;
  934. }
  935. def : SchedAlias<WriteCvtPS2PDLd, Zn2WriteCVTPS2PDLd>;
  936. def : SchedAlias<WriteCvtPS2PDYLd, Zn2WriteCVTPS2PDLd>;
  937. defm : X86WriteResUnsupported<WriteCvtPS2PDZLd>;
  938. // y,x.
  939. def Zn2WriteVCVTPS2PDY : SchedWriteRes<[Zn2FPU3]> {
  940. let Latency = 3;
  941. }
  942. def : SchedAlias<WriteCvtPS2PDY, Zn2WriteVCVTPS2PDY>;
  943. defm : X86WriteResUnsupported<WriteCvtPS2PDZ>;
  944. // CVTSS2SD.
  945. // x,x.
  946. def Zn2WriteCVTSS2SDr : SchedWriteRes<[Zn2FPU3]> {
  947. let Latency = 3;
  948. }
  949. def : SchedAlias<WriteCvtSS2SD, Zn2WriteCVTSS2SDr>;
  950. // x,m32.
  951. def Zn2WriteCVTSS2SDLd : SchedWriteRes<[Zn2AGU, Zn2FPU3]> {
  952. let Latency = 10;
  953. let NumMicroOps = 2;
  954. let ResourceCycles = [1, 2];
  955. }
  956. def : SchedAlias<WriteCvtSS2SDLd, Zn2WriteCVTSS2SDLd>;
  957. def Zn2WriteCVTDQ2PDr: SchedWriteRes<[Zn2FPU12,Zn2FPU3]> {
  958. let Latency = 3;
  959. }
  960. // CVTDQ2PD.
  961. // x,x.
  962. def : InstRW<[Zn2WriteCVTDQ2PDr], (instregex "(V)?CVTDQ2P(D|S)rr")>;
  963. // Same as xmm
  964. // y,x.
  965. def : InstRW<[Zn2WriteCVTDQ2PDr], (instrs VCVTDQ2PDYrr)>;
  966. def : InstRW<[Zn2WriteCVTDQ2PDr], (instrs VCVTDQ2PSYrr)>;
  967. def Zn2WriteCVTPD2DQr: SchedWriteRes<[Zn2FPU12, Zn2FPU3]> {
  968. let Latency = 3;
  969. }
  970. // CVT(T)P(D|S)2DQ.
  971. // x,x.
  972. def : InstRW<[Zn2WriteCVTPD2DQr], (instregex "(V?)CVT(T?)P(D|S)2DQrr")>;
  973. def Zn2WriteCVTPD2DQLd: SchedWriteRes<[Zn2AGU,Zn2FPU12,Zn2FPU3]> {
  974. let Latency = 10;
  975. let NumMicroOps = 2;
  976. }
  977. // x,m128.
  978. def : InstRW<[Zn2WriteCVTPD2DQLd], (instregex "(V?)CVT(T?)PD2DQrm")>;
  979. // same as xmm handling
  980. // x,y.
  981. def : InstRW<[Zn2WriteCVTPD2DQr], (instregex "VCVT(T?)PD2DQYrr")>;
  982. // x,m256.
  983. def : InstRW<[Zn2WriteCVTPD2DQLd], (instregex "VCVT(T?)PD2DQYrm")>;
  984. def Zn2WriteCVTPS2PIr: SchedWriteRes<[Zn2FPU3]> {
  985. let Latency = 4;
  986. }
  987. // CVT(T)PS2PI.
  988. // mm,x.
  989. def : InstRW<[Zn2WriteCVTPS2PIr], (instregex "MMX_CVT(T?)PS2PIrr")>;
  990. // CVTPI2PD.
  991. // x,mm.
  992. def : InstRW<[Zn2WriteCVTPS2PDr], (instrs MMX_CVTPI2PDrr)>;
  993. // CVT(T)PD2PI.
  994. // mm,x.
  995. def : InstRW<[Zn2WriteCVTPS2PIr], (instregex "MMX_CVT(T?)PD2PIrr")>;
  996. def Zn2WriteCVSTSI2SSr: SchedWriteRes<[Zn2FPU3]> {
  997. let Latency = 3;
  998. }
  999. // same as CVTPD2DQr
  1000. // CVT(T)SS2SI.
  1001. // r32,x.
  1002. def : InstRW<[Zn2WriteCVTPD2DQr], (instregex "(V?)CVT(T?)SS2SI(64)?rr")>;
  1003. // same as CVTPD2DQm
  1004. // r32,m32.
  1005. def : InstRW<[Zn2WriteCVTPD2DQLd], (instregex "(V?)CVT(T?)SS2SI(64)?rm")>;
  1006. def Zn2WriteCVSTSI2SDr: SchedWriteRes<[Zn2FPU013, Zn2FPU3]> {
  1007. let Latency = 3;
  1008. }
  1009. // CVTSI2SD.
  1010. // x,r32/64.
  1011. def : InstRW<[Zn2WriteCVSTSI2SDr], (instregex "(V?)CVTSI(64)?2SDrr")>;
  1012. def Zn2WriteCVSTSI2SIr: SchedWriteRes<[Zn2FPU3, Zn2FPU2]> {
  1013. let Latency = 4;
  1014. }
  1015. def Zn2WriteCVSTSI2SILd: SchedWriteRes<[Zn2AGU, Zn2FPU3, Zn2FPU2]> {
  1016. let Latency = 11;
  1017. }
  1018. // CVTSD2SI.
  1019. // r32/64
  1020. def : InstRW<[Zn2WriteCVSTSI2SIr], (instregex "(V?)CVT(T?)SD2SI(64)?rr")>;
  1021. // r32,m32.
  1022. def : InstRW<[Zn2WriteCVSTSI2SILd], (instregex "(V?)CVT(T?)SD2SI(64)?rm")>;
  1023. // VCVTPS2PH.
  1024. // x,v,i.
  1025. def : SchedAlias<WriteCvtPS2PH, Zn2WriteMicrocoded>;
  1026. def : SchedAlias<WriteCvtPS2PHY, Zn2WriteMicrocoded>;
  1027. defm : X86WriteResUnsupported<WriteCvtPS2PHZ>;
  1028. // m,v,i.
  1029. def : SchedAlias<WriteCvtPS2PHSt, Zn2WriteMicrocoded>;
  1030. def : SchedAlias<WriteCvtPS2PHYSt, Zn2WriteMicrocoded>;
  1031. defm : X86WriteResUnsupported<WriteCvtPS2PHZSt>;
  1032. // VCVTPH2PS.
  1033. // v,x.
  1034. def : SchedAlias<WriteCvtPH2PS, Zn2WriteMicrocoded>;
  1035. def : SchedAlias<WriteCvtPH2PSY, Zn2WriteMicrocoded>;
  1036. defm : X86WriteResUnsupported<WriteCvtPH2PSZ>;
  1037. // v,m.
  1038. def : SchedAlias<WriteCvtPH2PSLd, Zn2WriteMicrocoded>;
  1039. def : SchedAlias<WriteCvtPH2PSYLd, Zn2WriteMicrocoded>;
  1040. defm : X86WriteResUnsupported<WriteCvtPH2PSZLd>;
  1041. //-- SSE4A instructions --//
  1042. // EXTRQ
  1043. def Zn2WriteEXTRQ: SchedWriteRes<[Zn2FPU12, Zn2FPU2]> {
  1044. let Latency = 3;
  1045. }
  1046. def : InstRW<[Zn2WriteEXTRQ], (instregex "EXTRQ")>;
  1047. // INSERTQ
  1048. def Zn2WriteINSERTQ: SchedWriteRes<[Zn2FPU03,Zn2FPU1]> {
  1049. let Latency = 4;
  1050. }
  1051. def : InstRW<[Zn2WriteINSERTQ], (instregex "INSERTQ")>;
  1052. //-- SHA instructions --//
  1053. // SHA256MSG2
  1054. def : InstRW<[WriteMicrocoded], (instregex "SHA256MSG2(Y?)r(r|m)")>;
  1055. // SHA1MSG1, SHA256MSG1
  1056. // x,x.
  1057. def Zn2WriteSHA1MSG1r : SchedWriteRes<[Zn2FPU12]> {
  1058. let Latency = 2;
  1059. }
  1060. def : InstRW<[Zn2WriteSHA1MSG1r], (instregex "SHA(1|256)MSG1rr")>;
  1061. // x,m.
  1062. def Zn2WriteSHA1MSG1Ld : SchedWriteRes<[Zn2AGU, Zn2FPU12]> {
  1063. let Latency = 9;
  1064. }
  1065. def : InstRW<[Zn2WriteSHA1MSG1Ld], (instregex "SHA(1|256)MSG1rm")>;
  1066. // SHA1MSG2
  1067. // x,x.
  1068. def Zn2WriteSHA1MSG2r : SchedWriteRes<[Zn2FPU12]> ;
  1069. def : InstRW<[Zn2WriteSHA1MSG2r], (instrs SHA1MSG2rr)>;
  1070. // x,m.
  1071. def Zn2WriteSHA1MSG2Ld : SchedWriteRes<[Zn2AGU, Zn2FPU12]> {
  1072. let Latency = 8;
  1073. }
  1074. def : InstRW<[Zn2WriteSHA1MSG2Ld], (instrs SHA1MSG2rm)>;
  1075. // SHA1NEXTE
  1076. // x,x.
  1077. def Zn2WriteSHA1NEXTEr : SchedWriteRes<[Zn2FPU1]> ;
  1078. def : InstRW<[Zn2WriteSHA1NEXTEr], (instrs SHA1NEXTErr)>;
  1079. // x,m.
  1080. def Zn2WriteSHA1NEXTELd : SchedWriteRes<[Zn2AGU, Zn2FPU1]> {
  1081. let Latency = 8;
  1082. }
  1083. def : InstRW<[Zn2WriteSHA1NEXTELd], (instrs SHA1NEXTErm)>;
  1084. // SHA1RNDS4
  1085. // x,x.
  1086. def Zn2WriteSHA1RNDS4r : SchedWriteRes<[Zn2FPU1]> {
  1087. let Latency = 6;
  1088. }
  1089. def : InstRW<[Zn2WriteSHA1RNDS4r], (instrs SHA1RNDS4rri)>;
  1090. // x,m.
  1091. def Zn2WriteSHA1RNDS4Ld : SchedWriteRes<[Zn2AGU, Zn2FPU1]> {
  1092. let Latency = 13;
  1093. }
  1094. def : InstRW<[Zn2WriteSHA1RNDS4Ld], (instrs SHA1RNDS4rmi)>;
  1095. // SHA256RNDS2
  1096. // x,x.
  1097. def Zn2WriteSHA256RNDS2r : SchedWriteRes<[Zn2FPU1]> {
  1098. let Latency = 4;
  1099. }
  1100. def : InstRW<[Zn2WriteSHA256RNDS2r], (instrs SHA256RNDS2rr)>;
  1101. // x,m.
  1102. def Zn2WriteSHA256RNDS2Ld : SchedWriteRes<[Zn2AGU, Zn2FPU1]> {
  1103. let Latency = 11;
  1104. }
  1105. def : InstRW<[Zn2WriteSHA256RNDS2Ld], (instrs SHA256RNDS2rm)>;
  1106. //-- Arithmetic instructions --//
  1107. // DPPS.
  1108. // x,x,i / v,v,v,i.
  1109. defm : Zn2WriteResPair<WriteDPPS, [], 15>;
  1110. def : SchedAlias<WriteDPPSY, Zn2WriteMicrocoded>;
  1111. // x,m,i / v,v,m,i.
  1112. def : SchedAlias<WriteDPPSYLd,Zn2WriteMicrocoded>;
  1113. // DPPD.
  1114. // x,x,i.
  1115. def : SchedAlias<WriteDPPD, Zn2WriteMicrocoded>;
  1116. // x,m,i.
  1117. def : SchedAlias<WriteDPPDLd, Zn2WriteMicrocoded>;
  1118. //-- Other instructions --//
  1119. // VZEROUPPER.
  1120. def : InstRW<[WriteALU], (instrs VZEROUPPER)>;
  1121. // VZEROALL.
  1122. def : InstRW<[WriteMicrocoded], (instrs VZEROALL)>;
  1123. ///////////////////////////////////////////////////////////////////////////////
  1124. // Dependency breaking instructions.
  1125. ///////////////////////////////////////////////////////////////////////////////
  1126. def : IsZeroIdiomFunction<[
  1127. // GPR Zero-idioms.
  1128. DepBreakingClass<[
  1129. SUB32rr, SUB64rr,
  1130. XOR32rr, XOR64rr
  1131. ], ZeroIdiomPredicate>,
  1132. // MMX Zero-idioms.
  1133. DepBreakingClass<[
  1134. MMX_PXORrr, MMX_PANDNrr, MMX_PSUBBrr,
  1135. MMX_PSUBDrr, MMX_PSUBQrr, MMX_PSUBWrr,
  1136. MMX_PSUBSBrr, MMX_PSUBSWrr, MMX_PSUBUSBrr, MMX_PSUBUSWrr,
  1137. MMX_PCMPGTBrr, MMX_PCMPGTDrr, MMX_PCMPGTWrr
  1138. ], ZeroIdiomPredicate>,
  1139. // SSE Zero-idioms.
  1140. DepBreakingClass<[
  1141. // fp variants.
  1142. XORPSrr, XORPDrr, ANDNPSrr, ANDNPDrr,
  1143. // int variants.
  1144. PXORrr, PANDNrr,
  1145. PSUBBrr, PSUBWrr, PSUBDrr, PSUBQrr,
  1146. PCMPGTBrr, PCMPGTDrr, PCMPGTQrr, PCMPGTWrr
  1147. ], ZeroIdiomPredicate>,
  1148. // AVX XMM Zero-idioms.
  1149. DepBreakingClass<[
  1150. // fp variants.
  1151. VXORPSrr, VXORPDrr, VANDNPSrr, VANDNPDrr,
  1152. // int variants.
  1153. VPXORrr, VPANDNrr,
  1154. VPSUBBrr, VPSUBWrr, VPSUBDrr, VPSUBQrr,
  1155. VPCMPGTBrr, VPCMPGTWrr, VPCMPGTDrr, VPCMPGTQrr
  1156. ], ZeroIdiomPredicate>,
  1157. // AVX YMM Zero-idioms.
  1158. DepBreakingClass<[
  1159. // fp variants
  1160. VXORPSYrr, VXORPDYrr, VANDNPSYrr, VANDNPDYrr,
  1161. // int variants
  1162. VPXORYrr, VPANDNYrr,
  1163. VPSUBBYrr, VPSUBWYrr, VPSUBDYrr, VPSUBQYrr,
  1164. VPCMPGTBYrr, VPCMPGTWYrr, VPCMPGTDYrr, VPCMPGTQYrr
  1165. ], ZeroIdiomPredicate>
  1166. ]>;
  1167. def : IsDepBreakingFunction<[
  1168. // GPR
  1169. DepBreakingClass<[ SBB32rr, SBB64rr ], ZeroIdiomPredicate>,
  1170. DepBreakingClass<[ CMP32rr, CMP64rr ], CheckSameRegOperand<0, 1> >,
  1171. // MMX
  1172. DepBreakingClass<[
  1173. MMX_PCMPEQBrr, MMX_PCMPEQWrr, MMX_PCMPEQDrr
  1174. ], ZeroIdiomPredicate>,
  1175. // SSE
  1176. DepBreakingClass<[
  1177. PCMPEQBrr, PCMPEQWrr, PCMPEQDrr, PCMPEQQrr
  1178. ], ZeroIdiomPredicate>,
  1179. // AVX XMM
  1180. DepBreakingClass<[
  1181. VPCMPEQBrr, VPCMPEQWrr, VPCMPEQDrr, VPCMPEQQrr
  1182. ], ZeroIdiomPredicate>,
  1183. // AVX YMM
  1184. DepBreakingClass<[
  1185. VPCMPEQBYrr, VPCMPEQWYrr, VPCMPEQDYrr, VPCMPEQQYrr
  1186. ], ZeroIdiomPredicate>,
  1187. ]>;
  1188. } // SchedModel