30 #include "llvm/Config/llvm-config.h" 53 assert((PrevMask & ~NewMask).none() &&
"Must not remove bits");
54 if (PrevMask.
any() || NewMask.
none())
59 for (; PSetI.
isValid(); ++PSetI)
60 CurrSetPressure[*PSetI] += Weight;
68 if (NewMask.
any() || PrevMask.
none())
73 for (; PSetI.
isValid(); ++PSetI) {
74 assert(CurrSetPressure[*PSetI] >= Weight &&
"register pressure underflow");
75 CurrSetPressure[*PSetI] -= Weight;
79 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 84 for (
unsigned i = 0,
e = SetPressure.
size(); i <
e; ++i) {
85 if (SetPressure[i] != 0) {
96 dbgs() <<
"Max Pressure: ";
98 dbgs() <<
"Live In: ";
101 if (!
P.LaneMask.all())
106 dbgs() <<
"Live Out: ";
109 if (!
P.LaneMask.all())
118 if (!isTopClosed() || !isBottomClosed()) {
119 dbgs() <<
"Curr Pressure: ";
127 const char *sep =
"";
140 dbgs() <<
"[" << getPSetOrMax() <<
", " << getUnitInc() <<
"]\n";
144 dbgs() <<
"[Excess=";
146 dbgs() <<
", CriticalMax=";
148 dbgs() <<
", CurrentMax=";
158 if (PreviousMask.
any() || NewMask.
none())
163 for (; PSetI.
isValid(); ++PSetI) {
164 CurrSetPressure[*PSetI] += Weight;
165 P.MaxSetPressure[*PSetI] =
166 std::max(
P.MaxSetPressure[*PSetI], CurrSetPressure[*PSetI]);
195 if (TopIdx <= NextTop)
203 if (TopPos != PrevTop)
211 if (BottomIdx > PrevBottom)
219 if (BottomPos != PrevBottom)
229 Regs.setUniverse(NumRegUnits + NumVirtRegs);
230 this->NumRegUnits = NumRegUnits;
247 CurrSetPressure.clear();
248 LiveThruPressure.clear();
249 P.MaxSetPressure.clear();
251 if (RequireIntervals)
268 bool TrackLaneMasks,
bool TrackUntiedDefs) {
272 TRI = MF->getSubtarget().getRegisterInfo();
274 MRI = &MF->getRegInfo();
276 this->TrackUntiedDefs = TrackUntiedDefs;
277 this->TrackLaneMasks = TrackLaneMasks;
279 if (RequireIntervals) {
280 assert(lis &&
"IntervalPressure requires LiveIntervals");
285 CurrSetPressure.assign(
TRI->getNumRegPressureSets(), 0);
287 P.MaxSetPressure = CurrSetPressure;
291 UntiedDefs.setUniverse(
MRI->getNumVirtRegs());
296 if (RequireIntervals)
298 return (static_cast<RegionPressure&>(
P).TopPos ==
304 if (RequireIntervals)
306 return (static_cast<RegionPressure&>(
P).BottomPos ==
313 if (IdxPos == MBB->end())
314 return LIS->getMBBEndIdx(MBB);
315 return LIS->getInstructionIndex(*IdxPos).getRegSlot();
320 if (RequireIntervals)
325 assert(
P.LiveInRegs.empty() &&
"inconsistent max pressure result");
326 P.LiveInRegs.reserve(LiveRegs.size());
327 LiveRegs.appendTo(
P.LiveInRegs);
332 if (RequireIntervals)
337 assert(
P.LiveOutRegs.empty() &&
"inconsistent max pressure result");
338 P.LiveOutRegs.reserve(LiveRegs.size());
339 LiveRegs.appendTo(
P.LiveOutRegs);
344 if (!isTopClosed() && !isBottomClosed()) {
345 assert(LiveRegs.size() == 0 &&
"no region boundary");
348 if (!isBottomClosed())
350 else if (!isTopClosed())
360 LiveThruPressure.assign(
TRI->getNumRegPressureSets(), 0);
361 assert(isBottomClosed() &&
"need bottom-up tracking to intialize.");
363 unsigned RegUnit = Pair.
RegUnit;
374 return Other.
RegUnit == RegUnit;
376 if (
I == RegUnits.
end())
383 unsigned RegUnit = Pair.
RegUnit;
386 return Other.
RegUnit == RegUnit;
388 if (I == RegUnits.
end()) {
398 return Other.
RegUnit == RegUnit;
400 if (
I == RegUnits.
end()) {
409 unsigned RegUnit = Pair.
RegUnit;
412 return Other.
RegUnit == RegUnit;
414 if (I != RegUnits.
end()) {
416 if (I->LaneMask.none())
430 if (Property(SR, Pos))
431 Result |= SR.LaneMask;
433 }
else if (Property(LI, Pos)) {
451 bool TrackLaneMasks,
unsigned RegUnit,
467 class RegisterOperandsCollector {
478 : RegOpers(RegOpers),
TRI(TRI),
MRI(MRI), IgnoreDead(IgnoreDead) {}
482 collectOperand(*OperI);
491 collectOperandLanes(*OperI);
505 pushReg(Reg, RegOpers.
Uses);
510 pushReg(Reg, RegOpers.
Uses);
516 pushReg(Reg, RegOpers.
Defs);
520 void pushReg(
unsigned Reg,
537 pushRegLanes(Reg, SubRegIdx, RegOpers.
Uses);
546 pushRegLanes(Reg, SubRegIdx, RegOpers.
DeadDefs);
548 pushRegLanes(Reg, SubRegIdx, RegOpers.
Defs);
552 void pushRegLanes(
unsigned Reg,
unsigned SubRegIdx,
571 bool TrackLaneMasks,
bool IgnoreDead) {
572 RegisterOperandsCollector
Collector(*
this, TRI, MRI, IgnoreDead);
574 Collector.collectInstrLanes(MI);
576 Collector.collectInstr(MI);
582 for (
auto RI =
Defs.begin(); RI !=
Defs.end(); ) {
583 unsigned Reg = RI->RegUnit;
603 for (
auto I =
Defs.begin();
I !=
Defs.end(); ) {
608 unsigned RegUnit =
I->RegUnit;
610 AddFlagsMI !=
nullptr && (LiveAfter & ~
I->LaneMask).none())
614 if (ActualDef.
none()) {
617 I->LaneMask = ActualDef;
621 for (
auto I =
Uses.begin();
I !=
Uses.end(); ) {
625 if (LaneMask.none()) {
628 I->LaneMask = LaneMask;
632 if (AddFlagsMI !=
nullptr) {
634 unsigned RegUnit =
P.RegUnit;
639 if (LiveAfter.
none())
674 for (; PSetI.
isValid(); ++PSetI) {
691 unsigned NewUnitInc = I->
getUnitInc() + Weight;
692 if (NewUnitInc != 0) {
697 for (J = std::next(I); J !=
E && J->
isValid(); ++J, ++
I)
709 increaseRegPressure(
P.RegUnit, PrevMask, NewMask);
717 unsigned RegUnit = Pair.
RegUnit;
719 return Other.
RegUnit == RegUnit;
723 if (
I == LiveInOrOut.
end()) {
728 PrevMask =
I->LaneMask;
730 I->LaneMask = NewMask;
736 discoverLiveInOrOut(Pair,
P.LiveInRegs);
740 discoverLiveInOrOut(Pair,
P.LiveOutRegs);
745 unsigned Reg =
P.RegUnit;
748 increaseRegPressure(Reg, LiveMask, BumpedMask);
751 unsigned Reg =
P.RegUnit;
754 decreaseRegPressure(Reg, BumpedMask, LiveMask);
765 assert(!CurrPos->isDebugInstr());
784 PreviousMask = LiveOut;
787 if (NewMask.
none()) {
790 if (TrackLaneMasks && LiveUses !=
nullptr)
794 decreaseRegPressure(Reg, PreviousMask, NewMask);
798 if (RequireIntervals)
807 if (NewMask == PreviousMask)
811 if (PreviousMask.none()) {
812 if (LiveUses !=
nullptr) {
813 if (!TrackLaneMasks) {
820 bool IsRedef =
I != LiveUses->
end();
832 if (RequireIntervals) {
833 LaneBitmask LiveOut = getLiveThroughAt(Reg, SlotIdx);
839 increaseRegPressure(Reg, PreviousMask, NewMask);
841 if (TrackUntiedDefs) {
843 unsigned RegUnit = Def.
RegUnit;
845 (LiveRegs.contains(RegUnit) & Def.
LaneMask).none())
846 UntiedDefs.insert(RegUnit);
852 assert(CurrPos != MBB->begin());
853 if (!isBottomClosed())
857 if (!RequireIntervals && isTopClosed())
858 static_cast<RegionPressure&>(
P).openTop(CurrPos);
864 if (RequireIntervals && !CurrPos->isDebugInstr())
868 if (RequireIntervals && isTopClosed())
873 recedeSkipDebugValues();
874 if (CurrPos->isDebugValue()) {
877 assert(CurrPos == MBB->begin());
883 RegOpers.
collect(MI, *
TRI, *MRI, TrackLaneMasks,
false);
884 if (TrackLaneMasks) {
887 }
else if (RequireIntervals) {
891 recede(RegOpers, LiveUses);
896 assert(!TrackUntiedDefs &&
"unsupported mode");
897 assert(CurrPos != MBB->end());
902 if (RequireIntervals)
903 SlotIdx = getCurrSlot();
906 if (isBottomClosed()) {
907 if (RequireIntervals)
919 increaseRegPressure(Reg, LiveMask, LiveMask | LiveIn);
923 if (RequireIntervals) {
924 LaneBitmask LastUseMask = getLastUsedLanes(Reg, SlotIdx);
925 if (LastUseMask.
any()) {
927 decreaseRegPressure(Reg, LiveMask, LiveMask & ~LastUseMask);
936 increaseRegPressure(Def.
RegUnit, PreviousMask, NewMask);
949 RegOpers.
collect(MI, *
TRI, *MRI, TrackLaneMasks,
false);
950 if (TrackLaneMasks) {
964 for (
unsigned i = 0,
e = OldPressureVec.
size(); i <
e; ++i) {
965 unsigned POld = OldPressureVec[i];
966 unsigned PNew = NewPressureVec[i];
967 int PDiff = (int)PNew - (
int)POld;
972 if (!LiveThruPressureVec.
empty())
973 Limit += LiveThruPressureVec[i];
979 PDiff = PNew - Limit;
980 }
else if (Limit > PNew)
981 PDiff = Limit - POld;
1005 unsigned CritIdx = 0, CritEnd = CriticalPSets.
size();
1006 for (
unsigned i = 0,
e = OldMaxPressureVec.
size(); i <
e; ++i) {
1007 unsigned POld = OldMaxPressureVec[i];
1008 unsigned PNew = NewMaxPressureVec[i];
1013 while (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() < i)
1016 if (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() == i) {
1017 int PDiff = (int)PNew - (
int)CriticalPSets[CritIdx].getUnitInc();
1045 if (RequireIntervals)
1050 RegOpers.
collect(*MI, *
TRI, *MRI, TrackLaneMasks,
true);
1054 else if (RequireIntervals)
1067 LaneBitmask LiveAfter = (LiveLanes & ~DefLanes) | UseLanes;
1068 decreaseRegPressure(Reg, LiveLanes, LiveAfter);
1075 increaseRegPressure(Reg, LiveLanes, LiveAfter);
1100 std::vector<unsigned> SavedPressure = CurrSetPressure;
1101 std::vector<unsigned> SavedMaxPressure =
P.MaxSetPressure;
1103 bumpUpwardPressure(MI);
1108 MaxPressureLimit, Delta);
1113 P.MaxSetPressure.swap(SavedMaxPressure);
1114 CurrSetPressure.swap(SavedPressure);
1122 getUpwardPressureDelta(MI, *PDiff, Delta2, CriticalPSets, MaxPressureLimit);
1123 if (Delta != Delta2) {
1124 dbgs() <<
"PDiff: ";
1126 dbgs() <<
"DELTA: " << *
MI;
1165 unsigned CritIdx = 0, CritEnd = CriticalPSets.
size();
1167 PDiffI = PDiff.
begin(), PDiffE = PDiff.
end();
1168 PDiffI != PDiffE && PDiffI->
isValid(); ++PDiffI) {
1170 unsigned PSetID = PDiffI->getPSet();
1171 unsigned Limit = RCI->getRegPressureSetLimit(PSetID);
1172 if (!LiveThruPressure.empty())
1173 Limit += LiveThruPressure[PSetID];
1175 unsigned POld = CurrSetPressure[PSetID];
1176 unsigned MOld =
P.MaxSetPressure[PSetID];
1177 unsigned MNew = MOld;
1179 unsigned PNew = POld + PDiffI->getUnitInc();
1180 assert((PDiffI->getUnitInc() >= 0) == (PNew >= POld)
1181 &&
"PSet overflow/underflow");
1186 unsigned ExcessInc = 0;
1188 ExcessInc = POld > Limit ? PNew - POld : PNew - Limit;
1189 else if (POld > Limit)
1190 ExcessInc = Limit - POld;
1200 while (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() < PSetID)
1203 if (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() == PSetID) {
1204 int CritInc = (int)MNew - (
int)CriticalPSets[CritIdx].getUnitInc();
1232 if (InstSlot >= PriorUseIdx && InstSlot < NextUseIdx) {
1233 unsigned SubRegIdx = MO.getSubReg();
1235 LastUseMask &= ~UseMask;
1236 if (LastUseMask.
none())
1245 assert(RequireIntervals);
1255 assert(RequireIntervals);
1266 assert(RequireIntervals);
1286 if (RequireIntervals)
1291 RegOpers.
collect(*MI, *
TRI, *MRI, TrackLaneMasks,
false);
1295 if (RequireIntervals) {
1298 LaneBitmask LastUseMask = getLastUsedLanes(Reg, SlotIdx);
1299 if (LastUseMask.
none())
1309 if (LastUseMask.
none())
1314 decreaseRegPressure(Reg, LiveMask, NewMask);
1323 increaseRegPressure(Reg, LiveMask, NewMask);
1346 std::vector<unsigned> SavedPressure = CurrSetPressure;
1347 std::vector<unsigned> SavedMaxPressure =
P.MaxSetPressure;
1349 bumpDownwardPressure(MI);
1354 MaxPressureLimit, Delta);
1359 P.MaxSetPressure.swap(SavedMaxPressure);
1360 CurrSetPressure.swap(SavedPressure);
1366 std::vector<unsigned> &PressureResult,
1367 std::vector<unsigned> &MaxPressureResult) {
1369 PressureResult = CurrSetPressure;
1370 MaxPressureResult =
P.MaxSetPressure;
1372 bumpUpwardPressure(MI);
1375 P.MaxSetPressure.swap(MaxPressureResult);
1376 CurrSetPressure.swap(PressureResult);
1382 std::vector<unsigned> &PressureResult,
1383 std::vector<unsigned> &MaxPressureResult) {
1385 PressureResult = CurrSetPressure;
1386 MaxPressureResult =
P.MaxSetPressure;
1388 bumpDownwardPressure(MI);
1391 P.MaxSetPressure.swap(MaxPressureResult);
1392 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.
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.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
void init(unsigned N)
Initialize an array of N PressureDiffs.
static const LiveRange * getLiveRange(const LiveIntervals &LIS, unsigned Reg)
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 getSubReg() const
void dump(const TargetRegisterInfo *TRI) const
bool isValid() const
isValid - Returns true until all the operands have been visited.
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. ...
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...
void setRegisterDefReadUndef(Register Reg, bool IsUndef=true)
Mark all subregister defs of register Reg with the undef flag.
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.
LiveInterval & getInterval(Register Reg)
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.
Align max(MaybeAlign Lhs, Align Rhs)
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. ...
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
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...
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
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
Register getReg() const
getReg - Returns the register number.
unsigned getWeight() const
SlotIndex - An opaque wrapper around machine indexes.
Register Usage Information Collector
Wrapper class representing virtual and physical registers.
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.