25#define DEBUG_TYPE "machine-scheduler"
29 if (
S1.size() != S2.
size())
32 for (
const auto &
P :
S1) {
34 if (
I == S2.
end() ||
I->second !=
P.second)
58 if (NewNumCoveredRegs == PrevNumCoveredRegs)
62 if (NewMask < PrevMask) {
64 std::swap(NewNumCoveredRegs, PrevNumCoveredRegs);
67 assert(PrevMask < NewMask && PrevNumCoveredRegs < NewNumCoveredRegs &&
68 "prev mask should always be lesser than new");
74 if (
TRI->getRegSizeInBits(*RC) != 32) {
76 if (PrevMask.
none()) {
78 Value[TupleIdx] +=
Sign *
TRI->getRegClassWeight(RC).RegWeight;
98 Sign *= NewNumCoveredRegs - PrevNumCoveredRegs;
107 unsigned ArchVGPR = 0;
110 bool anyExcess()
const {
return SGPR || VGPR || ArchVGPR || AGPR; }
111 bool hasVectorRegisterExcess()
const {
return VGPR || ArchVGPR || AGPR; }
114 : RegExcess(MF,
RP, GCNRPTarget(MF,
RP)) {}
116 const GCNRPTarget &Target) {
117 unsigned MaxSGPRs =
Target.getMaxSGPRs();
118 unsigned MaxVGPRs =
Target.getMaxVGPRs();
121 SGPR = std::max(
static_cast<int>(
RP.getSGPRNum() - MaxSGPRs), 0);
124 unsigned WaveSize =
ST.getWavefrontSize();
125 unsigned VGPRForSGPRSpills =
divideCeil(SGPR, WaveSize);
127 unsigned MaxArchVGPRs =
ST.getAddressableNumArchVGPRs();
131 VGPR = std::max(
static_cast<int>(
RP.getVGPRNum(
ST.hasGFX90AInsts()) +
132 VGPRForSGPRSpills - MaxVGPRs),
135 unsigned ArchVGPRLimit =
ST.hasGFX90AInsts() ? MaxArchVGPRs : MaxVGPRs;
138 ArchVGPR = std::max(
static_cast<int>(
RP.getArchVGPRNum() +
139 VGPRForSGPRSpills - ArchVGPRLimit),
143 AGPR = std::max(
static_cast<int>(
RP.getAGPRNum() - ArchVGPRLimit), 0);
149 unsigned MaxOccupancy)
const {
151 unsigned DynamicVGPRBlockSize =
154 const auto SGPROcc = std::min(MaxOccupancy,
156 const auto VGPROcc = std::min(
157 MaxOccupancy, ST.getOccupancyWithNumVGPRs(
getVGPRNum(ST.hasGFX90AInsts()),
158 DynamicVGPRBlockSize));
159 const auto OtherSGPROcc = std::min(MaxOccupancy,
160 ST.getOccupancyWithNumSGPRs(O.getSGPRNum()));
161 const auto OtherVGPROcc =
162 std::min(MaxOccupancy,
163 ST.getOccupancyWithNumVGPRs(O.getVGPRNum(ST.hasGFX90AInsts()),
164 DynamicVGPRBlockSize));
166 const auto Occ = std::min(SGPROcc, VGPROcc);
167 const auto OtherOcc = std::min(OtherSGPROcc, OtherVGPROcc);
171 return Occ > OtherOcc;
173 unsigned MaxVGPRs = ST.getMaxNumVGPRs(MF);
175 RegExcess Excess(MF, *
this);
176 RegExcess OtherExcess(MF, O);
178 unsigned MaxArchVGPRs = ST.getAddressableNumArchVGPRs();
180 bool ExcessRP = Excess.anyExcess();
181 bool OtherExcessRP = OtherExcess.anyExcess();
185 if (ExcessRP || OtherExcessRP) {
189 ((OtherExcess.VGPR + OtherExcess.ArchVGPR + OtherExcess.AGPR) -
190 (Excess.VGPR + Excess.ArchVGPR + Excess.AGPR));
192 int SGPRDiff = OtherExcess.SGPR - Excess.SGPR;
197 unsigned PureExcessVGPR =
198 std::max(
static_cast<int>(
getVGPRNum(ST.hasGFX90AInsts()) - MaxVGPRs),
200 std::max(
static_cast<int>(
getVGPRNum(
false) - MaxArchVGPRs), 0);
201 unsigned OtherPureExcessVGPR =
203 static_cast<int>(O.getVGPRNum(ST.hasGFX90AInsts()) - MaxVGPRs),
205 std::max(
static_cast<int>(O.getVGPRNum(
false) - MaxArchVGPRs), 0);
210 if (PureExcessVGPR != OtherPureExcessVGPR)
218 bool SGPRImportant = SGPROcc < VGPROcc;
219 const bool OtherSGPRImportant = OtherSGPROcc < OtherVGPROcc;
222 if (SGPRImportant != OtherSGPRImportant) {
223 SGPRImportant =
false;
227 bool SGPRFirst = SGPRImportant;
228 for (
int I = 2;
I > 0; --
I, SGPRFirst = !SGPRFirst) {
231 auto OtherSW = O.getSGPRTuplesWeight();
236 auto OtherVW = O.getVGPRTuplesWeight();
243 return SGPRImportant ? (
getSGPRNum() < O.getSGPRNum()):
245 O.getVGPRNum(ST.hasGFX90AInsts()));
249 unsigned DynamicVGPRBlockSize) {
251 OS <<
"VGPRs: " << RP.getArchVGPRNum();
252 if (
unsigned NumAVGPRs = RP.getAVGPRNum())
253 OS <<
" (AV: " << NumAVGPRs <<
')';
254 OS <<
" AGPRs: " << RP.getAGPRNum();
257 << ST->getOccupancyWithNumVGPRs(RP.getVGPRNum(ST->hasGFX90AInsts()),
258 DynamicVGPRBlockSize)
260 OS <<
", SGPRs: " << RP.getSGPRNum();
262 OS <<
"(O" << ST->getOccupancyWithNumSGPRs(RP.getSGPRNum()) <<
')';
263 OS <<
", LVGPR WT: " << RP.getVGPRTuplesWeight()
264 <<
", LSGPR WT: " << RP.getSGPRTuplesWeight();
266 OS <<
" -> Occ: " << RP.getOccupancy(*ST, DynamicVGPRBlockSize);
280 MRI.getTargetRegisterInfo()->getSubRegIndexLaneMask(MO.
getSubReg());
288 auto &
TRI = *
MRI.getTargetRegisterInfo();
289 for (
const auto &MO :
MI.operands()) {
290 if (!MO.isReg() || !MO.getReg().isVirtual())
292 if (!MO.isUse() || !MO.readsReg())
297 return RM.VRegOrUnit.asVirtualReg() ==
Reg;
300 auto &
P =
I == VRegMaskOrUnits.
end()
305 P.LaneMask |= MO.getSubReg() ?
TRI.getSubRegIndexLaneMask(MO.getSubReg())
306 :
MRI.getMaxLaneMaskForVReg(
Reg);
310 for (
auto &
P : VRegMaskOrUnits) {
311 auto &LI = LIS.
getInterval(
P.VRegOrUnit.asVirtualReg());
312 if (!LI.hasSubRanges())
335 if (Property(SR, Pos))
336 Result |= SR.LaneMask;
338 }
else if (Property(LI, Pos)) {
355 bool Upward =
false) {
361 bool InRange = Upward ? (InstSlot > PriorUseIdx && InstSlot <= NextUseIdx)
362 : (InstSlot >= PriorUseIdx && InstSlot < NextUseIdx);
366 unsigned SubRegIdx = MO.getSubReg();
368 LastUseMask &= ~UseMask;
369 if (LastUseMask.
none())
382 setTarget(ST.getMaxNumSGPRs(
F), ST.getMaxNumVGPRs(
F));
388 setTarget(NumSGPRs, NumVGPRs);
395 unsigned DynamicVGPRBlockSize =
397 setTarget(ST.getMaxNumSGPRs(Occupancy,
false),
398 ST.getMaxNumVGPRs(Occupancy, DynamicVGPRBlockSize));
403 MaxSGPRs = std::min(ST.getAddressableNumSGPRs(), NumSGPRs);
404 MaxVGPRs = std::min(ST.getAddressableNumArchVGPRs(), NumVGPRs);
406 unsigned DynamicVGPRBlockSize =
409 std::min(ST.getAddressableNumVGPRs(DynamicVGPRBlockSize), NumVGPRs);
421 RegExcess Excess(MF, RP, *
this);
427 return (UnifiedRF && Excess.VGPR) || Excess.AGPR;
429 return (UnifiedRF && Excess.VGPR) || Excess.ArchVGPR;
433 RegExcess Excess(MF, RP, *
this);
434 if (SaveRP.
getSGPRNum() != 0 && Excess.SGPR != 0)
438 if (SaveRP.
getAGPRNum() != 0 && Excess.AGPR != 0)
440 if (UnifiedRF && Excess.VGPR != 0)
446 RegExcess Excess(MF, RP, *
this);
447 const unsigned NumVGPRAboveAddrLimit =
450 unsigned NumRegsSaved =
451 std::min(Excess.SGPR, SaveRP.
getSGPRNum()) + NumVGPRAboveAddrLimit;
453 if (UnifiedRF && Excess.VGPR) {
462 if (NumVGPRAboveAddrLimit < VGPRSave)
463 NumRegsSaved += std::min(Excess.VGPR, VGPRSave - NumVGPRAboveAddrLimit);
472 if (UnifiedRF && TestRP.
getVGPRNum(
true) > MaxUnifiedVGPRs)
478 RegExcess Excess(MF, RP, *
this);
479 return Excess.hasVectorRegisterExcess();
498 if ((S.LaneMask & LaneMaskFilter).any() && S.liveAt(
SI)) {
499 LiveMask |= S.LaneMask;
500 assert(LiveMask == (LiveMask &
MRI.getMaxLaneMaskForVReg(LI.
reg())));
503 LiveMask =
MRI.getMaxLaneMaskForVReg(LI.
reg());
505 LiveMask &= LaneMaskFilter;
514 for (
unsigned I = 0, E =
MRI.getNumVirtRegs();
I != E; ++
I) {
530 if (!
MI.isDebugInstr()) {
533 SI =
SI.getDeadSlot();
540 MBBEnd =
MI.getParent()->end();
543 if (NonDbgMI == MBBEnd) {
558 :
LIS.getMBBStartIdx(&
MBB);
583 const LiveRange::Segment *S = LR.getSegmentContaining(Pos);
584 return S != nullptr && S->end == Pos.getRegSlot();
596 if (
MI.isDebugInstr())
601 bool HasECDefs =
false;
603 if (!MO.getReg().isVirtual())
610 if (MO.isEarlyClobber()) {
622 LiveMask &= ~DefMask;
631 DefPressure += ECDefPressure;
640 LiveMask |= U.LaneMask;
641 CurPressure.inc(U.VRegOrUnit.asVirtualReg(), PrevMask, LiveMask, *
MRI);
656 MBBEnd =
MI.getParent()->end();
657 assert((
End == MBBEnd ||
End->getParent()->end() == MBBEnd) &&
658 "end unrelated to MI block");
668 else if (NextMI != MBBEnd)
672 return NextMI !=
End;
686 auto PrevMask = It->second;
687 It->second &= ~S.LaneMask;
691 if (It !=
LiveRegs.end() && It->second.none())
693 }
else if (!LI.
liveAt(SI)) {
712 if (Reg.isVirtual() && MO.isEarlyClobber())
724 if (MO.readsReg() && Reg.isVirtual() && SeenRegs.
insert(Reg).second)
725 retireVirtReg(Reg,
SI);
736 if (Reg.isVirtual() && SeenRegs.
insert(Reg).second)
737 retireVirtReg(Reg,
SI);
749 if (!Reg.isVirtual())
752 auto PrevMask = LiveMask;
761 return NextMI == MBBEnd;
762 assert(NextMI == MBBEnd || !NextMI->isDebugInstr());
765 ?
LIS.getInstructionIndex(*LastTrackedMI).getDeadSlot()
766 :
LIS.getInstructionIndex(*NextMI).getBaseIndex();
770 return NextMI == MBBEnd;
781 if (NextMI == MBBEnd)
790 bool AnyAdvance =
false;
799 if (!
reset(*Begin,
End, LiveRegsCopy))
808 MI,
LIS.getInstructionIndex(
MI).getDeadSlot());
819 for (
auto const &
P : TrackedLR) {
820 auto I = LISLR.
find(
P.first);
821 if (
I == LISLR.
end()) {
823 <<
" isn't found in LIS reported set\n";
824 }
else if (
I->second !=
P.second) {
826 <<
" masks doesn't match: LIS reported " <<
PrintLaneMask(
I->second)
830 for (
auto const &
P : LISLR) {
831 auto I = TrackedLR.find(
P.first);
832 if (
I == TrackedLR.end()) {
834 <<
" isn't found in tracked set\n";
842 assert(!
MI->isDebugOrPseudoInstr() &&
"Expect a nondebug instruction.");
845 SlotIdx =
LIS.getInstructionIndex(*MI).getRegSlot();
853 if (IdxPos ==
MBB->end()) {
854 CurrIdx =
LIS.getMBBEndIdx(
MBB);
856 CurrIdx =
LIS.getInstructionIndex(*IdxPos).getRegSlot();
868 if (!
Use.VRegOrUnit.isVirtualReg())
872 if (LastUseMask.
none())
881 if (LastUseMask.
none())
887 PostUseMask[Reg] = NewMask;
888 TempPressure.
inc(Reg, LiveMask, NewMask, *
MRI);
893 if (!Def.VRegOrUnit.isVirtualReg())
895 Register Reg = Def.VRegOrUnit.asVirtualReg();
896 auto PostIt = PostUseMask.
find(Reg);
898 if (PostIt != PostUseMask.
end()) {
899 LiveMask = PostIt->second;
906 TempPressure.
inc(Reg, LiveMask, NewMask, *
MRI);
913 const auto &
SI =
LIS.getInstructionIndex(*LastTrackedMI).getBaseIndex();
917 if (!
isEqual(LISLR, TrackedLR)) {
918 dbgs() <<
"\nGCNUpwardRPTracker error: Tracked and"
919 " LIS reported livesets mismatch:\n"
927 dbgs() <<
"GCNUpwardRPTracker error: Pressure sets different\nTracked: "
938 for (
unsigned I = 0, E =
MRI.getNumVirtRegs();
I != E; ++
I) {
941 if (It !=
LiveRegs.end() && It->second.any())
962 auto IsInOneSegment = [Begin,
End](
const LiveRange &LR) ->
bool {
963 auto *Segment = LR.getSegmentContaining(Begin);
964 return Segment && Segment->contains(
End);
970 for (auto &SR : LI.subranges()) {
971 if ((SR.LaneMask & Mask) == SR.LaneMask && IsInOneSegment(SR))
972 LiveThroughMask |= SR.LaneMask;
976 if ((RegMask & Mask) == RegMask && IsInOneSegment(LI))
977 LiveThroughMask = RegMask;
980 return LiveThroughMask;
987 const bool UseDownwardTracker =
995 OS <<
"---\nname: " << MF.
getName() <<
"\nbody: |\n";
999 OS <<
format(
PFX " %-5d", RP.getSGPRNum())
1000 <<
format(
" %-5d", RP.getVGPRNum(
false));
1006 if (LISLR != TrackedLR) {
1015 for (
auto &
MBB : MF) {
1017 RP.reserve(
MBB.size());
1029 if (UseDownwardTracker) {
1059 if (!
MI.isDebugInstr())
1067 if (!UseDownwardTracker)
1068 ReportLISMismatchIfAny(LiveIn,
getLiveRegs(MBBStartSlot, LIS,
MRI));
1070 OS <<
PFX " SGPR VGPR\n";
1072 for (
auto &
MI :
MBB) {
1073 if (!
MI.isDebugInstr()) {
1074 auto &[RPBeforeInstr, RPAtInstr] =
1075 RP[UseDownwardTracker ?
I : (RP.size() - 1 -
I)];
1077 OS << printRP(RPBeforeInstr) <<
'\n' << printRP(RPAtInstr) <<
" ";
1082 OS << printRP(RPAtMBBEnd) <<
'\n';
1085 if (UseDownwardTracker)
1086 ReportLISMismatchIfAny(LiveOut,
getLiveRegs(MBBLastSlot, LIS,
MRI));
1089 for (
auto [Reg, Mask] : LiveIn) {
1091 if (MaskIntersection.
any()) {
1093 MRI, LIS, Reg, MBBStartSlot, MBBLastSlot, MaskIntersection);
1095 LiveThrough[Reg] = LTMask;
1107#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1118 unsigned MaxNumRegs = 0;
1123 unsigned NumRegs = 0;
1125 NumRegs = std::max(NumRegs, RP.getNumRegs(Kind));
1132 if (NumRegs > MaxNumRegs) {
1133 MaxNumRegs = NumRegs;
1134 MaxPressureMI = &
MI;
1151 ECNumRegs > RNumRegs ? &ECLiveSet : &RLiveSet;
1152 SlotIndex MaxPressureSlot = ECNumRegs > RNumRegs ? ECSlot : RSlot;
1158 for (
auto [Reg, LaneMask] : *LiveSet) {
1164 return SR.getNumValNums() == 1;
1173 unsigned SDefNumRegs = SDefPressure.
getNumRegs(Kind);
1174 unsigned MDefNumRegs = MDefPressure.
getNumRegs(Kind);
1175 assert(SDefNumRegs + MDefNumRegs == MaxNumRegs);
1183 <<
", Depth " <<
ML->getLoopDepth() <<
")";
1191 <<
TRI->getRegClassName(
MRI.getRegClass(Reg)) <<
", LiveMask "
1192 <<
PrintLaneMask(LiveMask) <<
" (" << RegPressure.getNumRegs(Kind) <<
' '
1196 std::map<SlotIndex, const MachineInstr *> Instrs;
1201 for (
const auto &[
SI,
MI] : Instrs) {
1203 if (
MI->definesRegister(Reg,
TRI))
1205 if (
MI->readsRegister(Reg,
TRI))
1207 OS << printLoc(
MI->getParent(),
SI) <<
": " << *
MI;
1211 OS <<
"\n*** Register pressure info (" <<
RegName <<
"s) for " << MF.
getName()
1213 OS <<
"Max pressure is " << MaxNumRegs <<
' ' <<
RegName <<
"s at "
1214 << printLoc(MaxPressureMI->
getParent(), MaxPressureSlot) <<
": "
1217 OS <<
"\nLive registers with single definition (" << SDefNumRegs <<
' '
1222 return std::distance(
MRI.use_nodbg_begin(
A),
MRI.use_nodbg_end()) <
1223 std::distance(
MRI.use_nodbg_begin(
B),
MRI.use_nodbg_end());
1226 for (
const Register Reg : SDefRegs) {
1227 PrintRegInfo(Reg, LiveSet->
lookup(Reg));
1230 OS <<
"\nLive registers with multiple definitions (" << MDefNumRegs <<
' '
1232 for (
const Register Reg : MDefRegs) {
1233 PrintRegInfo(Reg, LiveSet->
lookup(Reg));
1247 auto checkAndCollect = [&](
Register VReg) {
1252 if (!
TRI.hasVGPRs(RC))
1260 for (
const auto &[RegNum, LaneMask] : LiveIns) {
1267 if (!MO.isReg() || !MO.isDef())
1269 checkAndCollect(MO.getReg());
1275 return LHS->beginIndex() < RHS->beginIndex();
1279 std::vector<LiveIntervalUnion> RegFile;
1280 unsigned MaxRegsUsed = 0;
1287 std::max<unsigned>(1,
TRI.getRegSizeInBits(*RC).getFixedValue() / 32);
1288 unsigned Alignment =
1289 std::max<unsigned>(1,
TRI.getRegClassAlignmentNumBits(RC) / 32);
1293 unsigned End = Start + Width;
1294 if (RegFile.size() <
End)
1298 for (
unsigned Idx = Start; Idx <
End; Idx++) {
1301 Start =
alignTo(Idx + 1, Alignment);
1308 for (
unsigned Idx = Start; Idx <
End; Idx++)
1309 RegFile[Idx].unify(*LI, *LI);
1310 MaxRegsUsed = std::max(MaxRegsUsed,
End);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
static void collectVirtualRegUses(SmallVectorImpl< VRegMaskOrUnit > &VRegMaskOrUnits, const MachineInstr &MI, const LiveIntervals &LIS, const MachineRegisterInfo &MRI)
static LaneBitmask getDefRegMask(const MachineOperand &MO, const MachineRegisterInfo &MRI)
static LaneBitmask getRegLiveThroughMask(const MachineRegisterInfo &MRI, const LiveIntervals &LIS, Register Reg, SlotIndex Begin, SlotIndex End, LaneBitmask Mask=LaneBitmask::getAll())
This file defines the GCNRegPressure class, which tracks registry pressure by bookkeeping number of S...
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static bool InRange(int64_t Value, unsigned short Shift, int LBound, int HBound)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
MachineRegisterInfo & MRI
static LaneBitmask getLanesWithProperty(LiveIntervals &LIS, const MachineRegisterInfo &MRI, bool TrackLaneMasks, VirtRegOrUnit VRegOrUnit, SlotIndex Pos, LaneBitmask SafeDefault, bool(*Property)(const LiveRange &LR, SlotIndex Pos), bool ComputePhysRegs=false)
static LaneBitmask findUseBetween(VirtRegOrUnit VRegOrUnit, LaneBitmask LastUseMask, SlotIndex PriorUseIdx, SlotIndex NextUseIdx, const MachineRegisterInfo &MRI, const LiveIntervals *LIS)
Helper to find a vreg use between two indices [PriorUseIdx, NextUseIdx).
This file implements a set that has insertion order iteration characteristics.
iterator find(const_arg_type_t< KeyT > Val)
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
void retireDeadDefs(const MachineInstr &MI, SlotIndex SI)
Retires the lanes defined by MI that are dead at SI, according to LIS.
GCNRegPressure bumpDownwardPressure(const MachineInstr *MI, const SIRegisterInfo *TRI) const
Mostly copy/paste from CodeGen/RegisterPressure.cpp Calculate the impact MI will have on CurPressure ...
void retireDeadUses(const MachineInstr &MI)
Retires the lanes of MI's used registers that die at MI, mirroring RegPressureTracker::advance().
void addDefs(const MachineInstr &MI)
Adds all lanes (dead or not) defined by MI's register operands to CurPressure.
Downward RP tracker that relies on program order to advance down the instruction stream.
bool advance()
Advance to the state at the next MI in program order.
void advanceToNext()
Move to the state at NextMI.
bool advanceBeforeNext()
Move to the state right before NextMI or the end of the MBB.
bool reset(const MachineInstr &MI, MachineBasicBlock::const_iterator End, const LiveRegSet *LiveRegsCopy=nullptr)
Reset tracker to the point before the MI (filling LiveRegs upon this point using LiveRegsCopy if prov...
void advance(const MachineInstr &MI)
Advances to the state after MI.
Models a register pressure target, allowing to evaluate and track register savings against that targe...
GCNRPTarget(const MachineFunction &MF, const GCNRegPressure &RP)
Sets up the target such that the register pressure starting at RP does not show register spilling on ...
bool isSaveBeneficial(Register Reg) const
Determines whether saving virtual register Reg will be beneficial towards achieving the RP target.
bool hasVectorRegisterExcess() const
bool satisfied() const
Whether the current RP is at or below the defined pressure target.
void setTarget(unsigned NumSGPRs, unsigned NumVGPRs)
Changes the target (same semantics as constructor).
unsigned getNumRegsBenefit(const GCNRegPressure &SaveRP) const
Returns the benefit towards achieving the RP target that saving SaveRP represents,...
const GCNRegPressure & getMaxPressure() const
GCNRegPressure getPressure() const
const decltype(LiveRegs) & getLiveRegs() const
GCNRegPressure CurPressure
DenseMap< unsigned, LaneBitmask > LiveRegSet
MachineBasicBlock::const_iterator LastTrackedMI
LaneBitmask getLastUsedLanes(Register Reg, SlotIndex Pos) const
Mostly copy/paste from CodeGen/RegisterPressure.cpp.
void updateMaxPressure(const GCNRegPressure &RP)
Folds the pressure RP of one program point into MaxPressure and passes it to the pressure callback.
GCNRegPressure MaxPressure
const MachineRegisterInfo * MRI
void setPressureCallback(std::function< void(const GCNRegPressure &)> CB)
Sets a function that the tracker calls with the pressure of every program point that it folds into th...
void reset(const MachineInstr &MI, bool After)
Resets tracker before or After the provided MI, which can be a debug instruction.
void recede(const MachineInstr &MI)
Move to the state of RP just before the MI.
bool isValid() const
returns whether the tracker's state after receding MI corresponds to reported by LIS.
void reset(const MachineInstr &MI)
Resets tracker to the point just after MI (in program order), which can be a debug instruction.
Query interferences between a single live virtual register and a live interval union.
Union of live intervals that are strong candidates for coalescing into a single register (either phys...
LiveSegments::Allocator Allocator
A live range for subregisters.
LiveInterval - This class represents the liveness of a register, or stack slot.
bool hasSubRanges() const
Returns true if subregister liveness information is available.
iterator_range< subrange_iterator > subranges()
bool hasInterval(Register Reg) const
SlotIndexes * getSlotIndexes() const
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
LiveInterval & getInterval(Register Reg)
This class represents the liveness of a register, stack slot, etc.
bool liveAt(SlotIndex index) const
unsigned getNumValNums() const
A set of live virtual registers and physical register units.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
MachineInstrBundleIterator< const MachineInstr > const_iterator
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Representation of each machine instruction.
const MachineBasicBlock * getParent() const
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI LaneBitmask getMaxLaneMaskForVReg(Register Reg) const
Returns a mask covering all bits that can appear in lane masks of subregisters of the virtual registe...
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
Simple wrapper around std::function<void(raw_ostream&)>.
List of registers defined and used by a machine instruction.
SmallVector< VRegMaskOrUnit, 8 > Defs
List of virtual registers and register units defined by the instruction which are not dead.
LLVM_ABI void adjustLaneLiveness(LiveIntervals &LIS, const MachineRegisterInfo &MRI, SlotIndex Pos)
Use liveness information to find out which uses/defs are partially undefined/dead at Pos and adjust t...
LLVM_ABI void collect(const MachineInstr &MI, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, bool TrackLaneMasks, bool IgnoreDead)
Analyze the given instruction MI and fill in the Uses, Defs and DeadDefs list based on the MachineOpe...
SmallVector< VRegMaskOrUnit, 8 > Uses
List of virtual registers and register units read by the instruction.
Wrapper class representing virtual and physical registers.
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
unsigned getDynamicVGPRBlockSize() const
static unsigned getNumCoveredRegs(LaneBitmask LM)
bool isVectorSuperClass(const TargetRegisterClass *RC) const
static bool isSGPRClass(const TargetRegisterClass *RC)
static bool isAGPRClass(const TargetRegisterClass *RC)
A vector that has set insertion semantics.
void reserve(size_type Size)
Reserve space in the SetVector if supported by the underlying containers.
Vector takeVector()
Clear the SetVector and return the underlying vector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
SlotIndex - An opaque wrapper around machine indexes.
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def.
SlotIndex getMBBLastIdx(const MachineBasicBlock *MBB) const
Returns the last valid index in the given basic block.
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Returns the index past the last valid index in the given basic block.
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Returns the first index in the given basic block.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
A Use represents the edge between a Value definition and its users.
Wrapper class representing a virtual register or register unit.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ VGPR
Address space for VGPRs.
This is an optimization pass for GlobalISel generic memory operations.
LaneBitmask getLiveLaneMask(unsigned Reg, SlotIndex SI, const LiveIntervals &LIS, const MachineRegisterInfo &MRI, LaneBitmask LaneMaskFilter=LaneBitmask::getAll())
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
GCNRPTracker::LiveRegSet getLiveRegs(SlotIndex SI, const LiveIntervals &LIS, const MachineRegisterInfo &MRI, GCNRegPressure::RegKind RegKind=GCNRegPressure::TOTAL_KINDS)
GCNRegPressure getRegPressure(const MachineRegisterInfo &MRI, Range &&LiveRegs)
Printable PrintLaneMask(LaneBitmask LaneMask)
Create Printable object to print LaneBitmasks on a raw_ostream.
IterT skipDebugInstructionsForward(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It until it points to a non-debug instruction or to End and return the resulting iterator.
auto reverse(ContainerTy &&C)
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
char & GCNRegPressurePrinterID
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void dumpMaxRegPressure(MachineFunction &MF, GCNRegPressure::RegKind Kind, LiveIntervals &LIS, const MachineLoopInfo *MLI)
@ End
Run the machine verifier once, at the end of the pipeline.
unsigned estimateGreedyVGPRPressure(MachineBasicBlock::const_iterator RegionBegin, MachineBasicBlock::const_iterator RegionEnd, const GCNRPTracker::LiveRegSet &LiveIns, const LiveIntervals &LIS, const MachineRegisterInfo &MRI, const SIRegisterInfo &TRI)
Estimate VGPR pressure using greedy, non-splitting register allocation simulation,...
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
Printable reportMismatch(const GCNRPTracker::LiveRegSet &LISLR, const GCNRPTracker::LiveRegSet &TrackedL, const TargetRegisterInfo *TRI, StringRef Pfx=" ")
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
MCRegisterClass TargetRegisterClass
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
static RegKind getRegKind(unsigned Reg, const MachineRegisterInfo &MRI)
static constexpr const char * getName(RegKind Kind)
unsigned getNumRegs(RegKind Kind) const
unsigned getVGPRTuplesWeight() const
unsigned getVGPRNum(bool UnifiedVGPRFile) const
friend Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST, unsigned DynamicVGPRBlockSize)
void inc(unsigned Reg, LaneBitmask PrevMask, LaneBitmask NewMask, const MachineRegisterInfo &MRI)
unsigned getArchVGPRNum() const
unsigned getAGPRNum() const
unsigned getSGPRNum() const
unsigned getSGPRTuplesWeight() const
bool less(const MachineFunction &MF, const GCNRegPressure &O, unsigned MaxOccupancy=std::numeric_limits< unsigned >::max()) const
Compares this GCNRegpressure to O, returning true if this is less.
static constexpr LaneBitmask getAll()
constexpr bool none() const
constexpr bool any() const
static constexpr LaneBitmask getNone()