Skip to content

Commit 5a5ce3d

Browse files
author
Jun Wang
committed
[AMDGPU] Set register bank for i1 arguments/return values for planned
calling convention update In planned work, the calling convention is to be updated such that i1 arguments and return values are assigned to SGPRs. For this change, we need to ensure the register banks are correctly assigned.
1 parent 0a6a3c1 commit 5a5ce3d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3745,6 +3745,21 @@ AMDGPURegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
37453745
if (!DstBank)
37463746
DstBank = SrcBank;
37473747

3748+
// The calling convention is to be updated such that i1 function arguments
3749+
// or return values are assigned to SGPRs without promoting to i32. With
3750+
// this, for i1 function arguments, the call of getRegBank() above gives
3751+
// incorrect result. We set both src and dst banks to VCCRegBank.
3752+
if (!MI.getOperand(1).getReg().isVirtual() &&
3753+
MRI.getType(MI.getOperand(0).getReg()) == LLT::scalar(1)) {
3754+
DstBank = SrcBank = &AMDGPU::VCCRegBank;
3755+
}
3756+
3757+
// Similarly, for i1 return value, the dst reg is an SReg but we need to
3758+
// explicitly set the reg bank to VCCRegBank.
3759+
if (!MI.getOperand(0).getReg().isVirtual() &&
3760+
SrcBank == &AMDGPU::VCCRegBank)
3761+
DstBank = SrcBank;
3762+
37483763
unsigned Size = getSizeInBits(MI.getOperand(0).getReg(), MRI, *TRI);
37493764
if (MI.getOpcode() != AMDGPU::G_FREEZE &&
37503765
cannotCopy(*DstBank, *SrcBank, TypeSize::getFixed(Size)))

0 commit comments

Comments
 (0)