Skip to content

Commit 8ddad18

Browse files
committed
[AMDGPU][GISel] Add RegBankLegalize support for G_SI_CALL
1 parent 22079e3 commit 8ddad18

16 files changed

+256
-14
lines changed

llvm/lib/Target/AMDGPU/AMDGPURegBankLegalizeHelper.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,22 @@ void RegBankLegalizeHelper::lower(MachineInstr &MI,
818818
return lowerUnpackAExt(MI);
819819
case WidenMMOToS32:
820820
return widenMMOToS32(cast<GAnyLoad>(MI));
821+
case WaterfallCall: {
822+
SmallSet<Register, 4> SGPROperandRegs;
823+
SGPROperandRegs.insert(MI.getOperand(1).getReg());
824+
825+
MachineBasicBlock::iterator Start(&MI);
826+
while (Start->getOpcode() != AMDGPU::ADJCALLSTACKUP)
827+
--Start;
828+
MachineBasicBlock::iterator End(&MI);
829+
while (End->getOpcode() != AMDGPU::ADJCALLSTACKDOWN)
830+
++End;
831+
++End;
832+
B.setInsertPt(B.getMBB(), Start);
833+
834+
executeInWaterfallLoop(B, make_range(Start, End), SGPROperandRegs);
835+
break;
836+
}
821837
}
822838

823839
if (!WaterfallSgprs.empty()) {

llvm/lib/Target/AMDGPU/AMDGPURegBankLegalizeRules.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ bool matchUniformityAndLLT(Register Reg, UniformityLLTOpPredicateID UniID,
170170
return MRI.getType(Reg).getSizeInBits() == 512 && MUI.isDivergent(Reg);
171171
case _:
172172
return true;
173+
case PhysReg:
174+
return true;
173175
default:
174176
llvm_unreachable("missing matchUniformityAndLLT");
175177
}
@@ -915,6 +917,12 @@ RegBankLegalizeRules::RegBankLegalizeRules(const GCNSubtarget &_ST,
915917

916918
addRulesForGOpcs({G_READSTEADYCOUNTER}, Standard).Uni(S64, {{Sgpr64}, {}});
917919

920+
addRulesForGOpcs({G_SI_CALL})
921+
.Any({{PhysReg, UniP0}, {{None}, {SgprP0}}})
922+
.Any({{PhysReg, DivP0}, {{None}, {VgprP0}, WaterfallCall}})
923+
.Any({{PhysReg, UniP4}, {{None}, {SgprP4}}})
924+
.Any({{PhysReg, DivP4}, {{None}, {VgprP4}, WaterfallCall}});
925+
918926
bool hasSALUFloat = ST->hasSALUFloatInsts();
919927

920928
addRulesForGOpcs({G_FADD}, Standard)

llvm/lib/Target/AMDGPU/AMDGPURegBankLegalizeRules.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ bool isAnyPtr(LLT Ty, unsigned Width);
3838
// be checked.
3939
enum UniformityLLTOpPredicateID {
4040
_,
41+
PhysReg,
4142
// scalars
4243
S1,
4344
S16,
@@ -134,6 +135,7 @@ enum RegBankLLTMappingApplyID {
134135
Sgpr32,
135136
Sgpr64,
136137
Sgpr128,
138+
SgprP0,
137139
SgprP1,
138140
SgprP3,
139141
SgprP4,
@@ -224,7 +226,8 @@ enum LoweringMethodID {
224226
SplitLoad,
225227
WidenLoad,
226228
WidenMMOToS32,
227-
UnpackAExt
229+
UnpackAExt,
230+
WaterfallCall
228231
};
229232

230233
enum FastRulesTypes {

llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-assert-align.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
; RUN: llc -mtriple=amdgcn -mcpu=fiji -O0 -stop-after=irtranslator -global-isel -o - %s | FileCheck %s
2+
; RUN: llc -mtriple=amdgcn -mcpu=fiji -O0 -stop-after=irtranslator -global-isel -new-reg-bank-select -o - %s | FileCheck %s
33

44
; TODO: Could potentially insert it here
55
define void @arg_align_8(ptr addrspace(1) align 8 %arg0) {

llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call-abi-attribute-hints.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
; RUN: llc -global-isel -stop-after=irtranslator -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -o - %s | FileCheck -enable-var-scope %s
2+
; RUN: llc -global-isel -new-reg-bank-select -stop-after=irtranslator -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -o - %s | FileCheck -enable-var-scope %s
33

44
; Test that we don't insert code to pass implicit arguments we know
55
; the callee does not need.

llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call-implicit-args.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
; RUN: llc -global-isel -stop-after=irtranslator -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -o - %s | FileCheck -enable-var-scope -check-prefix=GFX900 %s
3-
; RUN: llc -global-isel -stop-after=irtranslator -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx908 -o - %s | FileCheck -enable-var-scope -check-prefix=GFX908 %s
2+
; RUN: llc -global-isel -new-reg-bank-select -stop-after=irtranslator -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -o - %s | FileCheck -enable-var-scope -check-prefix=GFX900 %s
3+
; RUN: llc -global-isel -new-reg-bank-select -stop-after=irtranslator -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx908 -o - %s | FileCheck -enable-var-scope -check-prefix=GFX908 %s
44

55
; Workitem IDs are passed to the kernel differently for gfx908
66

llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call-non-fixed.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
; RUN: llc -global-isel -stop-after=irtranslator -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -o - %s | FileCheck -enable-var-scope %s
2+
; RUN: llc -global-isel -new-reg-bank-select -stop-after=irtranslator -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -o - %s | FileCheck -enable-var-scope %s
33

44
; amdgpu_gfx calling convention
55
declare hidden amdgpu_gfx void @external_gfx_void_func_void() #0

llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call-return-values.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
; RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -stop-after=irtranslator < %s | FileCheck -check-prefix=GCN %s
2+
; RUN: llc -global-isel -new-reg-bank-select -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -stop-after=irtranslator < %s | FileCheck -check-prefix=GCN %s
33

44
declare i1 @external_i1_func_void() #0
55
declare zeroext i1 @external_i1_zeroext_func_void() #0

llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call-sret.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
; RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -stop-after=irtranslator < %s | FileCheck -check-prefix=GCN %s
2+
; RUN: llc -global-isel -new-reg-bank-select -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -stop-after=irtranslator < %s | FileCheck -check-prefix=GCN %s
33

44
declare hidden void @external_void_func_sret_struct_i8_i32_byval_struct_i8_i32(ptr addrspace(5) sret({ i8, i32 }), ptr addrspace(5) byval({ i8, i32 })) #0
55

llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
; RUN: llc -global-isel -global-isel-abort=2 -stop-after=irtranslator -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -o - %s | FileCheck -enable-var-scope %s
2+
; RUN: llc -global-isel -new-reg-bank-select -global-isel-abort=2 -stop-after=irtranslator -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -o - %s | FileCheck -enable-var-scope %s
33

44
declare hidden void @external_void_func_void() #0
55

0 commit comments

Comments
 (0)