]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AArch64/AArch64SchedThunderX.td
MFV r336950: 9290 device removal reduces redundancy of mirrors
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / AArch64 / AArch64SchedThunderX.td
1 //==- AArch64SchedThunderX.td - Cavium ThunderX T8X Scheduling Definitions -*- tablegen -*-=//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the itinerary class data for the ARM ThunderX T8X
11 // (T88, T81, T83) processors.
12 // Loosely based on Cortex-A53 which is somewhat similar.
13 //
14 //===----------------------------------------------------------------------===//
15
16 // ===---------------------------------------------------------------------===//
17 // The following definitions describe the simpler per-operand machine model.
18 // This works with MachineScheduler. See llvm/MC/MCSchedule.h for details.
19
20 // Cavium ThunderX T8X scheduling machine model.
21 def ThunderXT8XModel : SchedMachineModel {
22   let IssueWidth = 2;         // 2 micro-ops dispatched per cycle.
23   let MicroOpBufferSize = 0;  // ThunderX T88/T81/T83 are in-order.
24   let LoadLatency = 3;        // Optimistic load latency.
25   let MispredictPenalty = 8;  // Branch mispredict penalty.
26   let PostRAScheduler = 1;    // Use PostRA scheduler.
27   let CompleteModel = 1;
28
29   list<Predicate> UnsupportedFeatures = [HasSVE];
30 }
31
32 // Modeling each pipeline with BufferSize == 0 since T8X is in-order.
33 def THXT8XUnitALU    : ProcResource<2> { let BufferSize = 0; } // Int ALU
34 def THXT8XUnitMAC    : ProcResource<1> { let BufferSize = 0; } // Int MAC
35 def THXT8XUnitDiv    : ProcResource<1> { let BufferSize = 0; } // Int Division
36 def THXT8XUnitLdSt   : ProcResource<1> { let BufferSize = 0; } // Load/Store
37 def THXT8XUnitBr     : ProcResource<1> { let BufferSize = 0; } // Branch
38 def THXT8XUnitFPALU  : ProcResource<1> { let BufferSize = 0; } // FP ALU
39 def THXT8XUnitFPMDS  : ProcResource<1> { let BufferSize = 0; } // FP Mul/Div/Sqrt
40
41 //===----------------------------------------------------------------------===//
42 // Subtarget-specific SchedWrite types mapping the ProcResources and
43 // latencies.
44
45 let SchedModel = ThunderXT8XModel in {
46
47 // ALU
48 def : WriteRes<WriteImm, [THXT8XUnitALU]> { let Latency = 1; }
49 def : WriteRes<WriteI, [THXT8XUnitALU]> { let Latency = 1; }
50 def : WriteRes<WriteISReg, [THXT8XUnitALU]> { let Latency = 2; }
51 def : WriteRes<WriteIEReg, [THXT8XUnitALU]> { let Latency = 2; }
52 def : WriteRes<WriteIS, [THXT8XUnitALU]> { let Latency = 2; }
53 def : WriteRes<WriteExtr, [THXT8XUnitALU]> { let Latency = 2; }
54
55 // MAC
56 def : WriteRes<WriteIM32, [THXT8XUnitMAC]> {
57   let Latency = 4;
58   let ResourceCycles = [1];
59 }
60
61 def : WriteRes<WriteIM64, [THXT8XUnitMAC]> {
62   let Latency = 4;
63   let ResourceCycles = [1];
64 }
65
66 // Div
67 def : WriteRes<WriteID32, [THXT8XUnitDiv]> {
68   let Latency = 12;
69   let ResourceCycles = [6];
70 }
71
72 def : WriteRes<WriteID64, [THXT8XUnitDiv]> {
73   let Latency = 14;
74   let ResourceCycles = [8];
75 }
76
77 // Load
78 def : WriteRes<WriteLD, [THXT8XUnitLdSt]> { let Latency = 3; }
79 def : WriteRes<WriteLDIdx, [THXT8XUnitLdSt]> { let Latency = 3; }
80 def : WriteRes<WriteLDHi, [THXT8XUnitLdSt]> { let Latency = 3; }
81
82 // Vector Load
83 def : WriteRes<WriteVLD, [THXT8XUnitLdSt]> {
84   let Latency = 8;
85   let ResourceCycles = [3];
86 }
87
88 def THXT8XWriteVLD1 : SchedWriteRes<[THXT8XUnitLdSt]> {
89   let Latency = 6;
90   let ResourceCycles = [1];
91 }
92
93 def THXT8XWriteVLD2 : SchedWriteRes<[THXT8XUnitLdSt]> {
94   let Latency = 11;
95   let ResourceCycles = [7];
96 }
97
98 def THXT8XWriteVLD3 : SchedWriteRes<[THXT8XUnitLdSt]> {
99   let Latency = 12;
100   let ResourceCycles = [8];
101 }
102
103 def THXT8XWriteVLD4 : SchedWriteRes<[THXT8XUnitLdSt]> {
104   let Latency = 13;
105   let ResourceCycles = [9];
106 }
107
108 def THXT8XWriteVLD5 : SchedWriteRes<[THXT8XUnitLdSt]> {
109   let Latency = 13;
110   let ResourceCycles = [9];
111 }
112
113 // Pre/Post Indexing
114 def : WriteRes<WriteAdr, []> { let Latency = 0; }
115
116 // Store
117 def : WriteRes<WriteST, [THXT8XUnitLdSt]> { let Latency = 1; }
118 def : WriteRes<WriteSTP, [THXT8XUnitLdSt]> { let Latency = 1; }
119 def : WriteRes<WriteSTIdx, [THXT8XUnitLdSt]> { let Latency = 1; }
120 def : WriteRes<WriteSTX, [THXT8XUnitLdSt]> { let Latency = 1; }
121
122 // Vector Store
123 def : WriteRes<WriteVST, [THXT8XUnitLdSt]>;
124 def THXT8XWriteVST1 : SchedWriteRes<[THXT8XUnitLdSt]>;
125
126 def THXT8XWriteVST2 : SchedWriteRes<[THXT8XUnitLdSt]> {
127   let Latency = 10;
128   let ResourceCycles = [9];
129 }
130
131 def THXT8XWriteVST3 : SchedWriteRes<[THXT8XUnitLdSt]> {
132   let Latency = 11;
133   let ResourceCycles = [10];
134 }
135
136 def : WriteRes<WriteAtomic, []> { let Unsupported = 1; }
137
138 // Branch
139 def : WriteRes<WriteBr, [THXT8XUnitBr]>;
140 def THXT8XWriteBR : SchedWriteRes<[THXT8XUnitBr]>;
141 def : WriteRes<WriteBrReg, [THXT8XUnitBr]>;
142 def THXT8XWriteBRR : SchedWriteRes<[THXT8XUnitBr]>;
143 def THXT8XWriteRET : SchedWriteRes<[THXT8XUnitALU]>;
144 def : WriteRes<WriteSys, [THXT8XUnitBr]>;
145 def : WriteRes<WriteBarrier, [THXT8XUnitBr]>;
146 def : WriteRes<WriteHint, [THXT8XUnitBr]>;
147
148 // FP ALU
149 def : WriteRes<WriteF, [THXT8XUnitFPALU]> { let Latency = 6; }
150 def : WriteRes<WriteFCmp, [THXT8XUnitFPALU]> { let Latency = 6; }
151 def : WriteRes<WriteFCvt, [THXT8XUnitFPALU]> { let Latency = 6; }
152 def : WriteRes<WriteFCopy, [THXT8XUnitFPALU]> { let Latency = 6; }
153 def : WriteRes<WriteFImm, [THXT8XUnitFPALU]> { let Latency = 6; }
154 def : WriteRes<WriteV, [THXT8XUnitFPALU]> { let Latency = 6; }
155
156 // FP Mul, Div, Sqrt
157 def : WriteRes<WriteFMul, [THXT8XUnitFPMDS]> { let Latency = 6; }
158 def : WriteRes<WriteFDiv, [THXT8XUnitFPMDS]> {
159   let Latency = 22;
160   let ResourceCycles = [19];
161 }
162
163 def THXT8XWriteFMAC : SchedWriteRes<[THXT8XUnitFPMDS]> { let Latency = 10; }
164
165 def THXT8XWriteFDivSP : SchedWriteRes<[THXT8XUnitFPMDS]> {
166   let Latency = 12;
167   let ResourceCycles = [9];
168 }
169
170 def THXT8XWriteFDivDP : SchedWriteRes<[THXT8XUnitFPMDS]> {
171   let Latency = 22;
172   let ResourceCycles = [19];
173 }
174
175 def THXT8XWriteFSqrtSP : SchedWriteRes<[THXT8XUnitFPMDS]> {
176   let Latency = 17;
177   let ResourceCycles = [14];
178 }
179
180 def THXT8XWriteFSqrtDP : SchedWriteRes<[THXT8XUnitFPMDS]> {
181   let Latency = 31;
182   let ResourceCycles = [28];
183 }
184
185 //===----------------------------------------------------------------------===//
186 // Subtarget-specific SchedRead types.
187
188 // No forwarding for these reads.
189 def : ReadAdvance<ReadExtrHi, 1>;
190 def : ReadAdvance<ReadAdrBase, 2>;
191 def : ReadAdvance<ReadVLD, 2>;
192
193 // FIXME: This needs more targeted benchmarking.
194 // ALU - Most operands in the ALU pipes are not needed for two cycles. Shiftable
195 //       operands are needed one cycle later if and only if they are to be
196 //       shifted. Otherwise, they too are needed two cycles later. This same
197 //       ReadAdvance applies to Extended registers as well, even though there is
198 //       a separate SchedPredicate for them.
199 def : ReadAdvance<ReadI, 2, [WriteImm, WriteI,
200                              WriteISReg, WriteIEReg, WriteIS,
201                              WriteID32, WriteID64,
202                              WriteIM32, WriteIM64]>;
203 def THXT8XReadShifted : SchedReadAdvance<1, [WriteImm, WriteI,
204                                           WriteISReg, WriteIEReg, WriteIS,
205                                           WriteID32, WriteID64,
206                                           WriteIM32, WriteIM64]>;
207 def THXT8XReadNotShifted : SchedReadAdvance<2, [WriteImm, WriteI,
208                                              WriteISReg, WriteIEReg, WriteIS,
209                                              WriteID32, WriteID64,
210                                              WriteIM32, WriteIM64]>;
211 def THXT8XReadISReg : SchedReadVariant<[
212         SchedVar<RegShiftedPred, [THXT8XReadShifted]>,
213         SchedVar<NoSchedPred, [THXT8XReadNotShifted]>]>;
214 def : SchedAlias<ReadISReg, THXT8XReadISReg>;
215
216 def THXT8XReadIEReg : SchedReadVariant<[
217         SchedVar<RegExtendedPred, [THXT8XReadShifted]>,
218         SchedVar<NoSchedPred, [THXT8XReadNotShifted]>]>;
219 def : SchedAlias<ReadIEReg, THXT8XReadIEReg>;
220
221 // MAC - Operands are generally needed one cycle later in the MAC pipe.
222 //       Accumulator operands are needed two cycles later.
223 def : ReadAdvance<ReadIM, 1, [WriteImm,WriteI,
224                               WriteISReg, WriteIEReg, WriteIS,
225                               WriteID32, WriteID64,
226                               WriteIM32, WriteIM64]>;
227 def : ReadAdvance<ReadIMA, 2, [WriteImm, WriteI,
228                                WriteISReg, WriteIEReg, WriteIS,
229                                WriteID32, WriteID64,
230                                WriteIM32, WriteIM64]>;
231
232 // Div
233 def : ReadAdvance<ReadID, 1, [WriteImm, WriteI,
234                               WriteISReg, WriteIEReg, WriteIS,
235                               WriteID32, WriteID64,
236                               WriteIM32, WriteIM64]>;
237
238 //===----------------------------------------------------------------------===//
239 // Subtarget-specific InstRW.
240
241 //---
242 // Branch
243 //---
244 def : InstRW<[THXT8XWriteBR], (instregex "^B$")>;
245 def : InstRW<[THXT8XWriteBR], (instregex "^BL$")>;
246 def : InstRW<[THXT8XWriteBR], (instregex "^B..$")>;
247 def : InstRW<[THXT8XWriteBR], (instregex "^CBNZ")>;
248 def : InstRW<[THXT8XWriteBR], (instregex "^CBZ")>;
249 def : InstRW<[THXT8XWriteBR], (instregex "^TBNZ")>;
250 def : InstRW<[THXT8XWriteBR], (instregex "^TBZ")>;
251 def : InstRW<[THXT8XWriteBRR], (instregex "^BR$")>;
252 def : InstRW<[THXT8XWriteBRR], (instregex "^BLR$")>;
253
254 //---
255 // Ret
256 //---
257 def : InstRW<[THXT8XWriteRET], (instregex "^RET$")>;
258
259 //---
260 // Miscellaneous
261 //---
262 def : InstRW<[WriteI], (instrs COPY)>;
263
264 //---
265 // Vector Loads
266 //---
267 def : InstRW<[THXT8XWriteVLD1], (instregex "LD1i(8|16|32|64)$")>;
268 def : InstRW<[THXT8XWriteVLD1], (instregex "LD1Rv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
269 def : InstRW<[THXT8XWriteVLD1], (instregex "LD1Onev(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
270 def : InstRW<[THXT8XWriteVLD2], (instregex "LD1Twov(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
271 def : InstRW<[THXT8XWriteVLD3], (instregex "LD1Threev(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
272 def : InstRW<[THXT8XWriteVLD4], (instregex "LD1Fourv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
273 def : InstRW<[THXT8XWriteVLD1, WriteAdr], (instregex "LD1i(8|16|32|64)_POST$")>;
274 def : InstRW<[THXT8XWriteVLD1, WriteAdr], (instregex "LD1Rv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
275 def : InstRW<[THXT8XWriteVLD1, WriteAdr], (instregex "LD1Onev(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
276 def : InstRW<[THXT8XWriteVLD2, WriteAdr], (instregex "LD1Twov(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
277 def : InstRW<[THXT8XWriteVLD3, WriteAdr], (instregex "LD1Threev(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
278 def : InstRW<[THXT8XWriteVLD4, WriteAdr], (instregex "LD1Fourv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
279
280 def : InstRW<[THXT8XWriteVLD1], (instregex "LD2i(8|16|32|64)$")>;
281 def : InstRW<[THXT8XWriteVLD1], (instregex "LD2Rv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
282 def : InstRW<[THXT8XWriteVLD2], (instregex "LD2Twov(8b|4h|2s)$")>;
283 def : InstRW<[THXT8XWriteVLD4], (instregex "LD2Twov(16b|8h|4s|2d)$")>;
284 def : InstRW<[THXT8XWriteVLD1, WriteAdr], (instregex "LD2i(8|16|32|64)(_POST)?$")>;
285 def : InstRW<[THXT8XWriteVLD1, WriteAdr], (instregex "LD2Rv(8b|4h|2s|1d|16b|8h|4s|2d)(_POST)?$")>;
286 def : InstRW<[THXT8XWriteVLD2, WriteAdr], (instregex "LD2Twov(8b|4h|2s)(_POST)?$")>;
287 def : InstRW<[THXT8XWriteVLD4, WriteAdr], (instregex "LD2Twov(16b|8h|4s|2d)(_POST)?$")>;
288
289 def : InstRW<[THXT8XWriteVLD2], (instregex "LD3i(8|16|32|64)$")>;
290 def : InstRW<[THXT8XWriteVLD2], (instregex "LD3Rv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
291 def : InstRW<[THXT8XWriteVLD4], (instregex "LD3Threev(8b|4h|2s|1d|16b|8h|4s)$")>;
292 def : InstRW<[THXT8XWriteVLD3], (instregex "LD3Threev(2d)$")>;
293 def : InstRW<[THXT8XWriteVLD2, WriteAdr], (instregex "LD3i(8|16|32|64)_POST$")>;
294 def : InstRW<[THXT8XWriteVLD2, WriteAdr], (instregex "LD3Rv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
295 def : InstRW<[THXT8XWriteVLD4, WriteAdr], (instregex "LD3Threev(8b|4h|2s|1d|16b|8h|4s)_POST$")>;
296 def : InstRW<[THXT8XWriteVLD3, WriteAdr], (instregex "LD3Threev(2d)_POST$")>;
297
298 def : InstRW<[THXT8XWriteVLD2], (instregex "LD4i(8|16|32|64)$")>;
299 def : InstRW<[THXT8XWriteVLD2], (instregex "LD4Rv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
300 def : InstRW<[THXT8XWriteVLD5], (instregex "LD4Fourv(8b|4h|2s|1d|16b|8h|4s)$")>;
301 def : InstRW<[THXT8XWriteVLD4], (instregex "LD4Fourv(2d)$")>;
302 def : InstRW<[THXT8XWriteVLD2, WriteAdr], (instregex "LD4i(8|16|32|64)_POST$")>;
303 def : InstRW<[THXT8XWriteVLD2, WriteAdr], (instregex "LD4Rv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
304 def : InstRW<[THXT8XWriteVLD5, WriteAdr], (instregex "LD4Fourv(8b|4h|2s|1d|16b|8h|4s)_POST$")>;
305 def : InstRW<[THXT8XWriteVLD4, WriteAdr], (instregex "LD4Fourv(2d)_POST$")>;
306
307 //---
308 // Vector Stores
309 //---
310 def : InstRW<[THXT8XWriteVST1], (instregex "ST1i(8|16|32|64)$")>;
311 def : InstRW<[THXT8XWriteVST1], (instregex "ST1Onev(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
312 def : InstRW<[THXT8XWriteVST1], (instregex "ST1Twov(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
313 def : InstRW<[THXT8XWriteVST2], (instregex "ST1Threev(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
314 def : InstRW<[THXT8XWriteVST2], (instregex "ST1Fourv(8b|4h|2s|1d|16b|8h|4s|2d)$")>;
315 def : InstRW<[THXT8XWriteVST1, WriteAdr], (instregex "ST1i(8|16|32|64)_POST$")>;
316 def : InstRW<[THXT8XWriteVST1, WriteAdr], (instregex "ST1Onev(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
317 def : InstRW<[THXT8XWriteVST1, WriteAdr], (instregex "ST1Twov(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
318 def : InstRW<[THXT8XWriteVST2, WriteAdr], (instregex "ST1Threev(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
319 def : InstRW<[THXT8XWriteVST2, WriteAdr], (instregex "ST1Fourv(8b|4h|2s|1d|16b|8h|4s|2d)_POST$")>;
320
321 def : InstRW<[THXT8XWriteVST1], (instregex "ST2i(8|16|32|64)$")>;
322 def : InstRW<[THXT8XWriteVST1], (instregex "ST2Twov(8b|4h|2s)$")>;
323 def : InstRW<[THXT8XWriteVST2], (instregex "ST2Twov(16b|8h|4s|2d)$")>;
324 def : InstRW<[THXT8XWriteVST1, WriteAdr], (instregex "ST2i(8|16|32|64)_POST$")>;
325 def : InstRW<[THXT8XWriteVST1, WriteAdr], (instregex "ST2Twov(8b|4h|2s)_POST$")>;
326 def : InstRW<[THXT8XWriteVST2, WriteAdr], (instregex "ST2Twov(16b|8h|4s|2d)_POST$")>;
327
328 def : InstRW<[THXT8XWriteVST2], (instregex "ST3i(8|16|32|64)$")>;
329 def : InstRW<[THXT8XWriteVST3], (instregex "ST3Threev(8b|4h|2s|1d|16b|8h|4s)$")>;
330 def : InstRW<[THXT8XWriteVST2], (instregex "ST3Threev(2d)$")>;
331 def : InstRW<[THXT8XWriteVST2, WriteAdr], (instregex "ST3i(8|16|32|64)_POST$")>;
332 def : InstRW<[THXT8XWriteVST3, WriteAdr], (instregex "ST3Threev(8b|4h|2s|1d|16b|8h|4s)_POST$")>;
333 def : InstRW<[THXT8XWriteVST2, WriteAdr], (instregex "ST3Threev(2d)_POST$")>;
334
335 def : InstRW<[THXT8XWriteVST2], (instregex "ST4i(8|16|32|64)$")>;
336 def : InstRW<[THXT8XWriteVST3], (instregex "ST4Fourv(8b|4h|2s|1d|16b|8h|4s)$")>;
337 def : InstRW<[THXT8XWriteVST2], (instregex "ST4Fourv(2d)$")>;
338 def : InstRW<[THXT8XWriteVST2, WriteAdr], (instregex "ST4i(8|16|32|64)_POST$")>;
339 def : InstRW<[THXT8XWriteVST3, WriteAdr], (instregex "ST4Fourv(8b|4h|2s|1d|16b|8h|4s)_POST$")>;
340 def : InstRW<[THXT8XWriteVST2, WriteAdr], (instregex "ST4Fourv(2d)_POST$")>;
341
342 //---
343 // Floating Point MAC, DIV, SQRT
344 //---
345 def : InstRW<[THXT8XWriteFMAC], (instregex "^FN?M(ADD|SUB).*")>;
346 def : InstRW<[THXT8XWriteFMAC], (instregex "^FML(A|S).*")>;
347 def : InstRW<[THXT8XWriteFDivSP], (instrs FDIVSrr)>;
348 def : InstRW<[THXT8XWriteFDivDP], (instrs FDIVDrr)>;
349 def : InstRW<[THXT8XWriteFDivSP], (instregex "^FDIVv.*32$")>;
350 def : InstRW<[THXT8XWriteFDivDP], (instregex "^FDIVv.*64$")>;
351 def : InstRW<[THXT8XWriteFSqrtSP], (instregex "^.*SQRT.*32$")>;
352 def : InstRW<[THXT8XWriteFSqrtDP], (instregex "^.*SQRT.*64$")>;
353
354 }