unsigned SIRegisterInfo::getNumReservedSGPRs(const SISubtarget &ST, const SIMachineFunctionInfo &MFI) const { if (MFI.hasFlatScratchInit()) { if (ST.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS) return 6; // FLAT_SCRATCH, XNACK, VCC (in that order) if (ST.getGeneration() == AMDGPUSubtarget::SEA_ISLANDS) return 4; // FLAT_SCRATCH, VCC (in that order) } if (ST.isXNACKEnabled()) return 4; // XNACK, VCC (in that order) return 2; // VCC. }
bool GCNRegPressure::less(const SISubtarget &ST, const GCNRegPressure& O, unsigned MaxOccupancy) const { const auto SGPROcc = std::min(MaxOccupancy, ST.getOccupancyWithNumSGPRs(getSGPRNum())); const auto VGPROcc = std::min(MaxOccupancy, ST.getOccupancyWithNumVGPRs(getVGPRNum())); const auto OtherSGPROcc = std::min(MaxOccupancy, ST.getOccupancyWithNumSGPRs(O.getSGPRNum())); const auto OtherVGPROcc = std::min(MaxOccupancy, ST.getOccupancyWithNumVGPRs(O.getVGPRNum())); const auto Occ = std::min(SGPROcc, VGPROcc); const auto OtherOcc = std::min(OtherSGPROcc, OtherVGPROcc); if (Occ != OtherOcc) return Occ > OtherOcc; bool SGPRImportant = SGPROcc < VGPROcc; const bool OtherSGPRImportant = OtherSGPROcc < OtherVGPROcc; // if both pressures disagree on what is more important compare vgprs if (SGPRImportant != OtherSGPRImportant) { SGPRImportant = false; } // compare large regs pressure bool SGPRFirst = SGPRImportant; for (int I = 2; I > 0; --I, SGPRFirst = !SGPRFirst) { if (SGPRFirst) { auto SW = getSGPRTuplesWeight(); auto OtherSW = O.getSGPRTuplesWeight(); if (SW != OtherSW) return SW < OtherSW; } else { auto VW = getVGPRTuplesWeight(); auto OtherVW = O.getVGPRTuplesWeight(); if (VW != OtherVW) return VW < OtherVW; } } return SGPRImportant ? (getSGPRNum() < O.getSGPRNum()): (getVGPRNum() < O.getVGPRNum()); }
static unsigned getNumExtraSGPRs(const SISubtarget &ST, bool VCCUsed, bool FlatScrUsed) { unsigned ExtraSGPRs = 0; if (VCCUsed) ExtraSGPRs = 2; if (ST.getGeneration() < SISubtarget::VOLCANIC_ISLANDS) { if (FlatScrUsed) ExtraSGPRs = 4; } else { if (ST.isXNACKEnabled()) ExtraSGPRs = 4; if (FlatScrUsed) ExtraSGPRs = 6; } return ExtraSGPRs; }
unsigned SIRegisterInfo::getNumSGPRsAllowed(const SISubtarget &ST, unsigned WaveCount) const { if (ST.getGeneration() >= SISubtarget::VOLCANIC_ISLANDS) { switch (WaveCount) { case 10: return 80; case 9: return 80; case 8: return 96; default: return 102; } } else { switch(WaveCount) { case 10: return 48; case 9: return 56; case 8: return 64; case 7: return 72; case 6: return 80; case 5: return 96; default: return 103; } } }
unsigned SIRegisterInfo::getMinNumSGPRs(const SISubtarget &ST, unsigned WavesPerEU) const { if (ST.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS) { switch (WavesPerEU) { case 0: return 0; case 10: return 0; case 9: return 0; case 8: return 81; default: return 97; } } else { switch (WavesPerEU) { case 0: return 0; case 10: return 0; case 9: return 49; case 8: return 57; case 7: return 65; case 6: return 73; case 5: return 81; default: return 97; } } }
unsigned SIRegisterInfo::getMaxNumSGPRs(const SISubtarget &ST, unsigned WavesPerEU) const { if (ST.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS) { switch (WavesPerEU) { case 0: return 80; case 10: return 80; case 9: return 80; case 8: return 96; default: return getNumAddressableSGPRs(ST); } } else { switch (WavesPerEU) { case 0: return 48; case 10: return 48; case 9: return 56; case 8: return 64; case 7: return 72; case 6: return 80; case 5: return 96; default: return getNumAddressableSGPRs(ST); } } }
unsigned SIRegisterInfo::getNumReservedSGPRs(const SISubtarget &ST) const { if (ST.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS) return 6; // VCC, FLAT_SCRATCH, XNACK. return 2; // VCC. }
unsigned SIRegisterInfo::getNumAddressableSGPRs(const SISubtarget &ST) const { if (ST.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS) return 102; return 104; }
unsigned SIRegisterInfo::getTotalNumSGPRs(const SISubtarget &ST) const { if (ST.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS) return 800; return 512; }
unsigned SIRegisterInfo::getNumDebuggerReservedVGPRs( const SISubtarget &ST) const { if (ST.debuggerReserveRegs()) return 4; return 0; }