Skip to content

Commit 70bfbfa

Browse files
authored
[AMDGPU] GlobalISel support for llvm.amdgcn.waterfall.last.use.vgpr (#3187)
1 parent 4530d1f commit 70bfbfa

File tree

4 files changed

+11120
-8852
lines changed

4 files changed

+11120
-8852
lines changed

llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5323,6 +5323,15 @@ AMDGPURegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
53235323
OpdsMapping[3] = AMDGPU::getValueMapping(AMDGPU::SGPRRegBankID, SizeSrc2);
53245324
break;
53255325
}
5326+
case Intrinsic::amdgcn_waterfall_last_use_vgpr: {
5327+
unsigned SizeDst = getSizeInBits(MI.getOperand(0).getReg(), MRI, *TRI);
5328+
unsigned SizeSrc1 = getSizeInBits(MI.getOperand(2).getReg(), MRI, *TRI);
5329+
unsigned SizeSrc2 = getSizeInBits(MI.getOperand(3).getReg(), MRI, *TRI);
5330+
OpdsMapping[0] = AMDGPU::getValueMapping(AMDGPU::VGPRRegBankID, SizeDst);
5331+
OpdsMapping[2] = AMDGPU::getValueMapping(AMDGPU::SGPRRegBankID, SizeSrc1);
5332+
OpdsMapping[3] = AMDGPU::getValueMapping(AMDGPU::VGPRRegBankID, SizeSrc2);
5333+
break;
5334+
}
53265335
case Intrinsic::amdgcn_ds_gws_init:
53275336
case Intrinsic::amdgcn_ds_gws_barrier:
53285337
case Intrinsic::amdgcn_ds_gws_sema_br: {

llvm/lib/Target/AMDGPU/SIInstructions.td

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,57 +2434,44 @@ def : GCNPat <
24342434
(V_RCP_IFLAG_F32_e32 (V_CVT_F32_U32_e32 $src0))))
24352435
>;
24362436

2437-
multiclass SI_WATERFALL_Pattern < ValueType dvt, ValueType svt, string VecSize> {
2438-
def : GCNPat<
2439-
(i32 (int_amdgcn_waterfall_begin i32:$tok, svt:$idx)),
2440-
(!cast<Instruction>("SI_WATERFALL_BEGIN_"#VecSize) i32:$tok, svt:$idx)
2441-
>;
2442-
2443-
def : GCNPat<
2444-
(dvt (int_amdgcn_waterfall_readfirstlane i32:$tok, svt:$src)),
2445-
(!cast<Instruction>("SI_WATERFALL_READFIRSTLANE_"#VecSize) i32:$tok, svt:$src)
2446-
>;
2447-
2448-
def : GCNPat<
2449-
(svt (int_amdgcn_waterfall_end i32:$tok, svt:$src)),
2450-
(!cast<Instruction>("SI_WATERFALL_END_"#VecSize) i32:$tok, svt:$src)
2451-
>;
2452-
}
2453-
2454-
multiclass SI_WATERFALL_S_Pattern < ValueType svt, string VecSize> {
2455-
def : GCNPat<
2456-
(i32 (int_amdgcn_waterfall_begin i32:$tok, svt:$idx)),
2457-
(!cast<Instruction>("SI_WATERFALL_BEGIN_"#VecSize) i32:$tok, svt:$idx)
2458-
>;
2459-
2460-
def : GCNPat<
2461-
(svt (int_amdgcn_waterfall_readfirstlane i32:$tok, svt:$src)),
2462-
(!cast<Instruction>("SI_WATERFALL_READFIRSTLANE_"#VecSize) i32:$tok, svt:$src)
2463-
>;
2464-
2465-
def : GCNPat<
2466-
(svt (int_amdgcn_waterfall_end i32:$tok, svt:$src)),
2467-
(!cast<Instruction>("SI_WATERFALL_END_"#VecSize) i32:$tok, svt:$src)
2468-
>;
2469-
2470-
def : GCNPat<
2471-
(svt (int_amdgcn_waterfall_last_use i32:$tok, svt:$src)),
2472-
(!cast<Instruction>("SI_WATERFALL_LAST_USE_"#VecSize) i32:$tok, svt:$src)
2473-
>;
2474-
def : GCNPat<
2475-
(svt (int_amdgcn_waterfall_last_use_vgpr i32:$tok, svt:$src)),
2476-
(!cast<Instruction>("SI_WATERFALL_LAST_USE_"#VecSize#"_V") i32:$tok, svt:$src)
2477-
>;
2437+
multiclass SI_WATERFALL_Pattern<ValueType dvt, ValueType svt, string VecSize> {
2438+
def : GCNPat<(dvt(int_amdgcn_waterfall_readfirstlane i32:$tok, svt:$src)),
2439+
(!cast<Instruction>("SI_WATERFALL_READFIRSTLANE_"#VecSize)
2440+
i32:$tok,
2441+
svt:$src)>;
2442+
}
2443+
2444+
multiclass SI_WATERFALL_S_Pattern<list<ValueType> vts, string VecSize> {
2445+
foreach vt = vts in {
2446+
def : GCNPat<(i32(int_amdgcn_waterfall_begin i32:$tok, vt:$idx)),
2447+
(!cast<Instruction>("SI_WATERFALL_BEGIN_"#VecSize) i32:$tok,
2448+
vt:$idx)>;
2449+
2450+
def : GCNPat<(vt(int_amdgcn_waterfall_readfirstlane i32:$tok, vt:$src)),
2451+
(!cast<Instruction>("SI_WATERFALL_READFIRSTLANE_"#VecSize)
2452+
i32:$tok,
2453+
vt:$src)>;
2454+
2455+
def : GCNPat<(vt(int_amdgcn_waterfall_end i32:$tok, vt:$src)),
2456+
(!cast<Instruction>("SI_WATERFALL_END_"#VecSize) i32:$tok,
2457+
vt:$src)>;
2458+
2459+
def : GCNPat<(vt(int_amdgcn_waterfall_last_use i32:$tok, vt:$src)),
2460+
(!cast<Instruction>("SI_WATERFALL_LAST_USE_"#VecSize) i32:$tok,
2461+
vt:$src)>;
2462+
2463+
def : GCNPat<(vt(int_amdgcn_waterfall_last_use_vgpr i32:$tok, vt:$src)),
2464+
(!cast<Instruction>("SI_WATERFALL_LAST_USE_"#VecSize#"_V")
2465+
i32:$tok,
2466+
vt:$src)>;
2467+
}
24782468
}
24792469

2480-
defm : SI_WATERFALL_S_Pattern <i16, "V1">;
2481-
defm : SI_WATERFALL_S_Pattern <v2i16, "V1">;
2482-
defm : SI_WATERFALL_S_Pattern <v4i16, "V2">;
2483-
2484-
defm : SI_WATERFALL_S_Pattern <i32, "V1">;
2485-
defm : SI_WATERFALL_S_Pattern <v2i32, "V2">;
2486-
defm : SI_WATERFALL_S_Pattern <v4i32, "V4">;
2487-
defm : SI_WATERFALL_S_Pattern <v8i32, "V8">;
2470+
defm : SI_WATERFALL_S_Pattern<Reg16Types.types, "V1">;
2471+
defm : SI_WATERFALL_S_Pattern<Reg32Types.types, "V1">;
2472+
defm : SI_WATERFALL_S_Pattern<Reg64Types.types, "V2">;
2473+
defm : SI_WATERFALL_S_Pattern<Reg128Types.types, "V4">;
2474+
defm : SI_WATERFALL_S_Pattern<Reg256Types.types, "V8">;
24882475

24892476
defm : SI_WATERFALL_Pattern <i16, f16, "V1">;
24902477
defm : SI_WATERFALL_Pattern <v2i16, v2f16, "V1">;

0 commit comments

Comments
 (0)