1 //==- MipsScheduleP5600.td - P5600 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 //===----------------------------------------------------------------------===//
9 def MipsP5600Model : SchedMachineModel {
10 int IssueWidth = 2; // 2x dispatched per cycle
11 int MicroOpBufferSize = 48; // min(48, 48, 64)
13 int MispredictPenalty = 8; // TODO: Estimated
15 let CompleteModel = 0;
16 let FullInstRWOverlapCheck = 1;
18 list<Predicate> UnsupportedFeatures = [HasMips32r6, HasMips64r6,
19 HasMips3, HasMips64r2, HasCnMips,
20 InMicroMips, InMips16Mode,
21 HasDSP, HasDSPR2, HasMT, HasCRC];
24 let SchedModel = MipsP5600Model in {
29 def P5600ALQ : ProcResource<1> { let BufferSize = 16; }
30 def P5600IssueALU : ProcResource<1> { let Super = P5600ALQ; }
35 def P5600WriteALU : SchedWriteRes<[P5600IssueALU]>;
37 // and, lui, nor, or, slti, sltiu, sub, subu, xor
38 def : InstRW<[P5600WriteALU], (instrs AND, LUi, NOR, OR, SLTi, SLTiu, SUB,
44 def P5600AGQ : ProcResource<3> { let BufferSize = 16; }
45 def P5600IssueAL2 : ProcResource<1> { let Super = P5600AGQ; }
46 def P5600IssueCTISTD : ProcResource<1> { let Super = P5600AGQ; }
47 def P5600IssueLDST : ProcResource<1> { let Super = P5600AGQ; }
49 def P5600AL2Div : ProcResource<1>;
50 // Pseudo-resource used to block CTISTD when handling multi-pipeline splits.
51 def P5600CTISTD : ProcResource<1>;
56 def P5600WriteJump : SchedWriteRes<[P5600IssueCTISTD, P5600CTISTD]>;
57 def P5600WriteJumpAndLink : SchedWriteRes<[P5600IssueCTISTD, P5600CTISTD]> {
61 // b, beq, beql, bg[et]z, bl[et]z, bne, bnel, j, syscall, jal, bltzal,
63 def : InstRW<[P5600WriteJump], (instrs B, BAL, BAL_BR, BEQ, BEQL, BGEZ, BGEZAL,
64 BGEZALL, BGEZL, BGTZ, BGTZL, BLEZ, BLEZL, BLTZ,
65 BLTZAL, BLTZALL, BLTZL, BNE, BNEL, BREAK,
66 DERET, ERET, ERETNC, J, JR, JR_HB,
68 PseudoIndirectHazardBranch, PseudoReturn,
69 SDBBP, SSNOP, SYSCALL, TAILCALL, TAILCALLREG,
70 TAILCALLREGHB, TEQ, TEQI, TGE, TGEI, TGEIU,
71 TGEU, TLT, TLTI, TLTU, TNE, TNEI, TRAP,
72 TTLTIU, WAIT, PAUSE)>;
74 def : InstRW<[P5600WriteJumpAndLink], (instrs JAL, JALR, JALRHBPseudo,
75 JALRPseudo, JALR_HB)>;
77 def : InstRW<[P5600WriteJumpAndLink], (instrs JALX)> {
81 def P5600COP0 : SchedWriteRes<[P5600IssueCTISTD, P5600CTISTD]>;
83 def : InstRW<[P5600COP0], (instrs TLBINV, TLBINVF, TLBP, TLBR, TLBWI, TLBWR,
86 def P5600COP2 : SchedWriteRes<[P5600IssueCTISTD, P5600CTISTD]>;
88 def : InstRW<[P5600COP2], (instrs MFC2, MTC2)> {
95 def P5600WriteLoad : SchedWriteRes<[P5600IssueLDST]> {
99 def P5600WriteLoadShifted : SchedWriteRes<[P5600IssueLDST, P5600CTISTD]> {
103 def P5600WriteCache : SchedWriteRes<[P5600IssueLDST]>;
105 def P5600WriteStore : SchedWriteRes<[P5600IssueLDST, P5600CTISTD]> {
106 // FIXME: This is a bit pessimistic. P5600CTISTD is only used during cycle 2
107 // not during 0, 1, and 2.
108 let ResourceCycles = [ 1, 3 ];
111 def P5600WriteGPRFromBypass : SchedWriteRes<[P5600IssueLDST]> {
115 def P5600WriteStoreFromOtherUnits : SchedWriteRes<[P5600IssueLDST]>;
116 def P5600WriteLoadToOtherUnits : SchedWriteRes<[P5600IssueLDST]> {
120 // l[bhw], l[bh]u, ll
121 def : InstRW<[P5600WriteLoad], (instrs LB, LBu, LH, LHu, LW, LL, LWC2, LWC3,
122 LDC2, LDC3, LBE, LBuE, LHE, LHuE, LWE, LLE,
126 def : InstRW<[P5600WriteLoadShifted], (instrs LWL, LWR, LWLE, LWRE)>;
129 def : InstRW<[P5600WriteStore], (instrs SB, SH, SW, SWC2, SWC3, SDC2, SDC3, SC,
130 SBE, SHE, SWE, SCE, SWL, SWR, SWLE, SWRE)>;
132 // pref, cache, sync, synci
133 def : InstRW<[P5600WriteCache], (instrs PREF, PREFE, CACHE, CACHEE, SYNC,
136 // LDST is also used in moves from general purpose registers to floating point
138 def P5600WriteMoveGPRToOtherUnits : SchedWriteRes<[P5600IssueLDST]> {
145 def P5600WriteAL2 : SchedWriteRes<[P5600IssueAL2]>;
146 def P5600WriteAL2BitExt : SchedWriteRes<[P5600IssueAL2]> { let Latency = 2; }
147 def P5600WriteAL2ShadowMov : SchedWriteRes<[P5600IssueAL2]> { let Latency = 2; }
148 def P5600WriteAL2CondMov : SchedWriteRes<[P5600IssueAL2, P5600CTISTD]> {
151 def P5600WriteAL2Div : SchedWriteRes<[P5600IssueAL2, P5600AL2Div]> {
152 // Estimated worst case
154 let ResourceCycles = [1, 34];
156 def P5600WriteAL2DivU : SchedWriteRes<[P5600IssueAL2, P5600AL2Div]> {
157 // Estimated worst case
159 let ResourceCycles = [1, 34];
161 def P5600WriteAL2Mul : SchedWriteRes<[P5600IssueAL2]> { let Latency = 3; }
162 def P5600WriteAL2Mult: SchedWriteRes<[P5600IssueAL2]> { let Latency = 5; }
163 def P5600WriteAL2MAdd: SchedWriteRes<[P5600IssueAL2, P5600CTISTD]> {
167 // clo, clz, di, ei, mfhi, mflo
168 def : InstRW<[P5600WriteAL2], (instrs CLO, CLZ, DI, EI, MFHI, MFLO,
169 PseudoMFHI, PseudoMFLO)>;
171 // ehb, rdhwr, rdpgpr, wrpgpr, wsbh
172 def : InstRW<[P5600WriteAL2ShadowMov], (instrs EHB, RDHWR, WSBH)>;
175 def : InstRW<[P5600WriteAL2CondMov], (instrs MOVN_I_I, MOVZ_I_I)>;
178 def : InstRW<[P5600WriteAL2Div], (instrs DIV, PseudoSDIV, SDIV)>;
179 def : InstRW<[P5600WriteAL2DivU], (instrs DIVU, PseudoUDIV, UDIV)>;
182 def : InstRW<[P5600WriteAL2Mul], (instrs MUL)>;
184 def : InstRW<[P5600WriteAL2Mult], (instrs MULT, MULTu, PseudoMULT,
186 // maddu?, msubu?, mthi, mtlo
187 def : InstRW<[P5600WriteAL2MAdd], (instrs MADD, MADDU, MSUB, MSUBU,
188 MTHI, MTLO, PseudoMADD, PseudoMADDU,
189 PseudoMSUB, PseudoMSUBU, PseudoMTLOHI)>;
192 def : InstRW<[P5600WriteAL2BitExt], (instrs EXT, INS)>;
194 // Either ALU or AL2 Pipelines
195 // ---------------------------
197 // Some instructions can choose between ALU and AL2, but once dispatched to
198 // ALQ or AGQ respectively they are committed to that path.
199 // The decision is based on the outcome of the most recent selection when the
200 // choice was last available. For now, we assume ALU is always chosen.
202 def P5600WriteEitherALU : SchedWriteVariant<
203 // FIXME: Implement selection predicate
204 [SchedVar<SchedPredicate<[{1}]>, [P5600WriteALU]>,
205 SchedVar<SchedPredicate<[{0}]>, [P5600WriteAL2]>
208 // add, addi, addiu, addu, andi, ori, rotr, se[bh], sllv?, sr[al]v?, slt, sltu,
210 def : InstRW<[P5600WriteEitherALU], (instrs ADD, ADDi, ADDiu, ANDi, ORi, ROTR,
211 SEB, SEH, SLT, SLTu, SLL, SRA, SRL, XORi,
212 ADDu, SLLV, SRAV, SRLV, LSA, COPY)>;
217 def P5600FPQ : ProcResource<3> { let BufferSize = 16; }
218 def P5600IssueFPUS : ProcResource<1> { let Super = P5600FPQ; }
219 def P5600IssueFPUL : ProcResource<1> { let Super = P5600FPQ; }
220 def P5600IssueFPULoad : ProcResource<1> { let Super = P5600FPQ; }
222 def P5600FPUDivSqrt : ProcResource<2>;
224 def P5600WriteFPUS : SchedWriteRes<[P5600IssueFPUS]>;
225 def P5600WriteFPUL : SchedWriteRes<[P5600IssueFPUL]> { let Latency = 4; }
226 def P5600WriteFPUL_MADDSUB : SchedWriteRes<[P5600IssueFPUL]> { let Latency = 6; }
227 def P5600WriteFPUDivI : SchedWriteRes<[P5600IssueFPUL, P5600FPUDivSqrt]> {
228 // Best/Common/Worst case = 7 / 23 / 27
229 let Latency = 23; // Using common case
230 let ResourceCycles = [ 1, 23 ];
232 def P5600WriteFPUDivS : SchedWriteRes<[P5600IssueFPUL, P5600FPUDivSqrt]> {
233 // Best/Common/Worst case = 7 / 23 / 27
234 let Latency = 23; // Using common case
235 let ResourceCycles = [ 1, 23 ];
237 def P5600WriteFPUDivD : SchedWriteRes<[P5600IssueFPUL, P5600FPUDivSqrt]> {
238 // Best/Common/Worst case = 7 / 31 / 35
239 let Latency = 31; // Using common case
240 let ResourceCycles = [ 1, 31 ];
242 def P5600WriteFPURcpS : SchedWriteRes<[P5600IssueFPUL, P5600FPUDivSqrt]> {
243 // Best/Common/Worst case = 7 / 19 / 23
244 let Latency = 19; // Using common case
245 let ResourceCycles = [ 1, 19 ];
247 def P5600WriteFPURcpD : SchedWriteRes<[P5600IssueFPUL, P5600FPUDivSqrt]> {
248 // Best/Common/Worst case = 7 / 27 / 31
249 let Latency = 27; // Using common case
250 let ResourceCycles = [ 1, 27 ];
252 def P5600WriteFPURsqrtS : SchedWriteRes<[P5600IssueFPUL, P5600FPUDivSqrt]> {
253 // Best/Common/Worst case = 7 / 27 / 27
254 let Latency = 27; // Using common case
255 let ResourceCycles = [ 1, 27 ];
257 def P5600WriteFPURsqrtD : SchedWriteRes<[P5600IssueFPUL, P5600FPUDivSqrt]> {
258 // Best/Common/Worst case = 7 / 27 / 31
259 let Latency = 27; // Using common case
260 let ResourceCycles = [ 1, 27 ];
262 def P5600WriteFPUSqrtS : SchedWriteRes<[P5600IssueFPUL, P5600FPUDivSqrt]> {
263 // Best/Common/Worst case = 7 / 27 / 31
264 let Latency = 27; // Using common case
265 let ResourceCycles = [ 1, 27 ];
267 def P5600WriteFPUSqrtD : SchedWriteRes<[P5600IssueFPUL, P5600FPUDivSqrt]> {
268 // Best/Common/Worst case = 7 / 35 / 39
269 let Latency = 35; // Using common case
270 let ResourceCycles = [ 1, 35 ];
272 def P5600WriteMSAShortLogic : SchedWriteRes<[P5600IssueFPUS]>;
273 def P5600WriteMSAShortInt : SchedWriteRes<[P5600IssueFPUS]> { let Latency = 2; }
274 def P5600WriteMoveOtherUnitsToFPU : SchedWriteRes<[P5600IssueFPUS]>;
275 def P5600WriteMSAOther3 : SchedWriteRes<[P5600IssueFPUS]> { let Latency = 3; }
276 def P5600WriteMSALongInt : SchedWriteRes<[P5600IssueFPUS]> { let Latency = 5; }
278 // vshf.[bhwd], binsl.[bhwd], binsr.[bhwd], insert.[bhwd], sld?.[bhwd],
279 // bset.[bhwd], bclr.[bhwd], bneg.[bhwd], bsel_v, bseli_b
280 def : InstRW<[P5600WriteMSAShortInt], (instregex "^VSHF_[BHWD]$")>;
281 def : InstRW<[P5600WriteMSAShortInt], (instregex "^(BINSL|BINSLI)_[BHWD]$")>;
282 def : InstRW<[P5600WriteMSAShortInt], (instregex "^(BINSR|BINSRI)_[BHWD]$")>;
283 def : InstRW<[P5600WriteMSAShortInt], (instregex "^INSERT_[BHWD]$")>;
284 def : InstRW<[P5600WriteMSAShortInt], (instregex "^(SLD|SLDI)_[BHWD]$")>;
285 def : InstRW<[P5600WriteMSAShortInt], (instregex "^(BSET|BSETI)_[BHWD]$")>;
286 def : InstRW<[P5600WriteMSAShortInt], (instregex "^(BCLR|BCLRI)_[BHWD]$")>;
287 def : InstRW<[P5600WriteMSAShortInt], (instregex "^(BNEG|BNEGI)_[BHWD]$")>;
288 def : InstRW<[P5600WriteMSAShortInt], (instregex "^(BSEL_V|BSELI_B)$")>;
289 def : InstRW<[P5600WriteMSAShortInt], (instregex "^BMN*Z.*$")>;
291 // pcnt.[bhwd], sat_s.[bhwd], sat_u.bhwd]
292 def : InstRW<[P5600WriteMSAOther3], (instregex "^PCNT_[BHWD]$")>;
293 def : InstRW<[P5600WriteMSAOther3], (instregex "^SAT_(S|U)_[BHWD]$")>;
295 // bnz.[bhwdv], cfcmsa, ctcmsa
296 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(BNZ|BZ)_[BHWDV]$")>;
297 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^C(F|T)CMSA$")>;
299 // FPUS is also used in moves from floating point and MSA registers to general
300 // purpose registers.
301 def P5600WriteMoveFPUSToOtherUnits : SchedWriteRes<[P5600IssueFPUS]> {
305 // FPUL is also used in moves from floating point and MSA registers to general
306 // purpose registers.
307 def P5600WriteMoveFPULToOtherUnits : SchedWriteRes<[P5600IssueFPUL]>;
312 // abs.[ds], abs.ps, bc1[tf]l?, mov[tf].[ds], mov[tf], mov.[ds], [cm][ft]c1,
313 // m[ft]hc1, neg.[ds], neg.ps, nor.v, nori.b, or.v, ori.b, xor.v, xori.b,
314 // sdxc1, sdc1, st.[bhwd], swc1, swxc1
315 def : InstRW<[P5600WriteFPUS], (instrs FABS_S, FABS_D32, FABS_D64, MOVF_D32,
316 MOVF_D64, MOVF_S, MOVT_D32, MOVT_D64,
317 MOVT_S, FMOV_D32, FMOV_D64, FMOV_S, FNEG_S,
318 FNEG_D32, FNEG_D64)>;
320 // adds_a.[bhwd], adds_[asu].[bhwd], addvi?.[bhwd], asub_[us].[bhwd],
321 // aver?_[us].[bhwd], shf.[bhw], fill[bhwd], splat?.[bhwd]
322 def : InstRW<[P5600WriteMSAShortInt], (instregex "^ADD_A_[BHWD]$")>;
323 def : InstRW<[P5600WriteMSAShortInt], (instregex "^ADDS_[ASU]_[BHWD]$")>;
324 // TODO: ADDVI_[BHW] might be 1 cycle latency rather than 2. Need to confirm it.
325 def : InstRW<[P5600WriteMSAShortInt], (instregex "^ADDVI?_[BHWD]$")>;
326 def : InstRW<[P5600WriteMSAShortInt], (instregex "^ASUB_[US].[BHWD]$")>;
327 def : InstRW<[P5600WriteMSAShortInt], (instregex "^AVER?_[US].[BHWD]$")>;
328 def : InstRW<[P5600WriteMSAShortInt], (instregex "^SHF_[BHW]$")>;
329 def : InstRW<[P5600WriteMSAShortInt], (instregex "^FILL_[BHWD]$")>;
330 def : InstRW<[P5600WriteMSAShortInt], (instregex "^(SPLAT|SPLATI)_[BHWD]$")>;
332 // and.v, andi.b, move.v, ldi.[bhwd]
333 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^MOVE_V$")>;
334 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^LDI_[BHWD]$")>;
335 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(AND|OR|[XN]OR)_V$")>;
336 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(AND|OR|[XN]OR)I_B$")>;
339 def : InstRW<[P5600WriteFPUS], (instregex "^FEXP2_(W|D)$")>;
341 // compare, converts, round to int, floating point truncate.
342 def : InstRW<[P5600WriteFPUS], (instregex "^(CLT|CLTI)_(S|U)_[BHWD]$")>;
343 def : InstRW<[P5600WriteFPUS], (instregex "^(CLE|CLEI)_(S|U)_[BHWD]$")>;
344 def : InstRW<[P5600WriteFPUS], (instregex "^(CEQ|CEQI)_[BHWD]$")>;
345 def : InstRW<[P5600WriteFPUS], (instregex "^CMP_UN_(S|D)$")>;
346 def : InstRW<[P5600WriteFPUS], (instregex "^CMP_UEQ_(S|D)$")>;
347 def : InstRW<[P5600WriteFPUS], (instregex "^CMP_EQ_(S|D)$")>;
348 def : InstRW<[P5600WriteFPUS], (instregex "^CMP_LT_(S|D)$")>;
349 def : InstRW<[P5600WriteFPUS], (instregex "^CMP_ULT_(S|D)$")>;
350 def : InstRW<[P5600WriteFPUS], (instregex "^CMP_LE_(S|D)$")>;
351 def : InstRW<[P5600WriteFPUS], (instregex "^CMP_ULE_(S|D)$")>;
352 def : InstRW<[P5600WriteFPUS], (instregex "^FS(AF|EQ|LT|LE|NE|OR)_(W|D)$")>;
353 def : InstRW<[P5600WriteFPUS], (instregex "^FSUEQ_(W|D)$")>;
354 def : InstRW<[P5600WriteFPUS], (instregex "^FSULE_(W|D)$")>;
355 def : InstRW<[P5600WriteFPUS], (instregex "^FSULT_(W|D)$")>;
356 def : InstRW<[P5600WriteFPUS], (instregex "^FSUNE_(W|D)$")>;
357 def : InstRW<[P5600WriteFPUS], (instregex "^FSUN_(W|D)$")>;
358 def : InstRW<[P5600WriteFPUS], (instregex "^FCAF_(W|D)$")>;
359 def : InstRW<[P5600WriteFPUS], (instregex "^FCEQ_(W|D)$")>;
360 def : InstRW<[P5600WriteFPUS], (instregex "^FCLE_(W|D)$")>;
361 def : InstRW<[P5600WriteFPUS], (instregex "^FCLT_(W|D)$")>;
362 def : InstRW<[P5600WriteFPUS], (instregex "^FCNE_(W|D)$")>;
363 def : InstRW<[P5600WriteFPUS], (instregex "^FCOR_(W|D)$")>;
364 def : InstRW<[P5600WriteFPUS], (instregex "^FCUEQ_(W|D)$")>;
365 def : InstRW<[P5600WriteFPUS], (instregex "^FCULE_(W|D)$")>;
366 def : InstRW<[P5600WriteFPUS], (instregex "^FCULT_(W|D)$")>;
367 def : InstRW<[P5600WriteFPUS], (instregex "^FCUNE_(W|D)$")>;
368 def : InstRW<[P5600WriteFPUS], (instregex "^FCUN_(W|D)$")>;
369 def : InstRW<[P5600WriteFPUS], (instregex "^FABS_(W|D)$")>;
370 def : InstRW<[P5600WriteFPUS], (instregex "^FFINT_(U|S)_(W|D)$")>;
371 def : InstRW<[P5600WriteFPUS], (instregex "^FFQL_(W|D)$")>;
372 def : InstRW<[P5600WriteFPUS], (instregex "^FFQR_(W|D)$")>;
373 def : InstRW<[P5600WriteFPUS], (instregex "^FTINT_(U|S)_(W|D)$")>;
374 def : InstRW<[P5600WriteFPUS], (instregex "^FRINT_(W|D)$")>;
375 def : InstRW<[P5600WriteFPUS], (instregex "^FTQ_(H|W)$")>;
376 def : InstRW<[P5600WriteFPUS], (instregex "^FTRUNC_(U|S)_(W|D)$")>;
378 // fexdo.[hw], fexupl.[wd], fexupr.[wd]
379 def : InstRW<[P5600WriteFPUS], (instregex "^FEXDO_(H|W)$")>;
380 def : InstRW<[P5600WriteFPUS], (instregex "^FEXUPL_(W|D)$")>;
381 def : InstRW<[P5600WriteFPUS], (instregex "^FEXUPR_(W|D)$")>;
383 // fclass.[wd], fmax.[wd], fmax_a.[wd], fmin.[wd], fmin_a.[wd], flog2.[wd]
384 def : InstRW<[P5600WriteFPUS], (instregex "^FCLASS_(W|D)$")>;
385 def : InstRW<[P5600WriteFPUS], (instregex "^FMAX_A_(W|D)$")>;
386 def : InstRW<[P5600WriteFPUS], (instregex "^FMAX_(W|D)$")>;
387 def : InstRW<[P5600WriteFPUS], (instregex "^FMIN_A_(W|D)$")>;
388 def : InstRW<[P5600WriteFPUS], (instregex "^FMIN_(W|D)$")>;
389 def : InstRW<[P5600WriteFPUS], (instregex "^FLOG2_(W|D)$")>;
391 // interleave right/left, interleave even/odd, insert
392 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(ILVR|ILVL)_[BHWD]$")>;
393 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(ILVEV|ILVOD)_[BHWD]$")>;
394 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^INSVE_[BHWD]$")>;
396 // subs_?.[bhwd], subsus_?.[bhwd], subsuu_?.[bhwd], subvi.[bhwd], subv.[bhwd],
397 def : InstRW<[P5600WriteMSAShortInt], (instregex "^SUBS_(S|U)_[BHWD]$")>;
398 def : InstRW<[P5600WriteMSAShortInt], (instregex "^SUBSUS_(S|U)_[BHWD]$")>;
399 def : InstRW<[P5600WriteMSAShortInt], (instregex "^SUBSUU_(S|U)_[BHWD]$")>;
400 def : InstRW<[P5600WriteMSAShortInt], (instregex "^SUBVI_[BHWD]$")>;
401 def : InstRW<[P5600WriteMSAShortInt], (instregex "^SUBV_[BHWD]$")>;
403 // mod_[su].[bhwd], div_[su].[bhwd]
404 def : InstRW<[P5600WriteFPUDivI], (instregex "^MOD_(S|U)_[BHWD]$")>;
405 def : InstRW<[P5600WriteFPUDivI], (instregex "^DIV_(S|U)_[BHWD]$")>;
407 // hadd_[su].[bhwd], hsub_[su].[bhwd], max_[sua].[bhwd], min_[sua].[bhwd],
408 // maxi_[su].[bhwd], mini_[su].[bhwd], sra?.[bhwd], srar?.[bhwd], srlr.[bhwd],
409 // sll?.[bhwd], pckev.[bhwd], pckod.[bhwd], nloc.[bhwd], nlzc.[bhwd],
411 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^HADD_(S|U)_[BHWD]$")>;
412 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^HSUB_(S|U)_[BHWD]$")>;
413 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(MAX|MIN)_S_[BHWD]$")>;
414 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(MAX|MIN)_U_[BHWD]$")>;
415 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(MAX|MIN)_A_[BHWD]$")>;
416 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(MAXI|MINI)_(S|U)_[BHWD]$")>;
417 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(SRA|SRAI)_[BHWD]$")>;
418 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(SRL|SRLI)_[BHWD]$")>;
419 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(SRAR|SRARI)_[BHWD]$")>;
420 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(SRLR|SRLRI)_[BHWD]$")>;
421 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(SLL|SLLI)_[BHWD]$")>;
422 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(PCKEV|PCKOD)_[BHWD]$")>;
423 def : InstRW<[P5600WriteMSAShortLogic], (instregex "^(NLOC|NLZC)_[BHWD]$")>;
428 // add.[ds], add.ps, cvt.d.[sw], cvt.s.[dw], cvt.w.[sd], cvt.[sw].ps,
429 // cvt.ps.[sw], c.<cc>.[ds], c.<cc>.ps, mul.[ds], mul.ps, sub.[ds], sub.ps,
430 // trunc.w.[ds], trunc.w.ps
431 def : InstRW<[P5600WriteFPUL],
432 (instrs FADD_D32, FADD_D64, FADD_S, FMUL_D32, FMUL_D64, FMUL_S,
433 FSUB_D32, FSUB_D64, FSUB_S)>;
434 def : InstRW<[P5600WriteFPUL], (instregex "^TRUNC_(L|W)_(S|D32|D64)$")>;
435 def : InstRW<[P5600WriteFPUL],
436 (instregex "^CVT_(S|D32|D64|L|W)_(S|D32|D64|L|W)$")>;
437 def : InstRW<[P5600WriteFPUL], (instregex "^C_[A-Z]+_(S|D32|D64)$")>;
438 def : InstRW<[P5600WriteFPUL], (instregex "^FCMP_(S32|D32|D64)$")>;
439 def : InstRW<[P5600WriteFPUL], (instregex "^PseudoCVT_(S|D32|D64)_(L|W)$")>;
442 def : InstRW<[P5600WriteFPUDivS], (instrs FDIV_S)>;
443 def : InstRW<[P5600WriteFPUDivD], (instrs FDIV_D32, FDIV_D64)>;
445 // sqrt.[ds], sqrt.ps
446 def : InstRW<[P5600WriteFPUSqrtS], (instrs FSQRT_S)>;
447 def : InstRW<[P5600WriteFPUSqrtD], (instrs FSQRT_D32, FSQRT_D64)>;
449 // frcp.[wd], frsqrt.[wd]
450 def : InstRW<[P5600WriteFPURsqrtD], (instregex "^FRCP_(W|D)$")>;
451 def : InstRW<[P5600WriteFPURsqrtD], (instregex "^FRSQRT_(W|D)$")>;
453 def : InstRW<[P5600WriteFPURsqrtD], (instrs RECIP_D32, RECIP_D64, RSQRT_D32,
455 def : InstRW<[P5600WriteFPURsqrtS], (instrs RECIP_S, RSQRT_S)>;
457 // fmadd.[wd], fmsubb.[wd], fdiv.[wd], fsqrt.[wd], fmul.[wd], fadd.[wd],
459 def : InstRW<[P5600WriteFPUL_MADDSUB], (instregex "^FMADD_(W|D)$")>;
460 def : InstRW<[P5600WriteFPUL_MADDSUB], (instregex "^FMSUB_(W|D)$")>;
461 def : InstRW<[P5600WriteFPUDivS], (instregex "^FDIV_W$")>;
462 def : InstRW<[P5600WriteFPUDivD], (instregex "^FDIV_D$")>;
463 def : InstRW<[P5600WriteFPUSqrtS], (instregex "^FSQRT_W$")>;
464 def : InstRW<[P5600WriteFPUSqrtD], (instregex "^FSQRT_D$")>;
465 def : InstRW<[P5600WriteFPUL], (instregex "^FMUL_(W|D)$")>;
466 def : InstRW<[P5600WriteFPUL], (instregex "^FADD_(W|D)$")>;
467 def : InstRW<[P5600WriteFPUL], (instregex "^FSUB_(W|D)$")>;
469 // dpadd_?.[bhwd], dpsub_?.[bhwd], dotp_?.[bhwd], msubv.[bhwd], maddv.[bhwd]
471 def : InstRW<[P5600WriteMSALongInt], (instregex "^DPADD_(S|U)_[HWD]$")>;
472 def : InstRW<[P5600WriteMSALongInt], (instregex "^DPSUB_(S|U)_[HWD]$")>;
473 def : InstRW<[P5600WriteMSALongInt], (instregex "^DOTP_(S|U)_[HWD]$")>;
474 def : InstRW<[P5600WriteMSALongInt], (instregex "^MSUBV_[BHWD]$")>;
475 def : InstRW<[P5600WriteMSALongInt], (instregex "^MADDV_[BHWD]$")>;
476 def : InstRW<[P5600WriteMSALongInt], (instregex "^MULV_[BHWD]$")>;
478 def : InstRW<[P5600WriteMSALongInt], (instregex "^MADDR_Q_[HW]$")>;
479 def : InstRW<[P5600WriteMSALongInt], (instregex "^MADD_Q_[HW]$")>;
480 def : InstRW<[P5600WriteMSALongInt], (instregex "^MSUBR_Q_[HW]$")>;
481 def : InstRW<[P5600WriteMSALongInt], (instregex "^MSUB_Q_[HW]$")>;
482 def : InstRW<[P5600WriteMSALongInt], (instregex "^MULR_Q_[HW]$")>;
483 def : InstRW<[P5600WriteMSALongInt], (instregex "^MUL_Q_[HW]$")>;
485 // madd.[ds], msub.[ds], nmadd.[ds], nmsub.[ds],
486 // Operand 0 is read on cycle 5. All other operands are read on operand 0.
487 def : InstRW<[SchedReadAdvance<5>, P5600WriteFPUL_MADDSUB],
488 (instrs MADD_D32, MADD_D64, MADD_S, MSUB_D32, MSUB_D64, MSUB_S,
489 NMADD_D32, NMADD_D64, NMADD_S, NMSUB_D32, NMSUB_D64, NMSUB_S)>;
491 // madd.ps, msub.ps, nmadd.ps, nmsub.ps
492 // Operand 0 and 1 are read on cycle 5. All others are read on operand 0.
493 // (none of these instructions exist in the backend yet)
498 // This is typically used in conjunction with the load pipeline under the AGQ
499 // All the instructions are in the 'Tricky Instructions' section.
501 def P5600WriteLoadOtherUnitsToFPU : SchedWriteRes<[P5600IssueFPULoad]> {
505 // Tricky Instructions
506 // ===================
508 // These instructions are split across multiple uops (in different pipelines)
509 // that must cooperate to complete the operation
511 // FIXME: This isn't quite right since the implementation of WriteSequence
512 // current aggregates the resources and ignores the exact cycle they are
514 def P5600WriteMoveGPRToFPU : WriteSequence<[P5600WriteMoveGPRToOtherUnits,
515 P5600WriteMoveOtherUnitsToFPU]>;
517 // FIXME: This isn't quite right since the implementation of WriteSequence
518 // current aggregates the resources and ignores the exact cycle they are
520 def P5600WriteMoveFPUToGPR : WriteSequence<[P5600WriteMoveFPUSToOtherUnits,
521 P5600WriteGPRFromBypass]>;
523 // FIXME: This isn't quite right since the implementation of WriteSequence
524 // current aggregates the resources and ignores the exact cycle they are
526 def P5600WriteStoreFPUS : WriteSequence<[P5600WriteMoveFPUSToOtherUnits,
527 P5600WriteStoreFromOtherUnits]>;
529 // FIXME: This isn't quite right since the implementation of WriteSequence
530 // current aggregates the resources and ignores the exact cycle they are
532 def P5600WriteStoreFPUL : WriteSequence<[P5600WriteMoveFPULToOtherUnits,
533 P5600WriteStoreFromOtherUnits]>;
535 // FIXME: This isn't quite right since the implementation of WriteSequence
536 // current aggregates the resources and ignores the exact cycle they are
538 def P5600WriteLoadFPU : WriteSequence<[P5600WriteLoadToOtherUnits,
539 P5600WriteLoadOtherUnitsToFPU]>;
542 def : InstRW<[P5600WriteMoveGPRToFPU], (instrs CTC1, MTC1, MTC1_D64, MTHC1_D32,
543 MTHC1_D64, BuildPairF64,
547 def : InstRW<[P5600WriteMoveFPUToGPR], (instregex "^COPY_U_[BHW]$")>;
548 def : InstRW<[P5600WriteMoveFPUToGPR], (instregex "^COPY_S_[BHWD]$")>;
550 // bc1[ft], cfc1, mfc1, mfhc1, movf, movt
551 def : InstRW<[P5600WriteMoveFPUToGPR], (instrs BC1F, BC1FL, BC1T, BC1TL, CFC1,
552 MFC1, MFC1_D64, MFHC1_D32, MFHC1_D64,
553 MOVF_I, MOVT_I, ExtractElementF64,
554 ExtractElementF64_64)>;
556 // swc1, swxc1, st.[bhwd]
557 def : InstRW<[P5600WriteStoreFPUS], (instrs SDC1, SDXC1, SUXC1, SWC1, SWXC1)>;
558 def : InstRW<[P5600WriteStoreFPUS], (instregex "^ST_[BHWD]$")>;
560 // movn.[ds], movz.[ds]
561 def : InstRW<[P5600WriteStoreFPUL], (instrs MOVN_I_D32, MOVN_I_D64, MOVN_I_S,
562 MOVZ_I_D32, MOVZ_I_D64, MOVZ_I_S)>;
564 // l[dw]x?c1, ld.[bhwd]
565 def : InstRW<[P5600WriteLoadFPU], (instrs LDC1, LDXC1, LWC1, LWXC1, LUXC1)>;
566 def : InstRW<[P5600WriteLoadFPU], (instregex "LD_[BHWD]")>;
568 // Unsupported Instructions
569 // ========================
571 // The following instruction classes are never valid on P5600.
572 // II_DADDIU, II_DADDU, II_DMFC1, II_DMTC1, II_DMULT, II_DMULTU, II_DROTR,
573 // II_DROTR32, II_DROTRV, II_DDIV, II_DSLL, II_DSLL32, II_DSLLV, II_DSRA,
574 // II_DSRA32, II_DSRAV, II_DSRL, II_DSRL32, II_DSRLV, II_DSUBU, II_DDIVU,
575 // II_JALRC, II_LD, II_LD[LR], II_RESTORE, II_SAVE, II_SD, II_SDC1, II_SD[LR]
577 // The following instructions are never valid on P5600.
578 // addq.ph, repl.ph, repl.qb, subq.ph, subu_s.qb
583 // This section is largely temporary guesswork.
585 // ceil.[lw].[ds], floor.[lw].[ds]
586 // Reason behind guess: trunc.[lw].ds and the various cvt's are in FPUL
587 def : InstRW<[P5600WriteFPUL], (instregex "^CEIL_(L|W)_(S|D32|D64)$")>;
588 def : InstRW<[P5600WriteFPUL], (instregex "^FLOOR_(L|W)_(S|D32|D64)$")>;
589 def : InstRW<[P5600WriteFPUL], (instregex "^ROUND_(L|W)_(S|D32|D64)$")>;
592 // Reason behind guess: rotr is in the same category and the two register forms
593 // generally follow the immediate forms in this category
594 def : InstRW<[P5600WriteEitherALU], (instrs ROTRV)>;