@@ -572,65 +572,6 @@ MCRegister SIRegisterInfo::reservedPrivateSegmentBufferReg(
572572 return getAlignedHighSGPRForRC (MF, /* Align=*/ 4 , &AMDGPU::SGPR_128RegClass);
573573}
574574
575- std::pair<unsigned , unsigned >
576- SIRegisterInfo::getMaxNumVectorRegs (const MachineFunction &MF) const {
577- const unsigned MaxVectorRegs = ST.getMaxNumVGPRs (MF);
578-
579- unsigned MaxNumVGPRs = MaxVectorRegs;
580- unsigned MaxNumAGPRs = 0 ;
581-
582- // On GFX90A, the number of VGPRs and AGPRs need not be equal. Theoretically,
583- // a wave may have up to 512 total vector registers combining together both
584- // VGPRs and AGPRs. Hence, in an entry function without calls and without
585- // AGPRs used within it, it is possible to use the whole vector register
586- // budget for VGPRs.
587- //
588- // TODO: it shall be possible to estimate maximum AGPR/VGPR pressure and split
589- // register file accordingly.
590- if (ST.hasGFX90AInsts ()) {
591- unsigned MinNumAGPRs = 0 ;
592- const unsigned TotalNumAGPRs = AMDGPU::AGPR_32RegClass.getNumRegs ();
593- const unsigned TotalNumVGPRs = AMDGPU::VGPR_32RegClass.getNumRegs ();
594-
595- const std::pair<unsigned , unsigned > DefaultNumAGPR = {~0u , ~0u };
596-
597- // TODO: Move this logic into subtarget on IR function
598- //
599- // TODO: The lower bound should probably force the number of required
600- // registers up, overriding amdgpu-waves-per-eu.
601- std::tie (MinNumAGPRs, MaxNumAGPRs) = AMDGPU::getIntegerPairAttribute (
602- MF.getFunction (), " amdgpu-agpr-alloc" , DefaultNumAGPR,
603- /* OnlyFirstRequired=*/ true );
604-
605- if (MinNumAGPRs == DefaultNumAGPR.first ) {
606- // Default to splitting half the registers if AGPRs are required.
607- MinNumAGPRs = MaxNumAGPRs = MaxVectorRegs / 2 ;
608- } else {
609- // Align to accum_offset's allocation granularity.
610- MinNumAGPRs = alignTo (MinNumAGPRs, 4 );
611-
612- MinNumAGPRs = std::min (MinNumAGPRs, TotalNumAGPRs);
613- }
614-
615- // Clamp values to be inbounds of our limits, and ensure min <= max.
616-
617- MaxNumAGPRs = std::min (std::max (MinNumAGPRs, MaxNumAGPRs), MaxVectorRegs);
618- MinNumAGPRs = std::min (std::min (MinNumAGPRs, TotalNumAGPRs), MaxNumAGPRs);
619-
620- MaxNumVGPRs = std::min (MaxVectorRegs - MinNumAGPRs, TotalNumVGPRs);
621- MaxNumAGPRs = std::min (MaxVectorRegs - MaxNumVGPRs, MaxNumAGPRs);
622-
623- assert (MaxNumVGPRs + MaxNumAGPRs <= MaxVectorRegs &&
624- MaxNumAGPRs <= TotalNumAGPRs && MaxNumVGPRs <= TotalNumVGPRs &&
625- " invalid register counts" );
626- } else if (ST.hasMAIInsts ()) {
627- // On gfx908 the number of AGPRs always equals the number of VGPRs.
628- MaxNumAGPRs = MaxNumVGPRs = MaxVectorRegs;
629- }
630-
631- return std::pair (MaxNumVGPRs, MaxNumAGPRs);
632- }
633-
634575BitVector SIRegisterInfo::getReservedRegs (const MachineFunction &MF) const {
635576 BitVector Reserved (getNumRegs ());
636577 Reserved.set (AMDGPU::MODE);
@@ -742,7 +683,7 @@ BitVector SIRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
742683
743684 // Reserve VGPRs/AGPRs.
744685 //
745- auto [MaxNumVGPRs, MaxNumAGPRs] = getMaxNumVectorRegs (MF);
686+ auto [MaxNumVGPRs, MaxNumAGPRs] = ST. getMaxNumVectorRegs (MF. getFunction () );
746687
747688 for (const TargetRegisterClass *RC : regclasses ()) {
748689 if (RC->isBaseClass () && isVGPRClass (RC)) {
0 commit comments