2012-12-12 05:25:42 +08:00
|
|
|
//===-- SISchedule.td - SI Scheduling definitons -------------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-12-12 05:25:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2015-01-14 09:13:19 +08:00
|
|
|
// MachineModel definitions for Southern Islands (SI)
|
2012-12-12 05:25:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-06-25 07:52:11 +08:00
|
|
|
def : PredicateProlog<[{
|
|
|
|
const SIInstrInfo *TII =
|
|
|
|
static_cast<const SIInstrInfo*>(SchedModel->getInstrInfo());
|
|
|
|
(void)TII;
|
|
|
|
}]>;
|
|
|
|
|
2015-01-14 09:13:19 +08:00
|
|
|
def WriteBranch : SchedWrite;
|
|
|
|
def WriteExport : SchedWrite;
|
|
|
|
def WriteLDS : SchedWrite;
|
|
|
|
def WriteSALU : SchedWrite;
|
|
|
|
def WriteSMEM : SchedWrite;
|
|
|
|
def WriteVMEM : SchedWrite;
|
2015-09-09 03:54:32 +08:00
|
|
|
def WriteBarrier : SchedWrite;
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2019-07-12 05:25:00 +08:00
|
|
|
def MIVGPRRead : SchedRead;
|
|
|
|
def MIMFMARead : SchedRead;
|
|
|
|
|
2015-01-14 09:13:19 +08:00
|
|
|
// Vector ALU instructions
|
|
|
|
def Write32Bit : SchedWrite;
|
|
|
|
def WriteQuarterRate32 : SchedWrite;
|
|
|
|
|
|
|
|
def WriteFloatFMA : SchedWrite;
|
|
|
|
|
2015-09-26 00:58:25 +08:00
|
|
|
// Slow quarter rate f64 instruction.
|
|
|
|
def WriteDouble : SchedWrite;
|
|
|
|
|
|
|
|
// half rate f64 instruction (same as v_add_f64)
|
2015-01-14 09:13:19 +08:00
|
|
|
def WriteDoubleAdd : SchedWrite;
|
|
|
|
|
2019-04-25 01:03:15 +08:00
|
|
|
// Conversion to or from f64 instruction
|
|
|
|
def WriteDoubleCvt : SchedWrite;
|
|
|
|
|
2015-09-26 00:58:25 +08:00
|
|
|
// Half rate 64-bit instructions.
|
|
|
|
def Write64Bit : SchedWrite;
|
|
|
|
|
2019-07-12 05:25:00 +08:00
|
|
|
// mAI multipass instructions.
|
|
|
|
def Write2PassMAI : SchedWrite;
|
|
|
|
def Write8PassMAI : SchedWrite;
|
|
|
|
def Write16PassMAI : SchedWrite;
|
|
|
|
|
2015-09-26 00:58:25 +08:00
|
|
|
// FIXME: Should there be a class for instructions which are VALU
|
|
|
|
// instructions and have VALU rates, but write to the SALU (i.e. VOPC
|
|
|
|
// instructions)
|
|
|
|
|
2016-03-31 00:35:13 +08:00
|
|
|
class SISchedMachineModel : SchedMachineModel {
|
2020-02-28 21:22:44 +08:00
|
|
|
let CompleteModel = 1;
|
2016-08-30 03:42:52 +08:00
|
|
|
// MicroOpBufferSize = 1 means that instructions will always be added
|
|
|
|
// the ready queue when they become available. This exposes them
|
|
|
|
// to the register pressure analysis.
|
|
|
|
let MicroOpBufferSize = 1;
|
2016-03-31 00:35:13 +08:00
|
|
|
let IssueWidth = 1;
|
2016-04-30 08:23:06 +08:00
|
|
|
let PostRAScheduler = 1;
|
2017-01-25 12:25:02 +08:00
|
|
|
|
|
|
|
// FIXME:Approximate 2 * branch cost. Try to hack around bad
|
|
|
|
// early-ifcvt heuristics. These need improvement to avoid the OOE
|
|
|
|
// heuristics.
|
|
|
|
int MispredictPenalty = 20;
|
2016-03-02 04:03:21 +08:00
|
|
|
}
|
2015-01-14 09:13:19 +08:00
|
|
|
|
2016-03-31 00:35:13 +08:00
|
|
|
def SIFullSpeedModel : SISchedMachineModel;
|
|
|
|
def SIQuarterSpeedModel : SISchedMachineModel;
|
2019-04-25 01:03:15 +08:00
|
|
|
def GFX10SpeedModel : SISchedMachineModel;
|
2015-01-14 09:13:19 +08:00
|
|
|
|
|
|
|
// XXX: Are the resource counts correct?
|
2016-03-31 00:35:13 +08:00
|
|
|
def HWBranch : ProcResource<1> {
|
|
|
|
let BufferSize = 1;
|
|
|
|
}
|
|
|
|
def HWExport : ProcResource<1> {
|
|
|
|
let BufferSize = 7; // Taken from S_WAITCNT
|
|
|
|
}
|
|
|
|
def HWLGKM : ProcResource<1> {
|
|
|
|
let BufferSize = 31; // Taken from S_WAITCNT
|
|
|
|
}
|
|
|
|
def HWSALU : ProcResource<1> {
|
|
|
|
let BufferSize = 1;
|
|
|
|
}
|
|
|
|
def HWVMEM : ProcResource<1> {
|
|
|
|
let BufferSize = 15; // Taken from S_WAITCNT
|
|
|
|
}
|
|
|
|
def HWVALU : ProcResource<1> {
|
|
|
|
let BufferSize = 1;
|
2015-01-14 09:13:19 +08:00
|
|
|
}
|
2019-04-25 01:03:15 +08:00
|
|
|
def HWRC : ProcResource<1> { // Register destination cache
|
|
|
|
let BufferSize = 1;
|
|
|
|
}
|
2015-01-14 09:13:19 +08:00
|
|
|
|
|
|
|
class HWWriteRes<SchedWrite write, list<ProcResourceKind> resources,
|
|
|
|
int latency> : WriteRes<write, resources> {
|
|
|
|
let Latency = latency;
|
|
|
|
}
|
|
|
|
|
|
|
|
class HWVALUWriteRes<SchedWrite write, int latency> :
|
|
|
|
HWWriteRes<write, [HWVALU], latency>;
|
|
|
|
|
2019-07-12 05:25:00 +08:00
|
|
|
def PredMIReadVGPR : SchedPredicate<[{TII->hasVGPRUses(*MI)}]>;
|
|
|
|
|
|
|
|
def MIReadVGPR : SchedReadVariant<[
|
|
|
|
SchedVar<PredMIReadVGPR, [MIVGPRRead]>,
|
|
|
|
SchedVar<NoSchedPred, [ReadDefault]>]>;
|
2015-01-14 09:13:19 +08:00
|
|
|
|
|
|
|
// The latency numbers are taken from AMD Accelerated Parallel Processing
|
2015-09-26 00:58:25 +08:00
|
|
|
// guide. They may not be accurate.
|
2015-01-14 09:13:19 +08:00
|
|
|
|
|
|
|
// The latency values are 1 / (operations / cycle) / 4.
|
|
|
|
multiclass SICommonWriteRes {
|
|
|
|
|
2016-03-31 00:35:13 +08:00
|
|
|
def : HWWriteRes<WriteBranch, [HWBranch], 8>;
|
|
|
|
def : HWWriteRes<WriteExport, [HWExport], 4>;
|
|
|
|
def : HWWriteRes<WriteLDS, [HWLGKM], 5>; // Can be between 2 and 64
|
|
|
|
def : HWWriteRes<WriteSALU, [HWSALU], 1>;
|
|
|
|
def : HWWriteRes<WriteSMEM, [HWLGKM], 5>;
|
|
|
|
def : HWWriteRes<WriteVMEM, [HWVMEM], 80>;
|
2015-09-09 03:54:32 +08:00
|
|
|
def : HWWriteRes<WriteBarrier, [HWBranch], 500>; // XXX: Guessed ???
|
2015-01-14 09:13:19 +08:00
|
|
|
|
|
|
|
def : HWVALUWriteRes<Write32Bit, 1>;
|
2015-09-26 00:58:25 +08:00
|
|
|
def : HWVALUWriteRes<Write64Bit, 2>;
|
2015-01-14 09:13:19 +08:00
|
|
|
def : HWVALUWriteRes<WriteQuarterRate32, 4>;
|
2019-07-12 05:25:00 +08:00
|
|
|
def : HWVALUWriteRes<Write2PassMAI, 2>;
|
|
|
|
def : HWVALUWriteRes<Write8PassMAI, 8>;
|
|
|
|
def : HWVALUWriteRes<Write16PassMAI, 16>;
|
|
|
|
|
|
|
|
def : ReadAdvance<MIVGPRRead, -2>;
|
|
|
|
def : InstRW<[Write64Bit, MIReadVGPR], (instregex "^V_ACCVGPR_WRITE_B32$")>;
|
|
|
|
|
|
|
|
// Technicaly mfma reads can be from 0 to 4 cycles but that does not make
|
|
|
|
// sense to model because its register setup is huge. In particular if we
|
|
|
|
// properly model read advanice as -2 for a vgpr read it will result in a
|
|
|
|
// bad scheduling of acc writes before that mfma. To avoid it we would
|
|
|
|
// need to consume 2 or 4 more vgprs to be initialized before the acc
|
|
|
|
// write sequence. Just assume worst case here.
|
|
|
|
def : ReadAdvance<MIMFMARead, -4>;
|
|
|
|
|
|
|
|
def : InstRW<[Write2PassMAI, MIMFMARead], (instregex "^V_MFMA_..._4X4X")>;
|
|
|
|
def : InstRW<[Write8PassMAI, MIMFMARead], (instregex "^V_MFMA_..._16X16X")>;
|
|
|
|
def : InstRW<[Write16PassMAI, MIMFMARead], (instregex "^V_MFMA_..._32X32X")>;
|
2015-01-14 09:13:19 +08:00
|
|
|
}
|
|
|
|
|
2016-06-25 07:52:11 +08:00
|
|
|
def PredIsVGPR32Copy : SchedPredicate<[{TII->isVGPRCopy(*MI) && TII->getOpSize(*MI, 0) <= 32}]>;
|
|
|
|
def PredIsVGPR64Copy : SchedPredicate<[{TII->isVGPRCopy(*MI) && TII->getOpSize(*MI, 0) > 32}]>;
|
|
|
|
def WriteCopy : SchedWriteVariant<[
|
|
|
|
SchedVar<PredIsVGPR32Copy, [Write32Bit]>,
|
|
|
|
SchedVar<PredIsVGPR64Copy, [Write64Bit]>,
|
|
|
|
SchedVar<NoSchedPred, [WriteSALU]>]>;
|
2015-01-14 09:13:19 +08:00
|
|
|
|
|
|
|
let SchedModel = SIFullSpeedModel in {
|
|
|
|
|
|
|
|
defm : SICommonWriteRes;
|
|
|
|
|
|
|
|
def : HWVALUWriteRes<WriteFloatFMA, 1>;
|
|
|
|
def : HWVALUWriteRes<WriteDouble, 4>;
|
|
|
|
def : HWVALUWriteRes<WriteDoubleAdd, 2>;
|
2019-04-25 01:03:15 +08:00
|
|
|
def : HWVALUWriteRes<WriteDoubleCvt, 4>;
|
2015-01-14 09:13:19 +08:00
|
|
|
|
2016-06-25 07:52:11 +08:00
|
|
|
def : InstRW<[WriteCopy], (instrs COPY)>;
|
|
|
|
|
2015-01-14 09:13:19 +08:00
|
|
|
} // End SchedModel = SIFullSpeedModel
|
|
|
|
|
|
|
|
let SchedModel = SIQuarterSpeedModel in {
|
|
|
|
|
|
|
|
defm : SICommonWriteRes;
|
|
|
|
|
|
|
|
def : HWVALUWriteRes<WriteFloatFMA, 16>;
|
|
|
|
def : HWVALUWriteRes<WriteDouble, 16>;
|
|
|
|
def : HWVALUWriteRes<WriteDoubleAdd, 8>;
|
2019-04-25 01:03:15 +08:00
|
|
|
def : HWVALUWriteRes<WriteDoubleCvt, 4>;
|
2015-01-14 09:13:19 +08:00
|
|
|
|
2016-06-25 07:52:11 +08:00
|
|
|
def : InstRW<[WriteCopy], (instrs COPY)>;
|
|
|
|
|
2015-01-14 09:13:19 +08:00
|
|
|
} // End SchedModel = SIQuarterSpeedModel
|
2019-04-25 01:03:15 +08:00
|
|
|
|
|
|
|
let SchedModel = GFX10SpeedModel in {
|
|
|
|
|
|
|
|
// The latency values are 1 / (operations / cycle).
|
|
|
|
// Add 1 stall cycle for VGPR read.
|
|
|
|
def : HWWriteRes<Write32Bit, [HWVALU, HWRC], 5>;
|
|
|
|
def : HWWriteRes<Write64Bit, [HWVALU, HWRC], 9>;
|
|
|
|
def : HWWriteRes<WriteQuarterRate32, [HWVALU, HWRC], 17>;
|
|
|
|
def : HWWriteRes<WriteFloatFMA, [HWVALU, HWRC], 5>;
|
|
|
|
def : HWWriteRes<WriteDouble, [HWVALU, HWRC], 17>;
|
|
|
|
def : HWWriteRes<WriteDoubleAdd, [HWVALU, HWRC], 17>;
|
|
|
|
def : HWWriteRes<WriteDoubleCvt, [HWVALU, HWRC], 17>;
|
|
|
|
|
|
|
|
def : HWWriteRes<WriteBranch, [HWBranch], 32>;
|
|
|
|
def : HWWriteRes<WriteExport, [HWExport, HWRC], 16>;
|
|
|
|
def : HWWriteRes<WriteLDS, [HWLGKM, HWRC], 20>;
|
|
|
|
def : HWWriteRes<WriteSALU, [HWSALU, HWRC], 5>;
|
|
|
|
def : HWWriteRes<WriteSMEM, [HWLGKM, HWRC], 20>;
|
|
|
|
def : HWWriteRes<WriteVMEM, [HWVMEM, HWRC], 320>;
|
|
|
|
def : HWWriteRes<WriteBarrier, [HWBranch], 2000>;
|
|
|
|
|
|
|
|
def : InstRW<[WriteCopy], (instrs COPY)>;
|
|
|
|
|
|
|
|
} // End SchedModel = GFX10SpeedModel
|