AArch64SchedCyclone.td 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. //=- AArch64SchedCyclone.td - Cyclone Scheduling Definitions -*- 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 AArch64 Cyclone to support
  10. // instruction scheduling and other instruction cost heuristics.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. def CycloneModel : SchedMachineModel {
  14. let IssueWidth = 6; // 6 micro-ops are dispatched per cycle.
  15. let MicroOpBufferSize = 192; // Based on the reorder buffer.
  16. let LoadLatency = 4; // Optimistic load latency.
  17. let MispredictPenalty = 16; // 14-19 cycles are typical.
  18. let CompleteModel = 1;
  19. list<Predicate> UnsupportedFeatures = !listconcat(SVEUnsupported.F,
  20. PAUnsupported.F,
  21. SMEUnsupported.F,
  22. [HasMTE]);
  23. }
  24. //===----------------------------------------------------------------------===//
  25. // Define each kind of processor resource and number available on Cyclone.
  26. // 4 integer pipes
  27. def CyUnitI : ProcResource<4> {
  28. let BufferSize = 48;
  29. }
  30. // 2 branch units: I[0..1]
  31. def CyUnitB : ProcResource<2> {
  32. let Super = CyUnitI;
  33. let BufferSize = 24;
  34. }
  35. // 1 indirect-branch unit: I[0]
  36. def CyUnitBR : ProcResource<1> {
  37. let Super = CyUnitB;
  38. }
  39. // 2 shifter pipes: I[2..3]
  40. // When an instruction consumes a CyUnitIS, it also consumes a CyUnitI
  41. def CyUnitIS : ProcResource<2> {
  42. let Super = CyUnitI;
  43. let BufferSize = 24;
  44. }
  45. // 1 mul pipe: I[0]
  46. def CyUnitIM : ProcResource<1> {
  47. let Super = CyUnitBR;
  48. let BufferSize = 32;
  49. }
  50. // 1 div pipe: I[1]
  51. def CyUnitID : ProcResource<1> {
  52. let Super = CyUnitB;
  53. let BufferSize = 16;
  54. }
  55. // 1 integer division unit. This is driven by the ID pipe, but only
  56. // consumes the pipe for one cycle at issue and another cycle at writeback.
  57. def CyUnitIntDiv : ProcResource<1>;
  58. // 2 ld/st pipes.
  59. def CyUnitLS : ProcResource<2> {
  60. let BufferSize = 28;
  61. }
  62. // 3 fp/vector pipes.
  63. def CyUnitV : ProcResource<3> {
  64. let BufferSize = 48;
  65. }
  66. // 2 fp/vector arithmetic and multiply pipes: V[0-1]
  67. def CyUnitVM : ProcResource<2> {
  68. let Super = CyUnitV;
  69. let BufferSize = 32;
  70. }
  71. // 1 fp/vector division/sqrt pipe: V[2]
  72. def CyUnitVD : ProcResource<1> {
  73. let Super = CyUnitV;
  74. let BufferSize = 16;
  75. }
  76. // 1 fp compare pipe: V[0]
  77. def CyUnitVC : ProcResource<1> {
  78. let Super = CyUnitVM;
  79. let BufferSize = 16;
  80. }
  81. // 2 fp division/square-root units. These are driven by the VD pipe,
  82. // but only consume the pipe for one cycle at issue and a cycle at writeback.
  83. def CyUnitFloatDiv : ProcResource<2>;
  84. //===----------------------------------------------------------------------===//
  85. // Define scheduler read/write resources and latency on Cyclone.
  86. // This mirrors sections 7.7-7.9 of the Tuning Guide v1.0.1.
  87. let SchedModel = CycloneModel in {
  88. //---
  89. // 7.8.1. Moves
  90. //---
  91. // A single nop micro-op (uX).
  92. def WriteX : SchedWriteRes<[]> { let Latency = 0; }
  93. // Move zero is a register rename (to machine register zero).
  94. // The move is replaced by a single nop micro-op.
  95. // MOVZ Rd, #0
  96. // AND Rd, Rzr, #imm
  97. def WriteZPred : SchedPredicate<[{TII->isGPRZero(*MI)}]>;
  98. def WriteImmZ : SchedWriteVariant<[
  99. SchedVar<WriteZPred, [WriteX]>,
  100. SchedVar<NoSchedPred, [WriteImm]>]>;
  101. def : InstRW<[WriteImmZ], (instrs MOVZWi,MOVZXi,ANDWri,ANDXri)>;
  102. // Move GPR is a register rename and single nop micro-op.
  103. // ORR Xd, XZR, Xm
  104. // ADD Xd, Xn, #0
  105. def WriteIMovPred : SchedPredicate<[{TII->isGPRCopy(*MI)}]>;
  106. def WriteVMovPred : SchedPredicate<[{TII->isFPRCopy(*MI)}]>;
  107. def WriteMov : SchedWriteVariant<[
  108. SchedVar<WriteIMovPred, [WriteX]>,
  109. SchedVar<WriteVMovPred, [WriteX]>,
  110. SchedVar<NoSchedPred, [WriteI]>]>;
  111. def : InstRW<[WriteMov], (instrs COPY,ORRXrr,ADDXrr)>;
  112. // Move non-zero immediate is an integer ALU op.
  113. // MOVN,MOVZ,MOVK
  114. def : WriteRes<WriteImm, [CyUnitI]>;
  115. //---
  116. // 7.8.2-7.8.5. Arithmetic and Logical, Comparison, Conditional,
  117. // Shifts and Bitfield Operations
  118. //---
  119. // ADR,ADRP
  120. // ADD(S)ri,SUB(S)ri,AND(S)ri,EORri,ORRri
  121. // ADD(S)rr,SUB(S)rr,AND(S)rr,BIC(S)rr,EONrr,EORrr,ORNrr,ORRrr
  122. // ADC(S),SBC(S)
  123. // Aliases: CMN, CMP, TST
  124. //
  125. // Conditional operations.
  126. // CCMNi,CCMPi,CCMNr,CCMPr,
  127. // CSEL,CSINC,CSINV,CSNEG
  128. //
  129. // Bit counting and reversal operations.
  130. // CLS,CLZ,RBIT,REV,REV16,REV32
  131. def : WriteRes<WriteI, [CyUnitI]>;
  132. // ADD with shifted register operand is a single micro-op that
  133. // consumes a shift pipeline for two cycles.
  134. // ADD(S)rs,SUB(S)rs,AND(S)rs,BIC(S)rs,EONrs,EORrs,ORNrs,ORRrs
  135. // EXAMPLE: ADDrs Xn, Xm LSL #imm
  136. def : WriteRes<WriteISReg, [CyUnitIS]> {
  137. let Latency = 2;
  138. let ResourceCycles = [2];
  139. }
  140. // ADD with extended register operand is the same as shifted reg operand.
  141. // ADD(S)re,SUB(S)re
  142. // EXAMPLE: ADDXre Xn, Xm, UXTB #1
  143. def : WriteRes<WriteIEReg, [CyUnitIS]> {
  144. let Latency = 2;
  145. let ResourceCycles = [2];
  146. }
  147. // Variable shift and bitfield operations.
  148. // ASRV,LSLV,LSRV,RORV,BFM,SBFM,UBFM
  149. def : WriteRes<WriteIS, [CyUnitIS]>;
  150. // EXTR Shifts a pair of registers and requires two micro-ops.
  151. // The second micro-op is delayed, as modeled by ReadExtrHi.
  152. // EXTR Xn, Xm, #imm
  153. def : WriteRes<WriteExtr, [CyUnitIS, CyUnitIS]> {
  154. let Latency = 2;
  155. let NumMicroOps = 2;
  156. }
  157. // EXTR's first register read is delayed by one cycle, effectively
  158. // shortening its writer's latency.
  159. // EXTR Xn, Xm, #imm
  160. def : ReadAdvance<ReadExtrHi, 1>;
  161. //---
  162. // 7.8.6. Multiplies
  163. //---
  164. // MUL/MNEG are aliases for MADD/MSUB.
  165. // MADDW,MSUBW,SMADDL,SMSUBL,UMADDL,UMSUBL
  166. def : WriteRes<WriteIM32, [CyUnitIM]> {
  167. let Latency = 4;
  168. }
  169. // MADDX,MSUBX,SMULH,UMULH
  170. def : WriteRes<WriteIM64, [CyUnitIM]> {
  171. let Latency = 5;
  172. }
  173. //---
  174. // 7.8.7. Divide
  175. //---
  176. // 32-bit divide takes 7-13 cycles. 10 cycles covers a 20-bit quotient.
  177. // The ID pipe is consumed for 2 cycles: issue and writeback.
  178. // SDIVW,UDIVW
  179. def : WriteRes<WriteID32, [CyUnitID, CyUnitIntDiv]> {
  180. let Latency = 10;
  181. let ResourceCycles = [2, 10];
  182. }
  183. // 64-bit divide takes 7-21 cycles. 13 cycles covers a 32-bit quotient.
  184. // The ID pipe is consumed for 2 cycles: issue and writeback.
  185. // SDIVX,UDIVX
  186. def : WriteRes<WriteID64, [CyUnitID, CyUnitIntDiv]> {
  187. let Latency = 13;
  188. let ResourceCycles = [2, 13];
  189. }
  190. //---
  191. // 7.8.8,7.8.10. Load/Store, single element
  192. //---
  193. // Integer loads take 4 cycles and use one LS unit for one cycle.
  194. def : WriteRes<WriteLD, [CyUnitLS]> {
  195. let Latency = 4;
  196. }
  197. // Store-load forwarding is 4 cycles.
  198. //
  199. // Note: The store-exclusive sequence incorporates this
  200. // latency. However, general heuristics should not model the
  201. // dependence between a store and subsequent may-alias load because
  202. // hardware speculation works.
  203. def : WriteRes<WriteST, [CyUnitLS]> {
  204. let Latency = 4;
  205. }
  206. // Load from base address plus an optionally scaled register offset.
  207. // Rt latency is latency WriteIS + WriteLD.
  208. // EXAMPLE: LDR Xn, Xm [, lsl 3]
  209. def CyWriteLDIdx : SchedWriteVariant<[
  210. SchedVar<ScaledIdxPred, [WriteIS, WriteLD]>, // Load from scaled register.
  211. SchedVar<NoSchedPred, [WriteLD]>]>; // Load from register offset.
  212. def : SchedAlias<WriteLDIdx, CyWriteLDIdx>; // Map AArch64->Cyclone type.
  213. // EXAMPLE: STR Xn, Xm [, lsl 3]
  214. def CyWriteSTIdx : SchedWriteVariant<[
  215. SchedVar<ScaledIdxPred, [WriteIS, WriteST]>, // Store to scaled register.
  216. SchedVar<NoSchedPred, [WriteST]>]>; // Store to register offset.
  217. def : SchedAlias<WriteSTIdx, CyWriteSTIdx>; // Map AArch64->Cyclone type.
  218. // Read the (unshifted) base register Xn in the second micro-op one cycle later.
  219. // EXAMPLE: LDR Xn, Xm [, lsl 3]
  220. def ReadBaseRS : SchedReadAdvance<1>;
  221. def CyReadAdrBase : SchedReadVariant<[
  222. SchedVar<ScaledIdxPred, [ReadBaseRS]>, // Read base reg after shifting offset.
  223. SchedVar<NoSchedPred, [ReadDefault]>]>; // Read base reg with no shift.
  224. def : SchedAlias<ReadAdrBase, CyReadAdrBase>; // Map AArch64->Cyclone type.
  225. def : ReadAdvance<ReadST, 0>;
  226. //---
  227. // 7.8.9,7.8.11. Load/Store, paired
  228. //---
  229. // Address pre/post increment is a simple ALU op with one cycle latency.
  230. def : WriteRes<WriteAdr, [CyUnitI]>;
  231. // LDP high register write is fused with the load, but a nop micro-op remains.
  232. def : WriteRes<WriteLDHi, []> {
  233. let Latency = 4;
  234. }
  235. // STP is a vector op and store, except for QQ, which is just two stores.
  236. def : SchedAlias<WriteSTP, WriteVSTShuffle>;
  237. def : InstRW<[WriteST, WriteST], (instrs STPQi)>;
  238. //---
  239. // 7.8.13. Branches
  240. //---
  241. // Branches take a single micro-op.
  242. // The misprediction penalty is defined as a SchedMachineModel property.
  243. def : WriteRes<WriteBr, [CyUnitB]> {let Latency = 0;}
  244. def : WriteRes<WriteBrReg, [CyUnitBR]> {let Latency = 0;}
  245. //---
  246. // 7.8.14. Never-issued Instructions, Barrier and Hint Operations
  247. //---
  248. // NOP,SEV,SEVL,WFE,WFI,YIELD
  249. def : WriteRes<WriteHint, []> {let Latency = 0;}
  250. // ISB
  251. def : InstRW<[WriteI], (instrs ISB)>;
  252. // SLREX,DMB,DSB
  253. def : WriteRes<WriteBarrier, [CyUnitLS]>;
  254. // System instructions get an invalid latency because the latency of
  255. // other operations across them is meaningless.
  256. def : WriteRes<WriteSys, []> {let Latency = -1;}
  257. //===----------------------------------------------------------------------===//
  258. // 7.9 Vector Unit Instructions
  259. // Simple vector operations take 2 cycles.
  260. def : WriteRes<WriteVd, [CyUnitV]> {let Latency = 2;}
  261. def : WriteRes<WriteVq, [CyUnitV]> {let Latency = 2;}
  262. // Define some longer latency vector op types for Cyclone.
  263. def CyWriteV3 : SchedWriteRes<[CyUnitV]> {let Latency = 3;}
  264. def CyWriteV4 : SchedWriteRes<[CyUnitV]> {let Latency = 4;}
  265. def CyWriteV5 : SchedWriteRes<[CyUnitV]> {let Latency = 5;}
  266. def CyWriteV6 : SchedWriteRes<[CyUnitV]> {let Latency = 6;}
  267. // Simple floating-point operations take 2 cycles.
  268. def : WriteRes<WriteF, [CyUnitV]> {let Latency = 2;}
  269. //---
  270. // 7.9.1 Vector Moves
  271. //---
  272. // TODO: Add Cyclone-specific zero-cycle zeros. LLVM currently
  273. // generates expensive int-float conversion instead:
  274. // FMOVDi Dd, #0.0
  275. // FMOVv2f64ns Vd.2d, #0.0
  276. // FMOVSi,FMOVDi
  277. def : WriteRes<WriteFImm, [CyUnitV]> {let Latency = 2;}
  278. // MOVI,MVNI are WriteV
  279. // FMOVv2f32ns,FMOVv2f64ns,FMOVv4f32ns are WriteV
  280. // Move FPR is a register rename and single nop micro-op.
  281. // ORR.16b Vd,Vn,Vn
  282. // COPY is handled above in the WriteMov Variant.
  283. def WriteVMov : SchedWriteVariant<[
  284. SchedVar<WriteVMovPred, [WriteX]>,
  285. SchedVar<NoSchedPred, [WriteVq]>]>;
  286. def : InstRW<[WriteVMov], (instrs ORRv16i8)>;
  287. // FMOVSr,FMOVDr are WriteF.
  288. // MOV V,V is a WriteV.
  289. // CPY D,V[x] is a WriteV
  290. // INS V[x],V[y] is a WriteV.
  291. // FMOVWSr,FMOVXDr,FMOVXDHighr
  292. def : WriteRes<WriteFCopy, [CyUnitLS]> {
  293. let Latency = 5;
  294. }
  295. // FMOVSWr,FMOVDXr
  296. def : InstRW<[WriteLD], (instrs FMOVSWr,FMOVDXr,FMOVDXHighr)>;
  297. // INS V[x],R
  298. def CyWriteCopyToFPR : WriteSequence<[WriteVLD, WriteVq]>;
  299. def : InstRW<[CyWriteCopyToFPR], (instregex "INSv")>;
  300. // SMOV,UMOV R,V[x]
  301. def CyWriteCopyToGPR : WriteSequence<[WriteLD, WriteI]>;
  302. def : InstRW<[CyWriteCopyToGPR], (instregex "SMOVv","UMOVv")>;
  303. // DUP V,R
  304. def : InstRW<[CyWriteCopyToFPR], (instregex "DUPv")>;
  305. // DUP V,V[x] is a WriteV.
  306. //---
  307. // 7.9.2 Integer Arithmetic, Logical, and Comparisons
  308. //---
  309. // BIC,ORR V,#imm are WriteV
  310. def : InstRW<[CyWriteV3], (instregex "ABSv")>;
  311. // MVN,NEG,NOT are WriteV
  312. def : InstRW<[CyWriteV3], (instregex "SQABSv","SQNEGv")>;
  313. // ADDP is a WriteV.
  314. def CyWriteVADDLP : SchedWriteRes<[CyUnitV]> {let Latency = 2;}
  315. def : InstRW<[CyWriteVADDLP], (instregex "SADDLPv","UADDLPv")>;
  316. def : InstRW<[CyWriteV3],
  317. (instregex "ADDVv","SMAXVv","UMAXVv","SMINVv","UMINVv")>;
  318. def : InstRW<[CyWriteV3], (instregex "SADDLV","UADDLV")>;
  319. // ADD,SUB are WriteV
  320. // Forward declare.
  321. def CyWriteVABD : SchedWriteRes<[CyUnitV]> {let Latency = 3;}
  322. // Add/Diff and accumulate uses the vector multiply unit.
  323. def CyWriteVAccum : SchedWriteRes<[CyUnitVM]> {let Latency = 3;}
  324. def CyReadVAccum : SchedReadAdvance<1,
  325. [CyWriteVAccum, CyWriteVADDLP, CyWriteVABD]>;
  326. def : InstRW<[CyWriteVAccum, CyReadVAccum],
  327. (instregex "SADALP","UADALP")>;
  328. def : InstRW<[CyWriteVAccum, CyReadVAccum],
  329. (instregex "SABAv","UABAv","SABALv","UABALv")>;
  330. def : InstRW<[CyWriteV3], (instregex "SQADDv","SQSUBv","UQADDv","UQSUBv")>;
  331. def : InstRW<[CyWriteV3], (instregex "SUQADDv","USQADDv")>;
  332. def : InstRW<[CyWriteV4], (instregex "ADDHNv","RADDHNv", "RSUBHNv", "SUBHNv")>;
  333. // WriteV includes:
  334. // AND,BIC,CMTST,EOR,ORN,ORR
  335. // ADDP
  336. // SHADD,SHSUB,SRHADD,UHADD,UHSUB,URHADD
  337. // SADDL,SSUBL,UADDL,USUBL
  338. // SADDW,SSUBW,UADDW,USUBW
  339. def : InstRW<[CyWriteV3], (instregex "CMEQv","CMGEv","CMGTv",
  340. "CMLEv","CMLTv",
  341. "CMHIv","CMHSv")>;
  342. def : InstRW<[CyWriteV3], (instregex "SMAXv","SMINv","UMAXv","UMINv",
  343. "SMAXPv","SMINPv","UMAXPv","UMINPv")>;
  344. def : InstRW<[CyWriteVABD], (instregex "SABDv","UABDv",
  345. "SABDLv","UABDLv")>;
  346. //---
  347. // 7.9.3 Floating Point Arithmetic and Comparisons
  348. //---
  349. // FABS,FNEG are WriteF
  350. def : InstRW<[CyWriteV4], (instrs FADDPv2i32p)>;
  351. def : InstRW<[CyWriteV5], (instrs FADDPv2i64p)>;
  352. def : InstRW<[CyWriteV3], (instregex "FMAXPv2i","FMAXNMPv2i",
  353. "FMINPv2i","FMINNMPv2i")>;
  354. def : InstRW<[CyWriteV4], (instregex "FMAXVv","FMAXNMVv","FMINVv","FMINNMVv")>;
  355. def : InstRW<[CyWriteV4], (instrs FADDSrr,FADDv2f32,FADDv4f32,
  356. FSUBSrr,FSUBv2f32,FSUBv4f32,
  357. FADDPv2f32,FADDPv4f32,
  358. FABD32,FABDv2f32,FABDv4f32)>;
  359. def : InstRW<[CyWriteV5], (instrs FADDDrr,FADDv2f64,
  360. FSUBDrr,FSUBv2f64,
  361. FADDPv2f64,
  362. FABD64,FABDv2f64)>;
  363. def : InstRW<[CyWriteV3], (instregex "FCMEQ","FCMGT","FCMLE","FCMLT")>;
  364. def : InstRW<[CyWriteV3], (instregex "FACGE","FACGT",
  365. "FMAXS","FMAXD","FMAXv",
  366. "FMINS","FMIND","FMINv",
  367. "FMAXNMS","FMAXNMD","FMAXNMv",
  368. "FMINNMS","FMINNMD","FMINNMv",
  369. "FMAXPv2f","FMAXPv4f",
  370. "FMINPv2f","FMINPv4f",
  371. "FMAXNMPv2f","FMAXNMPv4f",
  372. "FMINNMPv2f","FMINNMPv4f")>;
  373. // FCMP,FCMPE,FCCMP,FCCMPE
  374. def : WriteRes<WriteFCmp, [CyUnitVC]> {let Latency = 4;}
  375. // FCSEL is a WriteF.
  376. //---
  377. // 7.9.4 Shifts and Bitfield Operations
  378. //---
  379. // SHL is a WriteV
  380. def CyWriteVSHR : SchedWriteRes<[CyUnitV]> {let Latency = 2;}
  381. def : InstRW<[CyWriteVSHR], (instregex "SSHRv","USHRv")>;
  382. def CyWriteVSRSHR : SchedWriteRes<[CyUnitV]> {let Latency = 3;}
  383. def : InstRW<[CyWriteVSRSHR], (instregex "SRSHRv","URSHRv")>;
  384. // Shift and accumulate uses the vector multiply unit.
  385. def CyWriteVShiftAcc : SchedWriteRes<[CyUnitVM]> {let Latency = 3;}
  386. def CyReadVShiftAcc : SchedReadAdvance<1,
  387. [CyWriteVShiftAcc, CyWriteVSHR, CyWriteVSRSHR]>;
  388. def : InstRW<[CyWriteVShiftAcc, CyReadVShiftAcc],
  389. (instregex "SRSRAv","SSRAv","URSRAv","USRAv")>;
  390. // SSHL,USHL are WriteV.
  391. def : InstRW<[CyWriteV3], (instregex "SRSHLv","URSHLv")>;
  392. // SQSHL,SQSHLU,UQSHL are WriteV.
  393. def : InstRW<[CyWriteV3], (instregex "SQRSHLv","UQRSHLv")>;
  394. // WriteV includes:
  395. // SHLL,SSHLL,USHLL
  396. // SLI,SRI
  397. // BIF,BIT,BSL,BSP
  398. // EXT
  399. // CLS,CLZ,CNT,RBIT,REV16,REV32,REV64,XTN
  400. // XTN2
  401. def : InstRW<[CyWriteV4],
  402. (instregex "RSHRNv","SHRNv",
  403. "SQRSHRNv","SQRSHRUNv","SQSHRNv","SQSHRUNv",
  404. "UQRSHRNv","UQSHRNv","SQXTNv","SQXTUNv","UQXTNv")>;
  405. //---
  406. // 7.9.5 Multiplication
  407. //---
  408. def CyWriteVMul : SchedWriteRes<[CyUnitVM]> { let Latency = 4;}
  409. def : InstRW<[CyWriteVMul], (instregex "MULv","SMULLv","UMULLv",
  410. "SQDMULLv","SQDMULHv","SQRDMULHv")>;
  411. // FMUL,FMULX,FNMUL default to WriteFMul.
  412. def : WriteRes<WriteFMul, [CyUnitVM]> { let Latency = 4;}
  413. def CyWriteV64Mul : SchedWriteRes<[CyUnitVM]> { let Latency = 5;}
  414. def : InstRW<[CyWriteV64Mul], (instrs FMULDrr,FMULv2f64,FMULv2i64_indexed,
  415. FNMULDrr,FMULX64,FMULXv2f64,FMULXv2i64_indexed)>;
  416. def CyReadVMulAcc : SchedReadAdvance<1, [CyWriteVMul, CyWriteV64Mul]>;
  417. def : InstRW<[CyWriteVMul, CyReadVMulAcc],
  418. (instregex "MLA","MLS","SMLAL","SMLSL","UMLAL","UMLSL",
  419. "SQDMLAL","SQDMLSL")>;
  420. def CyWriteSMul : SchedWriteRes<[CyUnitVM]> { let Latency = 8;}
  421. def CyWriteDMul : SchedWriteRes<[CyUnitVM]> { let Latency = 10;}
  422. def CyReadSMul : SchedReadAdvance<4, [CyWriteSMul]>;
  423. def CyReadDMul : SchedReadAdvance<5, [CyWriteDMul]>;
  424. def : InstRW<[CyWriteSMul, CyReadSMul],
  425. (instrs FMADDSrrr,FMSUBSrrr,FNMADDSrrr,FNMSUBSrrr,
  426. FMLAv2f32,FMLAv4f32,
  427. FMLAv1i32_indexed,FMLAv1i64_indexed,FMLAv2i32_indexed)>;
  428. def : InstRW<[CyWriteDMul, CyReadDMul],
  429. (instrs FMADDDrrr,FMSUBDrrr,FNMADDDrrr,FNMSUBDrrr,
  430. FMLAv2f64,FMLAv2i64_indexed,
  431. FMLSv2f64,FMLSv2i64_indexed)>;
  432. def CyWritePMUL : SchedWriteRes<[CyUnitVD]> { let Latency = 3; }
  433. def : InstRW<[CyWritePMUL], (instregex "PMULv", "PMULLv")>;
  434. //---
  435. // 7.9.6 Divide and Square Root
  436. //---
  437. // FDIV,FSQRT
  438. // TODO: Add 64-bit variant with 19 cycle latency.
  439. // TODO: Specialize FSQRT for longer latency.
  440. def : WriteRes<WriteFDiv, [CyUnitVD, CyUnitFloatDiv]> {
  441. let Latency = 17;
  442. let ResourceCycles = [2, 17];
  443. }
  444. def : InstRW<[CyWriteV4], (instregex "FRECPEv","FRECPXv","URECPEv","URSQRTEv")>;
  445. def WriteFRSQRTE : SchedWriteRes<[CyUnitVM]> { let Latency = 4; }
  446. def : InstRW<[WriteFRSQRTE], (instregex "FRSQRTEv")>;
  447. def WriteFRECPS : SchedWriteRes<[CyUnitVM]> { let Latency = 8; }
  448. def WriteFRSQRTS : SchedWriteRes<[CyUnitVM]> { let Latency = 10; }
  449. def : InstRW<[WriteFRECPS], (instregex "FRECPSv")>;
  450. def : InstRW<[WriteFRSQRTS], (instregex "FRSQRTSv")>;
  451. //---
  452. // 7.9.7 Integer-FP Conversions
  453. //---
  454. // FCVT lengthen f16/s32
  455. def : InstRW<[WriteVq], (instrs FCVTSHr,FCVTDHr,FCVTDSr)>;
  456. // FCVT,FCVTN,FCVTXN
  457. // SCVTF,UCVTF V,V
  458. // FRINT(AIMNPXZ) V,V
  459. def : WriteRes<WriteFCvt, [CyUnitV]> {let Latency = 4;}
  460. // SCVT/UCVT S/D, Rd = VLD5+V4: 9 cycles.
  461. def CyWriteCvtToFPR : WriteSequence<[WriteVLD, CyWriteV4]>;
  462. def : InstRW<[CyWriteCopyToFPR], (instregex "FCVT[AMNPZ][SU][SU][WX][SD]r")>;
  463. // FCVT Rd, S/D = V6+LD4: 10 cycles
  464. def CyWriteCvtToGPR : WriteSequence<[CyWriteV6, WriteLD]>;
  465. def : InstRW<[CyWriteCvtToGPR], (instregex "[SU]CVTF[SU][WX][SD]r")>;
  466. // FCVTL is a WriteV
  467. //---
  468. // 7.9.8-7.9.10 Cryptography, Data Transposition, Table Lookup
  469. //---
  470. def CyWriteCrypto2 : SchedWriteRes<[CyUnitVD]> {let Latency = 2;}
  471. def : InstRW<[CyWriteCrypto2], (instrs AESIMCrr, AESMCrr, SHA1Hrr,
  472. AESDrr, AESErr, SHA1SU1rr, SHA256SU0rr,
  473. SHA1SU0rrr)>;
  474. def CyWriteCrypto3 : SchedWriteRes<[CyUnitVD]> {let Latency = 3;}
  475. def : InstRW<[CyWriteCrypto3], (instrs SHA256SU1rrr)>;
  476. def CyWriteCrypto6 : SchedWriteRes<[CyUnitVD]> {let Latency = 6;}
  477. def : InstRW<[CyWriteCrypto6], (instrs SHA1Crrr, SHA1Mrrr, SHA1Prrr,
  478. SHA256Hrrr,SHA256H2rrr)>;
  479. // TRN,UZP,ZUP are WriteV.
  480. // TBL,TBX are WriteV.
  481. //---
  482. // 7.9.11-7.9.14 Load/Store, single element and paired
  483. //---
  484. // Loading into the vector unit takes 5 cycles vs 4 for integer loads.
  485. def : WriteRes<WriteVLD, [CyUnitLS]> {
  486. let Latency = 5;
  487. }
  488. // Store-load forwarding is 4 cycles.
  489. def : WriteRes<WriteVST, [CyUnitLS]> {
  490. let Latency = 4;
  491. }
  492. // WriteVLDPair/VSTPair sequences are expanded by the target description.
  493. //---
  494. // 7.9.15 Load, element operations
  495. //---
  496. // Only the first WriteVLD and WriteAdr for writeback matches def operands.
  497. // Subsequent WriteVLDs consume resources. Since all loaded values have the
  498. // same latency, this is acceptable.
  499. // Vd is read 5 cycles after issuing the vector load.
  500. def : ReadAdvance<ReadVLD, 5>;
  501. def : InstRW<[WriteVLD],
  502. (instregex "LD1Onev(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  503. def : InstRW<[WriteVLD, WriteAdr],
  504. (instregex "LD1Onev(8b|4h|2s|1d|16b|8h|4s|2d)_POST")>;
  505. // Register writes from the load's high half are fused micro-ops.
  506. def : InstRW<[WriteVLD],
  507. (instregex "LD1Twov(8b|4h|2s|1d)$")>;
  508. def : InstRW<[WriteVLD, WriteAdr],
  509. (instregex "LD1Twov(8b|4h|2s|1d)_POST")>;
  510. def : InstRW<[WriteVLD, WriteVLD],
  511. (instregex "LD1Twov(16b|8h|4s|2d)$")>;
  512. def : InstRW<[WriteVLD, WriteAdr, WriteVLD],
  513. (instregex "LD1Twov(16b|8h|4s|2d)_POST")>;
  514. def : InstRW<[WriteVLD, WriteVLD],
  515. (instregex "LD1Threev(8b|4h|2s|1d)$")>;
  516. def : InstRW<[WriteVLD, WriteAdr, WriteVLD],
  517. (instregex "LD1Threev(8b|4h|2s|1d)_POST")>;
  518. def : InstRW<[WriteVLD, WriteVLD, WriteVLD],
  519. (instregex "LD1Threev(16b|8h|4s|2d)$")>;
  520. def : InstRW<[WriteVLD, WriteAdr, WriteVLD, WriteVLD],
  521. (instregex "LD1Threev(16b|8h|4s|2d)_POST")>;
  522. def : InstRW<[WriteVLD, WriteVLD],
  523. (instregex "LD1Fourv(8b|4h|2s|1d)$")>;
  524. def : InstRW<[WriteVLD, WriteAdr, WriteVLD],
  525. (instregex "LD1Fourv(8b|4h|2s|1d)_POST")>;
  526. def : InstRW<[WriteVLD, WriteVLD, WriteVLD, WriteVLD],
  527. (instregex "LD1Fourv(16b|8h|4s|2d)$")>;
  528. def : InstRW<[WriteVLD, WriteAdr, WriteVLD, WriteVLD, WriteVLD],
  529. (instregex "LD1Fourv(16b|8h|4s|2d)_POST")>;
  530. def : InstRW<[WriteVLDShuffle, ReadVLD],
  531. (instregex "LD1i(8|16|32)$")>;
  532. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteAdr],
  533. (instregex "LD1i(8|16|32)_POST")>;
  534. def : InstRW<[WriteVLDShuffle, ReadVLD], (instrs LD1i64)>;
  535. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteAdr],(instrs LD1i64_POST)>;
  536. def : InstRW<[WriteVLDShuffle],
  537. (instregex "LD1Rv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  538. def : InstRW<[WriteVLDShuffle, WriteAdr],
  539. (instregex "LD1Rv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  540. def : InstRW<[WriteVLDShuffle, WriteVq],
  541. (instregex "LD2Twov(8b|4h|2s)$")>;
  542. def : InstRW<[WriteVLDShuffle, WriteAdr, WriteVq],
  543. (instregex "LD2Twov(8b|4h|2s)_POST$")>;
  544. def : InstRW<[WriteVLDShuffle, WriteVLDShuffle],
  545. (instregex "LD2Twov(16b|8h|4s|2d)$")>;
  546. def : InstRW<[WriteVLDShuffle, WriteAdr, WriteVLDShuffle],
  547. (instregex "LD2Twov(16b|8h|4s|2d)_POST")>;
  548. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteVq],
  549. (instregex "LD2i(8|16|32)$")>;
  550. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteAdr, WriteVq],
  551. (instregex "LD2i(8|16|32)_POST")>;
  552. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteVq],
  553. (instregex "LD2i64$")>;
  554. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteAdr, WriteVq],
  555. (instregex "LD2i64_POST")>;
  556. def : InstRW<[WriteVLDShuffle, WriteVq],
  557. (instregex "LD2Rv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  558. def : InstRW<[WriteVLDShuffle, WriteAdr, WriteVq],
  559. (instregex "LD2Rv(8b|4h|2s|1d|16b|8h|4s|2d)_POST")>;
  560. def : InstRW<[WriteVLDShuffle, WriteVLDShuffle, WriteVq],
  561. (instregex "LD3Threev(8b|4h|2s)$")>;
  562. def : InstRW<[WriteVLDShuffle, WriteAdr, WriteVLDShuffle, WriteVq],
  563. (instregex "LD3Threev(8b|4h|2s)_POST")>;
  564. def : InstRW<[WriteVLDShuffle, WriteVLDShuffle, WriteVLDShuffle],
  565. (instregex "LD3Threev(16b|8h|4s|2d)$")>;
  566. def : InstRW<[WriteVLDShuffle, WriteAdr, WriteVLDShuffle, WriteVLDShuffle],
  567. (instregex "LD3Threev(16b|8h|4s|2d)_POST")>;
  568. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteVq, WriteVq],
  569. (instregex "LD3i(8|16|32)$")>;
  570. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteAdr, WriteVq, WriteVq],
  571. (instregex "LD3i(8|16|32)_POST")>;
  572. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteVLDShuffle, WriteVq],
  573. (instregex "LD3i64$")>;
  574. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteAdr, WriteVLDShuffle, WriteVq],
  575. (instregex "LD3i64_POST")>;
  576. def : InstRW<[WriteVLDShuffle, WriteVq, WriteVq],
  577. (instregex "LD3Rv(8b|4h|2s|16b|8h|4s)$")>;
  578. def : InstRW<[WriteVLDShuffle, WriteAdr, WriteVq, WriteVq],
  579. (instregex "LD3Rv(8b|4h|2s|16b|8h|4s)_POST")>;
  580. def : InstRW<[WriteVLDShuffle, WriteVLDShuffle, WriteVq],
  581. (instrs LD3Rv1d,LD3Rv2d)>;
  582. def : InstRW<[WriteVLDShuffle, WriteAdr, WriteVLDShuffle, WriteVq],
  583. (instrs LD3Rv1d_POST,LD3Rv2d_POST)>;
  584. def : InstRW<[WriteVLDShuffle, WriteVLDShuffle, WriteVq, WriteVq],
  585. (instregex "LD4Fourv(8b|4h|2s)$")>;
  586. def : InstRW<[WriteVLDShuffle, WriteAdr, WriteVLDShuffle, WriteVq, WriteVq],
  587. (instregex "LD4Fourv(8b|4h|2s)_POST")>;
  588. def : InstRW<[WriteVLDPairShuffle, WriteVLDPairShuffle,
  589. WriteVLDPairShuffle, WriteVLDPairShuffle],
  590. (instregex "LD4Fourv(16b|8h|4s|2d)$")>;
  591. def : InstRW<[WriteVLDPairShuffle, WriteAdr, WriteVLDPairShuffle,
  592. WriteVLDPairShuffle, WriteVLDPairShuffle],
  593. (instregex "LD4Fourv(16b|8h|4s|2d)_POST")>;
  594. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteVq, WriteVq, WriteVq],
  595. (instregex "LD4i(8|16|32)$")>;
  596. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteAdr, WriteVq, WriteVq, WriteVq],
  597. (instregex "LD4i(8|16|32)_POST")>;
  598. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteVLDShuffle, WriteVq, WriteVq],
  599. (instrs LD4i64)>;
  600. def : InstRW<[WriteVLDShuffle, ReadVLD, WriteAdr, WriteVLDShuffle, WriteVq],
  601. (instrs LD4i64_POST)>;
  602. def : InstRW<[WriteVLDShuffle, WriteVq, WriteVq, WriteVq],
  603. (instregex "LD4Rv(8b|4h|2s|16b|8h|4s)$")>;
  604. def : InstRW<[WriteVLDShuffle, WriteAdr, WriteVq, WriteVq, WriteVq],
  605. (instregex "LD4Rv(8b|4h|2s|16b|8h|4s)_POST")>;
  606. def : InstRW<[WriteVLDShuffle, WriteVLDShuffle, WriteVq, WriteVq],
  607. (instrs LD4Rv1d,LD4Rv2d)>;
  608. def : InstRW<[WriteVLDShuffle, WriteAdr, WriteVLDShuffle, WriteVq, WriteVq],
  609. (instrs LD4Rv1d_POST,LD4Rv2d_POST)>;
  610. //---
  611. // 7.9.16 Store, element operations
  612. //---
  613. // Only the WriteAdr for writeback matches a def operands.
  614. // Subsequent WriteVLDs only consume resources.
  615. def : InstRW<[WriteVST],
  616. (instregex "ST1Onev(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  617. def : InstRW<[WriteAdr, WriteVST],
  618. (instregex "ST1Onev(8b|4h|2s|1d|16b|8h|4s|2d)_POST")>;
  619. def : InstRW<[WriteVSTShuffle],
  620. (instregex "ST1Twov(8b|4h|2s|1d)$")>;
  621. def : InstRW<[WriteAdr, WriteVSTShuffle],
  622. (instregex "ST1Twov(8b|4h|2s|1d)_POST")>;
  623. def : InstRW<[WriteVST, WriteVST],
  624. (instregex "ST1Twov(16b|8h|4s|2d)$")>;
  625. def : InstRW<[WriteAdr, WriteVST, WriteVST],
  626. (instregex "ST1Twov(16b|8h|4s|2d)_POST")>;
  627. def : InstRW<[WriteVSTShuffle, WriteVST],
  628. (instregex "ST1Threev(8b|4h|2s|1d)$")>;
  629. def : InstRW<[WriteAdr, WriteVSTShuffle, WriteVST],
  630. (instregex "ST1Threev(8b|4h|2s|1d)_POST")>;
  631. def : InstRW<[WriteVST, WriteVST, WriteVST],
  632. (instregex "ST1Threev(16b|8h|4s|2d)$")>;
  633. def : InstRW<[WriteAdr, WriteVST, WriteVST, WriteVST],
  634. (instregex "ST1Threev(16b|8h|4s|2d)_POST")>;
  635. def : InstRW<[WriteVSTShuffle, WriteVSTShuffle],
  636. (instregex "ST1Fourv(8b|4h|2s|1d)$")>;
  637. def : InstRW<[WriteAdr, WriteVSTShuffle, WriteVSTShuffle],
  638. (instregex "ST1Fourv(8b|4h|2s|1d)_POST")>;
  639. def : InstRW<[WriteVST, WriteVST, WriteVST, WriteVST],
  640. (instregex "ST1Fourv(16b|8h|4s|2d)$")>;
  641. def : InstRW<[WriteAdr, WriteVST, WriteVST, WriteVST, WriteVST],
  642. (instregex "ST1Fourv(16b|8h|4s|2d)_POST")>;
  643. def : InstRW<[WriteVSTShuffle], (instregex "ST1i(8|16|32)$")>;
  644. def : InstRW<[WriteAdr, WriteVSTShuffle], (instregex "ST1i(8|16|32)_POST")>;
  645. def : InstRW<[WriteVSTShuffle], (instrs ST1i64)>;
  646. def : InstRW<[WriteAdr, WriteVSTShuffle], (instrs ST1i64_POST)>;
  647. def : InstRW<[WriteVSTShuffle],
  648. (instregex "ST2Twov(8b|4h|2s)$")>;
  649. def : InstRW<[WriteAdr, WriteVSTShuffle],
  650. (instregex "ST2Twov(8b|4h|2s)_POST")>;
  651. def : InstRW<[WriteVSTShuffle, WriteVSTShuffle],
  652. (instregex "ST2Twov(16b|8h|4s|2d)$")>;
  653. def : InstRW<[WriteAdr, WriteVSTShuffle, WriteVSTShuffle],
  654. (instregex "ST2Twov(16b|8h|4s|2d)_POST")>;
  655. def : InstRW<[WriteVSTShuffle], (instregex "ST2i(8|16|32)$")>;
  656. def : InstRW<[WriteAdr, WriteVSTShuffle], (instregex "ST2i(8|16|32)_POST")>;
  657. def : InstRW<[WriteVSTShuffle], (instrs ST2i64)>;
  658. def : InstRW<[WriteAdr, WriteVSTShuffle], (instrs ST2i64_POST)>;
  659. def : InstRW<[WriteVSTShuffle, WriteVSTShuffle],
  660. (instregex "ST3Threev(8b|4h|2s)$")>;
  661. def : InstRW<[WriteAdr, WriteVSTShuffle, WriteVSTShuffle],
  662. (instregex "ST3Threev(8b|4h|2s)_POST")>;
  663. def : InstRW<[WriteVSTShuffle, WriteVSTShuffle, WriteVSTShuffle],
  664. (instregex "ST3Threev(16b|8h|4s|2d)$")>;
  665. def : InstRW<[WriteAdr, WriteVSTShuffle, WriteVSTShuffle, WriteVSTShuffle],
  666. (instregex "ST3Threev(16b|8h|4s|2d)_POST")>;
  667. def : InstRW<[WriteVSTShuffle], (instregex "ST3i(8|16|32)$")>;
  668. def : InstRW<[WriteAdr, WriteVSTShuffle], (instregex "ST3i(8|16|32)_POST")>;
  669. def :InstRW<[WriteVSTShuffle, WriteVSTShuffle], (instrs ST3i64)>;
  670. def :InstRW<[WriteAdr, WriteVSTShuffle, WriteVSTShuffle], (instrs ST3i64_POST)>;
  671. def : InstRW<[WriteVSTPairShuffle, WriteVSTPairShuffle],
  672. (instregex "ST4Fourv(8b|4h|2s|1d)$")>;
  673. def : InstRW<[WriteAdr, WriteVSTPairShuffle, WriteVSTPairShuffle],
  674. (instregex "ST4Fourv(8b|4h|2s|1d)_POST")>;
  675. def : InstRW<[WriteVSTPairShuffle, WriteVSTPairShuffle,
  676. WriteVSTPairShuffle, WriteVSTPairShuffle],
  677. (instregex "ST4Fourv(16b|8h|4s|2d)$")>;
  678. def : InstRW<[WriteAdr, WriteVSTPairShuffle, WriteVSTPairShuffle,
  679. WriteVSTPairShuffle, WriteVSTPairShuffle],
  680. (instregex "ST4Fourv(16b|8h|4s|2d)_POST")>;
  681. def : InstRW<[WriteVSTPairShuffle], (instregex "ST4i(8|16|32)$")>;
  682. def : InstRW<[WriteAdr, WriteVSTPairShuffle], (instregex "ST4i(8|16|32)_POST")>;
  683. def : InstRW<[WriteVSTShuffle, WriteVSTShuffle], (instrs ST4i64)>;
  684. def : InstRW<[WriteAdr, WriteVSTShuffle, WriteVSTShuffle],(instrs ST4i64_POST)>;
  685. // Atomic operations are not supported.
  686. def : WriteRes<WriteAtomic, []> { let Unsupported = 1; }
  687. //---
  688. // Unused SchedRead types
  689. //---
  690. def : ReadAdvance<ReadI, 0>;
  691. def : ReadAdvance<ReadISReg, 0>;
  692. def : ReadAdvance<ReadIEReg, 0>;
  693. def : ReadAdvance<ReadIM, 0>;
  694. def : ReadAdvance<ReadIMA, 0>;
  695. def : ReadAdvance<ReadID, 0>;
  696. } // SchedModel = CycloneModel