Debian Codegraph @

suite/synctools/tablegen/AArch64/AArch64SchedCyclone.td

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