AArch64SchedA53.td 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. //==- AArch64SchedA53.td - Cortex-A53 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 itinerary class data for the ARM Cortex A53 processors.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. // ===---------------------------------------------------------------------===//
  13. // The following definitions describe the simpler per-operand machine model.
  14. // This works with MachineScheduler. See MCSchedule.h for details.
  15. // Cortex-A53 machine model for scheduling and other instruction cost heuristics.
  16. def CortexA53Model : SchedMachineModel {
  17. let MicroOpBufferSize = 0; // Explicitly set to zero since A53 is in-order.
  18. let IssueWidth = 2; // 2 micro-ops are dispatched per cycle.
  19. let LoadLatency = 3; // Optimistic load latency assuming bypass.
  20. // This is overriden by OperandCycles if the
  21. // Itineraries are queried instead.
  22. let MispredictPenalty = 9; // Based on "Cortex-A53 Software Optimisation
  23. // Specification - Instruction Timings"
  24. // v 1.0 Spreadsheet
  25. let CompleteModel = 1;
  26. list<Predicate> UnsupportedFeatures = !listconcat(SVEUnsupported.F,
  27. PAUnsupported.F,
  28. SMEUnsupported.F,
  29. [HasMTE]);
  30. }
  31. //===----------------------------------------------------------------------===//
  32. // Define each kind of processor resource and number available.
  33. // Modeling each pipeline as a ProcResource using the BufferSize = 0 since
  34. // Cortex-A53 is in-order.
  35. def A53UnitALU : ProcResource<2> { let BufferSize = 0; } // Int ALU
  36. def A53UnitMAC : ProcResource<1> { let BufferSize = 0; } // Int MAC
  37. def A53UnitDiv : ProcResource<1> { let BufferSize = 0; } // Int Division
  38. def A53UnitLdSt : ProcResource<1> { let BufferSize = 0; } // Load/Store
  39. def A53UnitB : ProcResource<1> { let BufferSize = 0; } // Branch
  40. def A53UnitFPALU : ProcResource<1> { let BufferSize = 0; } // FP ALU
  41. def A53UnitFPMDS : ProcResource<1> { let BufferSize = 0; } // FP Mult/Div/Sqrt
  42. //===----------------------------------------------------------------------===//
  43. // Subtarget-specific SchedWrite types which both map the ProcResources and
  44. // set the latency.
  45. let SchedModel = CortexA53Model in {
  46. // ALU - Despite having a full latency of 4, most of the ALU instructions can
  47. // forward a cycle earlier and then two cycles earlier in the case of a
  48. // shift-only instruction. These latencies will be incorrect when the
  49. // result cannot be forwarded, but modeling isn't rocket surgery.
  50. def : WriteRes<WriteImm, [A53UnitALU]> { let Latency = 3; }
  51. def : WriteRes<WriteI, [A53UnitALU]> { let Latency = 3; }
  52. def : WriteRes<WriteISReg, [A53UnitALU]> { let Latency = 3; }
  53. def : WriteRes<WriteIEReg, [A53UnitALU]> { let Latency = 3; }
  54. def : WriteRes<WriteIS, [A53UnitALU]> { let Latency = 2; }
  55. def : WriteRes<WriteExtr, [A53UnitALU]> { let Latency = 3; }
  56. // MAC
  57. def : WriteRes<WriteIM32, [A53UnitMAC]> { let Latency = 4; }
  58. def : WriteRes<WriteIM64, [A53UnitMAC]> { let Latency = 4; }
  59. // Div
  60. def : WriteRes<WriteID32, [A53UnitDiv]> { let Latency = 4; }
  61. def : WriteRes<WriteID64, [A53UnitDiv]> { let Latency = 4; }
  62. // Load
  63. def : WriteRes<WriteLD, [A53UnitLdSt]> { let Latency = 4; }
  64. def : WriteRes<WriteLDIdx, [A53UnitLdSt]> { let Latency = 4; }
  65. def : WriteRes<WriteLDHi, [A53UnitLdSt]> { let Latency = 4; }
  66. // Vector Load - Vector loads take 1-5 cycles to issue. For the WriteVecLd
  67. // below, choosing the median of 3 which makes the latency 6.
  68. // May model this more carefully in the future. The remaining
  69. // A53WriteVLD# types represent the 1-5 cycle issues explicitly.
  70. def : WriteRes<WriteVLD, [A53UnitLdSt]> { let Latency = 6;
  71. let ResourceCycles = [3]; }
  72. def A53WriteVLD1 : SchedWriteRes<[A53UnitLdSt]> { let Latency = 4; }
  73. def A53WriteVLD2 : SchedWriteRes<[A53UnitLdSt]> { let Latency = 5;
  74. let ResourceCycles = [2]; }
  75. def A53WriteVLD3 : SchedWriteRes<[A53UnitLdSt]> { let Latency = 6;
  76. let ResourceCycles = [3]; }
  77. def A53WriteVLD4 : SchedWriteRes<[A53UnitLdSt]> { let Latency = 7;
  78. let ResourceCycles = [4]; }
  79. def A53WriteVLD5 : SchedWriteRes<[A53UnitLdSt]> { let Latency = 8;
  80. let ResourceCycles = [5]; }
  81. // Pre/Post Indexing - Performed as part of address generation which is already
  82. // accounted for in the WriteST* latencies below
  83. def : WriteRes<WriteAdr, []> { let Latency = 0; }
  84. // Store
  85. def : WriteRes<WriteST, [A53UnitLdSt]> { let Latency = 4; }
  86. def : WriteRes<WriteSTP, [A53UnitLdSt]> { let Latency = 4; }
  87. def : WriteRes<WriteSTIdx, [A53UnitLdSt]> { let Latency = 4; }
  88. def : WriteRes<WriteSTX, [A53UnitLdSt]> { let Latency = 4; }
  89. // Vector Store - Similar to vector loads, can take 1-3 cycles to issue.
  90. def : WriteRes<WriteVST, [A53UnitLdSt]> { let Latency = 5;
  91. let ResourceCycles = [2];}
  92. def A53WriteVST1 : SchedWriteRes<[A53UnitLdSt]> { let Latency = 4; }
  93. def A53WriteVST2 : SchedWriteRes<[A53UnitLdSt]> { let Latency = 5;
  94. let ResourceCycles = [2]; }
  95. def A53WriteVST3 : SchedWriteRes<[A53UnitLdSt]> { let Latency = 6;
  96. let ResourceCycles = [3]; }
  97. def : WriteRes<WriteAtomic, []> { let Unsupported = 1; }
  98. // Branch
  99. def : WriteRes<WriteBr, [A53UnitB]>;
  100. def : WriteRes<WriteBrReg, [A53UnitB]>;
  101. def : WriteRes<WriteSys, [A53UnitB]>;
  102. def : WriteRes<WriteBarrier, [A53UnitB]>;
  103. def : WriteRes<WriteHint, [A53UnitB]>;
  104. // FP ALU
  105. def : WriteRes<WriteF, [A53UnitFPALU]> { let Latency = 6; }
  106. def : WriteRes<WriteFCmp, [A53UnitFPALU]> { let Latency = 6; }
  107. def : WriteRes<WriteFCvt, [A53UnitFPALU]> { let Latency = 6; }
  108. def : WriteRes<WriteFCopy, [A53UnitFPALU]> { let Latency = 6; }
  109. def : WriteRes<WriteFImm, [A53UnitFPALU]> { let Latency = 6; }
  110. def : WriteRes<WriteVd, [A53UnitFPALU]> { let Latency = 6; }
  111. def : WriteRes<WriteVq, [A53UnitFPALU]> { let Latency = 6; }
  112. // FP Mul, Div, Sqrt
  113. def : WriteRes<WriteFMul, [A53UnitFPMDS]> { let Latency = 6; }
  114. def : WriteRes<WriteFDiv, [A53UnitFPMDS]> { let Latency = 33;
  115. let ResourceCycles = [29]; }
  116. def A53WriteFMAC : SchedWriteRes<[A53UnitFPMDS]> { let Latency = 10; }
  117. def A53WriteFDivSP : SchedWriteRes<[A53UnitFPMDS]> { let Latency = 18;
  118. let ResourceCycles = [14]; }
  119. def A53WriteFDivDP : SchedWriteRes<[A53UnitFPMDS]> { let Latency = 33;
  120. let ResourceCycles = [29]; }
  121. def A53WriteFSqrtSP : SchedWriteRes<[A53UnitFPMDS]> { let Latency = 17;
  122. let ResourceCycles = [13]; }
  123. def A53WriteFSqrtDP : SchedWriteRes<[A53UnitFPMDS]> { let Latency = 32;
  124. let ResourceCycles = [28]; }
  125. //===----------------------------------------------------------------------===//
  126. // Subtarget-specific SchedRead types.
  127. // No forwarding for these reads.
  128. def : ReadAdvance<ReadExtrHi, 0>;
  129. def : ReadAdvance<ReadAdrBase, 0>;
  130. def : ReadAdvance<ReadST, 0>;
  131. def : ReadAdvance<ReadVLD, 0>;
  132. // ALU - Most operands in the ALU pipes are not needed for two cycles. Shiftable
  133. // operands are needed one cycle later if and only if they are to be
  134. // shifted. Otherwise, they too are needed two cycles later. This same
  135. // ReadAdvance applies to Extended registers as well, even though there is
  136. // a separate SchedPredicate for them.
  137. def : ReadAdvance<ReadI, 2, [WriteImm,WriteI,
  138. WriteISReg, WriteIEReg,WriteIS,
  139. WriteID32,WriteID64,
  140. WriteIM32,WriteIM64]>;
  141. def A53ReadShifted : SchedReadAdvance<1, [WriteImm,WriteI,
  142. WriteISReg, WriteIEReg,WriteIS,
  143. WriteID32,WriteID64,
  144. WriteIM32,WriteIM64]>;
  145. def A53ReadNotShifted : SchedReadAdvance<2, [WriteImm,WriteI,
  146. WriteISReg, WriteIEReg,WriteIS,
  147. WriteID32,WriteID64,
  148. WriteIM32,WriteIM64]>;
  149. def A53ReadISReg : SchedReadVariant<[
  150. SchedVar<RegShiftedPred, [A53ReadShifted]>,
  151. SchedVar<NoSchedPred, [A53ReadNotShifted]>]>;
  152. def : SchedAlias<ReadISReg, A53ReadISReg>;
  153. def A53ReadIEReg : SchedReadVariant<[
  154. SchedVar<RegExtendedPred, [A53ReadShifted]>,
  155. SchedVar<NoSchedPred, [A53ReadNotShifted]>]>;
  156. def : SchedAlias<ReadIEReg, A53ReadIEReg>;
  157. // MAC - Operands are generally needed one cycle later in the MAC pipe.
  158. // Accumulator operands are needed two cycles later.
  159. def : ReadAdvance<ReadIM, 1, [WriteImm,WriteI,
  160. WriteISReg, WriteIEReg,WriteIS,
  161. WriteID32,WriteID64,
  162. WriteIM32,WriteIM64]>;
  163. def : ReadAdvance<ReadIMA, 2, [WriteImm,WriteI,
  164. WriteISReg, WriteIEReg,WriteIS,
  165. WriteID32,WriteID64,
  166. WriteIM32,WriteIM64]>;
  167. // Div
  168. def : ReadAdvance<ReadID, 1, [WriteImm,WriteI,
  169. WriteISReg, WriteIEReg,WriteIS,
  170. WriteID32,WriteID64,
  171. WriteIM32,WriteIM64]>;
  172. //===----------------------------------------------------------------------===//
  173. // Subtarget-specific InstRWs.
  174. //---
  175. // Miscellaneous
  176. //---
  177. def : InstRW<[WriteI], (instrs COPY)>;
  178. //---
  179. // Vector Loads
  180. //---
  181. def : InstRW<[A53WriteVLD1], (instregex "LD1i(8|16|32|64)$")>;
  182. def : InstRW<[A53WriteVLD1], (instregex "LD1Rv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  183. def : InstRW<[A53WriteVLD1], (instregex "LD1Onev(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  184. def : InstRW<[A53WriteVLD2], (instregex "LD1Twov(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  185. def : InstRW<[A53WriteVLD3], (instregex "LD1Threev(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  186. def : InstRW<[A53WriteVLD4], (instregex "LD1Fourv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  187. def : InstRW<[A53WriteVLD1, WriteAdr], (instregex "LD1i(8|16|32|64)_POST$")>;
  188. def : InstRW<[A53WriteVLD1, WriteAdr], (instregex "LD1Rv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  189. def : InstRW<[A53WriteVLD1, WriteAdr], (instregex "LD1Onev(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  190. def : InstRW<[A53WriteVLD2, WriteAdr], (instregex "LD1Twov(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  191. def : InstRW<[A53WriteVLD3, WriteAdr], (instregex "LD1Threev(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  192. def : InstRW<[A53WriteVLD4, WriteAdr], (instregex "LD1Fourv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  193. def : InstRW<[A53WriteVLD1], (instregex "LD2i(8|16|32|64)$")>;
  194. def : InstRW<[A53WriteVLD1], (instregex "LD2Rv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  195. def : InstRW<[A53WriteVLD2], (instregex "LD2Twov(8b|4h|2s)$")>;
  196. def : InstRW<[A53WriteVLD4], (instregex "LD2Twov(16b|8h|4s|2d)$")>;
  197. def : InstRW<[A53WriteVLD1, WriteAdr], (instregex "LD2i(8|16|32|64)_POST$")>;
  198. def : InstRW<[A53WriteVLD1, WriteAdr], (instregex "LD2Rv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  199. def : InstRW<[A53WriteVLD2, WriteAdr], (instregex "LD2Twov(8b|4h|2s)_POST$")>;
  200. def : InstRW<[A53WriteVLD4, WriteAdr], (instregex "LD2Twov(16b|8h|4s|2d)_POST$")>;
  201. def : InstRW<[A53WriteVLD2], (instregex "LD3i(8|16|32|64)$")>;
  202. def : InstRW<[A53WriteVLD2], (instregex "LD3Rv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  203. def : InstRW<[A53WriteVLD4], (instregex "LD3Threev(8b|4h|2s|1d|16b|8h|4s)$")>;
  204. def : InstRW<[A53WriteVLD3], (instregex "LD3Threev2d$")>;
  205. def : InstRW<[A53WriteVLD2, WriteAdr], (instregex "LD3i(8|16|32|64)_POST$")>;
  206. def : InstRW<[A53WriteVLD2, WriteAdr], (instregex "LD3Rv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  207. def : InstRW<[A53WriteVLD4, WriteAdr], (instregex "LD3Threev(8b|4h|2s|1d|16b|8h|4s)_POST$")>;
  208. def : InstRW<[A53WriteVLD3, WriteAdr], (instregex "LD3Threev2d_POST$")>;
  209. def : InstRW<[A53WriteVLD2], (instregex "LD4i(8|16|32|64)$")>;
  210. def : InstRW<[A53WriteVLD2], (instregex "LD4Rv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  211. def : InstRW<[A53WriteVLD5], (instregex "LD4Fourv(8b|4h|2s|1d|16b|8h|4s)$")>;
  212. def : InstRW<[A53WriteVLD4], (instregex "LD4Fourv(2d)$")>;
  213. def : InstRW<[A53WriteVLD2, WriteAdr], (instregex "LD4i(8|16|32|64)_POST$")>;
  214. def : InstRW<[A53WriteVLD2, WriteAdr], (instregex "LD4Rv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  215. def : InstRW<[A53WriteVLD5, WriteAdr], (instregex "LD4Fourv(8b|4h|2s|1d|16b|8h|4s)_POST$")>;
  216. def : InstRW<[A53WriteVLD4, WriteAdr], (instregex "LD4Fourv(2d)_POST$")>;
  217. //---
  218. // Vector Stores
  219. //---
  220. def : InstRW<[A53WriteVST1], (instregex "ST1i(8|16|32|64)$")>;
  221. def : InstRW<[A53WriteVST1], (instregex "ST1Onev(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  222. def : InstRW<[A53WriteVST1], (instregex "ST1Twov(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  223. def : InstRW<[A53WriteVST2], (instregex "ST1Threev(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  224. def : InstRW<[A53WriteVST2], (instregex "ST1Fourv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
  225. def : InstRW<[A53WriteVST1, WriteAdr], (instregex "ST1i(8|16|32|64)_POST$")>;
  226. def : InstRW<[A53WriteVST1, WriteAdr], (instregex "ST1Onev(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  227. def : InstRW<[A53WriteVST1, WriteAdr], (instregex "ST1Twov(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  228. def : InstRW<[A53WriteVST2, WriteAdr], (instregex "ST1Threev(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  229. def : InstRW<[A53WriteVST2, WriteAdr], (instregex "ST1Fourv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
  230. def : InstRW<[A53WriteVST1], (instregex "ST2i(8|16|32|64)$")>;
  231. def : InstRW<[A53WriteVST1], (instregex "ST2Twov(8b|4h|2s)$")>;
  232. def : InstRW<[A53WriteVST2], (instregex "ST2Twov(16b|8h|4s|2d)$")>;
  233. def : InstRW<[A53WriteVST1, WriteAdr], (instregex "ST2i(8|16|32|64)_POST$")>;
  234. def : InstRW<[A53WriteVST1, WriteAdr], (instregex "ST2Twov(8b|4h|2s)_POST$")>;
  235. def : InstRW<[A53WriteVST2, WriteAdr], (instregex "ST2Twov(16b|8h|4s|2d)_POST$")>;
  236. def : InstRW<[A53WriteVST2], (instregex "ST3i(8|16|32|64)$")>;
  237. def : InstRW<[A53WriteVST3], (instregex "ST3Threev(8b|4h|2s|1d|16b|8h|4s)$")>;
  238. def : InstRW<[A53WriteVST2], (instregex "ST3Threev(2d)$")>;
  239. def : InstRW<[A53WriteVST2, WriteAdr], (instregex "ST3i(8|16|32|64)_POST$")>;
  240. def : InstRW<[A53WriteVST3, WriteAdr], (instregex "ST3Threev(8b|4h|2s|1d|16b|8h|4s)_POST$")>;
  241. def : InstRW<[A53WriteVST2, WriteAdr], (instregex "ST3Threev(2d)_POST$")>;
  242. def : InstRW<[A53WriteVST2], (instregex "ST4i(8|16|32|64)$")>;
  243. def : InstRW<[A53WriteVST3], (instregex "ST4Fourv(8b|4h|2s|1d|16b|8h|4s)$")>;
  244. def : InstRW<[A53WriteVST2], (instregex "ST4Fourv(2d)$")>;
  245. def : InstRW<[A53WriteVST2, WriteAdr], (instregex "ST4i(8|16|32|64)_POST$")>;
  246. def : InstRW<[A53WriteVST3, WriteAdr], (instregex "ST4Fourv(8b|4h|2s|1d|16b|8h|4s)_POST$")>;
  247. def : InstRW<[A53WriteVST2, WriteAdr], (instregex "ST4Fourv(2d)_POST$")>;
  248. //---
  249. // Floating Point MAC, DIV, SQRT
  250. //---
  251. def : InstRW<[A53WriteFMAC], (instregex "^FN?M(ADD|SUB).*")>;
  252. def : InstRW<[A53WriteFMAC], (instregex "^FML(A|S).*")>;
  253. def : InstRW<[A53WriteFDivSP], (instrs FDIVSrr)>;
  254. def : InstRW<[A53WriteFDivDP], (instrs FDIVDrr)>;
  255. def : InstRW<[A53WriteFDivSP], (instregex "^FDIVv.*32$")>;
  256. def : InstRW<[A53WriteFDivDP], (instregex "^FDIVv.*64$")>;
  257. def : InstRW<[A53WriteFSqrtSP], (instregex "^.*SQRT.*32$")>;
  258. def : InstRW<[A53WriteFSqrtDP], (instregex "^.*SQRT.*64$")>;
  259. }