41 IsHazardRecognizerMode(
false),
42 CurrCycleInstr(nullptr),
45 TII(*
ST.getInstrInfo()),
46 TRI(
TII.getRegisterInfo()),
47 ClauseUses(
TRI.getNumRegUnits()),
48 ClauseDefs(
TRI.getNumRegUnits()) {
50 TSchedModel.
init(&ST);
62 return Opcode == AMDGPU::V_DIV_FMAS_F32 || Opcode == AMDGPU::V_DIV_FMAS_F64;
66 return Opcode == AMDGPU::S_GETREG_B32;
70 return Opcode == AMDGPU::S_SETREG_B32 || Opcode == AMDGPU::S_SETREG_IMM32_B32;
74 return Opcode == AMDGPU::V_READLANE_B32 || Opcode == AMDGPU::V_WRITELANE_B32;
77 static bool isRFE(
unsigned Opcode) {
78 return Opcode == AMDGPU::S_RFE_B64;
83 case AMDGPU::S_MOVRELS_B32:
84 case AMDGPU::S_MOVRELS_B64:
85 case AMDGPU::S_MOVRELD_B32:
86 case AMDGPU::S_MOVRELD_B64:
99 case AMDGPU::S_SENDMSG:
100 case AMDGPU::S_SENDMSGHALT:
101 case AMDGPU::S_TTRACEDATA:
105 case AMDGPU::DS_PERMUTE_B32:
106 case AMDGPU::DS_BPERMUTE_B32:
111 AMDGPU::OpName::gds);
121 return Opcode == AMDGPU::V_PERMLANE16_B32 ||
122 Opcode == AMDGPU::V_PERMLANEX16_B32;
127 AMDGPU::OpName::simm16);
143 && checkVMEMHazards(MI) > 0)
149 if (checkFPAtomicToDenormModeHazard(MI) > 0)
178 checkReadM0Hazards(MI) > 0)
182 checkReadM0Hazards(MI) > 0)
191 if (MI->
isInlineAsm() && checkInlineAsmHazards(MI) > 0)
194 if (checkAnyInstHazards(MI) > 0)
205 void GCNHazardRecognizer::processBundle() {
209 for (; MI != E && MI->isInsideBundle(); ++
MI) {
210 CurrCycleInstr = &*
MI;
213 if (IsHazardRecognizerMode)
214 fixHazards(CurrCycleInstr);
216 for (
unsigned i = 0; i < WaitStates; ++i)
222 for (
unsigned i = 0,
e = std::min(WaitStates,
MaxLookAhead - 1); i <
e; ++i)
223 EmittedInstrs.push_front(
nullptr);
225 EmittedInstrs.push_front(CurrCycleInstr);
228 CurrCycleInstr =
nullptr;
232 IsHazardRecognizerMode =
false;
237 IsHazardRecognizerMode =
true;
241 CurrCycleInstr =
nullptr;
249 int WaitStates =
std::max(0, checkAnyInstHazards(MI));
252 return std::max(WaitStates, checkSMRDHazards(MI));
255 WaitStates =
std::max(WaitStates, checkVMEMHazards(MI));
258 WaitStates =
std::max(WaitStates, checkNSAtoVMEMHazard(MI));
260 WaitStates =
std::max(WaitStates, checkFPAtomicToDenormModeHazard(MI));
266 WaitStates =
std::max(WaitStates, checkVALUHazards(MI));
269 WaitStates =
std::max(WaitStates, checkDPPHazards(MI));
272 WaitStates =
std::max(WaitStates, checkDivFMasHazards(MI));
275 WaitStates =
std::max(WaitStates, checkRWLaneHazards(MI));
278 return std::max(WaitStates, checkInlineAsmHazards(MI));
281 return std::max(WaitStates, checkGetRegHazards(MI));
284 return std::max(WaitStates, checkSetRegHazards(MI));
287 return std::max(WaitStates, checkRFEHazards(MI));
291 return std::max(WaitStates, checkReadM0Hazards(MI));
294 return std::max(WaitStates, checkReadM0Hazards(MI));
297 return std::max(WaitStates, checkMAIHazards(MI));
300 return std::max(WaitStates, checkMAILdStHazards(MI));
306 EmittedInstrs.push_front(
nullptr);
330 EmittedInstrs.push_front(CurrCycleInstr);
337 EmittedInstrs.push_front(
nullptr);
345 CurrCycleInstr =
nullptr;
349 llvm_unreachable(
"hazard recognizer does not support bottom-up scheduling.");
375 if (I->isInlineAsm() || I->isImplicitDef() || I->isDebugInstr())
380 if (IsExpired(&*I, WaitStates))
384 int MinWaitStates = WaitStates;
387 if (!Visited.
insert(Pred).second)
390 int W = getWaitStatesSince(IsHazard, Pred, Pred->instr_rbegin(),
391 WaitStates, IsExpired, Visited);
396 MinWaitStates = Found ? std::min(MinWaitStates, W) :
W;
397 if (IsExpired(
nullptr, MinWaitStates))
398 return MinWaitStates;
404 return MinWaitStates;
413 return getWaitStatesSince(IsHazard, MI->
getParent(),
415 0, IsExpired, Visited);
418 int GCNHazardRecognizer::getWaitStatesSince(
IsHazardFn IsHazard,
int Limit) {
419 if (IsHazardRecognizerMode) {
421 return WaitStates >= Limit;
432 if (
MI->isInlineAsm())
437 if (WaitStates >= Limit)
443 int GCNHazardRecognizer::getWaitStatesSinceDef(
unsigned Reg,
449 return IsHazardDef(
MI) &&
MI->modifiesRegister(Reg, TRI);
455 int GCNHazardRecognizer::getWaitStatesSinceSetReg(
IsHazardFn IsHazard,
489 int GCNHazardRecognizer::checkSoftClauseHazards(
MachineInstr *MEM) {
495 bool IsSMRD = TII.
isSMRD(*MEM);
521 if (ClauseDefs.
none())
534 return ClauseDefs.
anyCommon(ClauseUses) ? 1 : 0;
538 int WaitStatesNeeded = 0;
540 WaitStatesNeeded = checkSoftClauseHazards(SMRD);
544 return WaitStatesNeeded;
548 int SmrdSgprWaitStates = 4;
557 int WaitStatesNeededForUse =
558 SmrdSgprWaitStates - getWaitStatesSinceDef(
Use.getReg(), IsHazardDefFn,
560 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
570 int WaitStatesNeededForUse =
571 SmrdSgprWaitStates - getWaitStatesSinceDef(
Use.getReg(),
574 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
578 return WaitStatesNeeded;
581 int GCNHazardRecognizer::checkVMEMHazards(
MachineInstr* VMEM) {
585 int WaitStatesNeeded = checkSoftClauseHazards(VMEM);
589 const int VmemSgprWaitStates = 5;
595 int WaitStatesNeededForUse =
596 VmemSgprWaitStates - getWaitStatesSinceDef(
Use.getReg(), IsHazardDefFn,
598 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
600 return WaitStatesNeeded;
608 int DppVgprWaitStates = 2;
609 int DppExecWaitStates = 5;
610 int WaitStatesNeeded = 0;
616 int WaitStatesNeededForUse =
617 DppVgprWaitStates - getWaitStatesSinceDef(
Use.getReg(),
620 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
625 DppExecWaitStates - getWaitStatesSinceDef(AMDGPU::EXEC, IsHazardDefFn,
628 return WaitStatesNeeded;
631 int GCNHazardRecognizer::checkDivFMasHazards(
MachineInstr *DivFMas) {
636 const int DivFMasWaitStates = 4;
638 int WaitStatesNeeded = getWaitStatesSinceDef(AMDGPU::VCC, IsHazardDefFn,
641 return DivFMasWaitStates - WaitStatesNeeded;
644 int GCNHazardRecognizer::checkGetRegHazards(
MachineInstr *GetRegInstr) {
646 unsigned GetRegHWReg =
getHWReg(TII, *GetRegInstr);
648 const int GetRegWaitStates = 2;
650 return GetRegHWReg ==
getHWReg(TII, *MI);
652 int WaitStatesNeeded = getWaitStatesSinceSetReg(
IsHazardFn, GetRegWaitStates);
654 return GetRegWaitStates - WaitStatesNeeded;
657 int GCNHazardRecognizer::checkSetRegHazards(
MachineInstr *SetRegInstr) {
659 unsigned HWReg =
getHWReg(TII, *SetRegInstr);
665 int WaitStatesNeeded = getWaitStatesSinceSetReg(
IsHazardFn, SetRegWaitStates);
666 return SetRegWaitStates - WaitStatesNeeded;
669 int GCNHazardRecognizer::createsVALUHazard(
const MachineInstr &MI) {
694 (!SOffset || !SOffset->
isReg()))
724 const int VALUWaitStates = 1;
725 int WaitStatesNeeded = 0;
728 return WaitStatesNeeded;
731 int DataIdx = createsVALUHazard(*MI);
732 return DataIdx >= 0 &&
735 int WaitStatesNeededForDef =
736 VALUWaitStates - getWaitStatesSince(
IsHazardFn, VALUWaitStates);
737 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForDef);
739 return WaitStatesNeeded;
749 int WaitStatesNeeded = 0;
752 WaitStatesNeeded =
std::max(WaitStatesNeeded, checkVALUHazardsHelper(Def, MRI));
755 return WaitStatesNeeded;
758 int GCNHazardRecognizer::checkInlineAsmHazards(
MachineInstr *IA) {
771 int WaitStatesNeeded = 0;
777 WaitStatesNeeded =
std::max(WaitStatesNeeded, checkVALUHazardsHelper(Op, MRI));
781 return WaitStatesNeeded;
784 int GCNHazardRecognizer::checkRWLaneHazards(
MachineInstr *RWLane) {
800 const int RWLaneWaitStates = 4;
801 int WaitStatesSince = getWaitStatesSinceDef(LaneSelectReg,
IsHazardFn,
803 return RWLaneWaitStates - WaitStatesSince;
806 int GCNHazardRecognizer::checkRFEHazards(
MachineInstr *RFE) {
812 const int RFEWaitStates = 1;
817 int WaitStatesNeeded = getWaitStatesSinceSetReg(
IsHazardFn, RFEWaitStates);
818 return RFEWaitStates - WaitStatesNeeded;
821 int GCNHazardRecognizer::checkAnyInstHazards(
MachineInstr *MI) {
831 int MovFedWaitStates = 1;
832 int WaitStatesNeeded = 0;
838 return MI->
getOpcode() == AMDGPU::S_MOV_FED_B32;
840 int WaitStatesNeededForUse =
841 MovFedWaitStates - getWaitStatesSinceDef(
Use.getReg(),
IsHazardFn,
843 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
846 return WaitStatesNeeded;
849 int GCNHazardRecognizer::checkReadM0Hazards(
MachineInstr *MI) {
851 const int SMovRelWaitStates = 1;
855 return SMovRelWaitStates - getWaitStatesSinceDef(AMDGPU::M0,
IsHazardFn,
859 void GCNHazardRecognizer::fixHazards(
MachineInstr *MI) {
860 fixVMEMtoScalarWriteHazards(MI);
861 fixVcmpxPermlaneHazards(MI);
862 fixSMEMtoVectorWriteHazards(MI);
863 fixVcmpxExecWARHazard(MI);
864 fixLdsBranchVmemWARHazard(MI);
867 bool GCNHazardRecognizer::fixVcmpxPermlaneHazards(
MachineInstr *MI) {
881 Opc != AMDGPU::V_NOP_e32 &&
882 Opc != AMDGPU::V_NOP_e64 &&
883 Opc != AMDGPU::V_NOP_sdwa;
895 bool IsUndef = Src0->isUndef();
897 TII->get(AMDGPU::V_MOV_B32_e32))
904 bool GCNHazardRecognizer::fixVMEMtoScalarWriteHazards(
MachineInstr *MI) {
945 bool GCNHazardRecognizer::fixSMEMtoVectorWriteHazards(
MachineInstr *MI) {
954 case AMDGPU::V_READLANE_B32:
955 case AMDGPU::V_READLANE_B32_gfx10:
956 case AMDGPU::V_READFIRSTLANE_B32:
957 SDSTName = AMDGPU::OpName::vdst;
960 SDSTName = AMDGPU::OpName::sdst;
980 const Register SDSTReg = SDST->getReg();
988 switch (MI->getOpcode()) {
989 case AMDGPU::S_SETVSKIP:
990 case AMDGPU::S_VERSION:
991 case AMDGPU::S_WAITCNT_VSCNT:
992 case AMDGPU::S_WAITCNT_VMCNT:
993 case AMDGPU::S_WAITCNT_EXPCNT:
996 case AMDGPU::S_WAITCNT_LGKMCNT:
998 return (MI->getOperand(1).getImm() == 0) &&
999 (MI->getOperand(0).getReg() == AMDGPU::SGPR_NULL);
1000 case AMDGPU::S_WAITCNT: {
1001 const int64_t Imm = MI->getOperand(0).getImm();
1003 return (Decoded.LgkmCnt == 0);
1027 BuildMI(*MI->getParent(),
MI, MI->getDebugLoc(),
1028 TII->get(AMDGPU::S_MOV_B32), AMDGPU::SGPR_NULL)
1033 bool GCNHazardRecognizer::fixVcmpxExecWARHazard(
MachineInstr *MI) {
1044 return I->readsRegister(AMDGPU::EXEC, TRI);
1054 for (
auto MO : MI->implicit_operands())
1058 if (MI->getOpcode() == AMDGPU::S_WAITCNT_DEPCTR &&
1059 (MI->getOperand(0).getImm() & 0xfffe) == 0xfffe)
1068 BuildMI(*MI->getParent(),
MI, MI->getDebugLoc(),
1069 TII->get(AMDGPU::S_WAITCNT_DEPCTR))
1074 bool GCNHazardRecognizer::fixLdsBranchVmemWARHazard(
MachineInstr *MI) {
1086 auto InstType = IsHazardInst(MI);
1091 return I && (IsHazardInst(I) ||
1092 (I->
getOpcode() == AMDGPU::S_WAITCNT_VSCNT &&
1102 auto InstType2 = IsHazardInst(I);
1103 return InstType2 && InstType != InstType2;
1110 auto InstType2 = IsHazardInst(I);
1111 if (InstType == InstType2)
1114 return I->getOpcode() == AMDGPU::S_WAITCNT_VSCNT &&
1115 I->getOperand(0).getReg() == AMDGPU::SGPR_NULL &&
1116 !I->getOperand(1).getImm();
1129 TII->get(AMDGPU::S_WAITCNT_VSCNT))
1136 int GCNHazardRecognizer::checkNSAtoVMEMHazard(
MachineInstr *MI) {
1137 int NSAtoVMEMWaitStates = 1;
1154 return Info->
MIMGEncoding == AMDGPU::MIMGEncGfx10NSA &&
1158 return NSAtoVMEMWaitStates - getWaitStatesSince(
IsHazardFn, 1);
1161 int GCNHazardRecognizer::checkFPAtomicToDenormModeHazard(
MachineInstr *MI) {
1162 int FPAtomicToDenormModeWaitStates = 3;
1164 if (MI->
getOpcode() != AMDGPU::S_DENORM_MODE)
1178 case AMDGPU::S_WAITCNT:
1179 case AMDGPU::S_WAITCNT_VSCNT:
1180 case AMDGPU::S_WAITCNT_VMCNT:
1181 case AMDGPU::S_WAITCNT_EXPCNT:
1182 case AMDGPU::S_WAITCNT_LGKMCNT:
1183 case AMDGPU::S_WAITCNT_IDLE:
1193 return FPAtomicToDenormModeWaitStates -
1197 int GCNHazardRecognizer::checkMAIHazards(
MachineInstr *MI) {
1200 int WaitStatesNeeded = 0;
1207 if (Opc != AMDGPU::V_ACCVGPR_READ_B32) {
1208 const int LegacyVALUWritesVGPRWaitStates = 2;
1209 const int VALUWritesExecWaitStates = 4;
1210 const int MaxWaitStates = 4;
1212 int WaitStatesNeededForUse = VALUWritesExecWaitStates -
1213 getWaitStatesSinceDef(AMDGPU::EXEC, IsVALUFn, MaxWaitStates);
1214 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
1216 if (WaitStatesNeeded < MaxWaitStates) {
1218 const int MaxWaitStates = 2;
1223 int WaitStatesNeededForUse = LegacyVALUWritesVGPRWaitStates -
1224 getWaitStatesSinceDef(
Use.getReg(), IsVALUFn, MaxWaitStates);
1225 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
1227 if (WaitStatesNeeded == MaxWaitStates)
1235 MI->
getOpcode() != AMDGPU::V_ACCVGPR_WRITE_B32 &&
1236 MI->
getOpcode() != AMDGPU::V_ACCVGPR_READ_B32;
1243 if (
Op.isDef() && Opc != AMDGPU::V_ACCVGPR_WRITE_B32)
1246 const int MFMAWritesAGPROverlappedSrcABWaitStates = 4;
1247 const int MFMAWritesAGPROverlappedSrcCWaitStates = 2;
1248 const int MFMA4x4WritesAGPRAccVgprReadWaitStates = 4;
1249 const int MFMA16x16WritesAGPRAccVgprReadWaitStates = 10;
1250 const int MFMA32x32WritesAGPRAccVgprReadWaitStates = 18;
1251 const int MFMA4x4WritesAGPRAccVgprWriteWaitStates = 1;
1252 const int MFMA16x16WritesAGPRAccVgprWriteWaitStates = 7;
1253 const int MFMA32x32WritesAGPRAccVgprWriteWaitStates = 15;
1254 const int MaxWaitStates = 18;
1256 unsigned HazardDefLatency = 0;
1258 auto IsOverlappedMFMAFn = [
Reg, &IsMFMAFn, &HazardDefLatency,
this]
1265 HazardDefLatency =
std::max(HazardDefLatency,
1266 TSchedModel.computeInstrLatency(MI));
1267 return TRI.regsOverlap(DstReg, Reg);
1270 int WaitStatesSinceDef = getWaitStatesSinceDef(Reg, IsOverlappedMFMAFn,
1272 int NeedWaitStates = MFMAWritesAGPROverlappedSrcABWaitStates;
1275 if (OpNo == SrcCIdx) {
1276 NeedWaitStates = MFMAWritesAGPROverlappedSrcCWaitStates;
1277 }
else if (Opc == AMDGPU::V_ACCVGPR_READ_B32) {
1278 switch (HazardDefLatency) {
1279 case 2: NeedWaitStates = MFMA4x4WritesAGPRAccVgprReadWaitStates;
1281 case 8: NeedWaitStates = MFMA16x16WritesAGPRAccVgprReadWaitStates;
1284 default: NeedWaitStates = MFMA32x32WritesAGPRAccVgprReadWaitStates;
1287 }
else if (Opc == AMDGPU::V_ACCVGPR_WRITE_B32) {
1288 switch (HazardDefLatency) {
1289 case 2: NeedWaitStates = MFMA4x4WritesAGPRAccVgprWriteWaitStates;
1291 case 8: NeedWaitStates = MFMA16x16WritesAGPRAccVgprWriteWaitStates;
1294 default: NeedWaitStates = MFMA32x32WritesAGPRAccVgprWriteWaitStates;
1299 int WaitStatesNeededForUse = NeedWaitStates - WaitStatesSinceDef;
1300 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
1302 if (WaitStatesNeeded == MaxWaitStates)
1303 return WaitStatesNeeded;
1306 if (MI->
getOpcode() != AMDGPU::V_ACCVGPR_WRITE_B32)
1309 return TRI.regsOverlap(Reg, DstReg);
1312 const int AccVGPRWriteMFMAReadSrcCWaitStates = 1;
1313 const int AccVGPRWriteMFMAReadSrcABWaitStates = 3;
1314 const int AccVGPRWriteAccVgprReadWaitStates = 3;
1315 NeedWaitStates = AccVGPRWriteMFMAReadSrcABWaitStates;
1316 if (OpNo == SrcCIdx)
1317 NeedWaitStates = AccVGPRWriteMFMAReadSrcCWaitStates;
1318 else if (Opc == AMDGPU::V_ACCVGPR_READ_B32)
1319 NeedWaitStates = AccVGPRWriteAccVgprReadWaitStates;
1321 WaitStatesNeededForUse = NeedWaitStates -
1322 getWaitStatesSinceDef(Reg, IsAccVgprWriteFn, MaxWaitStates);
1323 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
1325 if (WaitStatesNeeded == MaxWaitStates)
1326 return WaitStatesNeeded;
1329 if (Opc == AMDGPU::V_ACCVGPR_WRITE_B32) {
1330 const int MFMA4x4ReadSrcCAccVgprWriteWaitStates = 0;
1331 const int MFMA16x16ReadSrcCAccVgprWriteWaitStates = 5;
1332 const int MFMA32x32ReadSrcCAccVgprWriteWaitStates = 13;
1333 const int MaxWaitStates = 13;
1335 unsigned HazardDefLatency = 0;
1337 auto IsSrcCMFMAFn = [DstReg, &IsMFMAFn, &HazardDefLatency,
this]
1342 HazardDefLatency =
std::max(HazardDefLatency,
1343 TSchedModel.computeInstrLatency(MI));
1344 return TRI.regsOverlap(Reg, DstReg);
1347 int WaitStatesSince = getWaitStatesSince(IsSrcCMFMAFn, MaxWaitStates);
1349 switch (HazardDefLatency) {
1350 case 2: NeedWaitStates = MFMA4x4ReadSrcCAccVgprWriteWaitStates;
1352 case 8: NeedWaitStates = MFMA16x16ReadSrcCAccVgprWriteWaitStates;
1355 default: NeedWaitStates = MFMA32x32ReadSrcCAccVgprWriteWaitStates;
1359 int WaitStatesNeededForUse = NeedWaitStates - WaitStatesSince;
1360 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
1363 return WaitStatesNeeded;
1366 int GCNHazardRecognizer::checkMAILdStHazards(
MachineInstr *MI) {
1370 int WaitStatesNeeded = 0;
1373 return MI->
getOpcode() == AMDGPU::V_ACCVGPR_READ_B32;
1382 const int AccVgprReadLdStWaitStates = 2;
1383 const int VALUWriteAccVgprReadLdStDepVALUWaitStates = 1;
1384 const int MaxWaitStates = 2;
1386 int WaitStatesNeededForUse = AccVgprReadLdStWaitStates -
1387 getWaitStatesSinceDef(Reg, IsAccVgprReadFn, MaxWaitStates);
1388 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
1390 if (WaitStatesNeeded == MaxWaitStates)
1391 return WaitStatesNeeded;
1394 if (MI->
getOpcode() != AMDGPU::V_ACCVGPR_READ_B32)
1399 return getWaitStatesSinceDef(Reg, IsVALUFn, 2 ) <
1403 WaitStatesNeededForUse = VALUWriteAccVgprReadLdStDepVALUWaitStates -
1404 getWaitStatesSince(IsVALUAccVgprReadCheckFn, MaxWaitStates);
1405 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
1408 return WaitStatesNeeded;
static bool isSMovRel(unsigned Opcode)
Interface definition for SIRegisterInfo.
AMDGPU specific subclass of TargetSubtarget.
instr_iterator instr_end()
LLVM_READONLY const MIMGInfo * getMIMGInfo(unsigned Opc)
bool hasSMRDReadVALUDefHazard() const
A read of an SGPR by SMRD instruction requires 4 wait states when the SGPR was written by a VALU inst...
This class represents lattice values for constants.
iterator_range< mop_iterator > uses()
Returns a range that includes all operands that are register uses.
bool hasReadM0MovRelInterpHazard() const
iterator_range< mop_iterator > explicit_operands()
Implements a dense probed hash-table based set.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Describe properties that are true of each instruction in the target description file.
static bool isVINTRP(const MachineInstr &MI)
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
bool hasNSAtoVMEMBug() const
unsigned getRegBitWidth(unsigned RCID)
Get the size in bits of a register from the register class RC.
An efficient, type-erasing, non-owning reference to a callable.
bool hasVcmpxPermlaneHazard() const
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
static bool isRFE(unsigned Opcode)
const SIInstrInfo * getInstrInfo() const override
static void addRegUnits(const SIRegisterInfo &TRI, BitVector &BV, unsigned Reg)
unsigned const TargetRegisterInfo * TRI
bool isAGPR(const MachineRegisterInfo &MRI, unsigned Reg) const
static bool isSOPP(const MachineInstr &MI)
static bool isSMRD(const MachineInstr &MI)
function_ref< bool(MachineInstr *)> IsHazardFn
LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx)
void EmitNoop() override
EmitNoop - This callback is invoked when a noop was added to the instruction stream.
static bool isDS(const MachineInstr &MI)
static bool isFLAT(const MachineInstr &MI)
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
const HexagonInstrInfo * TII
bool isAlwaysGDS(uint16_t Opcode) const
bool isSGPRReg(const MachineRegisterInfo &MRI, unsigned Reg) const
unsigned getNumOperands() const
Retuns the total number of operands.
static bool isMIMG(const MachineInstr &MI)
A Use represents the edge between a Value definition and its users.
bool hasLdsBranchVmemWARHazard() const
static bool isFPAtomic(const MachineInstr &MI)
bool hasSMovFedHazard() const
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
static bool isVALU(const MachineInstr &MI)
bool isSGPRClass(const TargetRegisterClass *RC) const
static bool isPermlane(const MachineInstr &MI)
bool isVGPR(const MachineRegisterInfo &MRI, unsigned Reg) const
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
static bool isSendMsgTraceDataOrGDS(const SIInstrInfo &TII, const MachineInstr &MI)
static bool isMUBUF(const MachineInstr &MI)
unsigned getSetRegWaitStates() const
Number of hazard wait states for s_setreg_b32/s_setreg_imm32_b32.
static bool isSSetReg(unsigned Opcode)
LLVM_READONLY MachineOperand * getNamedOperand(MachineInstr &MI, unsigned OperandName) const
Returns the operand named Op.
unsigned PreEmitNoops(SUnit *SU) override
PreEmitNoops - This callback is invoked prior to emitting an instruction.
bool hasVMEMtoScalarWriteHazard() const
function_ref< bool(MachineInstr *, int WaitStates)> IsExpiredFn
bool hasNoDataDepHazard() const
bool isBranch(QueryType Type=AnyInBundle) const
Returns true if this is a conditional, unconditional, or indirect branch.
void RecedeCycle() override
RecedeCycle - This callback is invoked whenever the next bottom-up instruction to be scheduled cannot...
Analysis containing CSE Info
void EmitInstruction(SUnit *SU) override
EmitInstruction - This callback is invoked when an instruction is emitted, to advance the hazard stat...
unsigned MaxLookAhead
MaxLookAhead - Indicate the number of cycles in the scoreboard state.
static bool isDPP(const MachineInstr &MI)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
static void addRegsToSet(const SIRegisterInfo &TRI, iterator_range< MachineInstr::const_mop_iterator > Ops, BitVector &Set)
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
unsigned const MachineRegisterInfo * MRI
unsigned getMaxLookAhead() const
bool anyCommon(const BitVector &RHS) const
Test if any common bits are set.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static void insertNoopInBundle(MachineInstr *MI, const SIInstrInfo &TII)
std::pair< iterator, bool > insert(const ValueT &V)
static int getWaitStatesSince(GCNHazardRecognizer::IsHazardFn IsHazard, MachineBasicBlock *MBB, MachineBasicBlock::reverse_instr_iterator I, int WaitStates, IsExpiredFn IsExpired, DenseSet< const MachineBasicBlock *> &Visited)
bool hasSMEMtoVectorWriteHazard() const
iterator_range< mop_iterator > defs()
Returns a range over all explicit operands that are register definitions.
self_iterator getIterator()
iterator_range< pred_iterator > predecessors()
void init(const TargetSubtargetInfo *TSInfo)
Initialize the machine model for instruction scheduling.
bool isImplicitDef() const
static unsigned getNumWaitStates(const MachineInstr &MI)
Return the number of wait states that result from executing this instruction.
bool isDebugInstr() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool hasVMEMReadSGPRVALUDefHazard() const
A read of an SGPR by a VMEM instruction requires 5 wait states when the SGPR was written by a VALU In...
iterator_range< mop_iterator > explicit_uses()
IsaVersion getIsaVersion(StringRef GPU)
bool hasVcmpxExecWARHazard() const
Iterator for intrusive lists based on ilist_node.
bool hasRFEHazards() const
Align max(MaybeAlign Lhs, Align Rhs)
static bool isSALU(const MachineInstr &MI)
HazardType getHazardType(SUnit *SU, int Stalls) override
getHazardType - Return the hazard type of emitting this node.
MachineOperand class - Representation of each machine instruction operand.
bool modifiesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
GCNHazardRecognizer(const MachineFunction &MF)
reverse_instr_iterator instr_rend()
bool isPhysRegUsed(unsigned PhysReg) const
Return true if the specified register is modified or read in this function.
A range adaptor for a pair of iterators.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
void AdvanceCycle() override
AdvanceCycle - This callback is invoked whenever the next top-down instruction to be scheduled cannot...
iterator_range< mop_iterator > implicit_operands()
static bool isSegmentSpecificFLAT(const MachineInstr &MI)
static bool isRWLane(unsigned Opcode)
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
bool none() const
none - Returns true if none of the bits are set.
Provides AMDGPU specific target descriptions.
Representation of each machine instruction.
Interface definition for SIInstrInfo.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
reverse_self_iterator getReverseIterator()
static bool isMTBUF(const MachineInstr &MI)
bool has12DWordStoreHazard() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static bool isVOPC(const MachineInstr &MI)
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
static bool isMAI(const MachineInstr &MI)
bool isXNACKEnabled() const
static bool isVMEM(const MachineInstr &MI)
unsigned getNumDefs() const
Returns the total number of definitions.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isSGetReg(unsigned Opcode)
const TargetRegisterClass * getPhysRegClass(unsigned Reg) const
Return the 'base' register class for this register.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
const MCOperandInfo * OpInfo
Register getReg() const
getReg - Returns the register number.
static unsigned getHWReg(const SIInstrInfo *TII, const MachineInstr &RegInstr)
const MachineOperand & getOperand(unsigned i) const
bool hasReadM0SendMsgHazard() const
bool isBufferSMRD(const MachineInstr &MI) const
Scheduling unit. This is a node in the scheduling DAG.
Wrapper class representing virtual and physical registers.
unsigned PreEmitNoopsCommon(MachineInstr *)
void decodeWaitcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned &Vmcnt, unsigned &Expcnt, unsigned &Lgkmcnt)
Decodes Vmcnt, Expcnt and Lgkmcnt from given Waitcnt for given isa Version, and writes decoded values...
const SIRegisterInfo * getRegisterInfo() const override
static bool isDivFMas(unsigned Opcode)