15 #ifndef LLVM_CODEGEN_REGISTERPRESSURE_H
16 #define LLVM_CODEGEN_REGISTERPRESSURE_H
26 class RegisterClassInfo;
106 assert(
id < UINT16_MAX &&
"PSetID overflow.");
112 assert(
isValid() &&
"invalid PressureChange");
123 return PSetID == RHS.PSetID && UnitInc == RHS.UnitInc;
140 enum { MaxPSets = 16 };
166 void init(
unsigned N);
169 assert(Idx < Size &&
"PressureDiff index out of bounds");
170 return PDiffArray[Idx];
265 bool RequireIntervals;
268 bool TrackUntiedDefs;
276 std::vector<unsigned> CurrSetPressure;
284 std::vector<unsigned> LiveThruPressure;
288 MF(0), TRI(0), RCI(0), LIS(0), MBB(0), P(rp), RequireIntervals(
true),
289 TrackUntiedDefs(
false) {}
292 MF(0), TRI(0), RCI(0), LIS(0), MBB(0), P(rp), RequireIntervals(
false),
293 TrackUntiedDefs(
false) {}
300 bool ShouldTrackUntiedDefs =
false);
335 LiveThruPressure.assign(PressureSet.
begin(), PressureSet.
end());
402 std::vector<unsigned> &PressureResult,
403 std::vector<unsigned> &MaxPressureResult);
407 std::vector<unsigned> &PressureResult,
408 std::vector<unsigned> &MaxPressureResult);
411 std::vector<unsigned> &PressureResult,
412 std::vector<unsigned> &MaxPressureResult) {
421 return UntiedDefs.count(VirtReg);
436 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
438 const TargetRegisterInfo *TRI);
void decrease(unsigned Reg, const TargetRegisterInfo *TRI, const MachineRegisterInfo *MRI)
void dump(const TargetRegisterInfo *TRI) const
bool advance()
Advance across the current instruction.
void increaseRegPressure(ArrayRef< unsigned > Regs)
void getPressureAfterInst(const MachineInstr *MI, std::vector< unsigned > &PressureResult, std::vector< unsigned > &MaxPressureResult)
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.
bool operator==(const PressureChange &RHS) const
std::pair< iterator, bool > insert(const ValueT &Val)
static bool isVirtualRegister(unsigned Reg)
const LiveRange * getLiveRange(unsigned Reg) const
void closeRegion()
Finalize the region boundaries and recored live ins and live outs.
bool isTopClosed() const
Does this pressure result have a valid top position and live ins.
void openBottom(MachineBasicBlock::const_iterator PrevBottom)
If the current bottom is the previous instr (before advancing), open it.
MachineBasicBlock::const_iterator getPos() const
Get the MI position corresponding to this register pressure.
Base class for register pressure results.
SlotIndex TopIdx
Record the boundary of the region being tracked.
void closeBottom()
Set the boundary for the bottom of the region and summarize live outs.
void openBottom(SlotIndex PrevBottom)
If the current bottom is not greater than the previous index, open it.
MachineBasicBlock::const_iterator TopPos
Record the boundary of the region being tracked.
void discoverLiveOut(unsigned Reg)
Add Reg to the live out set and increase max pressure.
bool recede(SmallVectorImpl< unsigned > *LiveUses=0, PressureDiff *PDiff=0)
Recede across the previous instruction.
SlotIndex getCurrSlot() const
Get the SlotIndex for the first nondebug instruction including or after the current position...
std::vector< unsigned > & getRegSetPressureAtPos()
const_iterator end() const
void openTop(SlotIndex NextTop)
SparseSet< unsigned, VirtReg2IndexFunctor > VirtRegs
bool hasUntiedDef(unsigned VirtReg) const
PressureDiff & operator[](unsigned Idx)
iterator erase(iterator I)
void decreaseRegPressure(ArrayRef< unsigned > Regs)
Simply decrease the current pressure as impacted by these registers.
void getMaxDownwardPressureDelta(const MachineInstr *MI, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit)
ArrayRef< unsigned > getLiveThru() const
PressureChange CurrentMax
bool operator!=(const RegPressureDelta &RHS) const
bool operator==(const RegPressureDelta &RHS) const
void bumpDownwardPressure(const MachineInstr *MI)
SparseSet< unsigned > PhysRegs
A set of live virtual registers and physical register units.
void openTop(MachineBasicBlock::const_iterator PrevTop)
If the current top is the previous instruction (before receding), open it.
SmallVector< unsigned, 8 > LiveOutRegs
void increase(unsigned Reg, const TargetRegisterInfo *TRI, const MachineRegisterInfo *MRI)
void dumpRegSetPressure(ArrayRef< unsigned > SetPressure, const TargetRegisterInfo *TRI)
void initLiveThru(const RegPressureTracker &RPTracker)
std::vector< unsigned > MaxSetPressure
Map of max reg pressure indexed by pressure set ID, not class ID.
const RegisterPressure & getPressure() const
void discoverLiveIn(unsigned Reg)
Add Reg to the live in set and increase max pressure.
bool insert(unsigned Reg)
void getMaxPressureDelta(const MachineInstr *MI, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit)
void reset()
Clear the result so it can be used for another round of pressure tracking.
bool contains(unsigned Reg) const
PressureChange(unsigned id)
bool count(const KeyT &Key) const
RegPressureTracker(RegionPressure &rp)
PressureChange CriticalMax
void init(const MachineFunction *mf, const RegisterClassInfo *rci, const LiveIntervals *lis, const MachineBasicBlock *mbb, MachineBasicBlock::const_iterator pos, bool ShouldTrackUntiedDefs=false)
void closeTop()
Set the boundary for the top of the region and summarize live ins.
bundle_iterator< const MachineInstr, const_instr_iterator > const_iterator
RegPressureTracker(IntervalPressure &rp)
void getMaxUpwardPressureDelta(const MachineInstr *MI, PressureDiff *PDiff, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit)
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.
const_iterator begin() const
bool isBottomClosed() const
Does this pressure result have a valid bottom position and live outs.
PressureChange * iterator
void bumpUpwardPressure(const MachineInstr *MI)
unsigned getPSetOrMax() const
void addLiveRegs(ArrayRef< unsigned > Regs)
Force liveness of registers.
const PressureChange * const_iterator
const PressureDiff & operator[](unsigned Idx) const
void initLiveThru(ArrayRef< unsigned > PressureSet)
Copy an existing live thru pressure result.
void reset()
Clear the result so it can be used for another round of pressure tracking.
SmallVector< unsigned, 8 > LiveInRegs
List of live in virtual registers or physical register units.
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.
const MCRegisterInfo & MRI
void setPos(MachineBasicBlock::const_iterator Pos)
RegisterPressure & getPressure()
MachineBasicBlock::const_iterator BottomPos
SlotIndex - An opaque wrapper around machine indexes.
void getUpwardPressureDelta(const MachineInstr *MI, PressureDiff &PDiff, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit) const