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