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 assert((NewMask & ~PrevMask).
none() &&
"Must not add bits");
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)
84 for (
unsigned i = 0, e = SetPressure.
size(); i < e; ++i) {
85 if (SetPressure[i] != 0) {
86 dbgs() <<
TRI->getRegPressureSetName(i) <<
"=" << SetPressure[i] <<
' ';
94 dbgs() <<
"Max Pressure: ";
96 dbgs() <<
"Live In: ";
99 if (!
P.LaneMask.all())
104 dbgs() <<
"Live Out: ";
107 if (!
P.LaneMask.all())
117 dbgs() <<
"Curr Pressure: ";
125 const char *sep =
"";
142 dbgs() <<
"[Excess=";
144 dbgs() <<
", CriticalMax=";
146 dbgs() <<
", CurrentMax=";
156 if (PreviousMask.
any() || NewMask.
none())
161 for (; PSetI.
isValid(); ++PSetI) {
162 CurrSetPressure[*PSetI] += Weight;
163 P.MaxSetPressure[*PSetI] =
164 std::max(P.MaxSetPressure[*PSetI], CurrSetPressure[*PSetI]);
225 unsigned NumRegUnits =
TRI.getNumRegs();
227 Regs.setUniverse(NumRegUnits + NumVirtRegs);
228 this->NumRegUnits = NumRegUnits;
239 CurrSetPressure.clear();
240 LiveThruPressure.clear();
241 P.MaxSetPressure.clear();
243 if (RequireIntervals)
259 bool TrackLaneMasks,
bool TrackUntiedDefs) {
265 MRI = &MF->getRegInfo();
267 this->TrackUntiedDefs = TrackUntiedDefs;
268 this->TrackLaneMasks = TrackLaneMasks;
270 if (RequireIntervals) {
271 assert(lis &&
"IntervalPressure requires LiveIntervals");
276 CurrSetPressure.assign(TRI->getNumRegPressureSets(), 0);
278 P.MaxSetPressure = CurrSetPressure;
282 UntiedDefs.setUniverse(MRI->getNumVirtRegs());
287 if (RequireIntervals)
295 if (RequireIntervals)
304 if (IdxPos == MBB->end())
305 return LIS->getMBBEndIdx(MBB);
306 return LIS->getInstructionIndex(*IdxPos).getRegSlot();
311 if (RequireIntervals)
316 assert(P.LiveInRegs.empty() &&
"inconsistent max pressure result");
317 P.LiveInRegs.reserve(LiveRegs.size());
318 LiveRegs.appendTo(P.LiveInRegs);
323 if (RequireIntervals)
328 assert(P.LiveOutRegs.empty() &&
"inconsistent max pressure result");
329 P.LiveOutRegs.reserve(LiveRegs.size());
330 LiveRegs.appendTo(P.LiveOutRegs);
336 assert(LiveRegs.size() == 0 &&
"no region boundary");
351 LiveThruPressure.assign(TRI->getNumRegPressureSets(), 0);
365 return Other.VRegOrUnit == VRegOrUnit;
367 if (
I == RegUnits.
end())
377 return Other.VRegOrUnit == VRegOrUnit;
379 if (
I == RegUnits.
end()) {
389 return Other.VRegOrUnit == VRegOrUnit;
391 if (
I == RegUnits.
end()) {
403 return Other.VRegOrUnit == VRegOrUnit;
405 if (
I != RegUnits.
end()) {
406 I->LaneMask &= ~Pair.LaneMask;
407 if (
I->LaneMask.none())
417 bool ComputePhysRegs =
false) {
423 if (Property(SR, Pos))
424 Result |= SR.LaneMask;
426 }
else if (Property(LI, Pos)) {
427 Result = TrackLaneMasks
450 SlotIndex Pos,
bool ComputePhysRegs =
false) {
463class RegisterOperandsCollector {
464 friend class llvm::RegisterOperands;
466 RegisterOperands &RegOpers;
467 const TargetRegisterInfo &
TRI;
468 const MachineRegisterInfo &MRI;
471 RegisterOperandsCollector(RegisterOperands &RegOpers,
472 const TargetRegisterInfo &
TRI,
473 const MachineRegisterInfo &MRI,
bool IgnoreDead)
474 : RegOpers(RegOpers),
TRI(
TRI), MRI(MRI), IgnoreDead(IgnoreDead) {}
476 void collectInstr(
const MachineInstr &
MI)
const {
477 for (ConstMIBundleOperands OperI(
MI); OperI.isValid(); ++OperI)
478 collectOperand(*OperI);
482 for (
const VRegMaskOrUnit &
P : RegOpers.
Defs)
486 void collectInstrLanes(
const MachineInstr &
MI)
const {
487 for (ConstMIBundleOperands OperI(
MI); OperI.isValid(); ++OperI)
488 collectOperandLanes(*OperI);
491 for (
const VRegMaskOrUnit &
P : RegOpers.
Defs)
496 void collectOperand(
const MachineOperand &MO)
const {
517 void pushReg(
Register Reg, SmallVectorImpl<VRegMaskOrUnit> &RegUnits)
const {
528 void collectOperandLanes(
const MachineOperand &MO)
const {
535 pushRegLanes(
Reg, SubRegIdx, RegOpers.
Uses);
546 pushRegLanes(
Reg, SubRegIdx, RegOpers.
Defs);
550 void pushRegLanes(
Register Reg,
unsigned SubRegIdx,
551 SmallVectorImpl<VRegMaskOrUnit> &RegUnits)
const {
553 LaneBitmask LaneMask = SubRegIdx != 0
554 ?
TRI.getSubRegIndexLaneMask(SubRegIdx)
556 addRegLanes(RegUnits, VRegMaskOrUnit(VirtRegOrUnit(
Reg), LaneMask));
570 bool TrackLaneMasks,
bool IgnoreDead) {
571 RegisterOperandsCollector
Collector(*
this,
TRI, MRI, IgnoreDead);
582 for (
auto *
I =
Defs.begin();
I !=
Defs.end(); ) {
588 I = adjustDef(*
I, LiveAfter);
595 for (
auto *
I =
Defs.begin();
I !=
Defs.end(); ) {
598 I = adjustDef(*
I, LiveAfter);
607 for (
auto *
I =
Defs.begin();
I !=
Defs.end(); ) {
613 if (VRegOrUnit.
isVirtualReg() && (LiveAfter & ~
I->LaneMask).none())
615 I = adjustDef(*
I, LiveAfter);
618 adjustUses(LIS, MRI, Pos);
628 if (!LiveAfter.
none())
632 MI.setRegisterDefReadUndef(VReg);
637 MI.addRegisterDead(VReg,
TRI,
false);
647 assert(!
MI.isDebugInstr() &&
"No flags to restore on debug instructions");
650 bool HasClearedDef =
false;
656 HasClearedDef =
true;
662 if (TrackLaneMasks) {
673 LaneBitmask ActualDef = Def.LaneMask & LiveAfterDef;
674 if (ActualDef.
none()) {
676 return Defs.erase(&Def);
679 Def.LaneMask = ActualDef;
686 for (
auto &[VRegOrUnit, LaneMask] :
Uses) {
721 for (; PSetI.
isValid(); ++PSetI) {
723 PressureDiff::iterator
I = nonconst_begin(), E = nonconst_end();
724 for (;
I != E &&
I->isValid(); ++
I) {
725 if (
I->getPSet() >= *PSetI)
732 if (!
I->isValid() ||
I->getPSet() != *PSetI) {
734 for (PressureDiff::iterator J =
I; J != E && PTmp.
isValid(); ++J)
738 unsigned NewUnitInc =
I->getUnitInc() + Weight;
739 if (NewUnitInc != 0) {
740 I->setUnitInc(NewUnitInc);
743 PressureDiff::iterator J;
744 for (J = std::next(
I); J != E && J->
isValid(); ++J, ++
I)
766 return Other.VRegOrUnit == VRegOrUnit;
770 if (
I == LiveInOrOut.
end()) {
775 PrevMask =
I->LaneMask;
777 I->LaneMask = NewMask;
792 LaneBitmask LiveMask = LiveRegs.contains(P.VRegOrUnit);
797 LaneBitmask LiveMask = LiveRegs.contains(P.VRegOrUnit);
810 assert(!CurrPos->isDebugOrPseudoInstr());
821 LaneBitmask NewMask = PreviousMask & ~Def.LaneMask;
823 LaneBitmask LiveOut = Def.LaneMask & ~PreviousMask;
829 PreviousMask = LiveOut;
832 if (NewMask.
none()) {
835 if (TrackLaneMasks && LiveUses !=
nullptr)
843 if (RequireIntervals)
844 SlotIdx = LIS->getInstructionIndex(*CurrPos).
getRegSlot();
852 if (NewMask == PreviousMask)
856 if (PreviousMask.
none()) {
857 if (LiveUses !=
nullptr) {
858 if (!TrackLaneMasks) {
862 return Other.VRegOrUnit == VRegOrUnit;
864 bool IsRedef =
I != LiveUses->
end();
876 if (RequireIntervals) {
885 if (TrackUntiedDefs) {
889 (LiveRegs.contains(VRegOrUnit) & Def.LaneMask).none())
896 assert(CurrPos != MBB->begin());
908 if (RequireIntervals && !CurrPos->isDebugOrPseudoInstr())
909 SlotIdx = LIS->getInstructionIndex(*CurrPos).
getRegSlot();
918 if (CurrPos->isDebugOrPseudoInstr()) {
921 assert(CurrPos == MBB->begin());
927 RegOpers.
collect(
MI, *TRI, *MRI, TrackLaneMasks,
false);
928 if (TrackLaneMasks) {
931 }
else if (RequireIntervals) {
935 recede(RegOpers, LiveUses);
940 assert(!TrackUntiedDefs &&
"unsupported mode");
941 assert(CurrPos != MBB->end());
946 if (RequireIntervals)
951 if (RequireIntervals)
959 LaneBitmask LiveMask = LiveRegs.contains(VRegOrUnit);
967 if (RequireIntervals) {
969 if (LastUseMask.
any()) {
993 RegOpers.
collect(
MI, *TRI, *MRI, TrackLaneMasks,
false);
994 if (TrackLaneMasks) {
1008 for (
unsigned i = 0, e = OldPressureVec.
size(); i < e; ++i) {
1009 unsigned POld = OldPressureVec[i];
1010 unsigned PNew = NewPressureVec[i];
1011 int PDiff = (int)PNew - (
int)POld;
1016 if (!LiveThruPressureVec.
empty())
1017 Limit += LiveThruPressureVec[i];
1023 PDiff = PNew - Limit;
1024 }
else if (Limit > PNew)
1025 PDiff = Limit - POld;
1049 unsigned CritIdx = 0, CritEnd = CriticalPSets.
size();
1050 for (
unsigned i = 0, e = OldMaxPressureVec.
size(); i < e; ++i) {
1051 unsigned POld = OldMaxPressureVec[i];
1052 unsigned PNew = NewMaxPressureVec[i];
1057 while (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() < i)
1060 if (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() == i) {
1061 int PDiff = (int)PNew - CriticalPSets[CritIdx].getUnitInc();
1086 assert(!
MI->isDebugOrPseudoInstr() &&
"Expect a nondebug instruction.");
1089 if (RequireIntervals)
1090 SlotIdx = LIS->getInstructionIndex(*MI).
getRegSlot();
1094 RegOpers.
collect(*
MI, *TRI, *MRI, TrackLaneMasks,
true);
1098 else if (RequireIntervals)
1107 LaneBitmask LiveAfter = LiveRegs.contains(P.VRegOrUnit);
1110 LaneBitmask LiveBefore = (LiveAfter & ~DefLanes) | UseLanes;
1118 LaneBitmask LiveAfter = LiveRegs.contains(P.VRegOrUnit);
1145 std::vector<unsigned> SavedPressure = CurrSetPressure;
1146 std::vector<unsigned> SavedMaxPressure = P.MaxSetPressure;
1153 MaxPressureLimit, Delta);
1158 P.MaxSetPressure.swap(SavedMaxPressure);
1159 CurrSetPressure.swap(SavedPressure);
1168 if (Delta != Delta2) {
1169 dbgs() <<
"PDiff: ";
1171 dbgs() <<
"DELTA: " << *
MI;
1210 unsigned CritIdx = 0, CritEnd = CriticalPSets.
size();
1212 PDiffI = PDiff.
begin(), PDiffE = PDiff.
end();
1213 PDiffI != PDiffE && PDiffI->
isValid(); ++PDiffI) {
1215 unsigned PSetID = PDiffI->getPSet();
1216 unsigned Limit = RCI->getRegPressureSetLimit(PSetID);
1217 if (!LiveThruPressure.empty())
1218 Limit += LiveThruPressure[PSetID];
1220 unsigned POld = CurrSetPressure[PSetID];
1221 unsigned MOld = P.MaxSetPressure[PSetID];
1222 unsigned MNew = MOld;
1224 unsigned PNew = POld + PDiffI->getUnitInc();
1225 assert((PDiffI->getUnitInc() >= 0) == (PNew >= POld)
1226 &&
"PSet overflow/underflow");
1231 unsigned ExcessInc = 0;
1233 ExcessInc = POld > Limit ? PNew - POld : PNew - Limit;
1234 else if (POld > Limit)
1235 ExcessInc = Limit - POld;
1245 while (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() < PSetID)
1248 if (CritIdx != CritEnd && CriticalPSets[CritIdx].getPSet() == PSetID) {
1249 int CritInc = (int)MNew - CriticalPSets[CritIdx].getUnitInc();
1250 if (CritInc > 0 && CritInc <= std::numeric_limits<int16_t>::max()) {
1283 if (InstSlot >= PriorUseIdx && InstSlot < NextUseIdx) {
1286 LastUseMask &= ~UseMask;
1287 if (LastUseMask.
none())
1296 assert(RequireIntervals);
1304 assert(RequireIntervals);
1306 *LIS, *MRI, TrackLaneMasks, VRegOrUnit, Pos.
getBaseIndex(),
1308 const LiveRange::Segment *S = LR.getSegmentContaining(Pos);
1309 return S != nullptr && S->end == Pos.getRegSlot();
1315 assert(RequireIntervals);
1332 assert(!
MI->isDebugOrPseudoInstr() &&
"Expect a nondebug instruction.");
1335 if (RequireIntervals)
1336 SlotIdx = LIS->getInstructionIndex(*MI).
getRegSlot();
1340 RegOpers.
collect(*
MI, *TRI, *MRI, TrackLaneMasks,
false);
1344 if (RequireIntervals) {
1348 if (LastUseMask.
none())
1357 findUseBetween(VRegOrUnit, LastUseMask, CurrIdx, SlotIdx, *MRI, LIS);
1358 if (LastUseMask.
none())
1361 LaneBitmask LiveMask = LiveRegs.contains(VRegOrUnit);
1369 LaneBitmask LiveMask = LiveRegs.contains(Def.VRegOrUnit);
1394 std::vector<unsigned> SavedPressure = CurrSetPressure;
1395 std::vector<unsigned> SavedMaxPressure = P.MaxSetPressure;
1402 MaxPressureLimit, Delta);
1407 P.MaxSetPressure.swap(SavedMaxPressure);
1408 CurrSetPressure.swap(SavedPressure);
1414 std::vector<unsigned> &PressureResult,
1415 std::vector<unsigned> &MaxPressureResult) {
1417 PressureResult = CurrSetPressure;
1418 MaxPressureResult = P.MaxSetPressure;
1423 P.MaxSetPressure.swap(MaxPressureResult);
1424 CurrSetPressure.swap(PressureResult);
1430 std::vector<unsigned> &PressureResult,
1431 std::vector<unsigned> &MaxPressureResult) {
1433 PressureResult = CurrSetPressure;
1434 MaxPressureResult = P.MaxSetPressure;
1439 P.MaxSetPressure.swap(MaxPressureResult);
1440 CurrSetPressure.swap(PressureResult);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
A common definition of LaneBitmask for use in TableGen and CodeGen.
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Register Usage Information Collector
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.
static void increaseSetPressure(std::vector< unsigned > &CurrSetPressure, const MachineRegisterInfo &MRI, VirtRegOrUnit VRegOrUnit, LaneBitmask PrevMask, LaneBitmask NewMask)
Increase pressure for each pressure set provided by TargetRegisterInfo.
static LaneBitmask getRegLanes(ArrayRef< VRegMaskOrUnit > RegUnits, VirtRegOrUnit VRegOrUnit)
static void removeRegLanes(SmallVectorImpl< VRegMaskOrUnit > &RegUnits, VRegMaskOrUnit Pair)
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 LaneBitmask getLanesWithProperty(LiveIntervals &LIS, const MachineRegisterInfo &MRI, bool TrackLaneMasks, VirtRegOrUnit VRegOrUnit, SlotIndex Pos, LaneBitmask SafeDefault, bool(*Property)(const LiveRange &LR, SlotIndex Pos), bool ComputePhysRegs=false)
static void setRegZero(SmallVectorImpl< VRegMaskOrUnit > &RegUnits, VirtRegOrUnit VRegOrUnit)
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).
static LaneBitmask getLiveLanesAt(LiveIntervals &LIS, const MachineRegisterInfo &MRI, bool TrackLaneMasks, VirtRegOrUnit VRegOrUnit, SlotIndex Pos, bool ComputePhysRegs=false)
static void addRegLanes(SmallVectorImpl< VRegMaskOrUnit > &RegUnits, VRegMaskOrUnit Pair)
static void decreaseSetPressure(std::vector< unsigned > &CurrSetPressure, const MachineRegisterInfo &MRI, VirtRegOrUnit VRegOrUnit, LaneBitmask PrevMask, LaneBitmask NewMask)
Decrease pressure for each pressure set provided by TargetRegisterInfo.
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
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()
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
LiveInterval & getInterval(Register Reg)
LiveRange & getRegUnit(MCRegUnit Unit)
Return the live range for register unit Unit.
LiveRange * getCachedRegUnit(MCRegUnit Unit)
Return the live range for register unit Unit if it has already been computed, or nullptr if it hasn't...
This class represents the liveness of a register, stack slot, etc.
const Segment * getSegmentContaining(SlotIndex Idx) const
Return the segment that contains the specified index, or null if there is none.
bool liveAt(SlotIndex index) const
LLVM_ABI void init(const MachineRegisterInfo &MRI)
MachineInstrBundleIterator< const MachineInstr > const_iterator
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
void setIsUndef(bool Val=true)
Register getReg() const
getReg - Returns the register number.
bool isInternalRead() const
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
iterator_range< use_nodbg_iterator > use_nodbg_operands(Register Reg) const
PSetIterator getPressureSets(VirtRegOrUnit VRegOrUnit) const
Get an iterator over the pressure sets affected by the virtual register or register unit.
bool isAllocatable(MCRegister PhysReg) const
isAllocatable - Returns true when PhysReg belongs to an allocatable register class and it hasn't been...
const TargetRegisterInfo * getTargetRegisterInfo() const
LLVM_ABI LaneBitmask getMaxLaneMaskForVReg(Register Reg) const
Returns a mask covering all bits that can appear in lane masks of subregisters of the virtual registe...
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
Iterate over the pressure sets affected by the given physical or virtual register.
unsigned getWeight() const
Capture a change in pressure for a single pressure set.
unsigned getPSetOrMax() const
LLVM_ABI void dump() const
List of PressureChanges in order of increasing, unique PSetID.
const PressureChange * const_iterator
LLVM_ABI void dump(const TargetRegisterInfo &TRI) const
const_iterator end() const
LLVM_ABI void addPressureChange(VirtRegOrUnit VRegOrUnit, bool IsDec, const MachineRegisterInfo *MRI)
Add a change in pressure to the pressure diff of a given instruction.
const_iterator begin() const
LLVM_ABI void addInstruction(unsigned Idx, const RegisterOperands &RegOpers, const MachineRegisterInfo &MRI)
Record pressure difference induced by the given operand list to node with index Idx.
LLVM_ABI void init(unsigned N)
Initialize an array of N PressureDiffs.
LLVM_ABI void init(const MachineFunction *mf, const RegisterClassInfo *rci, LiveIntervals *lis, const MachineBasicBlock *mbb, MachineBasicBlock::const_iterator pos, bool TrackLaneMasks, bool TrackUntiedDefs)
Setup the RegPressureTracker.
LLVM_ABI void closeRegion()
Finalize the region boundaries and recored live ins and live outs.
LLVM_ABI void discoverLiveIn(VRegMaskOrUnit Pair)
Add Reg to the live in set and increase max pressure.
LLVM_ABI void closeBottom()
Set the boundary for the bottom of the region and summarize live outs.
LLVM_ABI void recede(SmallVectorImpl< VRegMaskOrUnit > *LiveUses=nullptr)
Recede across the previous instruction.
LLVM_ABI void bumpDownwardPressure(const MachineInstr *MI)
Record the downward impact of a single instruction on current register pressure.
LLVM_ABI void addLiveRegs(ArrayRef< VRegMaskOrUnit > Regs)
Force liveness of virtual registers or physical register units.
LLVM_ABI void recedeSkipDebugValues()
Recede until we find an instruction which is not a DebugValue.
LLVM_ABI 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.
LLVM_ABI void initLiveThru(const RegPressureTracker &RPTracker)
Initialize the LiveThru pressure set based on the untied defs found in RPTracker.
LLVM_ABI void bumpDeadDefs(ArrayRef< VRegMaskOrUnit > DeadDefs)
RegPressureTracker(IntervalPressure &rp)
LLVM_ABI void dump() const
LLVM_ABI void discoverLiveInOrOut(VRegMaskOrUnit Pair, SmallVectorImpl< VRegMaskOrUnit > &LiveInOrOut)
LLVM_ABI LaneBitmask getLiveThroughAt(VirtRegOrUnit VRegOrUnit, SlotIndex Pos) const
LLVM_ABI bool isBottomClosed() const
Does this pressure result have a valid bottom position and live outs.
LLVM_ABI LaneBitmask getLiveLanesAt(VirtRegOrUnit VRegOrUnit, SlotIndex Pos) const
bool hasUntiedDef(Register VirtReg) const
LLVM_ABI void closeTop()
Set the boundary for the top of the region and summarize live ins.
LLVM_ABI void getMaxDownwardPressureDelta(const MachineInstr *MI, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit)
Consider the pressure increase caused by traversing this instruction top-down.
LLVM_ABI void advance()
Advance across the current instruction.
LLVM_ABI bool isTopClosed() const
Does this pressure result have a valid top position and live ins.
LLVM_ABI void bumpUpwardPressure(const MachineInstr *MI)
Record the upward impact of a single instruction on current register pressure.
LLVM_ABI LaneBitmask getLastUsedLanes(VirtRegOrUnit VRegOrUnit, SlotIndex Pos) const
LLVM_ABI void increaseRegPressure(VirtRegOrUnit VRegOrUnit, LaneBitmask PreviousMask, LaneBitmask NewMask)
LLVM_ABI 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_ABI SlotIndex getCurrSlot() const
Get the SlotIndex for the first nondebug instruction including or after the current position.
LLVM_ABI void decreaseRegPressure(VirtRegOrUnit VRegOrUnit, LaneBitmask PreviousMask, LaneBitmask NewMask)
LLVM_ABI 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.
LLVM_ABI void discoverLiveOut(VRegMaskOrUnit Pair)
Add Reg to the live out set and increase max pressure.
LLVM_ABI 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...
unsigned getRegPressureSetLimit(unsigned Idx) const
Get the register unit limit for the given pressure set index.
List of registers defined and used by a machine instruction.
LLVM_ABI void detectDeadDefs(const MachineInstr &MI, LiveIntervals &LIS, const MachineRegisterInfo &MRI)
Use liveness information to find dead defs at MI's dead slot not marked with a dead flag and move the...
SmallVector< VRegMaskOrUnit, 8 > Defs
List of virtual registers and register units defined by the instruction which are not dead.
LLVM_ABI void adjustLaneLiveness(LiveIntervals &LIS, const MachineRegisterInfo &MRI, SlotIndex Pos)
Use liveness information to find out which uses/defs are partially undefined/dead at Pos and adjust t...
LLVM_ABI void collect(const MachineInstr &MI, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, bool TrackLaneMasks, bool IgnoreDead)
Analyze the given instruction MI and fill in the Uses, Defs and DeadDefs list based on the MachineOpe...
SmallVector< VRegMaskOrUnit, 8 > DeadDefs
List of virtual registers and register units defined by the instruction but dead.
SmallVector< VRegMaskOrUnit, 8 > Uses
List of virtual registers and register units read by the instruction.
static LLVM_ABI void restoreLivenessFlags(MachineInstr &MI, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, LiveIntervals &LIS, bool TrackLaneMasks=true, ArrayRef< Register > OnlyRegs={})
Clear potentially-stale read-undef flags on the defs of MI, then recompute them from LIS.
Wrapper class representing virtual and physical registers.
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
SlotIndex - An opaque wrapper around machine indexes.
SlotIndex getDeadSlot() const
Returns the dead def kill slot for the current instruction.
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
iterator erase(const_iterator CI)
void push_back(const T &Elt)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
A Use represents the edge between a Value definition and its users.
Wrapper class representing a virtual register or register unit.
constexpr bool isVirtualReg() const
constexpr MCRegUnit asMCRegUnit() const
constexpr Register asVirtualReg() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
IterT next_nodbg(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It, then continue incrementing it while it points to a debug instruction.
Printable PrintLaneMask(LaneBitmask LaneMask)
Create Printable object to print LaneBitmasks on a raw_ostream.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_calloc(size_t Count, size_t Sz)
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.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
LLVM_ABI void dumpRegSetPressure(ArrayRef< unsigned > SetPressure, const TargetRegisterInfo *TRI)
IterT prev_nodbg(IterT It, IterT Begin, bool SkipPseudoOp=true)
Decrement It, then continue decrementing it while it points to a debug instruction.
LLVM_ABI Printable printVRegOrUnit(VirtRegOrUnit VRegOrUnit, const TargetRegisterInfo *TRI)
Create Printable object to print virtual registers and physical registers on a raw_ostream.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
RegisterPressure computed within a region of instructions delimited by TopIdx and BottomIdx.
LLVM_ABI void reset()
Clear the result so it can be used for another round of pressure tracking.
LLVM_ABI void openBottom(SlotIndex PrevBottom)
If the current bottom is not greater than the previous index, open it.
SlotIndex TopIdx
Record the boundary of the region being tracked.
LLVM_ABI void openTop(SlotIndex NextTop)
If the current top is not less than or equal to the next index, open it.
static constexpr LaneBitmask getAll()
constexpr bool none() const
constexpr bool any() const
static constexpr LaneBitmask getNone()
This represents a simple continuous liveness interval for a value.
Store the effects of a change in pressure on things that MI scheduler cares about.
PressureChange CriticalMax
PressureChange CurrentMax
LLVM_ABI void dump() const
RegisterPressure computed within a region of instructions delimited by TopPos and BottomPos.
MachineBasicBlock::const_iterator TopPos
Record the boundary of the region being tracked.
MachineBasicBlock::const_iterator BottomPos
LLVM_ABI void openTop(MachineBasicBlock::const_iterator PrevTop)
If the current top is the previous instruction (before receding), open it.
LLVM_ABI void reset()
Clear the result so it can be used for another round of pressure tracking.
LLVM_ABI void openBottom(MachineBasicBlock::const_iterator PrevBottom)
If the current bottom is the previous instr (before advancing), open it.
SmallVector< VRegMaskOrUnit, 8 > LiveOutRegs
SmallVector< VRegMaskOrUnit, 8 > LiveInRegs
List of live in virtual registers or physical register units.
LLVM_ABI void dump(const TargetRegisterInfo *TRI) const
std::vector< unsigned > MaxSetPressure
Map of max reg pressure indexed by pressure set ID, not class ID.