1 //===-- ARMSchedule.td - ARM Scheduling Definitions --------*- tablegen -*-===//
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
7 //===----------------------------------------------------------------------===//
8 //===----------------------------------------------------------------------===//
9 // Instruction scheduling annotations for in-order and out-of-order CPUs.
10 // These annotations are independent of the itinerary class defined below.
11 // Here we define the subtarget independent read/write per-operand resources.
12 // The subtarget schedule definitions will then map these to the subtarget's
15 // The instruction cycle timings table might contain an entry for an operation
16 // like the following:
17 // Rd <- ADD Rn, Rm, <shift> Rs
18 // Uops | Latency from register | Uops - resource requirements - latency
19 // 2 | Rn: 1 Rm: 4 Rs: 4 | uop T0, Rm, Rs - P01 - 3
20 // | | uopc Rd, Rn, T0 - P01 - 1
21 // This is telling us that the result will be available in destination register
22 // Rd after a minimum of three cycles after the result in Rm and Rs is available
23 // and one cycle after the result in Rn is available. The micro-ops can execute
25 // To model this, we need to express that we need to dispatch two micro-ops,
26 // that the resource P01 is needed and that the latency to Rn is different than
27 // the latency to Rm and Rs. The scheduler can decrease Rn's producer latency by
29 // We will do this by assigning (abstract) resources to register defs/uses.
31 // def WriteALUsr : SchedWrite;
32 // def ReadAdvanceALUsr : ScheRead;
35 // def ADDrs : I<>, Sched<[WriteALUsr, ReadAdvanceALUsr, ReadDefault,
36 // ReadDefault]> { ...}
37 // ReadAdvance read resources allow us to define "pipeline by-passes" or
38 // shorter latencies to certain registers as needed in the example above.
39 // The "ReadDefault" can be omitted.
40 // Next, the subtarget td file assigns resources to the abstract resources
42 // ARMScheduleSubtarget.td:
44 // def P01 : ProcResource<3>; // ALU unit (3 of it).
46 // // Resource usages.
47 // def : WriteRes<WriteALUsr, [P01, P01]> {
48 // Latency = 4; // Latency of 4.
49 // NumMicroOps = 2; // Dispatch 2 micro-ops.
50 // // The two instances of resource P01 are occupied for one cycle. It is one
51 // // cycle because these resources happen to be pipelined.
52 // ResourceCycles = [1, 1];
54 // def : ReadAdvance<ReadAdvanceALUsr, 3>;
56 //===----------------------------------------------------------------------===//
57 // Sched definitions for integer pipeline instructions
59 // Basic ALU operation.
60 def WriteALU : SchedWrite;
61 def ReadALU : SchedRead;
63 // Basic ALU with shifts.
64 def WriteALUsi : SchedWrite; // Shift by immediate.
65 def WriteALUsr : SchedWrite; // Shift by register.
66 def WriteALUSsr : SchedWrite; // Shift by register (flag setting).
67 def ReadALUsr : SchedRead; // Some operands are read later.
70 def WriteCMP : SchedWrite;
71 def WriteCMPsi : SchedWrite;
72 def WriteCMPsr : SchedWrite;
75 def WriteMUL16 : SchedWrite; // 16-bit multiply.
76 def WriteMUL32 : SchedWrite; // 32-bit multiply.
77 def WriteMUL64Lo : SchedWrite; // 64-bit result. Low reg.
78 def WriteMUL64Hi : SchedWrite; // 64-bit result. High reg.
79 def ReadMUL : SchedRead;
81 // Multiply-accumulates.
82 def WriteMAC16 : SchedWrite; // 16-bit mac.
83 def WriteMAC32 : SchedWrite; // 32-bit mac.
84 def WriteMAC64Lo : SchedWrite; // 64-bit mac. Low reg.
85 def WriteMAC64Hi : SchedWrite; // 64-bit mac. High reg.
86 def ReadMAC : SchedRead;
89 def WriteDIV : SchedWrite;
92 def WriteLd : SchedWrite;
93 def WritePreLd : SchedWrite;
94 def WriteST : SchedWrite;
97 def WriteBr : SchedWrite;
98 def WriteBrL : SchedWrite;
99 def WriteBrTbl : SchedWrite;
102 def WriteNoop : SchedWrite;
104 //===----------------------------------------------------------------------===//
105 // Sched definitions for floating-point and neon instructions
107 // Floating point conversions
108 def WriteFPCVT : SchedWrite;
109 def WriteFPMOV : SchedWrite; // FP -> GPR and vice-versa
111 // ALU operations (32/64-bit)
112 def WriteFPALU32 : SchedWrite;
113 def WriteFPALU64 : SchedWrite;
116 def WriteFPMUL32 : SchedWrite;
117 def WriteFPMUL64 : SchedWrite;
118 def ReadFPMUL : SchedRead; // multiplier read
119 def ReadFPMAC : SchedRead; // accumulator read
121 // Multiply-accumulate
122 def WriteFPMAC32 : SchedWrite;
123 def WriteFPMAC64 : SchedWrite;
126 def WriteFPDIV32 : SchedWrite;
127 def WriteFPDIV64 : SchedWrite;
130 def WriteFPSQRT32 : SchedWrite;
131 def WriteFPSQRT64 : SchedWrite;
133 // Vector load and stores
134 def WriteVLD1 : SchedWrite;
135 def WriteVLD2 : SchedWrite;
136 def WriteVLD3 : SchedWrite;
137 def WriteVLD4 : SchedWrite;
138 def WriteVST1 : SchedWrite;
139 def WriteVST2 : SchedWrite;
140 def WriteVST3 : SchedWrite;
141 def WriteVST4 : SchedWrite;
144 // Define TII for use in SchedVariant Predicates.
145 def : PredicateProlog<[{
146 const ARMBaseInstrInfo *TII =
147 static_cast<const ARMBaseInstrInfo*>(SchedModel->getInstrInfo());
149 const ARMSubtarget *STI =
150 static_cast<const ARMSubtarget*>(SchedModel->getSubtargetInfo());
154 def IsPredicatedPred : SchedPredicate<[{TII->isPredicated(*MI)}]>;
156 //===----------------------------------------------------------------------===//
157 // Instruction Itinerary classes used for ARM
159 def IIC_iALUx : InstrItinClass;
160 def IIC_iALUi : InstrItinClass;
161 def IIC_iALUr : InstrItinClass;
162 def IIC_iALUsi : InstrItinClass;
163 def IIC_iALUsir : InstrItinClass;
164 def IIC_iALUsr : InstrItinClass;
165 def IIC_iBITi : InstrItinClass;
166 def IIC_iBITr : InstrItinClass;
167 def IIC_iBITsi : InstrItinClass;
168 def IIC_iBITsr : InstrItinClass;
169 def IIC_iUNAr : InstrItinClass;
170 def IIC_iUNAsi : InstrItinClass;
171 def IIC_iEXTr : InstrItinClass;
172 def IIC_iEXTAr : InstrItinClass;
173 def IIC_iEXTAsr : InstrItinClass;
174 def IIC_iCMPi : InstrItinClass;
175 def IIC_iCMPr : InstrItinClass;
176 def IIC_iCMPsi : InstrItinClass;
177 def IIC_iCMPsr : InstrItinClass;
178 def IIC_iTSTi : InstrItinClass;
179 def IIC_iTSTr : InstrItinClass;
180 def IIC_iTSTsi : InstrItinClass;
181 def IIC_iTSTsr : InstrItinClass;
182 def IIC_iMOVi : InstrItinClass;
183 def IIC_iMOVr : InstrItinClass;
184 def IIC_iMOVsi : InstrItinClass;
185 def IIC_iMOVsr : InstrItinClass;
186 def IIC_iMOVix2 : InstrItinClass;
187 def IIC_iMOVix2addpc : InstrItinClass;
188 def IIC_iMOVix2ld : InstrItinClass;
189 def IIC_iMVNi : InstrItinClass;
190 def IIC_iMVNr : InstrItinClass;
191 def IIC_iMVNsi : InstrItinClass;
192 def IIC_iMVNsr : InstrItinClass;
193 def IIC_iCMOVi : InstrItinClass;
194 def IIC_iCMOVr : InstrItinClass;
195 def IIC_iCMOVsi : InstrItinClass;
196 def IIC_iCMOVsr : InstrItinClass;
197 def IIC_iCMOVix2 : InstrItinClass;
198 def IIC_iMUL16 : InstrItinClass;
199 def IIC_iMAC16 : InstrItinClass;
200 def IIC_iMUL32 : InstrItinClass;
201 def IIC_iMAC32 : InstrItinClass;
202 def IIC_iMUL64 : InstrItinClass;
203 def IIC_iMAC64 : InstrItinClass;
204 def IIC_iDIV : InstrItinClass;
205 def IIC_iLoad_i : InstrItinClass;
206 def IIC_iLoad_r : InstrItinClass;
207 def IIC_iLoad_si : InstrItinClass;
208 def IIC_iLoad_iu : InstrItinClass;
209 def IIC_iLoad_ru : InstrItinClass;
210 def IIC_iLoad_siu : InstrItinClass;
211 def IIC_iLoad_bh_i : InstrItinClass;
212 def IIC_iLoad_bh_r : InstrItinClass;
213 def IIC_iLoad_bh_si : InstrItinClass;
214 def IIC_iLoad_bh_iu : InstrItinClass;
215 def IIC_iLoad_bh_ru : InstrItinClass;
216 def IIC_iLoad_bh_siu : InstrItinClass;
217 def IIC_iLoad_d_i : InstrItinClass;
218 def IIC_iLoad_d_r : InstrItinClass;
219 def IIC_iLoad_d_ru : InstrItinClass;
220 def IIC_iLoad_m : InstrItinClass;
221 def IIC_iLoad_mu : InstrItinClass;
222 def IIC_iLoad_mBr : InstrItinClass;
223 def IIC_iPop : InstrItinClass;
224 def IIC_iPop_Br : InstrItinClass;
225 def IIC_iLoadiALU : InstrItinClass;
226 def IIC_iStore_i : InstrItinClass;
227 def IIC_iStore_r : InstrItinClass;
228 def IIC_iStore_si : InstrItinClass;
229 def IIC_iStore_iu : InstrItinClass;
230 def IIC_iStore_ru : InstrItinClass;
231 def IIC_iStore_siu : InstrItinClass;
232 def IIC_iStore_bh_i : InstrItinClass;
233 def IIC_iStore_bh_r : InstrItinClass;
234 def IIC_iStore_bh_si : InstrItinClass;
235 def IIC_iStore_bh_iu : InstrItinClass;
236 def IIC_iStore_bh_ru : InstrItinClass;
237 def IIC_iStore_bh_siu : InstrItinClass;
238 def IIC_iStore_d_i : InstrItinClass;
239 def IIC_iStore_d_r : InstrItinClass;
240 def IIC_iStore_d_ru : InstrItinClass;
241 def IIC_iStore_m : InstrItinClass;
242 def IIC_iStore_mu : InstrItinClass;
243 def IIC_Preload : InstrItinClass;
244 def IIC_Br : InstrItinClass;
245 def IIC_fpSTAT : InstrItinClass;
246 def IIC_fpUNA16 : InstrItinClass;
247 def IIC_fpUNA32 : InstrItinClass;
248 def IIC_fpUNA64 : InstrItinClass;
249 def IIC_fpCMP16 : InstrItinClass;
250 def IIC_fpCMP32 : InstrItinClass;
251 def IIC_fpCMP64 : InstrItinClass;
252 def IIC_fpCVTSD : InstrItinClass;
253 def IIC_fpCVTDS : InstrItinClass;
254 def IIC_fpCVTSH : InstrItinClass;
255 def IIC_fpCVTHS : InstrItinClass;
256 def IIC_fpCVTIH : InstrItinClass;
257 def IIC_fpCVTIS : InstrItinClass;
258 def IIC_fpCVTID : InstrItinClass;
259 def IIC_fpCVTHI : InstrItinClass;
260 def IIC_fpCVTSI : InstrItinClass;
261 def IIC_fpCVTDI : InstrItinClass;
262 def IIC_fpMOVIS : InstrItinClass;
263 def IIC_fpMOVID : InstrItinClass;
264 def IIC_fpMOVSI : InstrItinClass;
265 def IIC_fpMOVDI : InstrItinClass;
266 def IIC_fpALU16 : InstrItinClass;
267 def IIC_fpALU32 : InstrItinClass;
268 def IIC_fpALU64 : InstrItinClass;
269 def IIC_fpMUL16 : InstrItinClass;
270 def IIC_fpMUL32 : InstrItinClass;
271 def IIC_fpMUL64 : InstrItinClass;
272 def IIC_fpMAC16 : InstrItinClass;
273 def IIC_fpMAC32 : InstrItinClass;
274 def IIC_fpMAC64 : InstrItinClass;
275 def IIC_fpFMAC16 : InstrItinClass;
276 def IIC_fpFMAC32 : InstrItinClass;
277 def IIC_fpFMAC64 : InstrItinClass;
278 def IIC_fpDIV16 : InstrItinClass;
279 def IIC_fpDIV32 : InstrItinClass;
280 def IIC_fpDIV64 : InstrItinClass;
281 def IIC_fpSQRT16 : InstrItinClass;
282 def IIC_fpSQRT32 : InstrItinClass;
283 def IIC_fpSQRT64 : InstrItinClass;
284 def IIC_fpLoad16 : InstrItinClass;
285 def IIC_fpLoad32 : InstrItinClass;
286 def IIC_fpLoad64 : InstrItinClass;
287 def IIC_fpLoad_m : InstrItinClass;
288 def IIC_fpLoad_mu : InstrItinClass;
289 def IIC_fpStore16 : InstrItinClass;
290 def IIC_fpStore32 : InstrItinClass;
291 def IIC_fpStore64 : InstrItinClass;
292 def IIC_fpStore_m : InstrItinClass;
293 def IIC_fpStore_mu : InstrItinClass;
294 def IIC_VLD1 : InstrItinClass;
295 def IIC_VLD1x2 : InstrItinClass;
296 def IIC_VLD1x3 : InstrItinClass;
297 def IIC_VLD1x4 : InstrItinClass;
298 def IIC_VLD1u : InstrItinClass;
299 def IIC_VLD1x2u : InstrItinClass;
300 def IIC_VLD1x3u : InstrItinClass;
301 def IIC_VLD1x4u : InstrItinClass;
302 def IIC_VLD1ln : InstrItinClass;
303 def IIC_VLD1lnu : InstrItinClass;
304 def IIC_VLD1dup : InstrItinClass;
305 def IIC_VLD1dupu : InstrItinClass;
306 def IIC_VLD2 : InstrItinClass;
307 def IIC_VLD2x2 : InstrItinClass;
308 def IIC_VLD2u : InstrItinClass;
309 def IIC_VLD2x2u : InstrItinClass;
310 def IIC_VLD2ln : InstrItinClass;
311 def IIC_VLD2lnu : InstrItinClass;
312 def IIC_VLD2dup : InstrItinClass;
313 def IIC_VLD2dupu : InstrItinClass;
314 def IIC_VLD3 : InstrItinClass;
315 def IIC_VLD3ln : InstrItinClass;
316 def IIC_VLD3u : InstrItinClass;
317 def IIC_VLD3lnu : InstrItinClass;
318 def IIC_VLD3dup : InstrItinClass;
319 def IIC_VLD3dupu : InstrItinClass;
320 def IIC_VLD4 : InstrItinClass;
321 def IIC_VLD4ln : InstrItinClass;
322 def IIC_VLD4u : InstrItinClass;
323 def IIC_VLD4lnu : InstrItinClass;
324 def IIC_VLD4dup : InstrItinClass;
325 def IIC_VLD4dupu : InstrItinClass;
326 def IIC_VST1 : InstrItinClass;
327 def IIC_VST1x2 : InstrItinClass;
328 def IIC_VST1x3 : InstrItinClass;
329 def IIC_VST1x4 : InstrItinClass;
330 def IIC_VST1u : InstrItinClass;
331 def IIC_VST1x2u : InstrItinClass;
332 def IIC_VST1x3u : InstrItinClass;
333 def IIC_VST1x4u : InstrItinClass;
334 def IIC_VST1ln : InstrItinClass;
335 def IIC_VST1lnu : InstrItinClass;
336 def IIC_VST2 : InstrItinClass;
337 def IIC_VST2x2 : InstrItinClass;
338 def IIC_VST2u : InstrItinClass;
339 def IIC_VST2x2u : InstrItinClass;
340 def IIC_VST2ln : InstrItinClass;
341 def IIC_VST2lnu : InstrItinClass;
342 def IIC_VST3 : InstrItinClass;
343 def IIC_VST3u : InstrItinClass;
344 def IIC_VST3ln : InstrItinClass;
345 def IIC_VST3lnu : InstrItinClass;
346 def IIC_VST4 : InstrItinClass;
347 def IIC_VST4u : InstrItinClass;
348 def IIC_VST4ln : InstrItinClass;
349 def IIC_VST4lnu : InstrItinClass;
350 def IIC_VUNAD : InstrItinClass;
351 def IIC_VUNAQ : InstrItinClass;
352 def IIC_VBIND : InstrItinClass;
353 def IIC_VBINQ : InstrItinClass;
354 def IIC_VPBIND : InstrItinClass;
355 def IIC_VFMULD : InstrItinClass;
356 def IIC_VFMULQ : InstrItinClass;
357 def IIC_VMOV : InstrItinClass;
358 def IIC_VMOVImm : InstrItinClass;
359 def IIC_VMOVD : InstrItinClass;
360 def IIC_VMOVQ : InstrItinClass;
361 def IIC_VMOVIS : InstrItinClass;
362 def IIC_VMOVID : InstrItinClass;
363 def IIC_VMOVISL : InstrItinClass;
364 def IIC_VMOVSI : InstrItinClass;
365 def IIC_VMOVDI : InstrItinClass;
366 def IIC_VMOVN : InstrItinClass;
367 def IIC_VPERMD : InstrItinClass;
368 def IIC_VPERMQ : InstrItinClass;
369 def IIC_VPERMQ3 : InstrItinClass;
370 def IIC_VMACD : InstrItinClass;
371 def IIC_VMACQ : InstrItinClass;
372 def IIC_VFMACD : InstrItinClass;
373 def IIC_VFMACQ : InstrItinClass;
374 def IIC_VRECSD : InstrItinClass;
375 def IIC_VRECSQ : InstrItinClass;
376 def IIC_VCNTiD : InstrItinClass;
377 def IIC_VCNTiQ : InstrItinClass;
378 def IIC_VUNAiD : InstrItinClass;
379 def IIC_VUNAiQ : InstrItinClass;
380 def IIC_VQUNAiD : InstrItinClass;
381 def IIC_VQUNAiQ : InstrItinClass;
382 def IIC_VBINiD : InstrItinClass;
383 def IIC_VBINiQ : InstrItinClass;
384 def IIC_VSUBiD : InstrItinClass;
385 def IIC_VSUBiQ : InstrItinClass;
386 def IIC_VBINi4D : InstrItinClass;
387 def IIC_VBINi4Q : InstrItinClass;
388 def IIC_VSUBi4D : InstrItinClass;
389 def IIC_VSUBi4Q : InstrItinClass;
390 def IIC_VABAD : InstrItinClass;
391 def IIC_VABAQ : InstrItinClass;
392 def IIC_VSHLiD : InstrItinClass;
393 def IIC_VSHLiQ : InstrItinClass;
394 def IIC_VSHLi4D : InstrItinClass;
395 def IIC_VSHLi4Q : InstrItinClass;
396 def IIC_VPALiD : InstrItinClass;
397 def IIC_VPALiQ : InstrItinClass;
398 def IIC_VMULi16D : InstrItinClass;
399 def IIC_VMULi32D : InstrItinClass;
400 def IIC_VMULi16Q : InstrItinClass;
401 def IIC_VMULi32Q : InstrItinClass;
402 def IIC_VMACi16D : InstrItinClass;
403 def IIC_VMACi32D : InstrItinClass;
404 def IIC_VMACi16Q : InstrItinClass;
405 def IIC_VMACi32Q : InstrItinClass;
406 def IIC_VEXTD : InstrItinClass;
407 def IIC_VEXTQ : InstrItinClass;
408 def IIC_VTB1 : InstrItinClass;
409 def IIC_VTB2 : InstrItinClass;
410 def IIC_VTB3 : InstrItinClass;
411 def IIC_VTB4 : InstrItinClass;
412 def IIC_VTBX1 : InstrItinClass;
413 def IIC_VTBX2 : InstrItinClass;
414 def IIC_VTBX3 : InstrItinClass;
415 def IIC_VTBX4 : InstrItinClass;
416 def IIC_VDOTPROD : InstrItinClass;
418 //===----------------------------------------------------------------------===//
419 // Processor instruction itineraries.
421 include "ARMScheduleV6.td"
422 include "ARMScheduleA8.td"
423 include "ARMScheduleA9.td"
424 include "ARMScheduleSwift.td"
425 include "ARMScheduleR52.td"
426 include "ARMScheduleA57.td"
427 include "ARMScheduleM4.td"