31 #include "llvm/Config/llvm-config.h" 54 assert((PrevMask & ~NewMask).none() &&
"Must not remove bits");
55 if (PrevMask.
any() || NewMask.
none())
60 for (; PSetI.
isValid(); ++PSetI)
61 CurrSetPressure[*PSetI] += Weight;
69 if (NewMask.
any() || PrevMask.
none())
74 for (; PSetI.
isValid(); ++PSetI) {
75 assert(CurrSetPressure[*PSetI] >= Weight &&
"register pressure underflow");
76 CurrSetPressure[*PSetI] -= Weight;
80 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 85 for (
unsigned i = 0, e = SetPressure.
size(); i < e; ++i) {
86 if (SetPressure[i] != 0) {
97 dbgs() <<
"Max Pressure: ";
99 dbgs() <<
"Live In: ";
102 if (!
P.LaneMask.all())
107 dbgs() <<
"Live Out: ";
110 if (!
P.LaneMask.all())
119 if (!isTopClosed() || !isBottomClosed()) {
120 dbgs() <<
"Curr Pressure: ";
128 const char *sep =
"";
143 if (PreviousMask.
any() || NewMask.
none())
148 for (; PSetI.
isValid(); ++PSetI) {
149 CurrSetPressure[*PSetI] += Weight;
150 P.MaxSetPressure[*PSetI] =
151 std::max(
P.MaxSetPressure[*PSetI], CurrSetPressure[*PSetI]);
180 if (TopIdx <= NextTop)
188 if (TopPos != PrevTop)
196 if (BottomIdx > PrevBottom)
204 if (BottomPos != PrevBottom)
214 Regs.setUniverse(NumRegUnits + NumVirtRegs);
215 this->NumRegUnits = NumRegUnits;
232 CurrSetPressure.clear();
233 LiveThruPressure.clear();
234 P.MaxSetPressure.clear();
236 if (RequireIntervals)
253 bool TrackLaneMasks,
bool TrackUntiedDefs) {
257 TRI = MF->getSubtarget().getRegisterInfo();
259 MRI = &MF->getRegInfo();
261 this->TrackUntiedDefs = TrackUntiedDefs;
262 this->TrackLaneMasks = TrackLaneMasks;
264 if (RequireIntervals) {
265 assert(lis &&
"IntervalPressure requires LiveIntervals");
270 CurrSetPressure.assign(
TRI->getNumRegPressureSets(), 0);
272 P.MaxSetPressure = CurrSetPressure;
276 UntiedDefs.setUniverse(
MRI->getNumVirtRegs());
281 if (RequireIntervals)
283 return (static_cast<RegionPressure&>(
P).TopPos ==
289 if (RequireIntervals)
291 return (static_cast<RegionPressure&>(
P).BottomPos ==
298 if (IdxPos == MBB->end())
299 return LIS->getMBBEndIdx(MBB);
300 return LIS->getInstructionIndex(*IdxPos).getRegSlot();
305 if (RequireIntervals)
310 assert(
P.LiveInRegs.empty() &&
"inconsistent max pressure result");
311 P.LiveInRegs.reserve(LiveRegs.size());
312 LiveRegs.appendTo(
P.LiveInRegs);
317 if (RequireIntervals)
322 assert(
P.LiveOutRegs.empty() &&
"inconsistent max pressure result");
323 P.LiveOutRegs.reserve(LiveRegs.size());
324 LiveRegs.appendTo(
P.LiveOutRegs);
329 if (!isTopClosed() && !isBottomClosed()) {
330 assert(LiveRegs.size() == 0 &&
"no region boundary");
333 if (!isBottomClosed())
335 else if (!isTopClosed())
345 LiveThruPressure.assign(
TRI->getNumRegPressureSets(), 0);
346 assert(isBottomClosed() &&
"need bottom-up tracking to intialize.");
348 unsigned RegUnit = Pair.
RegUnit;
359 return Other.
RegUnit == RegUnit;
361 if (
I == RegUnits.
end())
368 unsigned RegUnit = Pair.
RegUnit;
371 return Other.
RegUnit == RegUnit;
373 if (I == RegUnits.
end()) {
383 return Other.
RegUnit == RegUnit;
385 if (
I == RegUnits.
end()) {
394 unsigned RegUnit = Pair.
RegUnit;
397 return Other.
RegUnit == RegUnit;
399 if (I != RegUnits.
end()) {
401 if (I->LaneMask.none())
415 if (Property(SR, Pos))
416 Result |= SR.LaneMask;
418 }
else if (Property(LI, Pos)) {
436 bool TrackLaneMasks,
unsigned RegUnit,
452 class RegisterOperandsCollector {
463 : RegOpers(RegOpers),
TRI(TRI),
MRI(MRI), IgnoreDead(IgnoreDead) {}
467 collectOperand(*OperI);
476 collectOperandLanes(*OperI);
490 pushReg(Reg, RegOpers.
Uses);
495 pushReg(Reg, RegOpers.
Uses);
501 pushReg(Reg, RegOpers.
Defs);
505 void pushReg(
unsigned Reg,
518 unsigned Reg = MO.
getReg();
522 pushRegLanes(Reg, SubRegIdx, RegOpers.
Uses);
531 pushRegLanes(Reg, SubRegIdx, RegOpers.
DeadDefs);
533 pushRegLanes(Reg, SubRegIdx, RegOpers.
Defs);
537 void pushRegLanes(
unsigned Reg,
unsigned SubRegIdx,
556 bool TrackLaneMasks,
bool IgnoreDead) {
557 RegisterOperandsCollector
Collector(*
this, TRI, MRI, IgnoreDead);
559 Collector.collectInstrLanes(MI);
561 Collector.collectInstr(MI);
567 for (
auto RI =
Defs.begin(); RI !=
Defs.end(); ) {
568 unsigned Reg = RI->RegUnit;
588 for (
auto I =
Defs.begin();
I !=
Defs.end(); ) {
593 unsigned RegUnit =
I->RegUnit;
595 AddFlagsMI !=
nullptr && (LiveAfter & ~
I->LaneMask).none())
599 if (ActualDef.
none()) {
602 I->LaneMask = ActualDef;
606 for (
auto I =
Uses.begin();
I !=
Uses.end(); ) {
610 if (LaneMask.none()) {
613 I->LaneMask = LaneMask;
617 if (AddFlagsMI !=
nullptr) {
619 unsigned RegUnit =
P.RegUnit;
624 if (LiveAfter.
none())
659 for (; PSetI.
isValid(); ++PSetI) {
676 unsigned NewUnitInc = I->
getUnitInc() + Weight;
677 if (NewUnitInc != 0) {
682 for (J = std::next(I); J !=
E && J->
isValid(); ++J, ++
I)
694 increaseRegPressure(
P.RegUnit, PrevMask, NewMask);
702 unsigned RegUnit = Pair.
RegUnit;
704 return Other.
RegUnit == RegUnit;
708 if (
I == LiveInOrOut.
end()) {
713 PrevMask =
I->LaneMask;
715 I->LaneMask = NewMask;
721 discoverLiveInOrOut(Pair,
P.LiveInRegs);
725 discoverLiveInOrOut(Pair,
P.LiveOutRegs);
730 unsigned Reg =
P.RegUnit;
733 increaseRegPressure(Reg, LiveMask, BumpedMask);
736 unsigned Reg =
P.RegUnit;
739 decreaseRegPressure(Reg, BumpedMask, LiveMask);
750 assert(!CurrPos->isDebugInstr());
769 PreviousMask = LiveOut;
772 if (NewMask.
none()) {
775 if (TrackLaneMasks && LiveUses !=
nullptr)
779 decreaseRegPressure(Reg, PreviousMask, NewMask);
783 if (RequireIntervals)
792 if (NewMask == PreviousMask)
796 if (PreviousMask.none()) {
797 if (LiveUses !=
nullptr) {
798 if (!TrackLaneMasks) {
805 bool IsRedef =
I != LiveUses->
end();
817 if (RequireIntervals) {
818 LaneBitmask LiveOut = getLiveThroughAt(Reg, SlotIdx);
824 increaseRegPressure(Reg, PreviousMask, NewMask);
826 if (TrackUntiedDefs) {
828 unsigned RegUnit = Def.
RegUnit;
830 (LiveRegs.contains(RegUnit) & Def.
LaneMask).none())
831 UntiedDefs.insert(RegUnit);
837 assert(CurrPos != MBB->begin());
838 if (!isBottomClosed())
842 if (!RequireIntervals && isTopClosed())
843 static_cast<RegionPressure&>(
P).openTop(CurrPos);
849 if (RequireIntervals)
853 if (RequireIntervals && isTopClosed())
858 recedeSkipDebugValues();
862 RegOpers.
collect(MI, *
TRI, *MRI, TrackLaneMasks,
false);
863 if (TrackLaneMasks) {
866 }
else if (RequireIntervals) {
870 recede(RegOpers, LiveUses);
875 assert(!TrackUntiedDefs &&
"unsupported mode");
876 assert(CurrPos != MBB->end());
881 if (RequireIntervals)
882 SlotIdx = getCurrSlot();
885 if (isBottomClosed()) {
886 if (RequireIntervals)
898 increaseRegPressure(Reg, LiveMask, LiveMask | LiveIn);
902 if (RequireIntervals) {
903 LaneBitmask LastUseMask = getLastUsedLanes(Reg, SlotIdx);
904 if (LastUseMask.
any()) {
906 decreaseRegPressure(Reg, LiveMask, LiveMask & ~LastUseMask);
915 increaseRegPressure(Def.
RegUnit, PreviousMask, NewMask);
928 RegOpers.
collect(MI, *
TRI, *MRI, TrackLaneMasks,
false);
929 if (TrackLaneMasks) {
943 for (
unsigned i = 0, e = OldPressureVec.
size(); i < e; ++i) {
944 unsigned POld = OldPressureVec[i];
945 unsigned PNew = NewPressureVec[i];
946 int PDiff = (int)PNew - (
int)POld;
951 if (!LiveThruPressureVec.
empty())
952 Limit += LiveThruPressureVec[i];
958 PDiff = PNew - Limit;
959 }
else if (Limit > PNew)
960 PDiff = Limit - POld;
984 unsigned CritIdx = 0, CritEnd = CriticalPSets.
size();
985 for (
unsigned i = 0, e = OldMaxPressureVec.
size(); i < e; ++i) {
986 unsigned POld = OldMaxPressureVec[i];
987 unsigned PNew = NewMaxPressureVec[i];
992 while (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() < i)
995 if (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() == i) {
996 int PDiff = (int)PNew - (
int)CriticalPSets[CritIdx].getUnitInc();
1024 if (RequireIntervals)
1029 RegOpers.
collect(*MI, *
TRI, *MRI, TrackLaneMasks,
true);
1033 else if (RequireIntervals)
1046 LaneBitmask LiveAfter = (LiveLanes & ~DefLanes) | UseLanes;
1047 decreaseRegPressure(Reg, LiveLanes, LiveAfter);
1054 increaseRegPressure(Reg, LiveLanes, LiveAfter);
1079 std::vector<unsigned> SavedPressure = CurrSetPressure;
1080 std::vector<unsigned> SavedMaxPressure =
P.MaxSetPressure;
1082 bumpUpwardPressure(MI);
1087 MaxPressureLimit, Delta);
1092 P.MaxSetPressure.swap(SavedMaxPressure);
1093 CurrSetPressure.swap(SavedPressure);
1101 getUpwardPressureDelta(MI, *PDiff, Delta2, CriticalPSets, MaxPressureLimit);
1102 if (Delta != Delta2) {
1103 dbgs() <<
"PDiff: ";
1105 dbgs() <<
"DELTA: " << *
MI;
1144 unsigned CritIdx = 0, CritEnd = CriticalPSets.
size();
1146 PDiffI = PDiff.
begin(), PDiffE = PDiff.
end();
1147 PDiffI != PDiffE && PDiffI->
isValid(); ++PDiffI) {
1149 unsigned PSetID = PDiffI->getPSet();
1150 unsigned Limit = RCI->getRegPressureSetLimit(PSetID);
1151 if (!LiveThruPressure.empty())
1152 Limit += LiveThruPressure[PSetID];
1154 unsigned POld = CurrSetPressure[PSetID];
1155 unsigned MOld =
P.MaxSetPressure[PSetID];
1156 unsigned MNew = MOld;
1158 unsigned PNew = POld + PDiffI->getUnitInc();
1159 assert((PDiffI->getUnitInc() >= 0) == (PNew >= POld)
1160 &&
"PSet overflow/underflow");
1165 unsigned ExcessInc = 0;
1167 ExcessInc = POld > Limit ? PNew - POld : PNew - Limit;
1168 else if (POld > Limit)
1169 ExcessInc = Limit - POld;
1179 while (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() < PSetID)
1182 if (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() == PSetID) {
1183 int CritInc = (int)MNew - (
int)CriticalPSets[CritIdx].getUnitInc();
1211 if (InstSlot >= PriorUseIdx && InstSlot < NextUseIdx) {
1212 unsigned SubRegIdx = MO.getSubReg();
1214 LastUseMask &= ~UseMask;
1215 if (LastUseMask.
none())
1224 assert(RequireIntervals);
1234 assert(RequireIntervals);
1245 assert(RequireIntervals);
1265 if (RequireIntervals)
1270 RegOpers.
collect(*MI, *
TRI, *MRI, TrackLaneMasks,
false);
1274 if (RequireIntervals) {
1277 LaneBitmask LastUseMask = getLastUsedLanes(Reg, SlotIdx);
1278 if (LastUseMask.
none())
1288 if (LastUseMask.
none())
1293 decreaseRegPressure(Reg, LiveMask, NewMask);
1302 increaseRegPressure(Reg, LiveMask, NewMask);
1325 std::vector<unsigned> SavedPressure = CurrSetPressure;
1326 std::vector<unsigned> SavedMaxPressure =
P.MaxSetPressure;
1328 bumpDownwardPressure(MI);
1333 MaxPressureLimit, Delta);
1338 P.MaxSetPressure.swap(SavedMaxPressure);
1339 CurrSetPressure.swap(SavedPressure);
1345 std::vector<unsigned> &PressureResult,
1346 std::vector<unsigned> &MaxPressureResult) {
1348 PressureResult = CurrSetPressure;
1349 MaxPressureResult =
P.MaxSetPressure;
1351 bumpUpwardPressure(MI);
1354 P.MaxSetPressure.swap(MaxPressureResult);
1355 CurrSetPressure.swap(PressureResult);
1361 std::vector<unsigned> &PressureResult,
1362 std::vector<unsigned> &MaxPressureResult) {
1364 PressureResult = CurrSetPressure;
1365 MaxPressureResult =
P.MaxSetPressure;
1367 bumpDownwardPressure(MI);
1370 P.MaxSetPressure.swap(MaxPressureResult);
1371 CurrSetPressure.swap(PressureResult);
void addInstruction(unsigned Idx, const RegisterOperands &RegOpers, const MachineRegisterInfo &MRI)
Record pressure difference induced by the given operand list to node with index Idx.
static void decreaseSetPressure(std::vector< unsigned > &CurrSetPressure, const MachineRegisterInfo &MRI, unsigned Reg, LaneBitmask PrevMask, LaneBitmask NewMask)
Decrease pressure for each pressure set provided by TargetRegisterInfo.
A common definition of LaneBitmask for use in TableGen and CodeGen.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
void detectDeadDefs(const MachineInstr &MI, const LiveIntervals &LIS)
Use liveness information to find dead defs not marked with a dead flag and move them to the DeadDefs ...
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
void bumpDeadDefs(ArrayRef< RegisterMaskPair > DeadDefs)
bool isAllocatable(unsigned PhysReg) const
isAllocatable - Returns true when PhysReg belongs to an allocatable register class and it hasn't been...
LaneBitmask getMaxLaneMaskForVReg(unsigned Reg) const
Returns a mask covering all bits that can appear in lane masks of subregisters of the virtual registe...
This class represents lattice values for constants.
void addPressureChange(unsigned RegUnit, bool IsDec, const MachineRegisterInfo *MRI)
Add a change in pressure to the pressure diff of a given instruction.
void init(unsigned N)
Initialize an array of N PressureDiffs.
static const LiveRange * getLiveRange(const LiveIntervals &LIS, unsigned Reg)
void setRegisterDefReadUndef(unsigned Reg, bool IsUndef=true)
Mark all subregister defs of register Reg with the undef flag.
void decreaseRegPressure(unsigned RegUnit, LaneBitmask PreviousMask, LaneBitmask NewMask)
void push_back(const T &Elt)
LiveInterval - This class represents the liveness of a register, or stack slot.
iterator_range< use_nodbg_iterator > use_nodbg_operands(unsigned Reg) const
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
unsigned getSubReg() const
void dump(const TargetRegisterInfo *TRI) const
unsigned RegUnit
Virtual register or register unit.
SmallVector< RegisterMaskPair, 8 > DeadDefs
List of virtual registers and register units defined by the instruction but dead. ...
bool isDeadDef() const
Return true if this instruction has a dead def.
A live range for subregisters.
This represents a simple continuous liveness interval for a value.
unsigned const TargetRegisterInfo * TRI
Printable PrintLaneMask(LaneBitmask LaneMask)
Create Printable object to print LaneBitmasks on a raw_ostream.
void closeRegion()
Finalize the region boundaries and recored live ins and live outs.
static void increaseSetPressure(std::vector< unsigned > &CurrSetPressure, const MachineRegisterInfo &MRI, unsigned Reg, LaneBitmask PrevMask, LaneBitmask NewMask)
Increase pressure for each pressure set provided by TargetRegisterInfo.
MachineInstrBundleIterator< const MachineInstr > const_iterator
void openBottom(MachineBasicBlock::const_iterator PrevBottom)
If the current bottom is the previous instr (before advancing), open it.
unsigned getRegPressureSetLimit(unsigned Idx) const
Get the register unit limit for the given pressure set index.
static LaneBitmask getLiveLanesAt(const LiveIntervals &LIS, const MachineRegisterInfo &MRI, bool TrackLaneMasks, unsigned RegUnit, SlotIndex Pos)
bool isInternalRead() const
void discoverLiveInOrOut(RegisterMaskPair Pair, SmallVectorImpl< RegisterMaskPair > &LiveInOrOut)
This class represents the liveness of a register, stack slot, etc.
void recede(SmallVectorImpl< RegisterMaskPair > *LiveUses=nullptr)
Recede across the previous instruction.
LaneBitmask getLastUsedLanes(unsigned RegUnit, SlotIndex Pos) const
void discoverLiveIn(RegisterMaskPair Pair)
Add Reg to the live in set and increase max pressure.
void closeBottom()
Set the boundary for the bottom of the region and summarize live outs.
SlotIndex getDeadSlot() const
Returns the dead def kill slot for the current instruction.
virtual const char * getRegPressureSetName(unsigned Idx) const =0
Get the name of this register unit pressure set.
A Use represents the edge between a Value definition and its users.
void openBottom(SlotIndex PrevBottom)
If the current bottom is not greater than the previous index, open it.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
iterator_range< subrange_iterator > subranges()
Result of a LiveRange query.
static constexpr LaneBitmask getAll()
bool hasSubRanges() const
Returns true if subregister liveness information is available.
static constexpr LaneBitmask getNone()
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).
bool isBottomClosed() const
Does this pressure result have a valid bottom position and live outs.
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
bool isValid() const
isValid - Returns true until all the operands have been visited.
void openTop(SlotIndex NextTop)
If the current top is not less than or equal to the next index, open it.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def...
SmallVector< RegisterMaskPair, 8 > LiveInRegs
List of live in virtual registers or physical register units.
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...
List of registers defined and used by a machine instruction.
SlotIndex getCurrSlot() const
Get the SlotIndex for the first nondebug instruction including or after the current position...
void increaseRegPressure(unsigned RegUnit, LaneBitmask PreviousMask, LaneBitmask NewMask)
LiveRange * getCachedRegUnit(unsigned Unit)
Return the live range for register unit Unit if it has already been computed, or nullptr if it hasn't...
const_iterator end() const
LiveQueryResult Query(SlotIndex Idx) const
Query Liveness at Idx.
void recedeSkipDebugValues()
Recede until we find an instruction which is not a DebugValue.
void init(const MachineRegisterInfo &MRI)
SmallVector< RegisterMaskPair, 8 > LiveOutRegs
void addLiveRegs(ArrayRef< RegisterMaskPair > Regs)
Force liveness of virtual registers or physical register units.
void getMaxDownwardPressureDelta(const MachineInstr *MI, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit)
Consider the pressure increase caused by traversing this instruction top-down.
SmallVector< RegisterMaskPair, 8 > Uses
List of virtual registers and register units read by the instruction.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
const TargetRegisterInfo * getTargetRegisterInfo() const
unsigned const MachineRegisterInfo * MRI
PressureChange CurrentMax
RegisterPressure computed within a region of instructions delimited by TopIdx and BottomIdx...
bool liveAt(SlotIndex index) const
void bumpDownwardPressure(const MachineInstr *MI)
Record the downward impact of a single instruction on current register pressure.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void getUpwardPressureDelta(const MachineInstr *MI, PressureDiff &PDiff, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit) const
This is the fast version of querying register pressure that does not directly depend on current liven...
Printable printVRegOrUnit(unsigned VRegOrUnit, const TargetRegisterInfo *TRI)
Create Printable object to print virtual registers and physical registers on a raw_ostream.
RegisterPressure computed within a region of instructions delimited by TopPos and BottomPos...
void openTop(MachineBasicBlock::const_iterator PrevTop)
If the current top is the previous instruction (before receding), open it.
LaneBitmask getLiveThroughAt(unsigned RegUnit, SlotIndex Pos) const
constexpr bool none() const
Track the current register pressure at some position in the instruction stream, and remember the high...
List of PressureChanges in order of increasing, unique PSetID.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
SmallVector< RegisterMaskPair, 8 > Defs
List of virtual registers and register units defined by the instruction which are not dead...
void discoverLiveOut(RegisterMaskPair Pair)
Add Reg to the live out set and increase max pressure.
iterator erase(const_iterator CI)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool hasUntiedDef(unsigned VirtReg) const
bool isDebugInstr() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void initLiveThru(const RegPressureTracker &RPTracker)
Initialize the LiveThru pressure set based on the untied defs found in RPTracker. ...
std::vector< unsigned > MaxSetPressure
Map of max reg pressure indexed by pressure set ID, not class ID.
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 Regi...
void advance()
Advance across the current instruction.
ConstMIBundleOperands - Iterate over all operands in a const bundle of machine instructions.
MachineOperand class - Representation of each machine instruction operand.
bool isTopClosed() const
Does this pressure result have a valid top position and live ins.
static LaneBitmask getRegLanes(ArrayRef< RegisterMaskPair > RegUnits, unsigned RegUnit)
void reset()
Clear the result so it can be used for another round of pressure tracking.
LaneBitmask getSubRegIndexLaneMask(unsigned SubIdx) const
Return a bitmask representing the parts of a register that are covered by SubIdx. ...
LiveInterval & getInterval(unsigned Reg)
IterT skipDebugInstructionsBackward(IterT It, IterT Begin)
Decrement It until it points to a non-debug instruction or to Begin and return the resulting iterator...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static void addRegLanes(SmallVectorImpl< RegisterMaskPair > &RegUnits, RegisterMaskPair Pair)
PressureChange CriticalMax
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
static LaneBitmask getLanesWithProperty(const LiveIntervals &LIS, const MachineRegisterInfo &MRI, bool TrackLaneMasks, unsigned RegUnit, SlotIndex Pos, LaneBitmask SafeDefault, bool(*Property)(const LiveRange &LR, SlotIndex Pos))
IterT skipDebugInstructionsForward(IterT It, IterT End)
Increment It until it points to a non-debug instruction or to End and return the resulting iterator...
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
void closeTop()
Set the boundary for the top of the region and summarize live ins.
Representation of each machine instruction.
void dump(const TargetRegisterInfo &TRI) const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
void dumpRegSetPressure(ArrayRef< unsigned > SetPressure, const TargetRegisterInfo *TRI)
static void removeRegLanes(SmallVectorImpl< RegisterMaskPair > &RegUnits, RegisterMaskPair Pair)
Iterate over the pressure sets affected by the given physical or virtual register.
PSetIterator getPressureSets(unsigned RegUnit) const
Get an iterator over the pressure sets affected by the given physical or virtual register.
constexpr bool any() const
Capture a change in pressure for a single pressure set.
void getMaxUpwardPressureDelta(const MachineInstr *MI, PressureDiff *PDiff, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit)
Consider the pressure increase caused by traversing this instruction bottom-up.
void getUpwardPressure(const MachineInstr *MI, std::vector< unsigned > &PressureResult, std::vector< unsigned > &MaxPressureResult)
Get the pressure of each PSet after traversing this instruction bottom-up.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void init(const MachineFunction *mf, const RegisterClassInfo *rci, const LiveIntervals *lis, const MachineBasicBlock *mbb, MachineBasicBlock::const_iterator pos, bool TrackLaneMasks, bool TrackUntiedDefs)
Setup the RegPressureTracker.
const Segment * getSegmentContaining(SlotIndex Idx) const
Return the segment that contains the specified index, or null if there is none.
void bumpUpwardPressure(const MachineInstr *MI)
Record the upward impact of a single instruction on current register pressure.
Store the effects of a change in pressure on things that MI scheduler cares about.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void setRegZero(SmallVectorImpl< RegisterMaskPair > &RegUnits, unsigned RegUnit)
const_iterator begin() const
static void computeMaxPressureDelta(ArrayRef< unsigned > OldMaxPressureVec, ArrayRef< unsigned > NewMaxPressureVec, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit, RegPressureDelta &Delta)
Find the max change in max pressure that either surpasses a critical PSet limit or exceeds the curren...
void reset()
Clear the result so it can be used for another round of pressure tracking.
void getDownwardPressure(const MachineInstr *MI, std::vector< unsigned > &PressureResult, std::vector< unsigned > &MaxPressureResult)
Get the pressure of each PSet after traversing this instruction top-down.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_calloc(size_t Count, size_t Sz)
LaneBitmask getLiveLanesAt(unsigned RegUnit, SlotIndex Pos) const
unsigned getWeight() const
SlotIndex - An opaque wrapper around machine indexes.
Register Usage Information Collector
bool empty() const
empty - Check if the array is empty.
static void computeExcessPressureDelta(ArrayRef< unsigned > OldPressureVec, ArrayRef< unsigned > NewPressureVec, RegPressureDelta &Delta, const RegisterClassInfo *RCI, ArrayRef< unsigned > LiveThruPressureVec)
Find the max change in excess pressure across all sets.