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;
104 unsigned ArchVGPR = 0;
107 bool anyExcess()
const {
return SGPR || VGPR || ArchVGPR || AGPR; }
108 bool hasVectorRegisterExcess()
const {
return VGPR || ArchVGPR || AGPR; }
110 RegExcess(
const MachineFunction &MF,
const GCNRegPressure &RP)
111 : RegExcess(MF,
RP, GCNRPTarget(MF,
RP)) {}
112 RegExcess(
const MachineFunction &MF,
const GCNRegPressure &RP,
113 const GCNRPTarget &Target) {
114 unsigned MaxSGPRs =
Target.getMaxSGPRs();
115 unsigned MaxVGPRs =
Target.getMaxVGPRs();
118 SGPR = std::max(
static_cast<int>(
RP.getSGPRNum() - MaxSGPRs), 0);
121 unsigned WaveSize =
ST.getWavefrontSize();
122 unsigned VGPRForSGPRSpills =
divideCeil(SGPR, WaveSize);
124 unsigned MaxArchVGPRs =
ST.getAddressableNumArchVGPRs();
128 VGPR = std::max(
static_cast<int>(
RP.getVGPRNum(
ST.hasGFX90AInsts()) +
129 VGPRForSGPRSpills - MaxVGPRs),
132 unsigned ArchVGPRLimit =
ST.hasGFX90AInsts() ? MaxArchVGPRs : MaxVGPRs;
135 ArchVGPR = std::max(
static_cast<int>(
RP.getArchVGPRNum() +
136 VGPRForSGPRSpills - ArchVGPRLimit),
140 AGPR = std::max(
static_cast<int>(
RP.getAGPRNum() - ArchVGPRLimit), 0);
146 unsigned MaxOccupancy)
const {
148 unsigned DynamicVGPRBlockSize =
151 const auto SGPROcc = std::min(MaxOccupancy,
153 const auto VGPROcc = std::min(
154 MaxOccupancy, ST.getOccupancyWithNumVGPRs(
getVGPRNum(ST.hasGFX90AInsts()),
155 DynamicVGPRBlockSize));
156 const auto OtherSGPROcc = std::min(MaxOccupancy,
157 ST.getOccupancyWithNumSGPRs(O.getSGPRNum()));
158 const auto OtherVGPROcc =
159 std::min(MaxOccupancy,
160 ST.getOccupancyWithNumVGPRs(O.getVGPRNum(ST.hasGFX90AInsts()),
161 DynamicVGPRBlockSize));
163 const auto Occ = std::min(SGPROcc, VGPROcc);
164 const auto OtherOcc = std::min(OtherSGPROcc, OtherVGPROcc);
168 return Occ > OtherOcc;
170 unsigned MaxVGPRs = ST.getMaxNumVGPRs(MF);
172 RegExcess Excess(MF, *
this);
173 RegExcess OtherExcess(MF, O);
175 unsigned MaxArchVGPRs = ST.getAddressableNumArchVGPRs();
177 bool ExcessRP = Excess.anyExcess();
178 bool OtherExcessRP = OtherExcess.anyExcess();
182 if (ExcessRP || OtherExcessRP) {
186 ((OtherExcess.VGPR + OtherExcess.ArchVGPR + OtherExcess.AGPR) -
187 (Excess.VGPR + Excess.ArchVGPR + Excess.AGPR));
189 int SGPRDiff = OtherExcess.SGPR - Excess.SGPR;
194 unsigned PureExcessVGPR =
195 std::max(
static_cast<int>(
getVGPRNum(ST.hasGFX90AInsts()) - MaxVGPRs),
197 std::max(
static_cast<int>(
getVGPRNum(
false) - MaxArchVGPRs), 0);
198 unsigned OtherPureExcessVGPR =
200 static_cast<int>(O.getVGPRNum(ST.hasGFX90AInsts()) - MaxVGPRs),
202 std::max(
static_cast<int>(O.getVGPRNum(
false) - MaxArchVGPRs), 0);
207 if (PureExcessVGPR != OtherPureExcessVGPR)
215 bool SGPRImportant = SGPROcc < VGPROcc;
216 const bool OtherSGPRImportant = OtherSGPROcc < OtherVGPROcc;
219 if (SGPRImportant != OtherSGPRImportant) {
220 SGPRImportant =
false;
224 bool SGPRFirst = SGPRImportant;
225 for (
int I = 2;
I > 0; --
I, SGPRFirst = !SGPRFirst) {
228 auto OtherSW = O.getSGPRTuplesWeight();
233 auto OtherVW = O.getVGPRTuplesWeight();
240 return SGPRImportant ? (
getSGPRNum() < O.getSGPRNum()):
242 O.getVGPRNum(ST.hasGFX90AInsts()));
246 unsigned DynamicVGPRBlockSize) {
248 OS <<
"VGPRs: " << RP.getArchVGPRNum() <<
' '
249 <<
"AGPRs: " << RP.getAGPRNum();
252 << ST->getOccupancyWithNumVGPRs(RP.getVGPRNum(ST->hasGFX90AInsts()),
253 DynamicVGPRBlockSize)
255 OS <<
", SGPRs: " << RP.getSGPRNum();
257 OS <<
"(O" << ST->getOccupancyWithNumSGPRs(RP.getSGPRNum()) <<
')';
258 OS <<
", LVGPR WT: " << RP.getVGPRTuplesWeight()
259 <<
", LSGPR WT: " << RP.getSGPRTuplesWeight();
261 OS <<
" -> Occ: " << RP.getOccupancy(*ST, DynamicVGPRBlockSize);
275 MRI.getTargetRegisterInfo()->getSubRegIndexLaneMask(MO.
getSubReg());
283 auto &
TRI = *
MRI.getTargetRegisterInfo();
284 for (
const auto &MO :
MI.operands()) {
285 if (!MO.isReg() || !MO.getReg().isVirtual())
287 if (!MO.isUse() || !MO.readsReg())
292 return RM.VRegOrUnit.asVirtualReg() ==
Reg;
295 auto &
P =
I == VRegMaskOrUnits.
end()
300 P.LaneMask |= MO.getSubReg() ?
TRI.getSubRegIndexLaneMask(MO.getSubReg())
301 :
MRI.getMaxLaneMaskForVReg(Reg);
305 for (
auto &
P : VRegMaskOrUnits) {
306 auto &LI =
LIS.getInterval(
P.VRegOrUnit.asVirtualReg());
307 if (!LI.hasSubRanges())
314 InstrSI =
LIS.getInstructionIndex(
MI).getBaseIndex();
330 if (Property(SR, Pos))
331 Result |= SR.LaneMask;
333 }
else if (Property(LI, Pos)) {
350 bool Upward =
false) {
356 bool InRange = Upward ? (InstSlot > PriorUseIdx && InstSlot <= NextUseIdx)
357 : (InstSlot >= PriorUseIdx && InstSlot < NextUseIdx);
361 unsigned SubRegIdx = MO.getSubReg();
363 LastUseMask &= ~UseMask;
364 if (LastUseMask.
none())
377 setTarget(ST.getMaxNumSGPRs(
F), ST.getMaxNumVGPRs(
F));
390 unsigned DynamicVGPRBlockSize =
392 setTarget(ST.getMaxNumSGPRs(Occupancy,
false),
393 ST.getMaxNumVGPRs(Occupancy, DynamicVGPRBlockSize));
398 MaxSGPRs = std::min(ST.getAddressableNumSGPRs(), NumSGPRs);
399 MaxVGPRs = std::min(ST.getAddressableNumArchVGPRs(), NumVGPRs);
401 unsigned DynamicVGPRBlockSize =
404 std::min(ST.getAddressableNumVGPRs(DynamicVGPRBlockSize), NumVGPRs);
416 RegExcess Excess(MF, RP, *
this);
422 return (UnifiedRF && Excess.VGPR) || Excess.AGPR;
424 return (UnifiedRF && Excess.VGPR) || Excess.ArchVGPR;
428 if (RP.getSGPRNum() > MaxSGPRs || RP.getVGPRNum(
false) > MaxVGPRs)
430 if (UnifiedRF && RP.getVGPRNum(
true) > MaxUnifiedVGPRs)
436 RegExcess Excess(MF, RP, *
this);
437 return Excess.hasVectorRegisterExcess();
456 if ((S.LaneMask & LaneMaskFilter).any() && S.liveAt(
SI)) {
457 LiveMask |= S.LaneMask;
458 assert(LiveMask == (LiveMask &
MRI.getMaxLaneMaskForVReg(LI.
reg())));
461 LiveMask =
MRI.getMaxLaneMaskForVReg(LI.
reg());
463 LiveMask &= LaneMaskFilter;
472 for (
unsigned I = 0, E =
MRI.getNumVirtRegs();
I != E; ++
I) {
515 const LiveRange::Segment *S = LR.getSegmentContaining(Pos);
516 return S != nullptr && S->end == Pos.getRegSlot();
528 if (
MI.isDebugInstr())
533 bool HasECDefs =
false;
535 if (!MO.getReg().isVirtual())
542 if (MO.isEarlyClobber()) {
554 LiveMask &= ~DefMask;
563 DefPressure += ECDefPressure;
572 LiveMask |= U.LaneMask;
573 CurPressure.inc(U.VRegOrUnit.asVirtualReg(), PrevMask, LiveMask, *
MRI);
588 MRI = &
MI.getMF()->getRegInfo();
590 MBBEnd =
MI.getParent()->end();
593 if (NextMI == MBBEnd)
600 bool UseInternalIterator) {
604 if (UseInternalIterator) {
606 return NextMI == MBBEnd;
608 assert(NextMI == MBBEnd || !NextMI->isDebugInstr());
611 SI = NextMI == MBBEnd
612 ?
LIS.getInstructionIndex(*LastTrackedMI).getDeadSlot()
613 :
LIS.getInstructionIndex(*NextMI).getBaseIndex();
615 SI =
LIS.getInstructionIndex(*MI).getBaseIndex();
623 for (
auto &MO : CurrMI->
operands()) {
624 if (!MO.isReg() || !MO.getReg().isVirtual())
626 if (MO.isUse() && !MO.readsReg())
628 if (!UseInternalIterator && MO.isDef())
630 if (!SeenRegs.
insert(MO.getReg()).second)
642 auto PrevMask = It->second;
643 It->second &= ~S.LaneMask;
647 if (It !=
LiveRegs.end() && It->second.none())
650 auto It =
LiveRegs.find(MO.getReg());
662 return UseInternalIterator && (NextMI == MBBEnd);
666 bool UseInternalIterator) {
667 if (UseInternalIterator) {
677 for (
const auto &MO : CurrMI->
all_defs()) {
679 if (!Reg.isVirtual())
682 auto PrevMask = LiveMask;
691 if (UseInternalIterator && NextMI == MBBEnd)
696 if (!UseInternalIterator) {
704 while (NextMI != End)
712 reset(*Begin, LiveRegsCopy);
720 for (
auto const &
P : TrackedLR) {
721 auto I = LISLR.
find(
P.first);
722 if (
I == LISLR.
end()) {
724 <<
" isn't found in LIS reported set\n";
725 }
else if (
I->second !=
P.second) {
727 <<
" masks doesn't match: LIS reported " <<
PrintLaneMask(
I->second)
731 for (
auto const &
P : LISLR) {
732 auto I = TrackedLR.find(
P.first);
733 if (
I == TrackedLR.end()) {
735 <<
" isn't found in tracked set\n";
744 assert(!
MI->isDebugOrPseudoInstr() &&
"Expect a nondebug instruction.");
747 SlotIdx =
LIS.getInstructionIndex(*MI).getRegSlot();
756 if (!
Use.VRegOrUnit.isVirtualReg())
760 if (LastUseMask.
none())
771 if (IdxPos ==
MBB->end()) {
772 CurrIdx =
LIS.getMBBEndIdx(
MBB);
774 CurrIdx =
LIS.getInstructionIndex(*IdxPos).getRegSlot();
779 if (LastUseMask.
none())
785 TempPressure.
inc(Reg, LiveMask, NewMask, *
MRI);
790 if (!Def.VRegOrUnit.isVirtualReg())
792 Register Reg = Def.VRegOrUnit.asVirtualReg();
796 TempPressure.
inc(Reg, LiveMask, NewMask, *
MRI);
803 const auto &
SI =
LIS.getInstructionIndex(*LastTrackedMI).getBaseIndex();
807 if (!
isEqual(LISLR, TrackedLR)) {
808 dbgs() <<
"\nGCNUpwardRPTracker error: Tracked and"
809 " LIS reported livesets mismatch:\n"
817 dbgs() <<
"GCNUpwardRPTracker error: Pressure sets different\nTracked: "
828 for (
unsigned I = 0, E =
MRI.getNumVirtRegs();
I != E; ++
I) {
831 if (It !=
LiveRegs.end() && It->second.any())
841 "amdgpu-print-rp-downward",
842 cl::desc(
"Use GCNDownwardRPTracker for GCNRegPressurePrinter pass"),
857 auto IsInOneSegment = [Begin, End](
const LiveRange &LR) ->
bool {
858 auto *Segment = LR.getSegmentContaining(Begin);
859 return Segment && Segment->contains(End);
865 for (auto &SR : LI.subranges()) {
866 if ((SR.LaneMask & Mask) == SR.LaneMask && IsInOneSegment(SR))
867 LiveThroughMask |= SR.LaneMask;
871 if ((RegMask & Mask) == RegMask && IsInOneSegment(LI))
872 LiveThroughMask = RegMask;
875 return LiveThroughMask;
888 OS <<
"---\nname: " << MF.
getName() <<
"\nbody: |\n";
892 OS <<
format(
PFX " %-5d", RP.getSGPRNum())
893 <<
format(
" %-5d", RP.getVGPRNum(
false));
899 if (LISLR != TrackedLR) {
908 for (
auto &
MBB : MF) {
910 RP.reserve(
MBB.size());
951 if (!
MI.isDebugInstr())
960 ReportLISMismatchIfAny(LiveIn,
getLiveRegs(MBBStartSlot, LIS,
MRI));
962 OS <<
PFX " SGPR VGPR\n";
964 for (
auto &
MI :
MBB) {
965 if (!
MI.isDebugInstr()) {
966 auto &[RPBeforeInstr, RPAtInstr] =
969 OS << printRP(RPBeforeInstr) <<
'\n' << printRP(RPAtInstr) <<
" ";
974 OS << printRP(RPAtMBBEnd) <<
'\n';
978 ReportLISMismatchIfAny(LiveOut,
getLiveRegs(MBBLastSlot, LIS,
MRI));
981 for (
auto [Reg, Mask] : LiveIn) {
983 if (MaskIntersection.
any()) {
985 MRI, LIS, Reg, MBBStartSlot, MBBLastSlot, MaskIntersection);
987 LiveThrough[Reg] = LTMask;
999#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1010 unsigned MaxNumRegs = 0;
1018 if (NumRegs > MaxNumRegs) {
1019 MaxNumRegs = NumRegs;
1020 MaxPressureMI = &
MI;
1037 ECNumRegs > RNumRegs ? &ECLiveSet : &RLiveSet;
1038 SlotIndex MaxPressureSlot = ECNumRegs > RNumRegs ? ECSlot : RSlot;
1044 for (
auto [Reg, LaneMask] : *LiveSet) {
1050 return SR.getNumValNums() == 1;
1059 unsigned SDefNumRegs = SDefPressure.
getNumRegs(Kind);
1060 unsigned MDefNumRegs = MDefPressure.
getNumRegs(Kind);
1061 assert(SDefNumRegs + MDefNumRegs == MaxNumRegs);
1069 <<
", Depth " <<
ML->getLoopDepth() <<
")";
1077 <<
TRI->getRegClassName(
MRI.getRegClass(Reg)) <<
", LiveMask "
1078 <<
PrintLaneMask(LiveMask) <<
" (" << RegPressure.getNumRegs(Kind) <<
' '
1082 std::map<SlotIndex, const MachineInstr *> Instrs;
1087 for (
const auto &[
SI,
MI] : Instrs) {
1089 if (
MI->definesRegister(Reg,
TRI))
1091 if (
MI->readsRegister(Reg,
TRI))
1093 OS << printLoc(
MI->getParent(),
SI) <<
": " << *
MI;
1097 OS <<
"\n*** Register pressure info (" <<
RegName <<
"s) for " << MF.
getName()
1099 OS <<
"Max pressure is " << MaxNumRegs <<
' ' <<
RegName <<
"s at "
1100 << printLoc(MaxPressureMI->
getParent(), MaxPressureSlot) <<
": "
1103 OS <<
"\nLive registers with single definition (" << SDefNumRegs <<
' '
1108 return std::distance(
MRI.use_nodbg_begin(
A),
MRI.use_nodbg_end()) <
1109 std::distance(
MRI.use_nodbg_begin(
B),
MRI.use_nodbg_end());
1112 for (
const Register Reg : SDefRegs) {
1113 PrintRegInfo(Reg, LiveSet->
lookup(Reg));
1116 OS <<
"\nLive registers with multiple definitions (" << MDefNumRegs <<
' '
1118 for (
const Register Reg : MDefRegs) {
1119 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 getLanesWithProperty(const LiveIntervals &LIS, const MachineRegisterInfo &MRI, bool TrackLaneMasks, VirtRegOrUnit VRegOrUnit, SlotIndex Pos, LaneBitmask SafeDefault, bool(*Property)(const LiveRange &LR, SlotIndex Pos))
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).
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.
bool hasVectorRegisterExcess() const
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
LaneBitmask getLastUsedLanes(Register Reg, SlotIndex Pos) const
Mostly copy/paste from CodeGen/RegisterPressure.cpp.
GCNRegPressure MaxPressure
void reset(const MachineInstr &MI, const LiveRegSet *LiveRegsCopy, bool After)
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.
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.
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.
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 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.
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.
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 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()