Skip to content

Commit ac2ff25

Browse files
committed
[AMDGPU] gfx11 scalar memory instructions
Contributors: Mirko Brkusanin <[email protected]> Patch 9/N for upstreaming of AMDGPU gfx11 architecture. Depends on D125820 Reviewed By: kosarev, #amdgpu, arsenm Differential Revision: https://reviews.llvm.org/D125822
1 parent fa7ce8e commit ac2ff25

File tree

4 files changed

+2184
-10
lines changed

4 files changed

+2184
-10
lines changed

llvm/lib/Target/AMDGPU/SMInstructions.td

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class SM_Pseudo <string opName, dag outs, dag ins, string asmOps, list<dag> patt
5454
bit is_buffer = 0;
5555
}
5656

57-
class SM_Real <SM_Pseudo ps>
58-
: InstSI<ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []> {
57+
class SM_Real <SM_Pseudo ps, string opName = ps.Mnemonic>
58+
: InstSI<ps.OutOperandList, ps.InOperandList, opName # ps.AsmOperands> {
5959

6060
let isPseudo = 0;
6161
let isCodeGenOnly = 0;
@@ -901,21 +901,25 @@ def : GCNPat <
901901
// GFX10.
902902
//===----------------------------------------------------------------------===//
903903

904-
class SMEM_Real_gfx10<bits<8> op, SM_Pseudo ps> :
905-
SM_Real<ps>, SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX10>, Enc64 {
906-
let AssemblerPredicate = isGFX10Plus;
907-
let DecoderNamespace = "GFX10";
908-
904+
class SMEM_Real_10Plus_common<bits<8> op, SM_Pseudo ps, string opName, int subtarget> :
905+
SM_Real<ps, opName>, SIMCInstr<ps.PseudoInstr, subtarget>, Enc64 {
909906
let Inst{5-0} = !if(ps.has_sbase, sbase{6-1}, ?);
910907
let Inst{12-6} = !if(ps.has_sdst, sdst{6-0}, ?);
911-
let Inst{14} = !if(ps.has_dlc, cpol{CPolBit.DLC}, ?);
912-
let Inst{16} = !if(ps.has_glc, cpol{CPolBit.GLC}, ?);
913908
let Inst{25-18} = op;
914909
let Inst{31-26} = 0x3d;
915-
916910
// There are SMEM instructions that do not employ any of the offset
917911
// fields, in which case we need them to remain undefined.
918912
let Inst{52-32} = !if(ps.has_offset, offset{20-0}, !if(ps.has_soffset, 0, ?));
913+
}
914+
915+
class SMEM_Real_gfx10<bits<8> op, SM_Pseudo ps>
916+
: SMEM_Real_10Plus_common<op, ps, ps.Mnemonic, SIEncodingFamily.GFX10> {
917+
let AssemblerPredicate = isGFX10Only;
918+
let DecoderNamespace = "GFX10";
919+
let Inst{14} = !if(ps.has_dlc, cpol{CPolBit.DLC}, ?);
920+
let Inst{16} = !if(ps.has_glc, cpol{CPolBit.GLC}, ?);
921+
// There are SMEM instructions that do not employ any of the offset
922+
// fields, in which case we need them to remain undefined.
919923
let Inst{63-57} = !if(ps.has_soffset, soffset{6-0},
920924
!if(ps.has_offset, !cast<int>(SGPR_NULL_gfxpre11.HWEncoding), ?));
921925
}
@@ -1107,3 +1111,62 @@ def SMInfoTable : GenericTable {
11071111
let PrimaryKey = ["Opcode"];
11081112
let PrimaryKeyName = "getSMEMOpcodeHelper";
11091113
}
1114+
1115+
//===----------------------------------------------------------------------===//
1116+
// GFX11.
1117+
//===----------------------------------------------------------------------===//
1118+
1119+
class SMEM_Real_gfx11<bits<8> op, SM_Pseudo ps, string opName = ps.Mnemonic> :
1120+
SMEM_Real_10Plus_common<op, ps, opName, SIEncodingFamily.GFX11> {
1121+
let AssemblerPredicate = isGFX11Plus;
1122+
let DecoderNamespace = "GFX11";
1123+
let Inst{13} = !if(ps.has_dlc, cpol{CPolBit.DLC}, 0);
1124+
let Inst{14} = !if(ps.has_glc, cpol{CPolBit.GLC}, 0);
1125+
// There are SMEM instructions that do not employ any of the offset
1126+
// fields, in which case we need them to remain undefined.
1127+
let Inst{63-57} = !if(ps.has_soffset, soffset{6-0},
1128+
!if(ps.has_offset, !cast<int>(SGPR_NULL_gfx11plus.HWEncoding), ?));
1129+
}
1130+
1131+
multiclass SM_Real_Loads_gfx11<bits<8> op, string ps, string opName,
1132+
SM_Load_Pseudo immPs = !cast<SM_Load_Pseudo>(ps#_IMM),
1133+
SM_Load_Pseudo sgprPs = !cast<SM_Load_Pseudo>(ps#_SGPR)> {
1134+
def _IMM_gfx11 : SMEM_Real_gfx11<op, immPs, opName> {
1135+
let InOperandList = (ins immPs.BaseClass:$sbase, smem_offset:$offset, CPol:$cpol);
1136+
}
1137+
def _SGPR_gfx11 : SMEM_Real_gfx11<op, sgprPs, opName> {
1138+
let InOperandList = (ins sgprPs.BaseClass:$sbase, SReg_32:$soffset, CPol:$cpol);
1139+
}
1140+
def : MnemonicAlias<immPs.Mnemonic, opName>, Requires<[isGFX11Plus]>;
1141+
}
1142+
1143+
defm S_LOAD_B32 : SM_Real_Loads_gfx11<0x000, "S_LOAD_DWORD", "s_load_b32">;
1144+
defm S_LOAD_B64 : SM_Real_Loads_gfx11<0x001, "S_LOAD_DWORDX2", "s_load_b64">;
1145+
defm S_LOAD_B128 : SM_Real_Loads_gfx11<0x002, "S_LOAD_DWORDX4", "s_load_b128">;
1146+
defm S_LOAD_B256 : SM_Real_Loads_gfx11<0x003, "S_LOAD_DWORDX8", "s_load_b256">;
1147+
defm S_LOAD_B512 : SM_Real_Loads_gfx11<0x004, "S_LOAD_DWORDX16", "s_load_b512">;
1148+
1149+
defm S_BUFFER_LOAD_B32 : SM_Real_Loads_gfx11<0x008, "S_BUFFER_LOAD_DWORD", "s_buffer_load_b32">;
1150+
defm S_BUFFER_LOAD_B64 : SM_Real_Loads_gfx11<0x009, "S_BUFFER_LOAD_DWORDX2", "s_buffer_load_b64">;
1151+
defm S_BUFFER_LOAD_B128 : SM_Real_Loads_gfx11<0x00a, "S_BUFFER_LOAD_DWORDX4", "s_buffer_load_b128">;
1152+
defm S_BUFFER_LOAD_B256 : SM_Real_Loads_gfx11<0x00b, "S_BUFFER_LOAD_DWORDX8", "s_buffer_load_b256">;
1153+
defm S_BUFFER_LOAD_B512 : SM_Real_Loads_gfx11<0x00c, "S_BUFFER_LOAD_DWORDX16", "s_buffer_load_b512">;
1154+
1155+
def S_GL1_INV_gfx11 : SMEM_Real_gfx11<0x020, S_GL1_INV>;
1156+
def S_DCACHE_INV_gfx11 : SMEM_Real_gfx11<0x021, S_DCACHE_INV>;
1157+
1158+
class SMEM_Real_Store_gfx11 <bits<8> op, SM_Pseudo ps> : SMEM_Real_gfx11<op, ps> {
1159+
// encoding
1160+
bits<7> sdata;
1161+
1162+
let sdst = ?;
1163+
let Inst{12-6} = !if(ps.has_sdst, sdata{6-0}, ?);
1164+
}
1165+
1166+
multiclass SM_Real_Probe_gfx11<bits<8> op, string ps> {
1167+
def _IMM_gfx11 : SMEM_Real_Store_gfx11 <op, !cast<SM_Probe_Pseudo>(ps#_IMM)>;
1168+
def _SGPR_gfx11 : SMEM_Real_Store_gfx11 <op, !cast<SM_Probe_Pseudo>(ps#_SGPR)>;
1169+
}
1170+
1171+
defm S_ATC_PROBE : SM_Real_Probe_gfx11 <0x22, "S_ATC_PROBE">;
1172+
defm S_ATC_PROBE_BUFFER : SM_Real_Probe_gfx11 <0x23, "S_ATC_PROBE_BUFFER">;

0 commit comments

Comments
 (0)