31 #define DEBUG_TYPE "si-insert-waitcnts"
41 #define CNT_MASK(t) (1u << (t))
45 typedef std::pair<signed, signed> RegInterval;
83 SQ_MAX_PGM_VGPRS = 256,
84 SQ_MAX_PGM_SGPRS = 256,
87 NUM_ALL_VGPRS = SQ_MAX_PGM_VGPRS + NUM_EXTRA_VGPRS,
90 #define ForAllWaitEventType(w) \
91 for (enum WaitEventType w = (enum WaitEventType)0; \
92 (w) < (enum WaitEventType)NUM_WAIT_EVENTS; \
93 (w) = (enum WaitEventType)((w) + 1))
102 class BlockWaitcntBrackets {
107 return HardwareLimits.VmcntMax;
109 return HardwareLimits.LgkmcntMax;
111 return HardwareLimits.ExpcntMax;
119 assert(T < NUM_INST_CNTS);
120 if (T >= NUM_INST_CNTS)
126 assert(T < NUM_INST_CNTS);
127 if (T >= NUM_INST_CNTS)
131 int32_t UB = (int)(ScoreUBs[T] - getWaitCountMax(
EXP_CNT));
132 if (ScoreLBs[T] < UB)
138 assert(T < NUM_INST_CNTS);
139 if (T >= NUM_INST_CNTS)
145 assert(T < NUM_INST_CNTS);
146 if (T >= NUM_INST_CNTS)
165 case EXP_PARAM_ACCESS:
170 return NUM_INST_CNTS;
174 if (GprNo < NUM_ALL_VGPRS) {
175 if (GprNo > VgprUB) {
178 VgprScores[
T][GprNo] = Val;
181 if (GprNo - NUM_ALL_VGPRS > SgprUB) {
182 SgprUB = GprNo - NUM_ALL_VGPRS;
184 SgprScores[GprNo - NUM_ALL_VGPRS] = Val;
189 if (GprNo < NUM_ALL_VGPRS) {
190 return VgprScores[
T][GprNo];
192 return SgprScores[GprNo - NUM_ALL_VGPRS];
196 memset(ScoreLBs, 0,
sizeof(ScoreLBs));
197 memset(ScoreUBs, 0,
sizeof(ScoreUBs));
198 memset(EventUBs, 0,
sizeof(EventUBs));
201 memset(VgprScores[T], 0,
sizeof(VgprScores[T]));
203 memset(SgprScores, 0,
sizeof(SgprScores));
213 unsigned OpNo, int32_t Val);
215 void setWaitAtBeginning() { WaitAtBeginning =
true; }
216 void clearWaitAtBeginning() { WaitAtBeginning =
false; }
217 bool getWaitAtBeginning()
const {
return WaitAtBeginning; }
218 void setEventUB(
enum WaitEventType W, int32_t Val) { EventUBs[W] = Val; }
219 int32_t getMaxVGPR()
const {
return VgprUB; }
220 int32_t getMaxSGPR()
const {
return SgprUB; }
222 assert(W < NUM_WAIT_EVENTS);
231 BlockWaitcntBrackets()
232 : WaitAtBeginning(
false), RevisitLoop(
false), ValidLoop(
false), MixedExpTypes(
false),
233 LoopRegion(NULL), PostOrder(0), Waitcnt(NULL), VgprUB(0), SgprUB(0) {
236 memset(VgprScores[T], 0,
sizeof(VgprScores[T]));
239 ~BlockWaitcntBrackets(){};
241 bool hasPendingSMEM()
const {
242 return (EventUBs[SMEM_ACCESS] > ScoreLBs[
LGKM_CNT] &&
243 EventUBs[SMEM_ACCESS] <= ScoreUBs[
LGKM_CNT]);
246 bool hasPendingFlat()
const {
253 void setPendingFlat() {
262 bool getRevisitLoop()
const {
return RevisitLoop; }
263 void setRevisitLoop(
bool RevisitLoopIn) { RevisitLoop = RevisitLoopIn; }
265 void setPostOrder(int32_t PostOrderIn) { PostOrder = PostOrderIn; }
266 int32_t getPostOrder()
const {
return PostOrder; }
268 void setWaitcnt(
MachineInstr *WaitcntIn) { Waitcnt = WaitcntIn; }
269 void clearWaitcnt() { Waitcnt = NULL; }
272 bool mixedExpTypes()
const {
return MixedExpTypes; }
273 void setMixedExpTypes(
bool MixedExpTypesIn) {
274 MixedExpTypes = MixedExpTypesIn;
281 bool WaitAtBeginning;
288 int32_t ScoreLBs[NUM_INST_CNTS] = {0};
289 int32_t ScoreUBs[NUM_INST_CNTS] = {0};
290 int32_t EventUBs[NUM_WAIT_EVENTS] = {0};
292 int32_t LastFlat[NUM_INST_CNTS] = {0};
297 int32_t VgprScores[NUM_INST_CNTS][NUM_ALL_VGPRS];
299 int32_t SgprScores[SQ_MAX_PGM_SGPRS] = {0};
307 class LoopWaitcntData {
309 void incIterCnt() { IterCnt++; }
310 void resetIterCnt() { IterCnt = 0; }
311 int32_t getIterCnt() {
return IterCnt; }
313 LoopWaitcntData() : LfWaitcnt(NULL), IterCnt(0) {}
314 ~LoopWaitcntData(){};
316 void setWaitcnt(
MachineInstr *WaitcntIn) { LfWaitcnt = WaitcntIn; }
320 DEBUG(
dbgs() <<
" iteration " << IterCnt <<
'\n';);
349 BlockWaitcntBracketsMap;
355 std::vector<std::unique_ptr<BlockWaitcntBrackets>> KillWaitBrackets;
362 MRI(nullptr), MLI(nullptr) {}
367 return "SI insert wait instructions";
376 void addKillWaitBracket(BlockWaitcntBrackets *Bracket) {
379 KillWaitBrackets.push_back(make_unique<BlockWaitcntBrackets>(*Bracket));
383 BlockWaitcntBrackets *ScoreBrackets);
385 BlockWaitcntBrackets *ScoreBrackets);
394 RegInterval BlockWaitcntBrackets::getRegInterval(
const MachineInstr *
MI,
401 if (!Op.
isReg() || !TRI->isInAllocatableClass(Op.
getReg()) ||
402 (Def && !Op.
isDef()))
412 unsigned Reg = TRI->getEncodingValue(Op.
getReg());
415 assert(Reg >= RegisterEncoding.VGPR0 && Reg <= RegisterEncoding.VGPRL);
416 Result.first = Reg - RegisterEncoding.VGPR0;
417 assert(Result.first >= 0 && Result.first < SQ_MAX_PGM_VGPRS);
419 assert(Reg >= RegisterEncoding.SGPR0 && Reg < SQ_MAX_PGM_SGPRS);
420 Result.first = Reg - RegisterEncoding.SGPR0 + NUM_ALL_VGPRS;
421 assert(Result.first >= NUM_ALL_VGPRS &&
422 Result.first < SQ_MAX_PGM_SGPRS + NUM_ALL_VGPRS);
431 unsigned Size = TRI->getRegSizeInBits(*RC);
432 Result.second = Result.first + (Size / 32);
437 void BlockWaitcntBrackets::setExpScore(
const MachineInstr *MI,
441 unsigned OpNo, int32_t Val) {
442 RegInterval
Interval = getRegInterval(MI, TII, MRI, TRI, OpNo,
false);
447 for (
signed RegNo = Interval.first; RegNo < Interval.second; ++RegNo) {
448 setRegScore(RegNo,
EXP_CNT, Val);
452 void BlockWaitcntBrackets::updateByEvent(
const SIInstrInfo *TII,
458 int32_t CurrScore = getScoreUB(T) + 1;
462 EventUBs[
E] = CurrScore;
463 setScoreUB(T, CurrScore);
468 if (!MixedExpTypes) {
469 MixedExpTypes = counterOutOfOrder(
EXP_CNT);
477 if (Inst.
getOpcode() != AMDGPU::DS_APPEND &&
478 Inst.
getOpcode() != AMDGPU::DS_CONSUME) {
480 &Inst, TII, TRI, MRI,
486 &Inst, TII, TRI, MRI,
490 AMDGPU::OpName::data1) != -1) {
491 setExpScore(&Inst, TII, TRI, MRI,
493 AMDGPU::OpName::data1),
497 Inst.
getOpcode() != AMDGPU::DS_GWS_INIT &&
498 Inst.
getOpcode() != AMDGPU::DS_GWS_SEMA_V &&
499 Inst.
getOpcode() != AMDGPU::DS_GWS_SEMA_BR &&
500 Inst.
getOpcode() != AMDGPU::DS_GWS_SEMA_P &&
501 Inst.
getOpcode() != AMDGPU::DS_GWS_BARRIER &&
503 Inst.
getOpcode() != AMDGPU::DS_CONSUME &&
504 Inst.
getOpcode() != AMDGPU::DS_ORDERED_COUNT) {
508 setExpScore(&Inst, TII, TRI, MRI,
I, CurrScore);
512 }
else if (TII->
isFLAT(Inst)) {
515 &Inst, TII, TRI, MRI,
520 &Inst, TII, TRI, MRI,
524 }
else if (TII->
isMIMG(Inst)) {
526 setExpScore(&Inst, TII, TRI, MRI, 0, CurrScore);
529 &Inst, TII, TRI, MRI,
533 }
else if (TII->
isMTBUF(Inst)) {
535 setExpScore(&Inst, TII, TRI, MRI, 0, CurrScore);
537 }
else if (TII->
isMUBUF(Inst)) {
539 setExpScore(&Inst, TII, TRI, MRI, 0, CurrScore);
542 &Inst, TII, TRI, MRI,
547 if (TII->
isEXP(Inst)) {
564 setExpScore(&Inst, TII, TRI, MRI,
I, CurrScore);
568 #if 0 // TODO: check if this is handled by MUBUF code above.
569 }
else if (Inst.
getOpcode() == AMDGPU::BUFFER_STORE_DWORD ||
570 Inst.
getOpcode() == AMDGPU::BUFFER_STORE_DWORDX2 ||
571 Inst.
getOpcode() == AMDGPU::BUFFER_STORE_DWORDX4) {
574 RegInterval Interval = getRegInterval(&Inst, TII, MRI, TRI, OpNo,
false);
575 for (
signed RegNo = Interval.first; RegNo < Interval.second;
577 setRegScore(RegNo + NUM_ALL_VGPRS,
t, CurrScore);
583 RegInterval Interval = getRegInterval(&Inst, TII, MRI, TRI,
I,
true);
584 if (T ==
VM_CNT && Interval.first >= NUM_ALL_VGPRS)
586 for (
signed RegNo = Interval.first; RegNo < Interval.second; ++RegNo) {
587 setRegScore(RegNo, T, CurrScore);
591 setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore);
596 void BlockWaitcntBrackets::print(
raw_ostream &OS) {
600 int LB = getScoreLB(T);
601 int UB = getScoreUB(T);
605 OS <<
" VM_CNT(" << UB - LB <<
"): ";
608 OS <<
" LGKM_CNT(" << UB - LB <<
"): ";
611 OS <<
" EXP_CNT(" << UB - LB <<
"): ";
614 OS <<
" UNKNOWN(" << UB - LB <<
"): ";
620 for (
int J = 0; J <= getMaxVGPR(); J++) {
621 int RegScore = getRegScore(J, T);
624 int RelScore = RegScore - LB - 1;
625 if (J < SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS) {
626 OS << RelScore <<
":v" << J <<
" ";
628 OS << RelScore <<
":ds ";
633 for (
int J = 0; J <= getMaxSGPR(); J++) {
634 int RegScore = getRegScore(J + NUM_ALL_VGPRS,
LGKM_CNT);
637 int RelScore = RegScore - LB - 1;
638 OS << RelScore <<
":s" << J <<
" ";
650 unsigned int NeedWait = 0;
651 if (ScoreToWait == -1) {
657 setScoreLB(T, getScoreUB(T));
663 const int32_t LB = getScoreLB(T);
664 const int32_t UB = getScoreUB(T);
665 if ((UB >= ScoreToWait) && (ScoreToWait > LB)) {
666 if (T ==
VM_CNT && hasPendingFlat()) {
670 setScoreLB(T, getScoreUB(T));
671 }
else if (counterOutOfOrder(T)) {
676 setScoreLB(T, getScoreUB(T));
679 setScoreLB(T, ScoreToWait);
693 if (EventUBs[SMEM_ACCESS] > ScoreLBs[
LGKM_CNT] &&
694 EventUBs[SMEM_ACCESS] <= ScoreUBs[
LGKM_CNT]) {
698 int NumEventTypes = 0;
699 if (EventUBs[LDS_ACCESS] > ScoreLBs[LGKM_CNT] &&
700 EventUBs[LDS_ACCESS] <= ScoreUBs[LGKM_CNT]) {
703 if (EventUBs[GDS_ACCESS] > ScoreLBs[LGKM_CNT] &&
704 EventUBs[GDS_ACCESS] <= ScoreUBs[LGKM_CNT]) {
707 if (EventUBs[SQ_MESSAGE] > ScoreLBs[LGKM_CNT] &&
708 EventUBs[SQ_MESSAGE] <= ScoreUBs[LGKM_CNT]) {
711 if (NumEventTypes <= 1) {
721 int NumEventTypes = 0;
722 if (EventUBs[EXP_GPR_LOCK] > ScoreLBs[
EXP_CNT] &&
723 EventUBs[EXP_GPR_LOCK] <= ScoreUBs[
EXP_CNT]) {
726 if (EventUBs[GDS_GPR_LOCK] > ScoreLBs[EXP_CNT] &&
727 EventUBs[GDS_GPR_LOCK] <= ScoreUBs[EXP_CNT]) {
730 if (EventUBs[VMW_GPR_LOCK] > ScoreLBs[EXP_CNT] &&
731 EventUBs[VMW_GPR_LOCK] <= ScoreUBs[EXP_CNT]) {
734 if (EventUBs[EXP_PARAM_ACCESS] > ScoreLBs[EXP_CNT] &&
735 EventUBs[EXP_PARAM_ACCESS] <= ScoreUBs[EXP_CNT]) {
739 if (EventUBs[EXP_POS_ACCESS] > ScoreLBs[EXP_CNT] &&
740 EventUBs[EXP_POS_ACCESS] <= ScoreUBs[EXP_CNT]) {
744 if (NumEventTypes <= 1) {
760 char SIInsertWaitcnts::
ID = 0;
765 return new SIInsertWaitcnts();
770 return (Opc == AMDGPU::S_CBRANCH_VCCNZ || Opc == AMDGPU::S_CBRANCH_VCCZ) &&
784 MachineInstr *SIInsertWaitcnts::generateSWaitCntInstBefore(
785 MachineInstr &MI, BlockWaitcntBrackets *ScoreBrackets) {
788 unsigned int EmitSwaitcnt = 0;
796 bool NeedLineMapping =
false;
805 if (ScoreBrackets->getWaitAtBeginning()) {
808 ScoreBrackets->clearWaitAtBeginning();
812 ScoreBrackets->setScoreLB(T, ScoreBrackets->getScoreUB(T));
818 else if (MI.
getOpcode() == AMDGPU::BUFFER_WBINVL1 ||
819 MI.
getOpcode() == AMDGPU::BUFFER_WBINVL1_SC ||
820 MI.
getOpcode() == AMDGPU::BUFFER_WBINVL1_VOL) {
822 ScoreBrackets->updateByWait(
VM_CNT, ScoreBrackets->getScoreUB(
VM_CNT));
829 MI.
getOpcode() == AMDGPU::SI_RETURN_TO_EPILOG ||
830 MI.
getOpcode() == AMDGPU::S_SETPC_B64_return) {
833 if (ScoreBrackets->getScoreUB(T) > ScoreBrackets->getScoreLB(T)) {
834 ScoreBrackets->setScoreLB(T, ScoreBrackets->getScoreUB(T));
840 else if ((MI.
getOpcode() == AMDGPU::S_SENDMSG ||
841 MI.
getOpcode() == AMDGPU::S_SENDMSGHALT) &&
844 if (ScoreBrackets->getScoreUB(
VM_CNT) > ScoreBrackets->getScoreLB(
VM_CNT)) {
845 ScoreBrackets->setScoreLB(
VM_CNT, ScoreBrackets->getScoreUB(
VM_CNT));
849 #if 0 // TODO: the following blocks of logic when we have fence.
851 const unsigned int group_size =
852 context->shader_info->GetMaxThreadGroupSize();
854 const bool group_is_multi_wave =
855 (group_size == 0 || group_size > target_info->GetWaveFrontSize());
856 const bool fence_is_global = !((SCInstInternalMisc*)Inst)->IsGroupFence();
858 for (
unsigned int i = 0; i < Inst->NumSrcOperands(); i++) {
859 SCRegType src_type = Inst->GetSrcType(i);
862 if (group_is_multi_wave ||
863 context->OptFlagIsOn(OPT_R1100_LDSMEM_FENCE_CHICKEN_BIT)) {
864 EmitSwaitcnt |= ScoreBrackets->updateByWait(LGKM_CNT,
865 ScoreBrackets->getScoreUB(LGKM_CNT));
867 if (target_info->HasBufferLoadToLDS()) {
868 EmitSwaitcnt |= ScoreBrackets->updateByWait(
VM_CNT,
869 ScoreBrackets->getScoreUB(
VM_CNT));
875 if (group_is_multi_wave || fence_is_global) {
876 EmitSwaitcnt |= ScoreBrackets->updateByWait(EXP_CNT,
877 ScoreBrackets->getScoreUB(EXP_CNT));
878 EmitSwaitcnt |= ScoreBrackets->updateByWait(LGKM_CNT,
879 ScoreBrackets->getScoreUB(LGKM_CNT));
887 if (group_is_multi_wave || fence_is_global) {
888 EmitSwaitcnt |= ScoreBrackets->updateByWait(EXP_CNT,
889 ScoreBrackets->getScoreUB(EXP_CNT));
890 EmitSwaitcnt |= ScoreBrackets->updateByWait(
VM_CNT,
891 ScoreBrackets->getScoreUB(
VM_CNT));
911 EmitSwaitcnt |= ScoreBrackets->updateByWait(
912 EXP_CNT, ScoreBrackets->getEventUB(EXP_GPR_LOCK));
913 EmitSwaitcnt |= ScoreBrackets->updateByWait(
914 EXP_CNT, ScoreBrackets->getEventUB(EXP_PARAM_ACCESS));
915 EmitSwaitcnt |= ScoreBrackets->updateByWait(
916 EXP_CNT, ScoreBrackets->getEventUB(EXP_POS_ACCESS));
917 EmitSwaitcnt |= ScoreBrackets->updateByWait(
918 EXP_CNT, ScoreBrackets->getEventUB(GDS_GPR_LOCK));
921 #if 0 // TODO: the following code to handle CALL.
929 if (ScoreBrackets->getScoreUB(EXP_CNT) >
930 ScoreBrackets->getScoreLB(EXP_CNT)) {
931 ScoreBrackets->setScoreLB(EXP_CNT, ScoreBrackets->getScoreUB(EXP_CNT));
944 unsigned AS = Memop->getAddrSpace();
945 if (AS != AMDGPUASI.LOCAL_ADDRESS)
947 unsigned RegNo = SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS;
949 EmitSwaitcnt |= ScoreBrackets->updateByWait(
955 RegInterval Interval =
956 ScoreBrackets->getRegInterval(&MI, TII, MRI, TRI,
I,
false);
957 for (
signed RegNo = Interval.first; RegNo < Interval.second; ++RegNo) {
960 EmitSwaitcnt |= ScoreBrackets->updateByWait(
963 EmitSwaitcnt |= ScoreBrackets->updateByWait(
964 LGKM_CNT, ScoreBrackets->getRegScore(RegNo, LGKM_CNT));
977 unsigned AS = Memop->getAddrSpace();
978 if (AS != AMDGPUASI.LOCAL_ADDRESS)
980 unsigned RegNo = SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS;
981 EmitSwaitcnt |= ScoreBrackets->updateByWait(
983 EmitSwaitcnt |= ScoreBrackets->updateByWait(
984 EXP_CNT, ScoreBrackets->getRegScore(RegNo, EXP_CNT));
990 RegInterval Interval =
991 ScoreBrackets->getRegInterval(&MI, TII, MRI, TRI,
I,
true);
992 for (
signed RegNo = Interval.first; RegNo < Interval.second; ++RegNo) {
994 EmitSwaitcnt |= ScoreBrackets->updateByWait(
996 EmitSwaitcnt |= ScoreBrackets->updateByWait(
997 EXP_CNT, ScoreBrackets->getRegScore(RegNo, EXP_CNT));
999 EmitSwaitcnt |= ScoreBrackets->updateByWait(
1000 LGKM_CNT, ScoreBrackets->getRegScore(RegNo, LGKM_CNT));
1006 bool ForceZero =
false;
1012 if (MI.
getOpcode() == AMDGPU::S_BARRIER &&
1013 !
ST->hasAutoWaitcntBeforeBarrier()) {
1015 ScoreBrackets->updateByWait(
VM_CNT, ScoreBrackets->getScoreUB(
VM_CNT));
1016 EmitSwaitcnt |= ScoreBrackets->updateByWait(
1017 EXP_CNT, ScoreBrackets->getScoreUB(EXP_CNT));
1018 EmitSwaitcnt |= ScoreBrackets->updateByWait(
1019 LGKM_CNT, ScoreBrackets->getScoreUB(LGKM_CNT));
1026 if (ScoreBrackets->getScoreLB(LGKM_CNT) <
1027 ScoreBrackets->getScoreUB(LGKM_CNT) &&
1028 ScoreBrackets->hasPendingSMEM()) {
1035 EmitSwaitcnt =
true;
1041 int CntVal[NUM_INST_CNTS];
1043 bool UseDefaultWaitcntStrategy =
true;
1048 ScoreBrackets->setScoreLB(T, ScoreBrackets->getScoreUB(T));
1053 UseDefaultWaitcntStrategy =
false;
1056 if (UseDefaultWaitcntStrategy) {
1061 ScoreBrackets->getScoreUB(T) - ScoreBrackets->getScoreLB(T);
1062 int MaxDelta = ScoreBrackets->getWaitCountMax(T);
1063 if (Delta >= MaxDelta) {
1066 ScoreBrackets->setScoreLB(
1067 T, ScoreBrackets->getScoreUB(T) - MaxDelta);
1081 if (EmitSwaitcnt != 0) {
1082 MachineInstr *OldWaitcnt = ScoreBrackets->getWaitcnt();
1091 if (ContainingLoop) {
1093 BlockWaitcntBrackets *ScoreBracket =
1094 BlockWaitcntBracketsMap[TBB].get();
1095 if (!ScoreBracket) {
1096 assert(BlockVisitedSet.find(TBB) == BlockVisitedSet.end());
1097 BlockWaitcntBracketsMap[TBB] = make_unique<BlockWaitcntBrackets>();
1098 ScoreBracket = BlockWaitcntBracketsMap[TBB].get();
1100 ScoreBracket->setRevisitLoop(
true);
1102 << ContainingLoop->
getHeader()->getNumber() <<
'\n';);
1108 if (OldWaitcnt && OldWaitcnt->
getOpcode() != AMDGPU::S_WAITCNT) {
1109 SWaitInst = OldWaitcnt;
1113 CompilerGeneratedWaitcntSet.insert(SWaitInst);
1118 IV, CntVal[
VM_CNT], CntVal[EXP_CNT], CntVal[LGKM_CNT]));
1121 if (CntVal[EXP_CNT] == 0) {
1122 ScoreBrackets->setMixedExpTypes(
false);
1148 void SIInsertWaitcnts::updateEventWaitCntAfter(
1149 MachineInstr &Inst, BlockWaitcntBrackets *ScoreBrackets) {
1158 ScoreBrackets->updateByEvent(TII, TRI, MRI, GDS_ACCESS, Inst);
1159 ScoreBrackets->updateByEvent(TII, TRI, MRI, GDS_GPR_LOCK, Inst);
1161 ScoreBrackets->updateByEvent(TII, TRI, MRI, LDS_ACCESS, Inst);
1163 }
else if (TII->
isFLAT(Inst)) {
1165 ScoreBrackets->updateByEvent(TII, TRI, MRI, VMEM_ACCESS, Inst);
1166 ScoreBrackets->updateByEvent(TII, TRI, MRI, LDS_ACCESS, Inst);
1170 bool FoundLDSMem =
false;
1172 unsigned AS = Memop->getAddrSpace();
1173 if (AS == AMDGPUASI.LOCAL_ADDRESS || AS == AMDGPUASI.FLAT_ADDRESS)
1181 ScoreBrackets->setPendingFlat();
1185 Inst.
getOpcode() != AMDGPU::BUFFER_WBINVL1 &&
1186 Inst.
getOpcode() != AMDGPU::BUFFER_WBINVL1_SC &&
1187 Inst.
getOpcode() != AMDGPU::BUFFER_WBINVL1_VOL) {
1188 ScoreBrackets->updateByEvent(TII, TRI, MRI, VMEM_ACCESS, Inst);
1191 ScoreBrackets->updateByEvent(TII, TRI, MRI, VMW_GPR_LOCK, Inst);
1193 }
else if (TII->
isSMRD(Inst)) {
1194 ScoreBrackets->updateByEvent(TII, TRI, MRI, SMEM_ACCESS, Inst);
1197 case AMDGPU::S_SENDMSG:
1198 case AMDGPU::S_SENDMSGHALT:
1199 ScoreBrackets->updateByEvent(TII, TRI, MRI, SQ_MESSAGE, Inst);
1202 case AMDGPU::EXP_DONE: {
1204 if (Imm >= 32 && Imm <= 63)
1205 ScoreBrackets->updateByEvent(TII, TRI, MRI, EXP_PARAM_ACCESS, Inst);
1206 else if (Imm >= 12 && Imm <= 15)
1207 ScoreBrackets->updateByEvent(TII, TRI, MRI, EXP_POS_ACCESS, Inst);
1209 ScoreBrackets->updateByEvent(TII, TRI, MRI, EXP_GPR_LOCK, Inst);
1212 case AMDGPU::S_MEMTIME:
1213 case AMDGPU::S_MEMREALTIME:
1214 ScoreBrackets->updateByEvent(TII, TRI, MRI, SMEM_ACCESS, Inst);
1223 BlockWaitcntBrackets *ScoreBrackets = BlockWaitcntBracketsMap[&Block].get();
1224 int32_t MaxPending[NUM_INST_CNTS] = {0};
1225 int32_t MaxFlat[NUM_INST_CNTS] = {0};
1226 bool MixedExpTypes =
false;
1229 ScoreBrackets->clear();
1240 BlockWaitcntBrackets *PredScoreBrackets =
1241 BlockWaitcntBracketsMap[
pred].get();
1242 bool Visited = BlockVisitedSet.find(
pred) != BlockVisitedSet.end();
1243 if (!Visited || PredScoreBrackets->getWaitAtBeginning()) {
1249 PredScoreBrackets->getScoreUB(T) - PredScoreBrackets->getScoreLB(T);
1250 MaxPending[
T] =
std::max(MaxPending[T], span);
1252 PredScoreBrackets->pendingFlat(T) - PredScoreBrackets->getScoreLB(T);
1253 MaxFlat[
T] =
std::max(MaxFlat[T], span);
1256 MixedExpTypes |= PredScoreBrackets->mixedExpTypes();
1261 if (Block.
succ_empty() && !KillWaitBrackets.empty()) {
1262 for (
unsigned int I = 0;
I < KillWaitBrackets.size();
I++) {
1265 int Span = KillWaitBrackets[
I]->getScoreUB(T) -
1266 KillWaitBrackets[
I]->getScoreLB(T);
1267 MaxPending[
T] =
std::max(MaxPending[T], Span);
1268 Span = KillWaitBrackets[
I]->pendingFlat(T) -
1269 KillWaitBrackets[
I]->getScoreLB(T);
1270 MaxFlat[
T] =
std::max(MaxFlat[T], Span);
1273 MixedExpTypes |= KillWaitBrackets[
I]->mixedExpTypes();
1279 BlockWaitcntBrackets *PredScoreBrackets =
1280 BlockWaitcntBracketsMap[Pred].get();
1281 bool Visited = BlockVisitedSet.find(Pred) != BlockVisitedSet.end();
1282 if (!Visited || PredScoreBrackets->getWaitAtBeginning()) {
1286 int GDSSpan = PredScoreBrackets->getEventUB(GDS_GPR_LOCK) -
1287 PredScoreBrackets->getScoreLB(EXP_CNT);
1289 int EXPSpan = PredScoreBrackets->getEventUB(EXP_GPR_LOCK) -
1290 PredScoreBrackets->getScoreLB(EXP_CNT);
1295 if (Block.
succ_empty() && !KillWaitBrackets.empty()) {
1296 for (
unsigned int I = 0;
I < KillWaitBrackets.size();
I++) {
1297 int GDSSpan = KillWaitBrackets[
I]->getEventUB(GDS_GPR_LOCK) -
1298 KillWaitBrackets[
I]->getScoreLB(EXP_CNT);
1300 int EXPSpan = KillWaitBrackets[
I]->getEventUB(EXP_GPR_LOCK) -
1301 KillWaitBrackets[
I]->getScoreLB(EXP_CNT);
1312 ScoreBrackets->setWaitAtBeginning();
1320 ScoreBrackets->setScoreUB(T, MaxPending[T]);
1321 ScoreBrackets->setScoreLB(T, 0);
1322 ScoreBrackets->setLastFlat(T, MaxFlat[T]);
1325 ScoreBrackets->setMixedExpTypes(MixedExpTypes);
1329 if (BlockVisitedSet.find(Pred) == BlockVisitedSet.end()) {
1333 BlockWaitcntBrackets *PredScoreBrackets =
1334 BlockWaitcntBracketsMap[Pred].get();
1339 int PredLB = PredScoreBrackets->getScoreLB(T);
1340 int PredUB = PredScoreBrackets->getScoreUB(T);
1341 if (PredLB < PredUB) {
1342 int PredScale = MaxPending[
T] - PredUB;
1344 for (
int J = 0; J <= PredScoreBrackets->getMaxVGPR(); J++) {
1345 int PredRegScore = PredScoreBrackets->getRegScore(J, T);
1346 if (PredRegScore <= PredLB)
1348 int NewRegScore = PredScale + PredRegScore;
1349 ScoreBrackets->setRegScore(
1350 J, T,
std::max(ScoreBrackets->getRegScore(J, T), NewRegScore));
1353 if (T == LGKM_CNT) {
1354 for (
int J = 0; J <= PredScoreBrackets->getMaxSGPR(); J++) {
1356 PredScoreBrackets->getRegScore(J + NUM_ALL_VGPRS, LGKM_CNT);
1357 if (PredRegScore <= PredLB)
1359 int NewRegScore = PredScale + PredRegScore;
1360 ScoreBrackets->setRegScore(
1361 J + NUM_ALL_VGPRS, LGKM_CNT,
1363 ScoreBrackets->getRegScore(J + NUM_ALL_VGPRS, LGKM_CNT),
1373 int PredEventUB = PredScoreBrackets->getEventUB(W);
1374 if (PredEventUB > PredScoreBrackets->getScoreLB(T)) {
1376 MaxPending[
T] + PredEventUB - PredScoreBrackets->getScoreUB(T);
1377 if (NewEventUB > 0) {
1378 ScoreBrackets->setEventUB(
1379 W,
std::max(ScoreBrackets->getEventUB(W), NewEventUB));
1387 if (Block.
succ_empty() && !KillWaitBrackets.empty()) {
1388 for (
unsigned int I = 0;
I < KillWaitBrackets.size();
I++) {
1392 int PredLB = KillWaitBrackets[
I]->getScoreLB(T);
1393 int PredUB = KillWaitBrackets[
I]->getScoreUB(T);
1394 if (PredLB < PredUB) {
1395 int PredScale = MaxPending[
T] - PredUB;
1397 for (
int J = 0; J <= KillWaitBrackets[
I]->getMaxVGPR(); J++) {
1398 int PredRegScore = KillWaitBrackets[
I]->getRegScore(J, T);
1399 if (PredRegScore <= PredLB)
1401 int NewRegScore = PredScale + PredRegScore;
1402 ScoreBrackets->setRegScore(
1403 J, T,
std::max(ScoreBrackets->getRegScore(J, T), NewRegScore));
1406 if (T == LGKM_CNT) {
1407 for (
int J = 0; J <= KillWaitBrackets[
I]->getMaxSGPR(); J++) {
1409 KillWaitBrackets[
I]->getRegScore(J + NUM_ALL_VGPRS, LGKM_CNT);
1410 if (PredRegScore <= PredLB)
1412 int NewRegScore = PredScale + PredRegScore;
1413 ScoreBrackets->setRegScore(
1414 J + NUM_ALL_VGPRS, LGKM_CNT,
1416 ScoreBrackets->getRegScore(J + NUM_ALL_VGPRS, LGKM_CNT),
1426 int PredEventUB = KillWaitBrackets[
I]->getEventUB(W);
1427 if (PredEventUB > KillWaitBrackets[
I]->getScoreLB(T)) {
1429 MaxPending[
T] + PredEventUB - KillWaitBrackets[
I]->getScoreUB(T);
1430 if (NewEventUB > 0) {
1431 ScoreBrackets->setEventUB(
1432 W,
std::max(ScoreBrackets->getEventUB(W), NewEventUB));
1443 if (BlockVisitedSet.find(Pred) == BlockVisitedSet.end()) {
1447 BlockWaitcntBrackets *PredScoreBrackets =
1448 BlockWaitcntBracketsMap[Pred].get();
1450 int pred_gds_ub = PredScoreBrackets->getEventUB(GDS_GPR_LOCK);
1451 if (pred_gds_ub > PredScoreBrackets->getScoreLB(EXP_CNT)) {
1452 int new_gds_ub = MaxPending[
EXP_CNT] + pred_gds_ub -
1453 PredScoreBrackets->getScoreUB(EXP_CNT);
1454 if (new_gds_ub > 0) {
1455 ScoreBrackets->setEventUB(
1457 std::max(ScoreBrackets->getEventUB(GDS_GPR_LOCK), new_gds_ub));
1460 int pred_exp_ub = PredScoreBrackets->getEventUB(EXP_GPR_LOCK);
1461 if (pred_exp_ub > PredScoreBrackets->getScoreLB(EXP_CNT)) {
1462 int new_exp_ub = MaxPending[
EXP_CNT] + pred_exp_ub -
1463 PredScoreBrackets->getScoreUB(EXP_CNT);
1464 if (new_exp_ub > 0) {
1465 ScoreBrackets->setEventUB(
1467 std::max(ScoreBrackets->getEventUB(EXP_GPR_LOCK), new_exp_ub));
1488 mergeInputScoreBrackets(Block);
1490 BlockWaitcntBrackets *ScoreBrackets = BlockWaitcntBracketsMap[&Block].get();
1494 ScoreBrackets->dump();
1497 bool InsertNOP =
false;
1504 if (Inst.
getOpcode() == AMDGPU::S_WAITCNT) {
1507 if (CompilerGeneratedWaitcntSet.find(&Inst) ==
1508 CompilerGeneratedWaitcntSet.end())
1511 ScoreBrackets->setWaitcnt(&Inst);
1522 addKillWaitBracket(ScoreBrackets);
1525 bool VCCZBugWorkAround =
false;
1527 (VCCZBugHandledSet.find(&Inst) == VCCZBugHandledSet.end())) {
1528 if (ScoreBrackets->getScoreLB(LGKM_CNT) <
1529 ScoreBrackets->getScoreUB(LGKM_CNT) &&
1530 ScoreBrackets->hasPendingSMEM()) {
1532 VCCZBugWorkAround =
true;
1538 MachineInstr *SWaitInst = generateSWaitCntInstBefore(Inst, ScoreBrackets);
1541 Block.
insert(Inst, SWaitInst);
1542 if (ScoreBrackets->getWaitcnt() != SWaitInst) {
1543 DEBUG(
dbgs() <<
"insertWaitcntInBlock\n"
1544 <<
"Old Instr: " << Inst <<
'\n'
1545 <<
"New Instr: " << *SWaitInst <<
'\n';);
1549 updateEventWaitCntAfter(Inst, ScoreBrackets);
1551 #if 0 // TODO: implement resource type check controlled by options with ub = LB.
1555 if (RequireCheckResourceType(Inst, context)) {
1557 ScoreBrackets->setScoreLB(
VM_CNT,
1558 ScoreBrackets->getScoreUB(
VM_CNT));
1562 ScoreBrackets->clearWaitcnt();
1569 ScoreBrackets->dump();
1575 if (Inst.
getOpcode() == AMDGPU::DS_GWS_INIT ||
1576 Inst.
getOpcode() == AMDGPU::DS_GWS_SEMA_V ||
1577 Inst.
getOpcode() == AMDGPU::DS_GWS_SEMA_BR ||
1578 Inst.
getOpcode() == AMDGPU::DS_GWS_SEMA_P ||
1579 Inst.
getOpcode() == AMDGPU::DS_GWS_BARRIER) {
1581 ScoreBrackets->updateByWait(
VM_CNT, ScoreBrackets->getScoreUB(
VM_CNT));
1582 ScoreBrackets->updateByWait(EXP_CNT, ScoreBrackets->getScoreUB(EXP_CNT));
1583 ScoreBrackets->updateByWait(LGKM_CNT,
1584 ScoreBrackets->getScoreUB(LGKM_CNT));
1589 if (VCCZBugWorkAround) {
1595 .addReg(AMDGPU::VCC);
1596 VCCZBugHandledSet.insert(&Inst);
1602 if (!SWaitInst && InsertNOP) {
1616 bool IsSMEM =
false;
1617 bool IsVMEM =
false;
1632 if (!IsSMEM && TII->
usesVM_CNT(Next) && IsVMEM &&
1635 ST->isXNACKEnabled()) {
1643 if ((Next.
getOpcode() == AMDGPU::S_SENDMSG ||
1644 Next.
getOpcode() == AMDGPU::S_SENDMSGHALT) &&
1655 MachineLoop *ContainingLoop = MLI->getLoopFor(&Block);
1656 if (ContainingLoop && loopBottom(ContainingLoop) == &Block) {
1657 LoopWaitcntData *WaitcntData = LoopWaitcntDataMap[ContainingLoop].get();
1658 WaitcntData->print();
1666 if (WaitcntData->getIterCnt() > 2) {
1671 bool HasPending =
false;
1675 if (ScoreBrackets->getScoreUB(T) > ScoreBrackets->getScoreLB(T)) {
1676 ScoreBrackets->setScoreLB(T, ScoreBrackets->getScoreUB(T));
1684 TII->get(AMDGPU::S_WAITCNT),
DebugLoc());
1685 CompilerGeneratedWaitcntSet.insert(SWaitInst);
1688 #if 0 // TODO: Format the debug output
1689 OutputTransformBanner(
"insertWaitcntInBlock",0,
"Create:",context);
1690 OutputTransformAdd(SWaitInst, context);
1694 _DEV( REPORTED_STATS->force_waitcnt_converge = 1; )
1701 dbgs() <<
"\nAdjusted score board:";
1702 ScoreBrackets->dump();
1708 insertWaitcntBeforeCF(Block, SWaitInst);
1709 WaitcntData->setWaitcnt(SWaitInst);
1717 TII =
ST->getInstrInfo();
1720 MLI = &getAnalysis<MachineLoopInfo>();
1723 AMDGPUASI =
ST->getAMDGPUAS();
1729 HardwareLimits.NumVGPRsMax =
ST->getAddressableNumVGPRs();
1730 HardwareLimits.NumSGPRsMax =
ST->getAddressableNumSGPRs();
1731 assert(HardwareLimits.NumVGPRsMax <= SQ_MAX_PGM_VGPRS);
1732 assert(HardwareLimits.NumSGPRsMax <= SQ_MAX_PGM_SGPRS);
1734 RegisterEncoding.VGPR0 = TRI->getEncodingValue(AMDGPU::VGPR0);
1735 RegisterEncoding.VGPRL =
1736 RegisterEncoding.VGPR0 + HardwareLimits.NumVGPRsMax - 1;
1737 RegisterEncoding.SGPR0 = TRI->getEncodingValue(AMDGPU::SGPR0);
1738 RegisterEncoding.SGPRL =
1739 RegisterEncoding.SGPR0 + HardwareLimits.NumSGPRsMax - 1;
1744 bool Modified =
false;
1747 E = RPOT.end(), J = RPOT.begin();
1751 BlockVisitedSet.insert(&MBB);
1753 BlockWaitcntBrackets *ScoreBrackets = BlockWaitcntBracketsMap[&MBB].get();
1754 if (!ScoreBrackets) {
1755 BlockWaitcntBracketsMap[&MBB] = make_unique<BlockWaitcntBrackets>();
1756 ScoreBrackets = BlockWaitcntBracketsMap[&MBB].get();
1758 ScoreBrackets->setPostOrder(MBB.
getNumber());
1759 MachineLoop *ContainingLoop = MLI->getLoopFor(&MBB);
1760 if (ContainingLoop && LoopWaitcntDataMap[ContainingLoop] ==
nullptr)
1761 LoopWaitcntDataMap[ContainingLoop] = make_unique<LoopWaitcntData>();
1766 if (ContainingLoop && ContainingLoop->
getHeader() == &MBB && J <
I &&
1767 (BlockWaitcntProcessedSet.find(&MBB) ==
1768 BlockWaitcntProcessedSet.end())) {
1769 BlockWaitcntBracketsMap[&MBB]->setRevisitLoop(
true);
1771 << ContainingLoop->
getHeader()->getNumber() <<
'\n';);
1775 insertWaitcntInBlock(MF, MBB);
1778 BlockWaitcntProcessedSet.insert(&MBB);
1781 if (ContainingLoop && loopBottom(ContainingLoop) == &MBB) {
1783 BlockWaitcntBrackets *EntrySB = BlockWaitcntBracketsMap[EntryBB].get();
1784 if (EntrySB && EntrySB->getRevisitLoop()) {
1785 EntrySB->setRevisitLoop(
false);
1787 int32_t PostOrder = EntrySB->getPostOrder();
1799 LoopWaitcntData *WaitcntData = LoopWaitcntDataMap[ContainingLoop].get();
1800 WaitcntData->incIterCnt();
1804 LoopWaitcntData *WaitcntData = LoopWaitcntDataMap[ContainingLoop].get();
1808 WaitcntData->resetIterCnt();
1818 bool HaveScalarStores =
false;
1828 if (!HaveScalarStores && TII->isScalarStore(*
I))
1829 HaveScalarStores =
true;
1831 if (
I->getOpcode() == AMDGPU::S_ENDPGM ||
1832 I->getOpcode() == AMDGPU::SI_RETURN_TO_EPILOG)
1837 if (HaveScalarStores) {
1846 bool SeenDCacheWB =
false;
1851 if (
I->getOpcode() == AMDGPU::S_DCACHE_WB)
1852 SeenDCacheWB =
true;
1853 else if (TII->isScalarStore(*
I))
1854 SeenDCacheWB =
false;
1857 if ((
I->getOpcode() == AMDGPU::S_ENDPGM ||
1858 I->getOpcode() == AMDGPU::SI_RETURN_TO_EPILOG) &&
1861 BuildMI(*MBB,
I,
I->getDebugLoc(), TII->get(AMDGPU::S_DCACHE_WB));
1867 if (!MFI->isEntryFunction()) {
void push_back(const T &Elt)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
AMDGPU specific subclass of TargetSubtarget.
bool isBranch(QueryType Type=AnyInBundle) const
Returns true if this is a conditional, unconditional, or indirect branch.
bool isVGPR(const MachineRegisterInfo &MRI, unsigned Reg) const
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
Interval Class - An Interval is a set of nodes defined such that every node in the interval has all o...
Implements a dense probed hash-table based set.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
iterator_range< mmo_iterator > memoperands()
void print(raw_ostream &OS, bool SkipOpers=false, bool SkipDebugLoc=false, const TargetInstrInfo *TII=nullptr) const
Debugging supportPrint this MI to OS.
LLVM_READONLY int getAtomicNoRetOp(uint16_t Opcode)
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL, bool NoImp=false)
CreateMachineInstr - Allocate a new MachineInstr.
BlockT * getHeader() const
static bool isSMRD(const MachineInstr &MI)
FunctionPass * createSIInsertWaitcntsPass()
LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx)
static bool isDS(const MachineInstr &MI)
AnalysisUsage & addRequired()
A description of a memory reference used in the backend.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static bool isFLAT(const MachineInstr &MI)
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
OpenCL uses address spaces to differentiate between various memory regions on the hardware...
const HexagonInstrInfo * TII
static bool isMIMG(const MachineInstr &MI)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
LLVM_READONLY MachineOperand * getNamedOperand(MachineInstr &MI, unsigned OperandName) const
Returns the operand named Op.
static bool readsVCCZ(const MachineInstr &MI)
Reg
All possible values of the reg field in the ModR/M byte.
unsigned decodeLgkmcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt)
unsigned getNumOperands() const
Access to explicit operands of the instruction.
const MachineBasicBlock & front() const
static bool isMUBUF(const MachineInstr &MI)
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
iterator_range< block_iterator > blocks() const
const MachineBasicBlock * getParent() const
bool isDebugValue() const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
unsigned const MachineRegisterInfo * MRI
static bool usesVM_CNT(const MachineInstr &MI)
const MachineOperand & getOperand(unsigned i) const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Represent the analysis usage information of a pass.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
Instruction set architecture version.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
FunctionPass class - This class is used to implement most global optimizations.
iterator_range< pred_iterator > predecessors()
unsigned getSubReg() const
bool definesRegister(unsigned Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr fully defines the specified register.
static bool isEXP(const MachineInstr &MI)
unsigned decodeVmcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt)
char & SIInsertWaitcntsID
unsigned getLgkmcntBitMask(const IsaInfo::IsaVersion &Version)
Iterator for intrusive lists based on ilist_node.
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
const SIRegisterInfo * getRegisterInfo() const override
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getExpcntBitMask(const IsaInfo::IsaVersion &Version)
bool isSGPRReg(const MachineRegisterInfo &MRI, unsigned Reg) const
void setPreservesCFG()
This function should be called by the pass, iff they do not:
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
static void clear(coro::Shape &Shape)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
Interface definition for SIInstrInfo.
static bool isMTBUF(const MachineInstr &MI)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
unsigned decodeExpcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt)
Represents a single loop in the control flow graph.
unsigned encodeWaitcnt(const IsaInfo::IsaVersion &Version, unsigned Vmcnt, unsigned Expcnt, unsigned Lgkmcnt)
Encodes Vmcnt, Expcnt and Lgkmcnt into Waitcnt for given isa Version.
static MachineOperand CreateImm(int64_t Val)
void push_back(MachineInstr *MI)
static bool isVMEM(const MachineInstr &MI)
typename std::vector< NodeRef >::reverse_iterator rpo_iterator
unsigned getVmcntBitMask(const IsaInfo::IsaVersion &Version)
#define ForAllWaitEventType(w)
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
MachineInstr * removeFromParent()
Unlink 'this' from the containing basic block, and return it without deleting it. ...
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
const TargetRegisterClass * getOpRegClass(const MachineInstr &MI, unsigned OpNo) const
Return the correct register class for OpNo.
StringRef - Represent a constant reference to a string, i.e.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
INITIALIZE_PASS_BEGIN(SIInsertWaitcnts, DEBUG_TYPE,"SI Insert Waitcnts", false, false) INITIALIZE_PASS_END(SIInsertWaitcnts
bool modifiesRegister(unsigned Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
IsaVersion getIsaVersion(const FeatureBitset &Features)