AArch64SchedCyclone.td 30 KB

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