15 #ifndef LLVM_CODEGEN_REGISTERPRESSURE_H
16 #define LLVM_CODEGEN_REGISTERPRESSURE_H
26 class RegisterClassInfo;
91 assert(
id < UINT16_MAX &&
"PSetID overflow.");
94 bool isValid()
const {
return PSetID > 0; }
97 assert(
isValid() &&
"invalid PressureChange");
108 return PSetID == RHS.PSetID && UnitInc == RHS.UnitInc;
125 enum { MaxPSets = 16 };
153 void init(
unsigned N);
156 assert(Idx < Size &&
"PressureDiff index out of bounds");
157 return PDiffArray[Idx];
252 bool RequireIntervals;
255 bool TrackUntiedDefs;
263 std::vector<unsigned> CurrSetPressure;
271 std::vector<unsigned> LiveThruPressure;
275 MF(nullptr), TRI(nullptr), RCI(nullptr), LIS(nullptr), MBB(nullptr), P(rp),
276 RequireIntervals(
true), TrackUntiedDefs(
false) {}
279 MF(nullptr), TRI(nullptr), RCI(nullptr), LIS(nullptr), MBB(nullptr), P(rp),
280 RequireIntervals(
false), TrackUntiedDefs(
false) {}
287 bool ShouldTrackUntiedDefs =
false);
323 LiveThruPressure.assign(PressureSet.
begin(), PressureSet.
end());
390 std::vector<unsigned> &PressureResult,
391 std::vector<unsigned> &MaxPressureResult);
395 std::vector<unsigned> &PressureResult,
396 std::vector<unsigned> &MaxPressureResult);
399 std::vector<unsigned> &PressureResult,
400 std::vector<unsigned> &MaxPressureResult) {
409 return UntiedDefs.count(VirtReg);
425 const TargetRegisterInfo *TRI);
void dump(const TargetRegisterInfo *TRI) const
bool advance()
Advance across the current instruction.
void increaseRegPressure(ArrayRef< unsigned > Regs)
Increase the current pressure as impacted by these registers and bump the high water mark if needed...
void getPressureAfterInst(const MachineInstr *MI, std::vector< unsigned > &PressureResult, std::vector< unsigned > &MaxPressureResult)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
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)
insert - Attempts to insert a new element.
size_type count(const KeyT &Key) const
count - Returns 1 if this set contains an element identified by Key, 0 otherwise. ...
static bool isVirtualRegister(unsigned Reg)
isVirtualRegister - Return true if the specified register number is in the virtual register namespace...
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.
This class represents the liveness of a register, stack slot, etc.
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.
Reg
All possible values of the reg field in the ModR/M byte.
void discoverLiveOut(unsigned Reg)
Add Reg to the live out set and increase max pressure.
SlotIndex getCurrSlot() const
Get the SlotIndex for the first nondebug instruction including or after the current position...
std::vector< unsigned > & getRegSetPressureAtPos()
Get the register set pressure at the current position, which may be less than the pressure across the...
const_iterator end() const
void openTop(SlotIndex NextTop)
If the current top is not less than or equal to the next index, open it.
SparseSet< unsigned, VirtReg2IndexFunctor > VirtRegs
bool recede(SmallVectorImpl< unsigned > *LiveUses=nullptr, PressureDiff *PDiff=nullptr)
Recede across the previous instruction.
bool hasUntiedDef(unsigned VirtReg) const
PressureDiff & operator[](unsigned Idx)
iterator erase(iterator I)
erase - Erases an existing element identified by a valid iterator.
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)
Consider the pressure increase caused by traversing this instruction top-down.
ArrayRef< unsigned > getLiveThru() const
PressureChange CurrentMax
RegisterPressure computed within a region of instructions delimited by TopIdx and BottomIdx...
bool operator!=(const RegPressureDelta &RHS) const
bool operator==(const RegPressureDelta &RHS) const
void bumpDownwardPressure(const MachineInstr *MI)
Record the downward impact of a single instruction on current register pressure.
SparseSet< unsigned > PhysRegs
A set of live virtual registers and physical register units.
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.
Track the current register pressure at some position in the instruction stream, and remember the high...
SmallVector< unsigned, 8 > LiveOutRegs
List of PressureChanges in order of increasing, unique PSetID.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
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.
isPodLike - This is a type trait that is used to determine whether a given type can be copied around ...
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)
Find the pressure set with the most change beyond its pressure limit after traversing this instructio...
void reset()
Clear the result so it can be used for another round of pressure tracking.
bool contains(unsigned Reg) const
PressureChange(unsigned id)
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)
Setup the RegPressureTracker.
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.
bundle_iterator< const MachineInstr, const_instr_iterator > const_iterator
void dumpRegSetPressure(ArrayRef< unsigned > SetPressure, const TargetRegisterInfo *TRI)
RegPressureTracker(IntervalPressure &rp)
LLVM_DUMP_METHOD void dump(const TargetRegisterInfo &TRI) 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.
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)
Record the upward impact of a single instruction on current register pressure.
unsigned getPSetOrMax() const
Store the effects of a change in pressure on things that MI scheduler cares about.
void addLiveRegs(ArrayRef< unsigned > Regs)
Force liveness of virtual registers or physical register units.
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.
void setPos(MachineBasicBlock::const_iterator Pos)
RegisterPressure & getPressure()
Get the resulting register pressure over the traversed region.
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
This is the fast version of querying register pressure that does not directly depend on current liven...