PPCScheduleP9.td 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. //===-- PPCScheduleP9.td - PPC P9 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 POWER9 processor.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. def P9Model : SchedMachineModel {
  13. // The maximum number of instructions to be issued at the same time.
  14. // While a value of 8 is technically correct since 8 instructions can be
  15. // fetched from the instruction cache. However, only 6 instructions may be
  16. // actually dispatched at a time.
  17. let IssueWidth = 8;
  18. // Load latency is 4 or 5 cycles depending on the load. This latency assumes
  19. // that we have a cache hit. For a cache miss the load latency will be more.
  20. // There are two instructions (lxvl, lxvll) that have a latency of 6 cycles.
  21. // However it is not worth bumping this value up to 6 when the vast majority
  22. // of instructions are 4 or 5 cycles.
  23. let LoadLatency = 5;
  24. // A total of 16 cycles to recover from a branch mispredict.
  25. let MispredictPenalty = 16;
  26. // Try to make sure we have at least 10 dispatch groups in a loop.
  27. // A dispatch group is 6 instructions.
  28. let LoopMicroOpBufferSize = 60;
  29. // As iops are dispatched to a slice, they are held in an independent slice
  30. // issue queue until all register sources and other dependencies have been
  31. // resolved and they can be issued. Each of four execution slices has an
  32. // 11-entry iop issue queue.
  33. let MicroOpBufferSize = 44;
  34. let CompleteModel = 1;
  35. // Do not support SPE (Signal Processing Engine), prefixed instructions on
  36. // Power 9, paired vector mem ops, MMA, PC relative mem ops, or instructions
  37. // introduced in ISA 3.1.
  38. let UnsupportedFeatures = [HasSPE, PrefixInstrs, PairedVectorMemops, MMA,
  39. PCRelativeMemops, IsISA3_1];
  40. }
  41. let SchedModel = P9Model in {
  42. // ***************** Processor Resources *****************
  43. // Dispatcher slots:
  44. // x0, x1, x2, and x3 are the dedicated slice dispatch ports, where each
  45. // corresponds to one of the four execution slices.
  46. def DISPx02 : ProcResource<2>;
  47. def DISPx13 : ProcResource<2>;
  48. // The xa and xb ports can be used to send an iop to either of the two slices
  49. // of the superslice, but are restricted to iops with only two primary sources.
  50. def DISPxab : ProcResource<2>;
  51. // b0 and b1 are dedicated dispatch ports into the branch slice.
  52. def DISPb01 : ProcResource<2>;
  53. // Any non BR dispatch ports
  54. def DISP_NBR
  55. : ProcResGroup<[ DISPx02, DISPx13, DISPxab]>;
  56. def DISP_SS : ProcResGroup<[ DISPx02, DISPx13]>;
  57. // Issue Ports
  58. // An instruction can go down one of two issue queues.
  59. // Address Generation (AGEN) mainly for loads and stores.
  60. // Execution (EXEC) for most other instructions.
  61. // Some instructions cannot be run on just any issue queue and may require an
  62. // Even or an Odd queue. The EXECE represents the even queues and the EXECO
  63. // represents the odd queues.
  64. def IP_AGEN : ProcResource<4>;
  65. def IP_EXEC : ProcResource<4>;
  66. def IP_EXECE : ProcResource<2> {
  67. //Even Exec Ports
  68. let Super = IP_EXEC;
  69. }
  70. def IP_EXECO : ProcResource<2> {
  71. //Odd Exec Ports
  72. let Super = IP_EXEC;
  73. }
  74. // Pipeline Groups
  75. // Four ALU (Fixed Point Arithmetic) units in total. Two even, two Odd.
  76. def ALU : ProcResource<4>;
  77. def ALUE : ProcResource<2> {
  78. //Even ALU pipelines
  79. let Super = ALU;
  80. }
  81. def ALUO : ProcResource<2> {
  82. //Odd ALU pipelines
  83. let Super = ALU;
  84. }
  85. // Two DIV (Fixed Point Divide) units.
  86. def DIV : ProcResource<2>;
  87. // Four DP (Floating Point) units in total. Two even, two Odd.
  88. def DP : ProcResource<4>;
  89. def DPE : ProcResource<2> {
  90. //Even DP pipelines
  91. let Super = DP;
  92. }
  93. def DPO : ProcResource<2> {
  94. //Odd DP pipelines
  95. let Super = DP;
  96. }
  97. // Four LS (Load or Store) units.
  98. def LS : ProcResource<4>;
  99. // Two PM (Permute) units.
  100. def PM : ProcResource<2>;
  101. // Only one DFU (Decimal Floating Point and Quad Precision) unit.
  102. def DFU : ProcResource<1>;
  103. // Only one Branch unit.
  104. def BR : ProcResource<1> {
  105. let BufferSize = 16;
  106. }
  107. // Only one CY (Crypto) unit.
  108. def CY : ProcResource<1>;
  109. // ***************** SchedWriteRes Definitions *****************
  110. // Dispatcher
  111. // Dispatch Rules: '-' or 'V'
  112. // Vector ('V') - vector iops (128-bit operand) take only one decode and
  113. // dispatch slot but are dispatched to both the even and odd slices of a
  114. // superslice.
  115. def DISP_1C : SchedWriteRes<[DISP_NBR]> {
  116. let NumMicroOps = 0;
  117. let Latency = 1;
  118. }
  119. // Dispatch Rules: 'E'
  120. // Even slice ('E')- certain operations must be sent only to an even slice.
  121. // Also consumes odd dispatch slice slot of the same superslice at dispatch
  122. def DISP_EVEN_1C : SchedWriteRes<[ DISPx02, DISPx13 ]> {
  123. let NumMicroOps = 0;
  124. let Latency = 1;
  125. }
  126. // Dispatch Rules: 'P'
  127. // Paired ('P') - certain cracked and expanded iops are paired such that they
  128. // must dispatch together to the same superslice.
  129. def DISP_PAIR_1C : SchedWriteRes<[ DISP_SS, DISP_SS]> {
  130. let NumMicroOps = 0;
  131. let Latency = 1;
  132. }
  133. // Tuple Restricted ('R') - certain iops preclude dispatching more than one
  134. // operation per slice for the super- slice to which they are dispatched
  135. def DISP_3SLOTS_1C : SchedWriteRes<[DISPx02, DISPx13, DISPxab]> {
  136. let NumMicroOps = 0;
  137. let Latency = 1;
  138. }
  139. // Each execution and branch slice can receive up to two iops per cycle
  140. def DISP_BR_1C : SchedWriteRes<[ DISPxab ]> {
  141. let NumMicroOps = 0;
  142. let Latency = 1;
  143. }
  144. // Issue Ports
  145. def IP_AGEN_1C : SchedWriteRes<[IP_AGEN]> {
  146. let NumMicroOps = 0;
  147. let Latency = 1;
  148. }
  149. def IP_EXEC_1C : SchedWriteRes<[IP_EXEC]> {
  150. let NumMicroOps = 0;
  151. let Latency = 1;
  152. }
  153. def IP_EXECE_1C : SchedWriteRes<[IP_EXECE]> {
  154. let NumMicroOps = 0;
  155. let Latency = 1;
  156. }
  157. def IP_EXECO_1C : SchedWriteRes<[IP_EXECO]> {
  158. let NumMicroOps = 0;
  159. let Latency = 1;
  160. }
  161. //Pipeline Groups
  162. // ALU Units
  163. // An ALU may take either 2 or 3 cycles to complete the operation.
  164. // However, the ALU unit is only ever busy for 1 cycle at a time and may
  165. // receive new instructions each cycle.
  166. def P9_ALU_2C : SchedWriteRes<[ALU]> {
  167. let Latency = 2;
  168. }
  169. def P9_ALUE_2C : SchedWriteRes<[ALUE]> {
  170. let Latency = 2;
  171. }
  172. def P9_ALUO_2C : SchedWriteRes<[ALUO]> {
  173. let Latency = 2;
  174. }
  175. def P9_ALU_3C : SchedWriteRes<[ALU]> {
  176. let Latency = 3;
  177. }
  178. def P9_ALUE_3C : SchedWriteRes<[ALUE]> {
  179. let Latency = 3;
  180. }
  181. def P9_ALUO_3C : SchedWriteRes<[ALUO]> {
  182. let Latency = 3;
  183. }
  184. // DIV Unit
  185. // A DIV unit may take from 5 to 40 cycles to complete.
  186. // Some DIV operations may keep the unit busy for up to 8 cycles.
  187. def P9_DIV_5C : SchedWriteRes<[DIV]> {
  188. let Latency = 5;
  189. }
  190. def P9_DIV_12C : SchedWriteRes<[DIV]> {
  191. let Latency = 12;
  192. }
  193. def P9_DIV_16C_8 : SchedWriteRes<[DIV]> {
  194. let ResourceCycles = [8];
  195. let Latency = 16;
  196. }
  197. def P9_DIV_24C_8 : SchedWriteRes<[DIV]> {
  198. let ResourceCycles = [8];
  199. let Latency = 24;
  200. }
  201. def P9_DIV_40C_8 : SchedWriteRes<[DIV]> {
  202. let ResourceCycles = [8];
  203. let Latency = 40;
  204. }
  205. // DP Unit
  206. // A DP unit may take from 2 to 36 cycles to complete.
  207. // Some DP operations keep the unit busy for up to 10 cycles.
  208. def P9_DP_5C : SchedWriteRes<[DP]> {
  209. let Latency = 5;
  210. }
  211. def P9_DP_7C : SchedWriteRes<[DP]> {
  212. let Latency = 7;
  213. }
  214. def P9_DPE_7C : SchedWriteRes<[DPE]> {
  215. let Latency = 7;
  216. }
  217. def P9_DPO_7C : SchedWriteRes<[DPO]> {
  218. let Latency = 7;
  219. }
  220. def P9_DP_22C_5 : SchedWriteRes<[DP]> {
  221. let ResourceCycles = [5];
  222. let Latency = 22;
  223. }
  224. def P9_DPO_24C_8 : SchedWriteRes<[DPO]> {
  225. let ResourceCycles = [8];
  226. let Latency = 24;
  227. }
  228. def P9_DPE_24C_8 : SchedWriteRes<[DPE]> {
  229. let ResourceCycles = [8];
  230. let Latency = 24;
  231. }
  232. def P9_DP_26C_5 : SchedWriteRes<[DP]> {
  233. let ResourceCycles = [5];
  234. let Latency = 22;
  235. }
  236. def P9_DPE_27C_10 : SchedWriteRes<[DP]> {
  237. let ResourceCycles = [10];
  238. let Latency = 27;
  239. }
  240. def P9_DPO_27C_10 : SchedWriteRes<[DP]> {
  241. let ResourceCycles = [10];
  242. let Latency = 27;
  243. }
  244. def P9_DP_33C_8 : SchedWriteRes<[DP]> {
  245. let ResourceCycles = [8];
  246. let Latency = 33;
  247. }
  248. def P9_DPE_33C_8 : SchedWriteRes<[DPE]> {
  249. let ResourceCycles = [8];
  250. let Latency = 33;
  251. }
  252. def P9_DPO_33C_8 : SchedWriteRes<[DPO]> {
  253. let ResourceCycles = [8];
  254. let Latency = 33;
  255. }
  256. def P9_DP_36C_10 : SchedWriteRes<[DP]> {
  257. let ResourceCycles = [10];
  258. let Latency = 36;
  259. }
  260. def P9_DPE_36C_10 : SchedWriteRes<[DP]> {
  261. let ResourceCycles = [10];
  262. let Latency = 36;
  263. }
  264. def P9_DPO_36C_10 : SchedWriteRes<[DP]> {
  265. let ResourceCycles = [10];
  266. let Latency = 36;
  267. }
  268. // PM Unit
  269. // Three cycle permute operations.
  270. def P9_PM_3C : SchedWriteRes<[PM]> {
  271. let Latency = 3;
  272. }
  273. // Load and Store Units
  274. // Loads can have 4, 5 or 6 cycles of latency.
  275. // Stores are listed as having a single cycle of latency. This is not
  276. // completely accurate since it takes more than 1 cycle to actually store
  277. // the value. However, since the store does not produce a result it can be
  278. // considered complete after one cycle.
  279. def P9_LS_1C : SchedWriteRes<[LS]> {
  280. let Latency = 1;
  281. }
  282. def P9_LS_4C : SchedWriteRes<[LS]> {
  283. let Latency = 4;
  284. }
  285. def P9_LS_5C : SchedWriteRes<[LS]> {
  286. let Latency = 5;
  287. }
  288. def P9_LS_6C : SchedWriteRes<[LS]> {
  289. let Latency = 6;
  290. }
  291. // DFU Unit
  292. // Some of the most expensive ops use the DFU.
  293. // Can take from 12 cycles to 76 cycles to obtain a result.
  294. // The unit may be busy for up to 62 cycles.
  295. def P9_DFU_12C : SchedWriteRes<[DFU]> {
  296. let Latency = 12;
  297. }
  298. def P9_DFU_23C : SchedWriteRes<[DFU]> {
  299. let Latency = 23;
  300. let ResourceCycles = [11];
  301. }
  302. def P9_DFU_24C : SchedWriteRes<[DFU]> {
  303. let Latency = 24;
  304. let ResourceCycles = [12];
  305. }
  306. def P9_DFU_37C : SchedWriteRes<[DFU]> {
  307. let Latency = 37;
  308. let ResourceCycles = [25];
  309. }
  310. def P9_DFU_58C : SchedWriteRes<[DFU]> {
  311. let Latency = 58;
  312. let ResourceCycles = [44];
  313. }
  314. def P9_DFU_76C : SchedWriteRes<[DFU]> {
  315. let Latency = 76;
  316. let ResourceCycles = [62];
  317. }
  318. // 2 or 5 cycle latencies for the branch unit.
  319. def P9_BR_2C : SchedWriteRes<[BR]> {
  320. let Latency = 2;
  321. }
  322. def P9_BR_5C : SchedWriteRes<[BR]> {
  323. let Latency = 5;
  324. }
  325. // 6 cycle latency for the crypto unit
  326. def P9_CY_6C : SchedWriteRes<[CY]> {
  327. let Latency = 6;
  328. }
  329. // ***************** WriteSeq Definitions *****************
  330. // These are combinations of the resources listed above.
  331. // The idea is that some cracked instructions cannot be done in parallel and
  332. // so the latencies for their resources must be added.
  333. def P9_LoadAndALUOp_6C : WriteSequence<[P9_LS_4C, P9_ALU_2C]>;
  334. def P9_LoadAndALUOp_7C : WriteSequence<[P9_LS_5C, P9_ALU_2C]>;
  335. def P9_LoadAndALU2Op_7C : WriteSequence<[P9_LS_4C, P9_ALU_3C]>;
  336. def P9_LoadAndALU2Op_8C : WriteSequence<[P9_LS_5C, P9_ALU_3C]>;
  337. def P9_LoadAndPMOp_8C : WriteSequence<[P9_LS_5C, P9_PM_3C]>;
  338. def P9_LoadAndLoadOp_8C : WriteSequence<[P9_LS_4C, P9_LS_4C]>;
  339. def P9_IntDivAndALUOp_18C_8 : WriteSequence<[P9_DIV_16C_8, P9_ALU_2C]>;
  340. def P9_IntDivAndALUOp_26C_8 : WriteSequence<[P9_DIV_24C_8, P9_ALU_2C]>;
  341. def P9_IntDivAndALUOp_42C_8 : WriteSequence<[P9_DIV_40C_8, P9_ALU_2C]>;
  342. def P9_StoreAndALUOp_3C : WriteSequence<[P9_LS_1C, P9_ALU_2C]>;
  343. def P9_ALUOpAndALUOp_4C : WriteSequence<[P9_ALU_2C, P9_ALU_2C]>;
  344. def P9_ALU2OpAndALU2Op_6C : WriteSequence<[P9_ALU_3C, P9_ALU_3C]>;
  345. def P9_ALUOpAndALUOpAndALUOp_6C :
  346. WriteSequence<[P9_ALU_2C, P9_ALU_2C, P9_ALU_2C]>;
  347. def P9_DPOpAndALUOp_7C : WriteSequence<[P9_DP_5C, P9_ALU_2C]>;
  348. def P9_DPOpAndALU2Op_10C : WriteSequence<[P9_DP_7C, P9_ALU_3C]>;
  349. def P9_DPOpAndALU2Op_25C_5 : WriteSequence<[P9_DP_22C_5, P9_ALU_3C]>;
  350. def P9_DPOpAndALU2Op_29C_5 : WriteSequence<[P9_DP_26C_5, P9_ALU_3C]>;
  351. def P9_DPOpAndALU2Op_36C_8 : WriteSequence<[P9_DP_33C_8, P9_ALU_3C]>;
  352. def P9_DPOpAndALU2Op_39C_10 : WriteSequence<[P9_DP_36C_10, P9_ALU_3C]>;
  353. def P9_BROpAndALUOp_7C : WriteSequence<[P9_BR_5C, P9_ALU_2C]>;
  354. // Include the resource requirements of individual instructions.
  355. include "P9InstrResources.td"
  356. }