9 #ifndef LLVM_LIB_TARGET_AMDGPU_GCNREGPRESSURE_H 10 #define LLVM_LIB_TARGET_AMDGPU_GCNREGPRESSURE_H 25 class MachineRegisterInfo;
116 const decltype(LiveRegs) &
getLiveRegs()
const {
return LiveRegs; }
123 auto Res = MaxPressure;
129 return std::move(LiveRegs);
149 bool isValid()
const;
170 bool advanceBeforeNext();
173 void advanceToNext();
201 template <
typename Range>
204 std::vector<SlotIndex> Indexes;
205 Indexes.reserve(std::distance(R.begin(), R.end()));
208 auto SI = SII.getInstructionIndex(*
I);
211 std::sort(Indexes.begin(), Indexes.end());
213 auto &MRI = (*R.begin())->
getParent()->getParent()->getRegInfo();
216 for (
unsigned I = 0,
E = MRI.getNumVirtRegs();
I !=
E; ++
I) {
222 if (!LI.findIndexesLiveAt(Indexes, std::back_inserter(LiveIdxs)))
224 if (!LI.hasSubRanges()) {
225 for (
auto SI : LiveIdxs)
226 LiveRegMap[SII.getInstructionFromIndex(SI)][
Reg] =
227 MRI.getMaxLaneMaskForVReg(Reg);
229 for (
const auto &S : LI.subranges()) {
232 S.findIndexesLiveAt(LiveIdxs, std::back_inserter(SRLiveIdxs));
233 for (
auto SI : SRLiveIdxs)
234 LiveRegMap[SII.getInstructionFromIndex(SI)][
Reg] |= S.LaneMask;
252 template <
typename Range>
256 for (
const auto &
RM : LiveRegs)
270 #endif // LLVM_LIB_TARGET_AMDGPU_GCNREGPRESSURE_H
A common definition of LaneBitmask for use in TableGen and CodeGen.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
AMDGPU specific subclass of TargetSubtarget.
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
This class represents lattice values for constants.
decltype(MaxPressure) moveMaxPressure()
unsigned getSGPRTuplesWeight() const
GCNRPTracker(const LiveIntervals &LIS_)
GCNRPTracker::LiveRegSet getLiveRegs(SlotIndex SI, const LiveIntervals &LIS, const MachineRegisterInfo &MRI)
friend GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
static unsigned index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
const LiveIntervals & LIS
decltype(LiveRegs) moveLiveRegs()
bool operator!=(const GCNRegPressure &O) const
decltype(LiveRegs) const & getLiveRegs() const
SlotIndex getDeadSlot() const
Returns the dead def kill slot for the current instruction.
unsigned getOccupancy(const GCNSubtarget &ST) const
static constexpr LaneBitmask getNone()
bool hasInterval(Register Reg) const
void inc(unsigned Reg, LaneBitmask PrevMask, LaneBitmask NewMask, const MachineRegisterInfo &MRI)
unsigned getVGPRTuplesWeight() const
GCNRPTracker::LiveRegSet getLiveRegsBefore(const MachineInstr &MI, const LiveIntervals &LIS)
const MachineBasicBlock::const_iterator getNext() const
bool less(const GCNSubtarget &ST, const GCNRegPressure &O, unsigned MaxOccupancy=std::numeric_limits< unsigned >::max()) const
unsigned const MachineRegisterInfo * MRI
const MachineInstr * getLastTrackedMI() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
unsigned getSGPRNum() const
DenseMap< MachineInstr *, GCNRPTracker::LiveRegSet > getLiveRegMap(Range &&R, bool After, LiveIntervals &LIS)
creates a map MachineInstr -> LiveRegSet R - range of iterators on instructions After - upon entry or...
LiveInterval & getInterval(Register Reg)
GCNRPTracker::LiveRegSet getLiveRegsAfter(const MachineInstr &MI, const LiveIntervals &LIS)
void sort(IteratorTy Start, IteratorTy End)
GCNUpwardRPTracker(const LiveIntervals &LIS_)
void printLivesAt(SlotIndex SI, const LiveIntervals &LIS, const MachineRegisterInfo &MRI)
unsigned getVGPRNum() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool higherOccupancy(const GCNSubtarget &ST, const GCNRegPressure &O) const
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const
Return the maximum number of waves per SIMD for kernels using SGPRs SGPRs.
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
GCNRegPressure getRegPressure(const MachineRegisterInfo &MRI, Range &&LiveRegs)
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
SlotIndexes * getSlotIndexes() const
LaneBitmask getLiveLaneMask(unsigned Reg, SlotIndex SI, const LiveIntervals &LIS, const MachineRegisterInfo &MRI)
bool operator==(const GCNRegPressure &O) const
void print(raw_ostream &OS, const GCNSubtarget *ST=nullptr) const
LLVM Value Representation.
static const Function * getParent(const Value *V)
This class implements an extremely fast bulk output stream that can only output to a stream...
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
GCNRegPressure MaxPressure
GCNDownwardRPTracker(const LiveIntervals &LIS_)
unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const
Return the maximum number of waves per SIMD for kernels using VGPRs VGPRs.
SlotIndex - An opaque wrapper around machine indexes.