Skip to content

Reland [AMDGPU] Serialize WWM_REG vreg flag (#110229) #112492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,13 @@ bool GCNTargetMachine::parseMachineFunctionInfo(
MFI->reserveWWMRegister(ParsedReg);
}

for (const auto &[_, Info] : PFS.VRegInfosNamed) {
MFI->setFlag(Info->VReg, Info->Flags);
}
for (const auto &[_, Info] : PFS.VRegInfos) {
MFI->setFlag(Info->VReg, Info->Flags);
}

auto parseAndCheckArgument = [&](const std::optional<yaml::SIArgument> &A,
const TargetRegisterClass &RC,
ArgDescriptor &Arg, unsigned UserSGPRs,
Expand Down
10 changes: 10 additions & 0 deletions llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3860,3 +3860,13 @@ SIRegisterInfo::getNumUsedPhysRegs(const MachineRegisterInfo &MRI,
return getHWRegIndex(Reg) + 1;
return 0;
}

SmallVector<StringLiteral>
SIRegisterInfo::getVRegFlagsOfReg(Register Reg,
const MachineFunction &MF) const {
SmallVector<StringLiteral> RegFlags;
const SIMachineFunctionInfo *FuncInfo = MF.getInfo<SIMachineFunctionInfo>();
if (FuncInfo->checkFlag(Reg, AMDGPU::VirtRegFlag::WWM_REG))
RegFlags.push_back("WWM_REG");
return RegFlags;
}
8 changes: 8 additions & 0 deletions llvm/lib/Target/AMDGPU/SIRegisterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,14 @@ class SIRegisterInfo final : public AMDGPUGenRegisterInfo {
// Does not go inside function calls.
unsigned getNumUsedPhysRegs(const MachineRegisterInfo &MRI,
const TargetRegisterClass &RC) const;

std::optional<uint8_t> getVRegFlagValue(StringRef Name) const override {
return Name == "WWM_REG" ? AMDGPU::VirtRegFlag::WWM_REG
: std::optional<uint8_t>{};
}

SmallVector<StringLiteral>
getVRegFlagsOfReg(Register Reg, const MachineFunction &MF) const override;
};

namespace AMDGPU {
Expand Down
15 changes: 15 additions & 0 deletions llvm/test/CodeGen/MIR/AMDGPU/machine-function-info-no-ir.mir
Original file line number Diff line number Diff line change
Expand Up @@ -578,3 +578,18 @@ body: |
SI_RETURN

...
---
name: vregs
# FULL: registers:
# FULL-NEXT: - { id: 0, class: vgpr_32, preferred-register: '$vgpr1', flags: [ WWM_REG ] }
# FULL-NEXT: - { id: 1, class: sgpr_64, preferred-register: '$sgpr0_sgpr1', flags: [ ] }
# FULL-NEXT: - { id: 2, class: sgpr_64, preferred-register: '', flags: [ ] }
registers:
- { id: 0, class: vgpr_32, preferred-register: $vgpr1, flags: [ WWM_REG ]}
- { id: 1, class: sgpr_64, preferred-register: $sgpr0_sgpr1 }
- { id: 2, class: sgpr_64, flags: [ ] }
body: |
bb.0:
%2:sgpr_64 = COPY %1
%1:sgpr_64 = COPY %0
...
Loading