diff --git a/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp b/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp --- a/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp @@ -24,17 +24,6 @@ #define DEBUG_TYPE "frame-info" -static ArrayRef getAllSGPR128(const GCNSubtarget &ST, - const MachineFunction &MF) { - return makeArrayRef(AMDGPU::SGPR_128RegClass.begin(), - ST.getMaxNumSGPRs(MF) / 4); -} - -static ArrayRef getAllSGPRs(const GCNSubtarget &ST, - const MachineFunction &MF) { - return makeArrayRef(AMDGPU::SGPR_32RegClass.begin(), ST.getMaxNumSGPRs(MF)); -} - // Find a scratch register that we can use at the start of the prologue to // re-align the stack pointer. We avoid using callee-save registers since they // may appear to be free when this is called from canUseAsPrologue (during @@ -344,7 +333,7 @@ // skip over user SGPRs and may leave unused holes. unsigned NumPreloaded = (MFI->getNumPreloadedSGPRs() + 3) / 4; - ArrayRef AllSGPR128s = getAllSGPR128(ST, MF); + ArrayRef AllSGPR128s = TRI->getAllSGPR128(MF); AllSGPR128s = AllSGPR128s.slice(std::min(static_cast(AllSGPR128s.size()), NumPreloaded)); // Skip the last N reserved elements because they should have already been @@ -438,7 +427,7 @@ // wave offset to a free SGPR. Register ScratchWaveOffsetReg; if (TRI->isSubRegisterEq(ScratchRsrcReg, PreloadedScratchWaveOffsetReg)) { - ArrayRef AllSGPRs = getAllSGPRs(ST, MF); + ArrayRef AllSGPRs = TRI->getAllSGPR32(MF); unsigned NumPreloaded = MFI->getNumPreloadedSGPRs(); AllSGPRs = AllSGPRs.slice( std::min(static_cast(AllSGPRs.size()), NumPreloaded)); diff --git a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp --- a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp +++ b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp @@ -231,11 +231,6 @@ return false; } -static ArrayRef getAllVGPR32(const GCNSubtarget &ST, - const MachineFunction &MF) { - return makeArrayRef(AMDGPU::VGPR_32RegClass.begin(), ST.getMaxNumVGPRs(MF)); -} - // Find lowest available VGPR and use it as VGPR reserved for SGPR spills. static bool lowerShiftReservedVGPR(MachineFunction &MF, const GCNSubtarget &ST) { @@ -243,7 +238,7 @@ MachineFrameInfo &FrameInfo = MF.getFrameInfo(); SIMachineFunctionInfo *FuncInfo = MF.getInfo(); Register LowestAvailableVGPR, ReservedVGPR; - ArrayRef AllVGPR32s = getAllVGPR32(ST, MF); + ArrayRef AllVGPR32s = ST.getRegisterInfo()->getAllVGPR32(MF); for (MCPhysReg Reg : AllVGPR32s) { if (MRI.isAllocatable(Reg) && !MRI.isPhysRegUsed(Reg)) { LowestAvailableVGPR = Reg; diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.h b/llvm/lib/Target/AMDGPU/SIRegisterInfo.h --- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.h +++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.h @@ -313,6 +313,18 @@ // \returns \p Reg otherwise. MCPhysReg get32BitRegister(MCPhysReg Reg) const; + /// Return all SGPR128 which satisfy the waves per execution unit requirement + /// of the subtarget. + ArrayRef getAllSGPR128(const MachineFunction &MF) const; + + /// Return all SGPR32 which satisfy the waves per execution unit requirement + /// of the subtarget. + ArrayRef getAllSGPR32(const MachineFunction &MF) const; + + /// Return all VGPR32 which satisfy the waves per execution unit requirement + /// of the subtarget. + ArrayRef getAllVGPR32(const MachineFunction &MF) const; + private: void buildSpillLoadStore(MachineBasicBlock::iterator MI, unsigned LoadStoreOp, diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp --- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp @@ -1978,3 +1978,19 @@ return false; } } + +ArrayRef +SIRegisterInfo::getAllSGPR128(const MachineFunction &MF) const { + return makeArrayRef(AMDGPU::SGPR_128RegClass.begin(), + ST.getMaxNumSGPRs(MF) / 4); +} + +ArrayRef +SIRegisterInfo::getAllSGPR32(const MachineFunction &MF) const { + return makeArrayRef(AMDGPU::SGPR_32RegClass.begin(), ST.getMaxNumSGPRs(MF)); +} + +ArrayRef +SIRegisterInfo::getAllVGPR32(const MachineFunction &MF) const { + return makeArrayRef(AMDGPU::VGPR_32RegClass.begin(), ST.getMaxNumVGPRs(MF)); +}