22#define DEBUG_TYPE "machine-scheduler"
26 if (
S1.size() != S2.
size())
29 for (
const auto &
P :
S1) {
31 if (
I == S2.
end() ||
I->second !=
P.second)
55 if (NewNumCoveredRegs == PrevNumCoveredRegs)
59 if (NewMask < PrevMask) {
61 std::swap(NewNumCoveredRegs, PrevNumCoveredRegs);
64 assert(PrevMask < NewMask && PrevNumCoveredRegs < NewNumCoveredRegs &&
65 "prev mask should always be lesser than new");
71 if (
TRI->getRegSizeInBits(*RC) != 32) {
73 if (PrevMask.
none()) {
75 Value[TupleIdx] += Sign *
TRI->getRegClassWeight(RC).RegWeight;
95 Sign *= NewNumCoveredRegs - PrevNumCoveredRegs;
101 unsigned MaxOccupancy)
const {
103 unsigned DynamicVGPRBlockSize =
106 const auto SGPROcc = std::min(MaxOccupancy,
108 const auto VGPROcc = std::min(
109 MaxOccupancy, ST.getOccupancyWithNumVGPRs(
getVGPRNum(ST.hasGFX90AInsts()),
110 DynamicVGPRBlockSize));
111 const auto OtherSGPROcc = std::min(MaxOccupancy,
112 ST.getOccupancyWithNumSGPRs(O.getSGPRNum()));
113 const auto OtherVGPROcc =
114 std::min(MaxOccupancy,
115 ST.getOccupancyWithNumVGPRs(O.getVGPRNum(ST.hasGFX90AInsts()),
116 DynamicVGPRBlockSize));
118 const auto Occ = std::min(SGPROcc, VGPROcc);
119 const auto OtherOcc = std::min(OtherSGPROcc, OtherVGPROcc);
123 return Occ > OtherOcc;
125 unsigned MaxVGPRs = ST.getMaxNumVGPRs(MF);
126 unsigned MaxSGPRs = ST.getMaxNumSGPRs(MF);
129 unsigned ExcessSGPR = std::max(
static_cast<int>(
getSGPRNum() - MaxSGPRs), 0);
130 unsigned OtherExcessSGPR =
131 std::max(
static_cast<int>(O.getSGPRNum() - MaxSGPRs), 0);
133 auto WaveSize = ST.getWavefrontSize();
135 unsigned VGPRForSGPRSpills = (ExcessSGPR + (WaveSize - 1)) / WaveSize;
136 unsigned OtherVGPRForSGPRSpills =
137 (OtherExcessSGPR + (WaveSize - 1)) / WaveSize;
139 unsigned MaxArchVGPRs = ST.getAddressableNumArchVGPRs();
143 unsigned ExcessVGPR =
144 std::max(
static_cast<int>(
getVGPRNum(ST.hasGFX90AInsts()) +
145 VGPRForSGPRSpills - MaxVGPRs),
147 unsigned OtherExcessVGPR =
148 std::max(
static_cast<int>(O.getVGPRNum(ST.hasGFX90AInsts()) +
149 OtherVGPRForSGPRSpills - MaxVGPRs),
153 unsigned ExcessArchVGPR = std::max(
154 static_cast<int>(
getVGPRNum(
false) + VGPRForSGPRSpills - MaxArchVGPRs),
156 unsigned OtherExcessArchVGPR =
157 std::max(
static_cast<int>(O.getVGPRNum(
false) + OtherVGPRForSGPRSpills -
161 unsigned ExcessAGPR = std::max(
162 static_cast<int>(ST.hasGFX90AInsts() ? (
getAGPRNum() - MaxArchVGPRs)
165 unsigned OtherExcessAGPR = std::max(
166 static_cast<int>(ST.hasGFX90AInsts() ? (O.getAGPRNum() - MaxArchVGPRs)
167 : (O.getAGPRNum() - MaxVGPRs)),
170 bool ExcessRP = ExcessSGPR || ExcessVGPR || ExcessArchVGPR || ExcessAGPR;
171 bool OtherExcessRP = OtherExcessSGPR || OtherExcessVGPR ||
172 OtherExcessArchVGPR || OtherExcessAGPR;
176 if (ExcessRP || OtherExcessRP) {
179 int VGPRDiff = ((OtherExcessVGPR + OtherExcessArchVGPR + OtherExcessAGPR) -
180 (ExcessVGPR + ExcessArchVGPR + ExcessAGPR));
182 int SGPRDiff = OtherExcessSGPR - ExcessSGPR;
187 unsigned PureExcessVGPR =
188 std::max(
static_cast<int>(
getVGPRNum(ST.hasGFX90AInsts()) - MaxVGPRs),
190 std::max(
static_cast<int>(
getVGPRNum(
false) - MaxArchVGPRs), 0);
191 unsigned OtherPureExcessVGPR =
193 static_cast<int>(O.getVGPRNum(ST.hasGFX90AInsts()) - MaxVGPRs),
195 std::max(
static_cast<int>(O.getVGPRNum(
false) - MaxArchVGPRs), 0);
200 if (PureExcessVGPR != OtherPureExcessVGPR)
208 bool SGPRImportant = SGPROcc < VGPROcc;
209 const bool OtherSGPRImportant = OtherSGPROcc < OtherVGPROcc;
212 if (SGPRImportant != OtherSGPRImportant) {
213 SGPRImportant =
false;
217 bool SGPRFirst = SGPRImportant;
218 for (
int I = 2;
I > 0; --
I, SGPRFirst = !SGPRFirst) {
221 auto OtherSW = O.getSGPRTuplesWeight();
226 auto OtherVW = O.getVGPRTuplesWeight();
233 return SGPRImportant ? (
getSGPRNum() < O.getSGPRNum()):
235 O.getVGPRNum(ST.hasGFX90AInsts()));
239 unsigned DynamicVGPRBlockSize) {
241 OS <<
"VGPRs: " << RP.getArchVGPRNum() <<
' '
242 <<
"AGPRs: " << RP.getAGPRNum();
245 << ST->getOccupancyWithNumVGPRs(RP.getVGPRNum(ST->hasGFX90AInsts()),
246 DynamicVGPRBlockSize)
248 OS <<
", SGPRs: " << RP.getSGPRNum();
250 OS <<
"(O" << ST->getOccupancyWithNumSGPRs(RP.getSGPRNum()) <<
')';
251 OS <<
", LVGPR WT: " << RP.getVGPRTuplesWeight()
252 <<
", LSGPR WT: " << RP.getSGPRTuplesWeight();
254 OS <<
" -> Occ: " << RP.getOccupancy(*ST, DynamicVGPRBlockSize);
268 MRI.getTargetRegisterInfo()->getSubRegIndexLaneMask(MO.
getSubReg());
276 auto &
TRI = *
MRI.getTargetRegisterInfo();
277 for (
const auto &MO :
MI.operands()) {
278 if (!MO.isReg() || !MO.getReg().isVirtual())
280 if (!MO.isUse() || !MO.readsReg())
285 return RM.RegUnit ==
Reg;
288 auto &
P =
I == VRegMaskOrUnits.
end()
292 P.LaneMask |= MO.getSubReg() ?
TRI.getSubRegIndexLaneMask(MO.getSubReg())
293 :
MRI.getMaxLaneMaskForVReg(Reg);
297 for (
auto &
P : VRegMaskOrUnits) {
299 if (!LI.hasSubRanges())
306 InstrSI =
LIS.getInstructionIndex(
MI).getBaseIndex();
323 if (Property(SR, Pos))
324 Result |= SR.LaneMask;
326 }
else if (Property(LI, Pos)) {
327 Result = TrackLaneMasks ?
MRI.getMaxLaneMaskForVReg(RegUnit)
349 bool Upward =
false) {
355 bool InRange = Upward ? (InstSlot > PriorUseIdx && InstSlot <= NextUseIdx)
356 : (InstSlot >= PriorUseIdx && InstSlot < NextUseIdx);
360 unsigned SubRegIdx = MO.getSubReg();
362 LastUseMask &= ~UseMask;
363 if (LastUseMask.
none())
376 setTarget(ST.getMaxNumSGPRs(
F), ST.getMaxNumVGPRs(
F));
389 unsigned DynamicVGPRBlockSize =
391 setTarget(ST.getMaxNumSGPRs(Occupancy,
false),
392 ST.getMaxNumVGPRs(Occupancy, DynamicVGPRBlockSize));
397 MaxSGPRs = std::min(ST.getAddressableNumSGPRs(), NumSGPRs);
398 MaxVGPRs = std::min(ST.getAddressableNumArchVGPRs(), NumVGPRs);
400 unsigned DynamicVGPRBlockSize =
403 std::min(ST.getAddressableNumVGPRs(DynamicVGPRBlockSize), NumVGPRs);
416 return RP.getSGPRNum() > MaxSGPRs;
418 SRI->
isAGPRClass(RC) ? RP.getAGPRNum() : RP.getArchVGPRNum();
420 if (NumVGPRs > MaxVGPRs)
423 return UnifiedRF && RP.getVGPRNum(
true) > MaxUnifiedVGPRs;
427 if (RP.getSGPRNum() > MaxSGPRs || RP.getVGPRNum(
false) > MaxVGPRs)
429 if (UnifiedRF && RP.getVGPRNum(
true) > MaxUnifiedVGPRs)
450 if ((S.LaneMask & LaneMaskFilter).any() && S.liveAt(
SI)) {
451 LiveMask |= S.LaneMask;
452 assert(LiveMask == (LiveMask &
MRI.getMaxLaneMaskForVReg(LI.
reg())));
455 LiveMask =
MRI.getMaxLaneMaskForVReg(LI.
reg());
457 LiveMask &= LaneMaskFilter;
466 for (
unsigned I = 0, E =
MRI.getNumVirtRegs();
I != E; ++
I) {
510 const LiveRange::Segment *S = LR.getSegmentContaining(Pos);
511 return S != nullptr && S->end == Pos.getRegSlot();
523 if (
MI.isDebugInstr())
528 bool HasECDefs =
false;
530 if (!MO.getReg().isVirtual())
537 if (MO.isEarlyClobber()) {
549 LiveMask &= ~DefMask;
558 DefPressure += ECDefPressure;
567 LiveMask |= U.LaneMask;
583 MRI = &
MI.getParent()->getParent()->getRegInfo();
585 MBBEnd =
MI.getParent()->end();
588 if (NextMI == MBBEnd)
595 bool UseInternalIterator) {
599 if (UseInternalIterator) {
601 return NextMI == MBBEnd;
603 assert(NextMI == MBBEnd || !NextMI->isDebugInstr());
606 SI = NextMI == MBBEnd
607 ?
LIS.getInstructionIndex(*LastTrackedMI).getDeadSlot()
608 :
LIS.getInstructionIndex(*NextMI).getBaseIndex();
610 SI =
LIS.getInstructionIndex(*MI).getBaseIndex();
618 for (
auto &MO : CurrMI->
operands()) {
619 if (!MO.isReg() || !MO.getReg().isVirtual())
621 if (MO.isUse() && !MO.readsReg())
623 if (!UseInternalIterator && MO.isDef())
625 if (!SeenRegs.
insert(MO.getReg()).second)
637 auto PrevMask = It->second;
638 It->second &= ~S.LaneMask;
642 if (It !=
LiveRegs.end() && It->second.none())
645 auto It =
LiveRegs.find(MO.getReg());
657 return UseInternalIterator && (NextMI == MBBEnd);
661 bool UseInternalIterator) {
662 if (UseInternalIterator) {
672 for (
const auto &MO : CurrMI->
all_defs()) {
674 if (!Reg.isVirtual())
677 auto PrevMask = LiveMask;
686 if (UseInternalIterator && NextMI == MBBEnd)
691 if (!UseInternalIterator) {
699 while (NextMI != End)
707 reset(*Begin, LiveRegsCopy);
715 for (
auto const &
P : TrackedLR) {
716 auto I = LISLR.
find(
P.first);
717 if (
I == LISLR.
end()) {
719 <<
" isn't found in LIS reported set\n";
720 }
else if (
I->second !=
P.second) {
722 <<
" masks doesn't match: LIS reported " <<
PrintLaneMask(
I->second)
726 for (
auto const &
P : LISLR) {
727 auto I = TrackedLR.find(
P.first);
728 if (
I == TrackedLR.end()) {
730 <<
" isn't found in tracked set\n";
739 assert(!
MI->isDebugOrPseudoInstr() &&
"Expect a nondebug instruction.");
742 SlotIdx =
LIS.getInstructionIndex(*MI).getRegSlot();
752 if (!Reg.isVirtual())
755 if (LastUseMask.
none())
766 if (IdxPos ==
MBB->end()) {
767 CurrIdx =
LIS.getMBBEndIdx(
MBB);
769 CurrIdx =
LIS.getInstructionIndex(*IdxPos).getRegSlot();
774 if (LastUseMask.
none())
780 TempPressure.
inc(Reg, LiveMask, NewMask, *
MRI);
786 if (!Reg.isVirtual())
791 TempPressure.
inc(Reg, LiveMask, NewMask, *
MRI);
798 const auto &
SI =
LIS.getInstructionIndex(*LastTrackedMI).getBaseIndex();
802 if (!
isEqual(LISLR, TrackedLR)) {
803 dbgs() <<
"\nGCNUpwardRPTracker error: Tracked and"
804 " LIS reported livesets mismatch:\n"
812 dbgs() <<
"GCNUpwardRPTracker error: Pressure sets different\nTracked: "
823 for (
unsigned I = 0, E =
MRI.getNumVirtRegs();
I != E; ++
I) {
826 if (It !=
LiveRegs.end() && It->second.any())
837 "amdgpu-print-rp-downward",
838 cl::desc(
"Use GCNDownwardRPTracker for GCNRegPressurePrinter pass"),
853 auto IsInOneSegment = [Begin, End](
const LiveRange &LR) ->
bool {
854 auto *Segment = LR.getSegmentContaining(Begin);
855 return Segment && Segment->contains(End);
861 for (auto &SR : LI.subranges()) {
862 if ((SR.LaneMask & Mask) == SR.LaneMask && IsInOneSegment(SR))
863 LiveThroughMask |= SR.LaneMask;
867 if ((RegMask & Mask) == RegMask && IsInOneSegment(LI))
868 LiveThroughMask = RegMask;
871 return LiveThroughMask;
884 OS <<
"---\nname: " << MF.
getName() <<
"\nbody: |\n";
888 OS <<
format(
PFX " %-5d", RP.getSGPRNum())
889 <<
format(
" %-5d", RP.getVGPRNum(
false));
895 if (LISLR != TrackedLR) {
904 for (
auto &
MBB : MF) {
906 RP.reserve(
MBB.size());
947 if (!
MI.isDebugInstr())
956 ReportLISMismatchIfAny(LiveIn,
getLiveRegs(MBBStartSlot, LIS,
MRI));
958 OS <<
PFX " SGPR VGPR\n";
960 for (
auto &
MI :
MBB) {
961 if (!
MI.isDebugInstr()) {
962 auto &[RPBeforeInstr, RPAtInstr] =
965 OS << printRP(RPBeforeInstr) <<
'\n' << printRP(RPAtInstr) <<
" ";
970 OS << printRP(RPAtMBBEnd) <<
'\n';
974 ReportLISMismatchIfAny(LiveOut,
getLiveRegs(MBBLastSlot, LIS,
MRI));
977 for (
auto [Reg, Mask] : LiveIn) {
979 if (MaskIntersection.
any()) {
981 MRI, LIS, Reg, MBBStartSlot, MBBLastSlot, MaskIntersection);
983 LiveThrough[Reg] = LTMask;
995#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1006 unsigned MaxNumRegs = 0;
1014 if (NumRegs > MaxNumRegs) {
1015 MaxNumRegs = NumRegs;
1016 MaxPressureMI = &
MI;
1033 ECNumRegs > RNumRegs ? &ECLiveSet : &RLiveSet;
1034 SlotIndex MaxPressureSlot = ECNumRegs > RNumRegs ? ECSlot : RSlot;
1040 for (
auto [Reg, LaneMask] : *LiveSet) {
1046 return SR.getNumValNums() == 1;
1055 unsigned SDefNumRegs = SDefPressure.
getNumRegs(Kind);
1056 unsigned MDefNumRegs = MDefPressure.
getNumRegs(Kind);
1057 assert(SDefNumRegs + MDefNumRegs == MaxNumRegs);
1065 <<
", Depth " <<
ML->getLoopDepth() <<
")";
1073 <<
TRI->getRegClassName(
MRI.getRegClass(Reg)) <<
", LiveMask "
1074 <<
PrintLaneMask(LiveMask) <<
" (" << RegPressure.getNumRegs(Kind) <<
' '
1078 std::map<SlotIndex, const MachineInstr *> Instrs;
1083 for (
const auto &[
SI,
MI] : Instrs) {
1085 if (
MI->definesRegister(Reg,
TRI))
1087 if (
MI->readsRegister(Reg,
TRI))
1089 OS << printLoc(
MI->getParent(),
SI) <<
": " << *
MI;
1093 OS <<
"\n*** Register pressure info (" <<
RegName <<
"s) for " << MF.
getName()
1095 OS <<
"Max pressure is " << MaxNumRegs <<
' ' <<
RegName <<
"s at "
1096 << printLoc(MaxPressureMI->
getParent(), MaxPressureSlot) <<
": "
1099 OS <<
"\nLive registers with single definition (" << SDefNumRegs <<
' '
1104 return std::distance(
MRI.use_nodbg_begin(
A),
MRI.use_nodbg_end()) <
1105 std::distance(
MRI.use_nodbg_begin(
B),
MRI.use_nodbg_end());
1108 for (
const Register Reg : SDefRegs) {
1109 PrintRegInfo(Reg, LiveSet->
lookup(Reg));
1112 OS <<
"\nLive registers with multiple definitions (" << MDefNumRegs <<
' '
1114 for (
const Register Reg : MDefRegs) {
1115 PrintRegInfo(Reg, LiveSet->
lookup(Reg));
unsigned const MachineRegisterInfo * MRI
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 cl::opt< bool > UseDownwardTracker("amdgpu-print-rp-downward", cl::desc("Use GCNDownwardRPTracker for GCNRegPressurePrinter pass"), cl::init(false), cl::Hidden)
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
static bool InRange(int64_t Value, unsigned short Shift, int LBound, int HBound)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static LaneBitmask findUseBetween(unsigned Reg, LaneBitmask LastUseMask, SlotIndex PriorUseIdx, SlotIndex NextUseIdx, const MachineRegisterInfo &MRI, const LiveIntervals *LIS)
Helper to find a vreg use between two indices [PriorUseIdx, NextUseIdx).
static LaneBitmask getLanesWithProperty(const LiveIntervals &LIS, const MachineRegisterInfo &MRI, bool TrackLaneMasks, Register RegUnit, SlotIndex Pos, LaneBitmask SafeDefault, bool(*Property)(const LiveRange &LR, SlotIndex Pos))
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
iterator find(const_arg_type_t< KeyT > Val)
bool advanceBeforeNext(MachineInstr *MI=nullptr, bool UseInternalIterator=true)
Move to the state right before the next MI or after the end of MBB.
bool advance(MachineInstr *MI=nullptr, bool UseInternalIterator=true)
Move to the state at the next MI.
GCNRegPressure bumpDownwardPressure(const MachineInstr *MI, const SIRegisterInfo *TRI) const
Mostly copy/paste from CodeGen/RegisterPressure.cpp Calculate the impact MI will have on CurPressure ...
bool reset(const MachineInstr &MI, const LiveRegSet *LiveRegs=nullptr)
Reset tracker to the point before the MI filling LiveRegs upon this point using LIS.
void advanceToNext(MachineInstr *MI=nullptr, bool UseInternalIterator=true)
Move to the state at the MI, advanceBeforeNext has to be called first.
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 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).
GCNRegPressure getPressure() const
const decltype(LiveRegs) & getLiveRegs() const
const MachineInstr * LastTrackedMI
GCNRegPressure CurPressure
DenseMap< unsigned, LaneBitmask > LiveRegSet
GCNRegPressure MaxPressure
void reset(const MachineInstr &MI, const LiveRegSet *LiveRegsCopy, bool After)
LaneBitmask getLastUsedLanes(Register RegUnit, SlotIndex Pos) const
Mostly copy/paste from CodeGen/RegisterPressure.cpp.
const MachineRegisterInfo * MRI
const LiveIntervals & LIS
void reset(const MachineRegisterInfo &MRI, SlotIndex SI)
reset tracker at the specified slot index SI.
void recede(const MachineInstr &MI)
Move to the state of RP just before the MI .
const GCNRegPressure & getMaxPressure() const
bool isValid() const
returns whether the tracker's state after receding MI corresponds to reported by LIS.
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.
LiveRange * getCachedRegUnit(unsigned Unit)
Return the live range for register unit Unit if it has already been computed, or nullptr if it hasn't...
LiveInterval & getInterval(Register Reg)
This class represents the liveness of a register, stack slot, etc.
bool liveAt(SlotIndex index) const
unsigned getNumValNums() const
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
filtered_mop_range all_defs()
Returns an iterator range over all operands that are (explicit or implicit) register defs.
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,...
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 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...
LLVM_ABI void adjustLaneLiveness(const LiveIntervals &LIS, const MachineRegisterInfo &MRI, SlotIndex Pos, MachineInstr *AddFlagsMI=nullptr)
Use liveness information to find out which uses/defs are partially undefined/dead and adjust the VReg...
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)
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(unsigned Num) const
Returns the index past the last valid index in the given basic block.
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
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.
StringRef - 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.
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.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
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.
GCNRPTracker::LiveRegSet getLiveRegsAfter(const MachineInstr &MI, const LiveIntervals &LIS)
auto reverse(ContainerTy &&C)
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI Printable printVRegOrUnit(unsigned VRegOrUnit, const TargetRegisterInfo *TRI)
Create Printable object to print virtual registers and physical registers on a raw_ostream.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
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.
GCNRPTracker::LiveRegSet getLiveRegsBefore(const MachineInstr &MI, const LiveIntervals &LIS)
LLVM_ABI void dumpMaxRegPressure(MachineFunction &MF, GCNRegPressure::RegKind Kind, LiveIntervals &LIS, const MachineLoopInfo *MLI)
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.
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 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()