Skip to content

Commit 6360652

Browse files
authored
Reland [AMDGPU] Serialize WWM_REG vreg flag (#110229) (#112492)
A reland but not an exact copy as `VRegInfo.Flags` from the parser is now an int8 instead of a vector; so only need to copy over the value.
1 parent c77e836 commit 6360652

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,13 @@ bool GCNTargetMachine::parseMachineFunctionInfo(
17181718
MFI->reserveWWMRegister(ParsedReg);
17191719
}
17201720

1721+
for (const auto &[_, Info] : PFS.VRegInfosNamed) {
1722+
MFI->setFlag(Info->VReg, Info->Flags);
1723+
}
1724+
for (const auto &[_, Info] : PFS.VRegInfos) {
1725+
MFI->setFlag(Info->VReg, Info->Flags);
1726+
}
1727+
17211728
auto parseAndCheckArgument = [&](const std::optional<yaml::SIArgument> &A,
17221729
const TargetRegisterClass &RC,
17231730
ArgDescriptor &Arg, unsigned UserSGPRs,

llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3860,3 +3860,13 @@ SIRegisterInfo::getNumUsedPhysRegs(const MachineRegisterInfo &MRI,
38603860
return getHWRegIndex(Reg) + 1;
38613861
return 0;
38623862
}
3863+
3864+
SmallVector<StringLiteral>
3865+
SIRegisterInfo::getVRegFlagsOfReg(Register Reg,
3866+
const MachineFunction &MF) const {
3867+
SmallVector<StringLiteral> RegFlags;
3868+
const SIMachineFunctionInfo *FuncInfo = MF.getInfo<SIMachineFunctionInfo>();
3869+
if (FuncInfo->checkFlag(Reg, AMDGPU::VirtRegFlag::WWM_REG))
3870+
RegFlags.push_back("WWM_REG");
3871+
return RegFlags;
3872+
}

llvm/lib/Target/AMDGPU/SIRegisterInfo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,14 @@ class SIRegisterInfo final : public AMDGPUGenRegisterInfo {
462462
// Does not go inside function calls.
463463
unsigned getNumUsedPhysRegs(const MachineRegisterInfo &MRI,
464464
const TargetRegisterClass &RC) const;
465+
466+
std::optional<uint8_t> getVRegFlagValue(StringRef Name) const override {
467+
return Name == "WWM_REG" ? AMDGPU::VirtRegFlag::WWM_REG
468+
: std::optional<uint8_t>{};
469+
}
470+
471+
SmallVector<StringLiteral>
472+
getVRegFlagsOfReg(Register Reg, const MachineFunction &MF) const override;
465473
};
466474

467475
namespace AMDGPU {

llvm/test/CodeGen/MIR/AMDGPU/machine-function-info-no-ir.mir

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,3 +578,18 @@ body: |
578578
SI_RETURN
579579
580580
...
581+
---
582+
name: vregs
583+
# FULL: registers:
584+
# FULL-NEXT: - { id: 0, class: vgpr_32, preferred-register: '$vgpr1', flags: [ WWM_REG ] }
585+
# FULL-NEXT: - { id: 1, class: sgpr_64, preferred-register: '$sgpr0_sgpr1', flags: [ ] }
586+
# FULL-NEXT: - { id: 2, class: sgpr_64, preferred-register: '', flags: [ ] }
587+
registers:
588+
- { id: 0, class: vgpr_32, preferred-register: $vgpr1, flags: [ WWM_REG ]}
589+
- { id: 1, class: sgpr_64, preferred-register: $sgpr0_sgpr1 }
590+
- { id: 2, class: sgpr_64, flags: [ ] }
591+
body: |
592+
bb.0:
593+
%2:sgpr_64 = COPY %1
594+
%1:sgpr_64 = COPY %0
595+
...

0 commit comments

Comments
 (0)