1 //===-- SISchedule.td - SI Scheduling definitons -------------------------===//
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 // MachineModel definitions for Southern Islands (SI)
11 //===----------------------------------------------------------------------===//
13 def : PredicateProlog<[{
14 const SIInstrInfo *TII =
15 static_cast<const SIInstrInfo*>(SchedModel->getInstrInfo());
19 def WriteBranch : SchedWrite;
20 def WriteExport : SchedWrite;
21 def WriteLDS : SchedWrite;
22 def WriteSALU : SchedWrite;
23 def WriteSMEM : SchedWrite;
24 def WriteVMEM : SchedWrite;
25 def WriteBarrier : SchedWrite;
27 // Vector ALU instructions
28 def Write32Bit : SchedWrite;
29 def WriteQuarterRate32 : SchedWrite;
30 def WriteFullOrQuarterRate32 : SchedWrite;
32 def WriteFloatFMA : SchedWrite;
34 // Slow quarter rate f64 instruction.
35 def WriteDouble : SchedWrite;
37 // half rate f64 instruction (same as v_add_f64)
38 def WriteDoubleAdd : SchedWrite;
40 // Half rate 64-bit instructions.
41 def Write64Bit : SchedWrite;
43 // FIXME: Should there be a class for instructions which are VALU
44 // instructions and have VALU rates, but write to the SALU (i.e. VOPC
47 class SISchedMachineModel : SchedMachineModel {
48 let CompleteModel = 0;
49 // MicroOpBufferSize = 1 means that instructions will always be added
50 // the ready queue when they become available. This exposes them
51 // to the register pressure analysis.
52 let MicroOpBufferSize = 1;
54 let PostRAScheduler = 1;
56 // FIXME:Approximate 2 * branch cost. Try to hack around bad
57 // early-ifcvt heuristics. These need improvement to avoid the OOE
59 int MispredictPenalty = 20;
62 def SIFullSpeedModel : SISchedMachineModel;
63 def SIQuarterSpeedModel : SISchedMachineModel;
65 // XXX: Are the resource counts correct?
66 def HWBranch : ProcResource<1> {
69 def HWExport : ProcResource<1> {
70 let BufferSize = 7; // Taken from S_WAITCNT
72 def HWLGKM : ProcResource<1> {
73 let BufferSize = 31; // Taken from S_WAITCNT
75 def HWSALU : ProcResource<1> {
78 def HWVMEM : ProcResource<1> {
79 let BufferSize = 15; // Taken from S_WAITCNT
81 def HWVALU : ProcResource<1> {
85 class HWWriteRes<SchedWrite write, list<ProcResourceKind> resources,
86 int latency> : WriteRes<write, resources> {
87 let Latency = latency;
90 class HWVALUWriteRes<SchedWrite write, int latency> :
91 HWWriteRes<write, [HWVALU], latency>;
94 // The latency numbers are taken from AMD Accelerated Parallel Processing
95 // guide. They may not be accurate.
97 // The latency values are 1 / (operations / cycle) / 4.
98 multiclass SICommonWriteRes {
100 def : HWWriteRes<WriteBranch, [HWBranch], 8>;
101 def : HWWriteRes<WriteExport, [HWExport], 4>;
102 def : HWWriteRes<WriteLDS, [HWLGKM], 5>; // Can be between 2 and 64
103 def : HWWriteRes<WriteSALU, [HWSALU], 1>;
104 def : HWWriteRes<WriteSMEM, [HWLGKM], 5>;
105 def : HWWriteRes<WriteVMEM, [HWVMEM], 80>;
106 def : HWWriteRes<WriteBarrier, [HWBranch], 500>; // XXX: Guessed ???
108 def : HWVALUWriteRes<Write32Bit, 1>;
109 def : HWVALUWriteRes<Write64Bit, 2>;
110 def : HWVALUWriteRes<WriteQuarterRate32, 4>;
113 def PredIsVGPR32Copy : SchedPredicate<[{TII->isVGPRCopy(*MI) && TII->getOpSize(*MI, 0) <= 32}]>;
114 def PredIsVGPR64Copy : SchedPredicate<[{TII->isVGPRCopy(*MI) && TII->getOpSize(*MI, 0) > 32}]>;
115 def WriteCopy : SchedWriteVariant<[
116 SchedVar<PredIsVGPR32Copy, [Write32Bit]>,
117 SchedVar<PredIsVGPR64Copy, [Write64Bit]>,
118 SchedVar<NoSchedPred, [WriteSALU]>]>;
120 let SchedModel = SIFullSpeedModel in {
122 defm : SICommonWriteRes;
124 def : HWVALUWriteRes<WriteFloatFMA, 1>;
125 def : HWVALUWriteRes<WriteDouble, 4>;
126 def : HWVALUWriteRes<WriteDoubleAdd, 2>;
128 def : InstRW<[WriteCopy], (instrs COPY)>;
130 } // End SchedModel = SIFullSpeedModel
132 let SchedModel = SIQuarterSpeedModel in {
134 defm : SICommonWriteRes;
136 def : HWVALUWriteRes<WriteFloatFMA, 16>;
137 def : HWVALUWriteRes<WriteDouble, 16>;
138 def : HWVALUWriteRes<WriteDoubleAdd, 8>;
140 def : InstRW<[WriteCopy], (instrs COPY)>;
142 } // End SchedModel = SIQuarterSpeedModel