Skip to content

Commit 19bb535

Browse files
committed
[AMDGPU] Remove unused MIMG tablegen variants
There are no AMDGPUSampleVariant versions for _G16, it is treated more like a modifier for derivatives (_D) (also for intrinsics where it is overloaded type instead of part of instrinsic name) so we ended up making more variants for these instruction then we actually needed. 32-bit derivatives need 6 dwords at most, while 16-bit need 4 at most. Using same AMDGPUSampleVariant for both, we ended up creating 2 extra variants per instruction than were necessary. In total this deletes 260 unused tablegen records. Differential Revision: https://reviews.llvm.org/D131252
1 parent 4bc9e60 commit 19bb535

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

llvm/lib/Target/AMDGPU/MIMGInstructions.td

+16-12
Original file line numberDiff line numberDiff line change
@@ -981,15 +981,19 @@ class MIMGAddrSizes_dw_range<list<int> range> {
981981
int Max = !if(!empty(!tail(range)), Min, !head(!tail(range)));
982982
}
983983

984-
class MIMG_Sampler_AddrSizes<AMDGPUSampleVariant sample> {
984+
class MIMG_Sampler_AddrSizes<AMDGPUSampleVariant sample, bit isG16> {
985985
// List of all possible numbers of address words, taking all combinations of
986986
// A16 and image dimension into account (note: no MSAA, since this is for
987987
// sample/gather ops).
988988
list<int> AllNumAddrWords =
989989
!foreach(dw, !if(sample.Gradients,
990-
!if(!eq(sample.LodOrClamp, ""),
991-
[2, 3, 4, 5, 6, 7, 8, 9],
992-
[2, 3, 4, 5, 6, 7, 8, 9, 10]),
990+
!if(isG16,
991+
!if(!eq(sample.LodOrClamp, ""),
992+
[2, 3, 4, 5, 6, 7],
993+
[2, 3, 4, 5, 6, 7, 8]),
994+
!if(!eq(sample.LodOrClamp, ""),
995+
[2, 3, 4, 5, 6, 7, 8, 9],
996+
[2, 3, 4, 5, 6, 7, 8, 9, 10])),
993997
!if(!eq(sample.LodOrClamp, ""),
994998
[1, 2, 3],
995999
[1, 2, 3, 4])),
@@ -1028,8 +1032,8 @@ class MIMG_Sampler_AddrSizes<AMDGPUSampleVariant sample> {
10281032
multiclass MIMG_Sampler_Src_Helper <mimgopc op, string asm,
10291033
AMDGPUSampleVariant sample, RegisterClass dst_rc,
10301034
bit enableDisasm = 0,
1031-
bit ExtendedImageInst = 1> {
1032-
foreach addr = MIMG_Sampler_AddrSizes<sample>.MachineInstrs in {
1035+
bit ExtendedImageInst = 1, bit isG16 = 0> {
1036+
foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.MachineInstrs in {
10331037
let VAddrDwords = addr.NumWords in {
10341038
if op.HAS_GFX10M then {
10351039
def _V # addr.NumWords
@@ -1051,7 +1055,7 @@ multiclass MIMG_Sampler_Src_Helper <mimgopc op, string asm,
10511055
}
10521056
}
10531057

1054-
foreach addr = MIMG_Sampler_AddrSizes<sample>.NSAInstrs in {
1058+
foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.NSAInstrs in {
10551059
let VAddrDwords = addr.NumWords in {
10561060
if op.HAS_GFX10M then {
10571061
def _V # addr.NumWords # _nsa_gfx10
@@ -1087,15 +1091,15 @@ multiclass MIMG_Sampler <mimgopc op, AMDGPUSampleVariant sample, bit wqm = 0,
10871091
let BaseOpcode = !cast<MIMGBaseOpcode>(NAME), WQM = wqm,
10881092
mayLoad = !not(isGetLod) in {
10891093
let VDataDwords = 1 in
1090-
defm _V1 : MIMG_Sampler_Src_Helper<op, asm, sample, VGPR_32, 1, ExtendedImageInst>;
1094+
defm _V1 : MIMG_Sampler_Src_Helper<op, asm, sample, VGPR_32, 1, ExtendedImageInst, isG16>;
10911095
let VDataDwords = 2 in
1092-
defm _V2 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_64, 0, ExtendedImageInst>;
1096+
defm _V2 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_64, 0, ExtendedImageInst, isG16>;
10931097
let VDataDwords = 3 in
1094-
defm _V3 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_96, 0, ExtendedImageInst>;
1098+
defm _V3 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_96, 0, ExtendedImageInst, isG16>;
10951099
let VDataDwords = 4 in
1096-
defm _V4 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_128, 0, ExtendedImageInst>;
1100+
defm _V4 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_128, 0, ExtendedImageInst, isG16>;
10971101
let VDataDwords = 5 in
1098-
defm _V5 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_160, 0, ExtendedImageInst>;
1102+
defm _V5 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_160, 0, ExtendedImageInst, isG16>;
10991103
}
11001104
}
11011105

0 commit comments

Comments
 (0)