xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/MIMGInstructions.td (revision aa1a8ff2d6dbc51ef058f46f3db5a8bb77967145)
1//===-- MIMGInstructions.td - MIMG Instruction Definitions ----------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// MIMG-specific encoding families to distinguish between semantically
10// equivalent machine instructions with different encoding.
11//
12// - MIMGEncGfx6: encoding introduced with gfx6 (obsoleted for atomics in gfx8)
13// - MIMGEncGfx8: encoding introduced with gfx8 for atomics
14// - MIMGEncGfx90a: encoding for gfx90a for atomics
15// - MIMGEncGfx10Default: gfx10 default (non-NSA) encoding
16// - MIMGEncGfx10NSA: gfx10 NSA encoding
17// - MIMGEncGfx11Default: gfx11 default (non-NSA) encoding
18// - MIMGEncGfx11NSA: gfx11 NSA encoding
19class MIMGEncoding;
20
21def MIMGEncGfx6 : MIMGEncoding;
22def MIMGEncGfx8 : MIMGEncoding;
23def MIMGEncGfx90a : MIMGEncoding;
24def MIMGEncGfx10Default : MIMGEncoding;
25def MIMGEncGfx10NSA : MIMGEncoding;
26def MIMGEncGfx11Default : MIMGEncoding;
27def MIMGEncGfx11NSA : MIMGEncoding;
28def MIMGEncGfx12 : MIMGEncoding;
29
30def MIMGEncoding : GenericEnum {
31  let FilterClass = "MIMGEncoding";
32}
33
34// Represent an ISA-level opcode, independent of the encoding and the
35// vdata/vaddr size.
36class MIMGBaseOpcode : PredicateControl {
37  MIMGBaseOpcode BaseOpcode = !cast<MIMGBaseOpcode>(NAME);
38  bit Store = 0;
39  bit Atomic = 0;
40  bit AtomicX2 = 0; // (f)cmpswap
41  bit Sampler = 0;
42  bit Gather4 = 0;
43  bits<8> NumExtraArgs = 0;
44  bit Gradients = 0;
45  bit G16 = 0;
46  bit Coordinates = 1;
47  bit LodOrClampOrMip = 0;
48  bit HasD16 = 0;
49  bit IsAtomicRet = 0;
50  bit MSAA = 0;
51  bit BVH = 0;
52  bit A16 = 0;
53}
54
55def MIMGBaseOpcode : GenericEnum {
56  let FilterClass = "MIMGBaseOpcode";
57}
58
59def MIMGBaseOpcodesTable : GenericTable {
60  let FilterClass = "MIMGBaseOpcode";
61  let CppTypeName = "MIMGBaseOpcodeInfo";
62  let Fields = ["BaseOpcode", "Store", "Atomic", "AtomicX2", "Sampler",
63                "Gather4", "NumExtraArgs", "Gradients", "G16", "Coordinates",
64                "LodOrClampOrMip", "HasD16", "MSAA", "BVH", "A16"];
65  string TypeOf_BaseOpcode = "MIMGBaseOpcode";
66
67  let PrimaryKey = ["BaseOpcode"];
68  let PrimaryKeyName = "getMIMGBaseOpcodeInfo";
69}
70
71def MIMGDim : GenericEnum {
72  let FilterClass = "AMDGPUDimProps";
73}
74
75def MIMGDimInfoTable : GenericTable {
76  let FilterClass = "AMDGPUDimProps";
77  let CppTypeName = "MIMGDimInfo";
78  let Fields = ["Dim", "NumCoords", "NumGradients", "MSAA", "DA", "Encoding", "AsmSuffix"];
79  string TypeOf_Dim = "MIMGDim";
80
81  let PrimaryKey = ["Dim"];
82  let PrimaryKeyName = "getMIMGDimInfo";
83}
84
85def getMIMGDimInfoByEncoding : SearchIndex {
86  let Table = MIMGDimInfoTable;
87  let Key = ["Encoding"];
88}
89
90def getMIMGDimInfoByAsmSuffix : SearchIndex {
91  let Table = MIMGDimInfoTable;
92  let Key = ["AsmSuffix"];
93}
94
95def MIMG {
96  int NOP = -1;
97}
98
99class mimgopc <int gfx12, int gfx11, int gfx10m, int vi = gfx10m, int si = gfx10m> {
100  field bits<8> GFX12 = gfx12;
101  field bits<8> GFX11 = gfx11;
102  field bits<8> GFX10M = gfx10m; // GFX10minus for all but atomics
103  field bits<8> VI = vi; // VI is only used for atomic/sampler/gather instructions
104  field bits<8> SI = si; // SI is only used for atomic instructions
105  bit HAS_GFX12 = !ne(gfx12, MIMG.NOP);
106  bit HAS_GFX11 = !ne(gfx11, MIMG.NOP);
107  bit HAS_GFX10M = !ne(gfx10m, MIMG.NOP);
108  bit HAS_VI = !ne(vi, MIMG.NOP);
109  bit HAS_SI = !ne(si, MIMG.NOP);
110}
111
112class MIMGLZMapping<MIMGBaseOpcode l, MIMGBaseOpcode lz> {
113  MIMGBaseOpcode L = l;
114  MIMGBaseOpcode LZ = lz;
115}
116
117def MIMGLZMappingTable : GenericTable {
118  let FilterClass = "MIMGLZMapping";
119  let CppTypeName = "MIMGLZMappingInfo";
120  let Fields = ["L", "LZ"];
121  string TypeOf_L = "MIMGBaseOpcode";
122  string TypeOf_LZ = "MIMGBaseOpcode";
123
124  let PrimaryKey = ["L"];
125  let PrimaryKeyName = "getMIMGLZMappingInfo";
126}
127
128class MIMGMIPMapping<MIMGBaseOpcode mip, MIMGBaseOpcode nonmip> {
129  MIMGBaseOpcode MIP = mip;
130  MIMGBaseOpcode NONMIP = nonmip;
131}
132
133def MIMGMIPMappingTable : GenericTable {
134  let FilterClass = "MIMGMIPMapping";
135  let CppTypeName = "MIMGMIPMappingInfo";
136  let Fields = ["MIP", "NONMIP"];
137  string TypeOf_MIP = "MIMGBaseOpcode";
138  string TypeOf_NONMIP = "MIMGBaseOpcode";
139
140  let PrimaryKey = ["MIP"];
141  let PrimaryKeyName = "getMIMGMIPMappingInfo";
142}
143
144class MIMGBiasMapping<MIMGBaseOpcode bias, MIMGBaseOpcode nobias> {
145  MIMGBaseOpcode Bias = bias;
146  MIMGBaseOpcode NoBias = nobias;
147}
148
149def MIMGBiasMappingTable : GenericTable {
150  let FilterClass = "MIMGBiasMapping";
151  let CppTypeName = "MIMGBiasMappingInfo";
152  let Fields = ["Bias", "NoBias"];
153  string TypeOf_Bias = "MIMGBaseOpcode";
154  string TypeOf_NoBias = "MIMGBaseOpcode";
155
156  let PrimaryKey = ["Bias"];
157  let PrimaryKeyName = "getMIMGBiasMappingInfo";
158}
159
160class MIMGOffsetMapping<MIMGBaseOpcode offset, MIMGBaseOpcode nooffset> {
161  MIMGBaseOpcode Offset = offset;
162  MIMGBaseOpcode NoOffset = nooffset;
163}
164
165def MIMGOffsetMappingTable : GenericTable {
166  let FilterClass = "MIMGOffsetMapping";
167  let CppTypeName = "MIMGOffsetMappingInfo";
168  let Fields = ["Offset", "NoOffset"];
169  string TypeOf_Offset = "MIMGBaseOpcode";
170  string TypeOf_NoOffset = "MIMGBaseOpcode";
171
172  let PrimaryKey = ["Offset"];
173  let PrimaryKeyName = "getMIMGOffsetMappingInfo";
174}
175
176class MIMGG16Mapping<MIMGBaseOpcode g, MIMGBaseOpcode g16> {
177  MIMGBaseOpcode G = g;
178  MIMGBaseOpcode G16 = g16;
179}
180
181def MIMGG16MappingTable : GenericTable {
182  let FilterClass = "MIMGG16Mapping";
183  let CppTypeName = "MIMGG16MappingInfo";
184  let Fields = ["G", "G16"];
185  string TypeOf_G = "MIMGBaseOpcode";
186  string TypeOf_G16 = "MIMGBaseOpcode";
187
188  let PrimaryKey = ["G"];
189  let PrimaryKeyName = "getMIMGG16MappingInfo";
190}
191
192class MIMG_Base <dag outs, string dns = "">
193  : InstSI <outs, (ins), "", []> {
194
195  let VM_CNT = 1;
196  let EXP_CNT = 1;
197  let MIMG = 1;
198  let Uses = [EXEC];
199  let mayLoad = 1;
200  let mayStore = 0;
201  let SchedRW = [WriteVMEM];
202  let UseNamedOperandTable = 1;
203  let hasSideEffects = 0; // XXX ????
204
205  let DecoderNamespace = dns;
206  let isAsmParserOnly = !eq(dns, "");
207}
208
209class MIMG <dag outs, string dns = "">
210  : MIMG_Base <outs, dns> {
211
212  let hasPostISelHook = 1;
213
214  Instruction Opcode = !cast<Instruction>(NAME);
215  MIMGBaseOpcode BaseOpcode;
216  MIMGEncoding MIMGEncoding;
217  bits<8> VDataDwords;
218  bits<8> VAddrDwords;
219
220  // If NSA is used this counts number of operands VAddrDwords is split into.
221  bits<8> VAddrOperands;
222}
223
224class VIMAGE <dag outs, string dns = ""> : MIMG<outs, dns> {
225  let MIMG = 0;
226  let VIMAGE = 1;
227}
228
229class VSAMPLE <dag outs, string dns = ""> : MIMG<outs, dns> {
230  let MIMG = 0;
231  let VSAMPLE = 1;
232}
233
234def MIMGInfoTable : GenericTable {
235  let FilterClass = "MIMG";
236  let CppTypeName = "MIMGInfo";
237  let Fields = ["Opcode", "BaseOpcode", "MIMGEncoding", "VDataDwords",
238                "VAddrDwords", "VAddrOperands"];
239  string TypeOf_BaseOpcode = "MIMGBaseOpcode";
240  string TypeOf_MIMGEncoding = "MIMGEncoding";
241
242  let PrimaryKey = ["BaseOpcode", "MIMGEncoding", "VDataDwords", "VAddrDwords"];
243  let PrimaryKeyName = "getMIMGOpcodeHelper";
244}
245
246def getMIMGInfo : SearchIndex {
247  let Table = MIMGInfoTable;
248  let Key = ["Opcode"];
249}
250
251class NSAHelper {
252  dag AddrIns;
253  string AddrAsm;
254  int NSA;
255}
256
257class MIMGNSAHelper<int num_addrs,
258                    list<RegisterClass> addr_types=!listsplat(VGPR_32, num_addrs)>
259  : NSAHelper<> {
260  list<string> AddrAsmNames = !foreach(i, !range(num_addrs), "vaddr" # i);
261  let AddrIns = !dag(ins, addr_types, AddrAsmNames);
262  let AddrAsm = "[$" # !interleave(AddrAsmNames, ", $") # "]";
263
264  let NSA = !if(!le(num_addrs, 1), ?,
265            !if(!le(num_addrs, 5), 1,
266            !if(!le(num_addrs, 9), 2,
267            !if(!le(num_addrs, 13), 3, ?))));
268}
269
270class PartialNSAHelper<int num_addrs, int max_addr, RegisterClass LastAddrRC>
271  : NSAHelper<> {
272
273  list<RegisterClass> addr_types =
274    !if(!ge(num_addrs, max_addr),
275      !listconcat(!listsplat(VGPR_32, !sub(max_addr, 1)), [LastAddrRC]),
276      !listsplat(VGPR_32, num_addrs));
277
278  int VAddrCount = !if(!gt(num_addrs, max_addr), max_addr, num_addrs);
279  list<string> AddrAsmNames =  !foreach(i, !range(VAddrCount), "vaddr" # i);
280
281  let AddrIns = !dag(ins, addr_types, AddrAsmNames);
282  let AddrAsm = "[$" # !interleave(AddrAsmNames, ", $") # "]";
283  let NSA = 1;
284}
285
286// Base class of all pre-gfx10 MIMG instructions.
287class MIMG_gfx6789<bits<8> op, dag outs, string dns = "">
288  : MIMG<outs, dns>, MIMGe_gfx6789<op> {
289  let SubtargetPredicate = isGFX6GFX7GFX8GFX9NotGFX90A;
290  let AssemblerPredicate = isGFX6GFX7GFX8GFX9NotGFX90A;
291
292  let MIMGEncoding = MIMGEncGfx6;
293  let VAddrOperands = 1;
294
295  let d16 = !if(BaseOpcode.HasD16, ?, 0);
296}
297
298class MIMG_gfx90a<bits<8> op, dag outs, string dns = "">
299  : MIMG<outs, dns>, MIMGe_gfx90a<op> {
300  let SubtargetPredicate = isGFX90APlus;
301  let AssemblerPredicate = isGFX90APlus;
302
303  let MIMGEncoding = MIMGEncGfx90a;
304  let VAddrOperands = 1;
305
306  let d16 = !if(BaseOpcode.HasD16, ?, 0);
307}
308
309// Base class of all non-NSA gfx10 MIMG instructions.
310class MIMG_gfx10<int op, dag outs, string dns = "">
311  : MIMG<outs, dns>, MIMGe_gfx10<op> {
312  let SubtargetPredicate = isGFX10Only;
313  let AssemblerPredicate = isGFX10Only;
314
315  let MIMGEncoding = MIMGEncGfx10Default;
316  let VAddrOperands = 1;
317
318  let d16 = !if(BaseOpcode.HasD16, ?, 0);
319  let nsa = 0;
320}
321
322// Base class for all NSA MIMG instructions.
323// Note that 1-dword addresses always use non-NSA variants.
324class MIMG_nsa_gfx10<int op, dag outs, int num_addrs, string dns="">
325  : MIMG<outs, dns>, MIMGe_gfx10<op> {
326  let SubtargetPredicate = isGFX10Only;
327  let AssemblerPredicate = isGFX10Only;
328
329  let MIMGEncoding = MIMGEncGfx10NSA;
330  let VAddrOperands = num_addrs;
331
332  MIMGNSAHelper nsah = MIMGNSAHelper<num_addrs>;
333  dag AddrIns = nsah.AddrIns;
334  string AddrAsm = nsah.AddrAsm;
335
336  let d16 = !if(BaseOpcode.HasD16, ?, 0);
337  let nsa = nsah.NSA;
338}
339
340// Base class of all non-NSA gfx11 MIMG instructions.
341class MIMG_gfx11<int op, dag outs, string dns = "">
342  : MIMG<outs, dns>, MIMGe_gfx11<op> {
343  let SubtargetPredicate = isGFX11Only;
344  let AssemblerPredicate = isGFX11Only;
345
346  let MIMGEncoding = MIMGEncGfx11Default;
347  let VAddrOperands = 1;
348
349  let d16 = !if(BaseOpcode.HasD16, ?, 0);
350  let nsa = 0;
351}
352
353// Base class for all NSA MIMG instructions.
354// Note that 1-dword addresses always use non-NSA variants.
355class MIMG_nsa_gfx11<int op, dag outs, int num_addrs, string dns="",
356                     list<RegisterClass> addr_types=[],
357                     RegisterClass LastAddrRC = VGPR_32>
358  : MIMG<outs, dns>, MIMGe_gfx11<op> {
359  let SubtargetPredicate = isGFX11Only;
360  let AssemblerPredicate = isGFX11Only;
361
362  let MIMGEncoding = MIMGEncGfx11NSA;
363  let VAddrOperands = num_addrs;
364
365  NSAHelper nsah = !if(!empty(addr_types),
366                        PartialNSAHelper<num_addrs, 5, LastAddrRC>,
367                        MIMGNSAHelper<num_addrs, addr_types>);
368  dag AddrIns = nsah.AddrIns;
369  string AddrAsm = nsah.AddrAsm;
370
371  let d16 = !if(BaseOpcode.HasD16, ?, 0);
372  let nsa = nsah.NSA;
373}
374
375class VIMAGE_gfx12<int op, dag outs, int num_addrs, string dns="",
376                   list<RegisterClass> addr_types=[]>
377  : VIMAGE<outs, dns>, VIMAGEe<op> {
378  let SubtargetPredicate = isGFX12Plus;
379  let AssemblerPredicate = isGFX12Plus;
380
381  let MIMGEncoding = MIMGEncGfx12;
382  let VAddrOperands = num_addrs;
383
384  MIMGNSAHelper nsah = !if(!empty(addr_types),
385                           MIMGNSAHelper<num_addrs>,
386                           MIMGNSAHelper<num_addrs, addr_types>);
387  dag AddrIns = nsah.AddrIns;
388  string AddrAsm = !if(!eq(num_addrs, 1), "$vaddr0", nsah.AddrAsm);
389
390  let d16 = !if(BaseOpcode.HasD16, ?, 0);
391  let vaddr1 = !if(!lt(num_addrs, 2), 0, ?);
392  let vaddr2 = !if(!lt(num_addrs, 3), 0, ?);
393  let vaddr3 = !if(!lt(num_addrs, 4), 0, ?);
394  let vaddr4 = !if(!lt(num_addrs, 5), 0, ?);
395}
396
397class VSAMPLE_gfx12<int op, dag outs, int num_addrs, string dns="",
398                    RegisterClass Addr3RC>
399  : VSAMPLE<outs, dns>, VSAMPLEe<op> {
400  let SubtargetPredicate = isGFX12Plus;
401  let AssemblerPredicate = isGFX12Plus;
402
403  let MIMGEncoding = MIMGEncGfx12;
404  let VAddrOperands = num_addrs;
405
406  PartialNSAHelper nsah = PartialNSAHelper<num_addrs, 4, Addr3RC>;
407
408  dag AddrIns = nsah.AddrIns;
409  string AddrAsm = !if(!eq(num_addrs, 1), "$vaddr0", nsah.AddrAsm);
410
411  let d16 = !if(BaseOpcode.HasD16, ?, 0);
412  let vaddr1 = !if(!lt(num_addrs, 2), 0, ?);
413  let vaddr2 = !if(!lt(num_addrs, 3), 0, ?);
414  let vaddr3 = !if(!lt(num_addrs, 4), 0, ?);
415}
416
417class MIMG_NoSampler_Helper <mimgopc op, string asm,
418                             RegisterClass dst_rc,
419                             RegisterClass addr_rc,
420                             string dns="">
421  : MIMG_gfx6789 <op.GFX10M, (outs dst_rc:$vdata), dns> {
422  let InOperandList = !con((ins addr_rc:$vaddr, SReg_256:$srsrc,
423                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
424                                R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
425                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
426  let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$tfe$lwe$da"
427                      #!if(BaseOpcode.HasD16, "$d16", "");
428}
429
430class MIMG_NoSampler_Helper_gfx90a <mimgopc op, string asm,
431                                    RegisterClass dst_rc,
432                                    RegisterClass addr_rc,
433                                    string dns="">
434  : MIMG_gfx90a <op.GFX10M, (outs getLdStRegisterOperand<dst_rc>.ret:$vdata), dns> {
435  let InOperandList = !con((ins addr_rc:$vaddr, SReg_256:$srsrc,
436                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
437                                R128A16:$r128, LWE:$lwe, DA:$da),
438                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
439  let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$lwe$da"
440                      #!if(BaseOpcode.HasD16, "$d16", "");
441}
442
443class MIMG_NoSampler_gfx10<mimgopc op, string opcode,
444                           RegisterClass DataRC, RegisterClass AddrRC,
445                           string dns="">
446  : MIMG_gfx10<op.GFX10M, (outs DataRC:$vdata), dns> {
447  let InOperandList = !con((ins AddrRC:$vaddr0, SReg_256:$srsrc, DMask:$dmask,
448                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
449                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
450                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
451  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
452                    #!if(BaseOpcode.HasD16, "$d16", "");
453}
454
455class MIMG_NoSampler_nsa_gfx10<mimgopc op, string opcode,
456                               RegisterClass DataRC, int num_addrs,
457                               string dns="">
458  : MIMG_nsa_gfx10<op.GFX10M, (outs DataRC:$vdata), num_addrs, dns> {
459  let InOperandList = !con(AddrIns,
460                           (ins SReg_256:$srsrc, DMask:$dmask,
461                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
462                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
463                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
464  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
465                    #!if(BaseOpcode.HasD16, "$d16", "");
466}
467
468class MIMG_NoSampler_gfx11<mimgopc op, string opcode,
469                           RegisterClass DataRC, RegisterClass AddrRC,
470                           string dns="">
471  : MIMG_gfx11<op.GFX11, (outs DataRC:$vdata), dns> {
472  let InOperandList = !con((ins AddrRC:$vaddr0, SReg_256:$srsrc, DMask:$dmask,
473                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
474                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
475                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
476  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
477                    #!if(BaseOpcode.HasD16, "$d16", "");
478}
479
480class MIMG_NoSampler_nsa_gfx11<mimgopc op, string opcode,
481                               RegisterClass DataRC, int num_addrs,
482                               string dns="">
483  : MIMG_nsa_gfx11<op.GFX11, (outs DataRC:$vdata), num_addrs, dns> {
484  let InOperandList = !con(AddrIns,
485                           (ins SReg_256:$srsrc, DMask:$dmask,
486                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
487                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
488                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
489  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
490                    #!if(BaseOpcode.HasD16, "$d16", "");
491}
492
493class VIMAGE_NoSampler_gfx12<mimgopc op, string opcode,
494                             RegisterClass DataRC, int num_addrs,
495                             string dns="">
496  : VIMAGE_gfx12<op.GFX11, (outs DataRC:$vdata), num_addrs, dns> {
497  let InOperandList = !con(AddrIns,
498                           (ins SReg_256:$rsrc, DMask:$dmask, Dim:$dim,
499                                CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe),
500                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
501  let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc$dmask$dim$cpol$r128$a16$tfe"
502                    #!if(BaseOpcode.HasD16, "$d16", "");
503}
504
505class VSAMPLE_Sampler_gfx12<mimgopc op, string opcode, RegisterClass DataRC,
506                            int num_addrs, RegisterClass Addr3RC = VGPR_32,
507                            string dns="">
508  : VSAMPLE_gfx12<op.GFX12, (outs DataRC:$vdata), num_addrs, dns, Addr3RC> {
509  let InOperandList = !con(AddrIns,
510                           (ins SReg_256:$rsrc),
511                           !if(BaseOpcode.Sampler, (ins SReg_128:$samp), (ins)),
512                           (ins DMask:$dmask, Dim:$dim, UNorm:$unorm,
513                                CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe,
514                                LWE:$lwe),
515                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
516  let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc"
517                    #!if(BaseOpcode.Sampler, ", $samp", "")
518                    #"$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
519                    #!if(BaseOpcode.HasD16, "$d16", "");
520}
521
522multiclass MIMG_NoSampler_Src_Helper <mimgopc op, string asm,
523                                      RegisterClass dst_rc, bit enableDisasm,
524                                      bit ExtendedImageInst = 1,
525                                      bit isVSample = 0> {
526  let VAddrDwords = 1 in {
527    let ssamp = 0 in {
528      if op.HAS_GFX10M then {
529        def _V1 : MIMG_NoSampler_Helper <op, asm, dst_rc, VGPR_32,
530                                         !if(enableDisasm, "AMDGPU", "")>;
531        if !not(ExtendedImageInst) then
532        def _V1_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VGPR_32,
533                                       !if(enableDisasm, "GFX90A", "")>;
534        def _V1_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VGPR_32,
535                                             !if(enableDisasm, "AMDGPU", "")>;
536      }
537      if op.HAS_GFX11 then {
538        def _V1_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VGPR_32,
539                                             !if(enableDisasm, "AMDGPU", "")>;
540      }
541    }
542    if op.HAS_GFX12 then {
543      if isVSample then {
544        let samp = 0 in
545          def _V1_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 1>;
546      }
547      else {
548        def _V1_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 1,
549                                               !if(enableDisasm, "GFX12", "")>;
550      }
551    }
552  }
553  let VAddrDwords = 2 in {
554    let ssamp = 0 in {
555      if op.HAS_GFX10M then {
556        def _V2 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_64>;
557        if !not(ExtendedImageInst) then
558        def _V2_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VReg_64>;
559        def _V2_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VReg_64>;
560        def _V2_nsa_gfx10 : MIMG_NoSampler_nsa_gfx10<op, asm, dst_rc, 2>;
561      }
562      if op.HAS_GFX11 then {
563        def _V2_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VReg_64>;
564        def _V2_nsa_gfx11 : MIMG_NoSampler_nsa_gfx11<op, asm, dst_rc, 2>;
565      }
566    }
567    if op.HAS_GFX12 then {
568      if isVSample then {
569        let samp = 0 in
570          def _V2_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 2>;
571      }
572      else {
573        def _V2_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 2>;
574      }
575    }
576  }
577  let VAddrDwords = 3 in {
578    let ssamp = 0 in {
579      if op.HAS_GFX10M then {
580        def _V3 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_96>;
581        if !not(ExtendedImageInst) then
582        def _V3_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VReg_96>;
583        def _V3_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VReg_96>;
584        def _V3_nsa_gfx10 : MIMG_NoSampler_nsa_gfx10<op, asm, dst_rc, 3>;
585      }
586      if op.HAS_GFX11 then {
587        def _V3_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VReg_96>;
588        def _V3_nsa_gfx11 : MIMG_NoSampler_nsa_gfx11<op, asm, dst_rc, 3>;
589      }
590    }
591    if op.HAS_GFX12 then {
592      if isVSample then {
593        let samp = 0 in
594          def _V3_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 3>;
595      }
596      else {
597        def _V3_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 3>;
598      }
599    }
600  }
601  let VAddrDwords = 4 in {
602    let ssamp = 0 in {
603      if op.HAS_GFX10M then {
604        def _V4 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_128>;
605        if !not(ExtendedImageInst) then
606        def _V4_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VReg_128>;
607        def _V4_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VReg_128>;
608        def _V4_nsa_gfx10 : MIMG_NoSampler_nsa_gfx10<op, asm, dst_rc, 4,
609                                                     !if(enableDisasm, "AMDGPU", "")>;
610      }
611      if op.HAS_GFX11 then {
612        def _V4_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VReg_128>;
613        def _V4_nsa_gfx11 : MIMG_NoSampler_nsa_gfx11<op, asm, dst_rc, 4,
614                                                     !if(enableDisasm, "AMDGPU", "")>;
615      }
616    }
617    if op.HAS_GFX12 then {
618      if isVSample then {
619        let samp = 0 in
620          def _V4_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 4, VGPR_32,
621                                                !if(enableDisasm, "GFX12", "")>;
622      }
623      else {
624        def _V4_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 4,
625                                               !if(enableDisasm, "GFX12", "")>;
626      }
627    }
628  }
629}
630
631multiclass MIMG_NoSampler <mimgopc op, string asm, bit has_d16, bit mip = 0,
632                           bit isResInfo = 0,
633                           bit msaa = 0> {
634  def "" : MIMGBaseOpcode {
635    let Coordinates = !not(isResInfo);
636    let LodOrClampOrMip = mip;
637    let HasD16 = has_d16;
638    let MSAA = msaa;
639  }
640
641  let BaseOpcode = !cast<MIMGBaseOpcode>(NAME),
642      mayLoad = !not(isResInfo) in {
643    let VDataDwords = 1 in
644    defm _V1 : MIMG_NoSampler_Src_Helper <op, asm, VGPR_32, 1, msaa>;
645    let VDataDwords = 2 in
646    defm _V2 : MIMG_NoSampler_Src_Helper <op, asm, VReg_64, 0, msaa>;
647    let VDataDwords = 3 in
648    defm _V3 : MIMG_NoSampler_Src_Helper <op, asm, VReg_96, 0, msaa>;
649    let VDataDwords = 4 in
650    defm _V4 : MIMG_NoSampler_Src_Helper <op, asm, VReg_128, 0, msaa>;
651    let VDataDwords = 5 in
652    defm _V5 : MIMG_NoSampler_Src_Helper <op, asm, VReg_160, 0, msaa>;
653  }
654}
655
656class MIMG_Store_Helper <mimgopc op, string asm,
657                         RegisterClass data_rc,
658                         RegisterClass addr_rc,
659                         string dns = "">
660  : MIMG_gfx6789<op.GFX10M, (outs), dns> {
661  let InOperandList = !con((ins data_rc:$vdata, addr_rc:$vaddr, SReg_256:$srsrc,
662                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
663                                R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
664                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
665  let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$tfe$lwe$da"
666                      #!if(BaseOpcode.HasD16, "$d16", "");
667}
668
669class MIMG_Store_Helper_gfx90a <mimgopc op, string asm,
670                                RegisterClass data_rc,
671                                RegisterClass addr_rc,
672                                string dns = "">
673  : MIMG_gfx90a<op.GFX10M, (outs), dns> {
674  let InOperandList = !con((ins getLdStRegisterOperand<data_rc>.ret:$vdata,
675                                addr_rc:$vaddr, SReg_256:$srsrc,
676                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
677                                R128A16:$r128, LWE:$lwe, DA:$da),
678                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
679  let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$lwe$da"
680                      #!if(BaseOpcode.HasD16, "$d16", "");
681}
682
683class MIMG_Store_gfx10<mimgopc op, string opcode,
684                       RegisterClass DataRC, RegisterClass AddrRC,
685                       string dns="">
686  : MIMG_gfx10<op.GFX10M, (outs), dns> {
687  let InOperandList = !con((ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
688                                DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
689                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
690                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
691  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
692                    #!if(BaseOpcode.HasD16, "$d16", "");
693}
694
695class MIMG_Store_nsa_gfx10<mimgopc op, string opcode,
696                           RegisterClass DataRC, int num_addrs,
697                           string dns="">
698  : MIMG_nsa_gfx10<op.GFX10M, (outs), num_addrs, dns> {
699  let InOperandList = !con((ins DataRC:$vdata),
700                           AddrIns,
701                           (ins SReg_256:$srsrc, DMask:$dmask,
702                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
703                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
704                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
705  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
706                    #!if(BaseOpcode.HasD16, "$d16", "");
707}
708
709class MIMG_Store_gfx11<mimgopc op, string opcode,
710                       RegisterClass DataRC, RegisterClass AddrRC,
711                       string dns="">
712  : MIMG_gfx11<op.GFX11, (outs), dns> {
713  let InOperandList = !con((ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
714                                DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
715                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
716                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
717  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
718                    #!if(BaseOpcode.HasD16, "$d16", "");
719}
720
721class MIMG_Store_nsa_gfx11<mimgopc op, string opcode,
722                           RegisterClass DataRC, int num_addrs,
723                           string dns="">
724  : MIMG_nsa_gfx11<op.GFX11, (outs), num_addrs, dns> {
725  let InOperandList = !con((ins DataRC:$vdata),
726                           AddrIns,
727                           (ins SReg_256:$srsrc, DMask:$dmask,
728                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
729                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
730                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
731  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
732                    #!if(BaseOpcode.HasD16, "$d16", "");
733}
734
735class VIMAGE_Store_gfx12<mimgopc op, string opcode,
736                         RegisterClass DataRC, int num_addrs,
737                         string dns="">
738  : VIMAGE_gfx12<op.GFX12, (outs), num_addrs, dns> {
739  let InOperandList = !con((ins DataRC:$vdata),
740                           AddrIns,
741                           (ins SReg_256:$rsrc, DMask:$dmask, Dim:$dim,
742                                CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe),
743                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
744  let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc$dmask$dim$cpol$r128$a16$tfe"
745                    #!if(BaseOpcode.HasD16, "$d16", "");
746}
747
748multiclass MIMG_Store_Addr_Helper <mimgopc op, string asm,
749                                  RegisterClass data_rc,
750                                  bit enableDisasm> {
751  let mayLoad = 0, mayStore = 1, hasSideEffects = 0, hasPostISelHook = 0,
752      DisableWQM = 1 in {
753    let VAddrDwords = 1 in {
754      let ssamp = 0 in {
755        if op.HAS_GFX10M then {
756          def _V1 : MIMG_Store_Helper <op, asm, data_rc, VGPR_32,
757                                      !if(enableDisasm, "AMDGPU", "")>;
758          let hasPostISelHook = 1 in
759          def _V1_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VGPR_32,
760                                      !if(enableDisasm, "GFX90A", "")>;
761          def _V1_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VGPR_32,
762                                            !if(enableDisasm, "AMDGPU", "")>;
763        }
764        if op.HAS_GFX11 then {
765          def _V1_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VGPR_32,
766                                            !if(enableDisasm, "AMDGPU", "")>;
767        }
768      }
769      if op.HAS_GFX12 then {
770        def _V1_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 1,
771                                            !if(enableDisasm, "GFX12", "")>;
772      }
773    }
774    let VAddrDwords = 2 in {
775      let ssamp = 0 in {
776        if op.HAS_GFX10M then {
777          def _V2 : MIMG_Store_Helper <op, asm, data_rc, VReg_64>;
778          def _V2_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VReg_64>;
779          def _V2_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VReg_64>;
780          def _V2_nsa_gfx10 : MIMG_Store_nsa_gfx10 <op, asm, data_rc, 2>;
781        }
782        if op.HAS_GFX11 then {
783          def _V2_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VReg_64>;
784          def _V2_nsa_gfx11 : MIMG_Store_nsa_gfx11 <op, asm, data_rc, 2>;
785        }
786      }
787      if op.HAS_GFX12 then {
788        def _V2_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 2>;
789      }
790    }
791    let VAddrDwords = 3 in {
792      let ssamp = 0 in {
793        if op.HAS_GFX10M then {
794          def _V3 : MIMG_Store_Helper <op, asm, data_rc, VReg_96>;
795          def _V3_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VReg_96>;
796          def _V3_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VReg_96>;
797          def _V3_nsa_gfx10 : MIMG_Store_nsa_gfx10 <op, asm, data_rc, 3>;
798        }
799        if op.HAS_GFX11 then {
800          def _V3_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VReg_96>;
801          def _V3_nsa_gfx11 : MIMG_Store_nsa_gfx11 <op, asm, data_rc, 3>;
802        }
803      }
804      if op.HAS_GFX12 then {
805        def _V3_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 3>;
806      }
807    }
808    let VAddrDwords = 4 in {
809      let ssamp = 0 in {
810        if op.HAS_GFX10M then {
811          def _V4 : MIMG_Store_Helper <op, asm, data_rc, VReg_128>;
812          def _V4_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VReg_128>;
813          def _V4_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VReg_128>;
814          def _V4_nsa_gfx10 : MIMG_Store_nsa_gfx10 <op, asm, data_rc, 4,
815                                                          !if(enableDisasm, "AMDGPU", "")>;
816        }
817        if op.HAS_GFX11 then {
818          def _V4_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VReg_128>;
819          def _V4_nsa_gfx11 : MIMG_Store_nsa_gfx11 <op, asm, data_rc, 4,
820                                                          !if(enableDisasm, "AMDGPU", "")>;
821        }
822      }
823      if op.HAS_GFX12 then {
824        def _V4_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 4,
825                                            !if(enableDisasm, "GFX12", "")>;
826      }
827    }
828  }
829}
830
831multiclass MIMG_Store <mimgopc op, string asm, bit has_d16, bit mip = 0> {
832  def "" : MIMGBaseOpcode {
833    let Store = 1;
834    let LodOrClampOrMip = mip;
835    let HasD16 = has_d16;
836  }
837
838  let BaseOpcode = !cast<MIMGBaseOpcode>(NAME) in {
839    let VDataDwords = 1 in
840    defm _V1 : MIMG_Store_Addr_Helper <op, asm, VGPR_32, 1>;
841    let VDataDwords = 2 in
842    defm _V2 : MIMG_Store_Addr_Helper <op, asm, VReg_64, 0>;
843    let VDataDwords = 3 in
844    defm _V3 : MIMG_Store_Addr_Helper <op, asm, VReg_96, 0>;
845    let VDataDwords = 4 in
846    defm _V4 : MIMG_Store_Addr_Helper <op, asm, VReg_128, 0>;
847    let VDataDwords = 5 in
848    defm _V5 : MIMG_Store_Addr_Helper <op, asm, VReg_160, 0>;
849  }
850}
851
852class MIMG_Atomic_gfx6789_base <bits<8> op, string asm, RegisterClass data_rc,
853                                RegisterClass addr_rc, string dns="">
854  : MIMG_gfx6789 <op, (outs data_rc:$vdst), dns> {
855  let Constraints = "$vdst = $vdata";
856
857  let InOperandList = (ins data_rc:$vdata, addr_rc:$vaddr, SReg_256:$srsrc,
858                           DMask:$dmask, UNorm:$unorm, CPol:$cpol,
859                           R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da);
860  let AsmString = asm#" $vdst, $vaddr, $srsrc$dmask$unorm$cpol$r128$tfe$lwe$da";
861}
862
863class MIMG_Atomic_gfx90a_base <bits<8> op, string asm, RegisterClass data_rc,
864                               RegisterClass addr_rc, string dns="">
865  : MIMG_gfx90a <op, (outs getLdStRegisterOperand<data_rc>.ret:$vdst), dns> {
866  let Constraints = "$vdst = $vdata";
867
868  let InOperandList = (ins getLdStRegisterOperand<data_rc>.ret:$vdata,
869                           addr_rc:$vaddr, SReg_256:$srsrc,
870                           DMask:$dmask, UNorm:$unorm, CPol:$cpol,
871                           R128A16:$r128, LWE:$lwe, DA:$da);
872  let AsmString = asm#" $vdst, $vaddr, $srsrc$dmask$unorm$cpol$r128$lwe$da";
873}
874
875class MIMG_Atomic_si<mimgopc op, string asm, RegisterClass data_rc,
876                     RegisterClass addr_rc, bit enableDasm = 0>
877  : MIMG_Atomic_gfx6789_base<op.SI, asm, data_rc, addr_rc,
878                             !if(enableDasm, "GFX6GFX7", "")> {
879  let AssemblerPredicate = isGFX6GFX7;
880}
881
882class MIMG_Atomic_vi<mimgopc op, string asm, RegisterClass data_rc,
883                     RegisterClass addr_rc, bit enableDasm = 0>
884  : MIMG_Atomic_gfx6789_base<op.VI, asm, data_rc, addr_rc, !if(enableDasm, "GFX8", "")> {
885  let AssemblerPredicate = isGFX8GFX9NotGFX90A;
886  let MIMGEncoding = MIMGEncGfx8;
887}
888
889class MIMG_Atomic_gfx90a<mimgopc op, string asm, RegisterClass data_rc,
890                         RegisterClass addr_rc, bit enableDasm = 0>
891  : MIMG_Atomic_gfx90a_base<op.VI, asm, data_rc, addr_rc, !if(enableDasm, "GFX90A", "")> {
892  let AssemblerPredicate = isGFX90APlus;
893  let MIMGEncoding = MIMGEncGfx90a;
894}
895
896class MIMG_Atomic_gfx10<mimgopc op, string opcode,
897                        RegisterClass DataRC, RegisterClass AddrRC,
898                        bit enableDisasm = 0>
899  : MIMG_gfx10<!cast<int>(op.GFX10M), (outs DataRC:$vdst),
900               !if(enableDisasm, "AMDGPU", "")> {
901  let Constraints = "$vdst = $vdata";
902
903  let InOperandList = (ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
904                           DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
905                           R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe);
906  let AsmString = opcode#" $vdst, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
907}
908
909class MIMG_Atomic_nsa_gfx10<mimgopc op, string opcode,
910                            RegisterClass DataRC, int num_addrs,
911                            bit enableDisasm = 0>
912  : MIMG_nsa_gfx10<!cast<int>(op.GFX10M), (outs DataRC:$vdst), num_addrs,
913                   !if(enableDisasm, "AMDGPU", "")> {
914  let Constraints = "$vdst = $vdata";
915
916  let InOperandList = !con((ins DataRC:$vdata),
917                           AddrIns,
918                           (ins SReg_256:$srsrc, DMask:$dmask,
919                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
920                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe));
921  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
922}
923
924class MIMG_Atomic_gfx11<mimgopc op, string opcode,
925                        RegisterClass DataRC, RegisterClass AddrRC,
926                        bit enableDisasm = 0>
927  : MIMG_gfx11<!cast<int>(op.GFX11), (outs DataRC:$vdst),
928               !if(enableDisasm, "AMDGPU", "")> {
929  let Constraints = "$vdst = $vdata";
930
931  let InOperandList = (ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
932                           DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
933                           R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe);
934  let AsmString = opcode#" $vdst, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
935}
936
937class MIMG_Atomic_nsa_gfx11<mimgopc op, string opcode,
938                            RegisterClass DataRC, int num_addrs,
939                            bit enableDisasm = 0>
940  : MIMG_nsa_gfx11<!cast<int>(op.GFX11), (outs DataRC:$vdst), num_addrs,
941                   !if(enableDisasm, "AMDGPU", "")> {
942  let Constraints = "$vdst = $vdata";
943
944  let InOperandList = !con((ins DataRC:$vdata),
945                           AddrIns,
946                           (ins SReg_256:$srsrc, DMask:$dmask,
947                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
948                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe));
949  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
950}
951
952class VIMAGE_Atomic_gfx12<mimgopc op, string opcode, RegisterClass DataRC,
953                          int num_addrs, bit enableDisasm = 0>
954  : VIMAGE_gfx12<!cast<int>(op.GFX12), (outs DataRC:$vdst), num_addrs,
955                  !if(enableDisasm, "GFX12", "")> {
956  let Constraints = "$vdst = $vdata";
957
958  let InOperandList = !con((ins DataRC:$vdata),
959                           AddrIns,
960                           (ins SReg_256:$rsrc, DMask:$dmask, Dim:$dim,
961                                 CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe));
962  let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc$dmask$dim$cpol$r128$a16$tfe";
963}
964
965class VIMAGE_Atomic_gfx12_Renamed<mimgopc op, string opcode, string renamed,
966                                  RegisterClass DataRC, int num_addrs,
967                                  bit enableDisasm = 0>
968   : VIMAGE_Atomic_gfx12<op, renamed, DataRC, num_addrs, enableDisasm>,
969     MnemonicAlias<opcode, renamed>, Requires<[isGFX12Plus]>;
970
971multiclass MIMG_Atomic_Addr_Helper_m <mimgopc op, string asm,
972                                      RegisterClass data_rc,
973                                      bit enableDasm = 0,
974                                      bit isFP = 0,
975                                      string renamed = ""> {
976  let hasSideEffects = 1, // FIXME: remove this
977      mayLoad = 1, mayStore = 1, hasPostISelHook = 0, DisableWQM = 1,
978      FPAtomic = isFP in {
979    let VAddrDwords = 1 in {
980      let ssamp = 0 in {
981        if op.HAS_SI then {
982          def _V1_si : MIMG_Atomic_si <op, asm, data_rc, VGPR_32, enableDasm>;
983        }
984        if op.HAS_VI then {
985          def _V1_vi : MIMG_Atomic_vi <op, asm, data_rc, VGPR_32, enableDasm>;
986          let hasPostISelHook = 1 in
987          def _V1_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VGPR_32, enableDasm>;
988        }
989        if op.HAS_GFX10M then {
990          def _V1_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VGPR_32, enableDasm>;
991        }
992        if op.HAS_GFX11 then {
993          def _V1_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VGPR_32, enableDasm>;
994        }
995      }
996      if op.HAS_GFX12 then {
997        if !empty(renamed) then
998          def _V1_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 1, enableDasm>;
999        else
1000          def _V1_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, asm, renamed, data_rc, 1, enableDasm>;
1001      }
1002    }
1003    let VAddrDwords = 2 in {
1004      let ssamp = 0 in {
1005        if op.HAS_SI then {
1006          def _V2_si : MIMG_Atomic_si <op, asm, data_rc, VReg_64, 0>;
1007        }
1008        if op.HAS_VI then {
1009          def _V2_vi : MIMG_Atomic_vi <op, asm, data_rc, VReg_64, 0>;
1010          def _V2_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VReg_64, 0>;
1011        }
1012        if op.HAS_GFX10M then {
1013          def _V2_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VReg_64, 0>;
1014          def _V2_nsa_gfx10 : MIMG_Atomic_nsa_gfx10 <op, asm, data_rc, 2, 0>;
1015        }
1016        if op.HAS_GFX11 then {
1017          def _V2_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VReg_64, 0>;
1018          def _V2_nsa_gfx11 : MIMG_Atomic_nsa_gfx11 <op, asm, data_rc, 2, 0>;
1019        }
1020      }
1021      if op.HAS_GFX12 then {
1022        if !empty(renamed) then
1023          def _V2_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 2, 0>;
1024        else
1025          def _V2_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, asm, renamed, data_rc, 2, 0>;
1026      }
1027    }
1028    let VAddrDwords = 3 in {
1029      let ssamp = 0 in {
1030        if op.HAS_SI then {
1031          def _V3_si : MIMG_Atomic_si <op, asm, data_rc, VReg_96, 0>;
1032        }
1033        if op.HAS_VI then {
1034          def _V3_vi : MIMG_Atomic_vi <op, asm, data_rc, VReg_96, 0>;
1035          def _V3_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VReg_96, 0>;
1036        }
1037        if op.HAS_GFX10M then {
1038          def _V3_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VReg_96, 0>;
1039          def _V3_nsa_gfx10 : MIMG_Atomic_nsa_gfx10 <op, asm, data_rc, 3, 0>;
1040        }
1041        if op.HAS_GFX11 then {
1042          def _V3_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VReg_96, 0>;
1043          def _V3_nsa_gfx11 : MIMG_Atomic_nsa_gfx11 <op, asm, data_rc, 3, 0>;
1044        }
1045      }
1046      if op.HAS_GFX12 then {
1047        if !empty(renamed) then
1048          def _V3_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 3, 0>;
1049        else
1050          def _V3_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, asm, renamed, data_rc, 3, 0>;
1051      }
1052    }
1053    let VAddrDwords = 4 in {
1054      let ssamp = 0 in {
1055        if op.HAS_SI then {
1056          def _V4_si : MIMG_Atomic_si <op, asm, data_rc, VReg_128, 0>;
1057        }
1058        if op.HAS_VI then {
1059          def _V4_vi : MIMG_Atomic_vi <op, asm, data_rc, VReg_128, 0>;
1060          def _V4_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VReg_128, 0>;
1061        }
1062        if op.HAS_GFX10M then {
1063          def _V4_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VReg_128, 0>;
1064          def _V4_nsa_gfx10 : MIMG_Atomic_nsa_gfx10 <op, asm, data_rc, 4, enableDasm>;
1065        }
1066        if op.HAS_GFX11 then {
1067          def _V4_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VReg_128, 0>;
1068          def _V4_nsa_gfx11 : MIMG_Atomic_nsa_gfx11 <op, asm, data_rc, 4, enableDasm>;
1069        }
1070      }
1071      if op.HAS_GFX12 then {
1072        if !empty(renamed) then
1073          def _V4_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 4, enableDasm>;
1074        else
1075          def _V4_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, asm, renamed, data_rc, 4, enableDasm>;
1076      }
1077    }
1078  }
1079}
1080
1081multiclass MIMG_Atomic <mimgopc op, string asm, bit isCmpSwap = 0, bit isFP = 0,
1082                        string renamed = ""> { // 64-bit atomics
1083  let IsAtomicRet = 1 in {
1084    def "" : MIMGBaseOpcode {
1085      let Atomic = 1;
1086      let AtomicX2 = isCmpSwap;
1087    }
1088
1089    let BaseOpcode = !cast<MIMGBaseOpcode>(NAME) in {
1090      // _V* variants have different dst size, but the size is encoded implicitly,
1091      // using dmask and tfe. Only 32-bit variant is registered with disassembler.
1092      // Other variants are reconstructed by disassembler using dmask and tfe.
1093      let VDataDwords = !if(isCmpSwap, 2, 1) in
1094      defm _V1 : MIMG_Atomic_Addr_Helper_m <op, asm, !if(isCmpSwap, VReg_64, VGPR_32), 1, isFP, renamed>;
1095      let VDataDwords = !if(isCmpSwap, 4, 2) in
1096      defm _V2 : MIMG_Atomic_Addr_Helper_m <op, asm, !if(isCmpSwap, VReg_128, VReg_64), 0, isFP, renamed>;
1097    }
1098  } // End IsAtomicRet = 1
1099}
1100
1101multiclass MIMG_Atomic_Renamed <mimgopc op, string asm, string renamed,
1102                                bit isCmpSwap = 0, bit isFP = 0>
1103  : MIMG_Atomic <op, asm, isCmpSwap, isFP, renamed>;
1104
1105class MIMG_Sampler_Helper <mimgopc op, string asm, RegisterClass dst_rc,
1106                           RegisterClass src_rc, string dns="">
1107  : MIMG_gfx6789 <op.VI, (outs dst_rc:$vdata), dns> {
1108  let InOperandList = !con((ins src_rc:$vaddr, SReg_256:$srsrc, SReg_128:$ssamp,
1109                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
1110                                R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
1111                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
1112  let AsmString = asm#" $vdata, $vaddr, $srsrc, $ssamp$dmask$unorm$cpol$r128$tfe$lwe$da"
1113                      #!if(BaseOpcode.HasD16, "$d16", "");
1114}
1115
1116class MIMG_Sampler_gfx90a<mimgopc op, string asm, RegisterClass dst_rc,
1117                          RegisterClass src_rc, string dns="">
1118  : MIMG_gfx90a<op.GFX10M, (outs getLdStRegisterOperand<dst_rc>.ret:$vdata), dns> {
1119  let InOperandList = !con((ins src_rc:$vaddr, SReg_256:$srsrc, SReg_128:$ssamp,
1120                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
1121                                R128A16:$r128, LWE:$lwe, DA:$da),
1122                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
1123  let AsmString = asm#" $vdata, $vaddr, $srsrc, $ssamp$dmask$unorm$cpol$r128$lwe$da"
1124                      #!if(BaseOpcode.HasD16, "$d16", "");
1125}
1126
1127class MIMG_Sampler_gfx10<mimgopc op, string opcode,
1128                         RegisterClass DataRC, RegisterClass AddrRC,
1129                         string dns="">
1130  : MIMG_gfx10<op.GFX10M, (outs DataRC:$vdata), dns> {
1131  let InOperandList = !con((ins AddrRC:$vaddr0, SReg_256:$srsrc, SReg_128:$ssamp,
1132                                DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
1133                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
1134                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
1135  let AsmString = opcode#" $vdata, $vaddr0, $srsrc, $ssamp$dmask$dim$unorm"
1136                    #"$cpol$r128$a16$tfe$lwe"
1137                    #!if(BaseOpcode.HasD16, "$d16", "");
1138}
1139
1140class MIMG_Sampler_nsa_gfx10<mimgopc op, string opcode,
1141                             RegisterClass DataRC, int num_addrs,
1142                             string dns="">
1143  : MIMG_nsa_gfx10<op.GFX10M, (outs DataRC:$vdata), num_addrs, dns> {
1144  let InOperandList = !con(AddrIns,
1145                           (ins SReg_256:$srsrc, SReg_128:$ssamp, DMask:$dmask,
1146                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
1147                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
1148                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
1149  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc, $ssamp$dmask$dim$unorm"
1150                    #"$cpol$r128$a16$tfe$lwe"
1151                    #!if(BaseOpcode.HasD16, "$d16", "");
1152}
1153
1154class MIMG_Sampler_gfx11<mimgopc op, string opcode,
1155                         RegisterClass DataRC, RegisterClass AddrRC,
1156                         string dns="">
1157  : MIMG_gfx11<op.GFX11, (outs DataRC:$vdata), dns> {
1158  let InOperandList = !con((ins AddrRC:$vaddr0, SReg_256:$srsrc, SReg_128:$ssamp,
1159                                DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
1160                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
1161                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
1162  let AsmString = opcode#" $vdata, $vaddr0, $srsrc, $ssamp$dmask$dim$unorm"
1163                    #"$cpol$r128$a16$tfe$lwe"
1164                    #!if(BaseOpcode.HasD16, "$d16", "");
1165}
1166
1167class MIMG_Sampler_nsa_gfx11<mimgopc op, string opcode,
1168                             RegisterClass DataRC, int num_addrs,
1169                             RegisterClass LastVAddrSize, string dns="">
1170  : MIMG_nsa_gfx11<op.GFX11, (outs DataRC:$vdata), num_addrs, dns, [],
1171                   LastVAddrSize> {
1172  let InOperandList = !con(AddrIns,
1173                           (ins SReg_256:$srsrc, SReg_128:$ssamp, DMask:$dmask,
1174                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
1175                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
1176                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
1177  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc, $ssamp$dmask$dim$unorm"
1178                    #"$cpol$r128$a16$tfe$lwe"
1179                    #!if(BaseOpcode.HasD16, "$d16", "");
1180}
1181
1182class MIMGAddrSize<int dw, bit enable_disasm, int AddrDW = dw> {
1183  int NumWords = dw;
1184
1185  RegisterClass RegClass = !if(!le(AddrDW, 0), ?,
1186                           !if(!eq(AddrDW, 1), VGPR_32,
1187                           !if(!eq(AddrDW, 2), VReg_64,
1188                           !if(!eq(AddrDW, 3), VReg_96,
1189                           !if(!eq(AddrDW, 4), VReg_128,
1190                           !if(!eq(AddrDW, 5), VReg_160,
1191                           !if(!eq(AddrDW, 6), VReg_192,
1192                           !if(!eq(AddrDW, 7), VReg_224,
1193                           !if(!eq(AddrDW, 8), VReg_256,
1194                           !if(!eq(AddrDW, 9), VReg_288,
1195                           !if(!eq(AddrDW, 10), VReg_320,
1196                           !if(!eq(AddrDW, 11), VReg_352,
1197                           !if(!eq(AddrDW, 12), VReg_384,
1198                           !if(!le(AddrDW, 16), VReg_512, ?))))))))))))));
1199
1200  // Whether the instruction variant with this vaddr size should be enabled for
1201  // the auto-generated disassembler.
1202  bit Disassemble = enable_disasm;
1203}
1204
1205// Returns the MIMGAddrSize with the size of last VAddr for partial NSA
1206class LastVAddrSize <int dw, int max_idx, bit enable_disasm>
1207  : MIMGAddrSize<dw, enable_disasm,
1208                 !if(!gt(dw, max_idx), !sub(dw, max_idx), 0)>;
1209
1210// Return whether x is in lst.
1211class isIntInList<int x, list<int> lst> {
1212  bit ret = !foldl(0, lst, lhs, y, !or(lhs, !eq(x, y)));
1213}
1214
1215// Return whether a value inside the range [min, max] (endpoints inclusive)
1216// is in the given list.
1217class isRangeInList<int min, int max, list<int> lst> {
1218  bit ret = !foldl(0, lst, lhs, y, !or(lhs, !and(!le(min, y), !le(y, max))));
1219}
1220
1221class MIMGAddrSizes_dw_range<list<int> range> {
1222  int Min = !head(range);
1223  int Max = !if(!empty(!tail(range)), Min, !head(!tail(range)));
1224}
1225
1226class MIMG_Sampler_AddrSizes<AMDGPUSampleVariant sample, bit isG16,
1227                             int nsa_max_addr = 5, bit includeNSA1 = 0> {
1228  // List of all possible numbers of address words, taking all combinations of
1229  // A16 and image dimension into account (note: no MSAA, since this is for
1230  // sample/gather ops).
1231  list<int> AllNumAddrWords =
1232    !foreach(dw, !if(sample.Gradients,
1233                     !if(isG16,
1234                         !if(!eq(sample.LodOrClamp, ""),
1235                             [2, 3, 4, 5, 6, 7],
1236                             [2, 3, 4, 5, 6, 7, 8]),
1237                         !if(!eq(sample.LodOrClamp, ""),
1238                             [2, 3, 4, 5, 6, 7, 8, 9],
1239                             [2, 3, 4, 5, 6, 7, 8, 9, 10])),
1240                     !if(!eq(sample.LodOrClamp, ""),
1241                         [1, 2, 3],
1242                         [1, 2, 3, 4])),
1243             !add(dw, !size(sample.ExtraAddrArgs)));
1244
1245  // Generate machine instructions based on possible register classes for the
1246  // required numbers of address words. The disassembler defaults to the
1247  // smallest register class.
1248  list<MIMGAddrSize> MachineInstrs =
1249    !foldl([]<MIMGAddrSize>,
1250           !foreach(range,
1251                    // V4 is generated for V3 and V4
1252                    // V8 is generated for V5 through V8
1253                    // V16 is generated for V13 through V16
1254                    [[1],[2],[3],[3,4],[5],[6],[7],[5,8],[9],[10],[11],[12],[13,16]],
1255                    MIMGAddrSizes_dw_range<range>),
1256           lhs, dw,
1257           !if(isRangeInList<dw.Min, dw.Max, AllNumAddrWords>.ret,
1258               !listconcat(lhs, [MIMGAddrSize<dw.Max, !empty(lhs)>]),
1259               lhs));
1260
1261  // For NSA, generate machine instructions for all possible numbers of words
1262  // except 1 (which is already covered by the non-NSA case).
1263  // The disassembler defaults to the largest number of arguments among the
1264  // variants with the same number of NSA words, and custom code then derives
1265  // the exact variant based on the sample variant and the image dimension.
1266  list<MIMGAddrSize> NSAInstrs =
1267    !foldl([]<MIMGAddrSize>, [[12, 11, 10], [9, 8, 7, 6], [5, 4, 3, 2]], prev, nsa_group,
1268           !listconcat(prev,
1269                       !foldl([]<MIMGAddrSize>, nsa_group, lhs, dw,
1270                              !if(isIntInList<dw, AllNumAddrWords>.ret,
1271                                  !listconcat(lhs, [MIMGAddrSize<dw, !empty(lhs)>]),
1272                                  lhs))));
1273
1274  // In NSA format if there is a requirement for more VGPRs than the format
1275  // supports, then the rest are sequential after the last one. Generate
1276  // machine instructions for all possible number of words. The disassembler
1277  // defaults to the largest number of arguments but no larger than max nsa
1278  // size. List is generated with the register class needed for last vaddr since
1279  // it is the only one that could have a register other than VGPR32.
1280  int EnableDisasmNum = !foldl(!head(AllNumAddrWords), !tail(AllNumAddrWords),
1281                               acc, var, !if(!le(var, nsa_max_addr), var, acc));
1282  list<int> PossibleVariants =
1283    !listconcat([12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2], !if(includeNSA1, [1], []));
1284  list<LastVAddrSize> PartialNSAInstrs =
1285        !foldl([]<LastVAddrSize>, PossibleVariants, lhs, dw,
1286               !if(isIntInList<dw, AllNumAddrWords>.ret,
1287                   !listconcat(lhs, [LastVAddrSize<dw, !sub(nsa_max_addr, 1),
1288                                                   !eq(dw, EnableDisasmNum)>]),
1289                   lhs));
1290}
1291
1292multiclass MIMG_Sampler_Src_Helper <mimgopc op, string asm,
1293                                    AMDGPUSampleVariant sample, RegisterClass dst_rc,
1294                                    bit enableDisasm = 0,
1295                                    bit ExtendedImageInst = 1, bit isG16 = 0> {
1296  foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.MachineInstrs in {
1297    let VAddrDwords = addr.NumWords in {
1298      if op.HAS_GFX10M then {
1299        def _V # addr.NumWords
1300          : MIMG_Sampler_Helper <op, asm, dst_rc, addr.RegClass,
1301                                 !if(!and(enableDisasm, addr.Disassemble), "AMDGPU", "")>;
1302        if !not(ExtendedImageInst) then
1303        def _V # addr.NumWords # _gfx90a
1304          : MIMG_Sampler_gfx90a <op, asm, dst_rc, addr.RegClass,
1305                                 !if(!and(enableDisasm, addr.Disassemble), "GFX90A", "")>;
1306        def _V # addr.NumWords # _gfx10
1307          : MIMG_Sampler_gfx10 <op, asm, dst_rc, addr.RegClass,
1308                                 !if(!and(enableDisasm, addr.Disassemble), "AMDGPU", "")>;
1309      }
1310      if op.HAS_GFX11 then {
1311        def _V # addr.NumWords # _gfx11
1312          : MIMG_Sampler_gfx11 <op, asm, dst_rc, addr.RegClass,
1313                                 !if(!and(enableDisasm, addr.Disassemble), "AMDGPU", "")>;
1314      }
1315    }
1316  }
1317
1318  foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.NSAInstrs in {
1319    let VAddrDwords = addr.NumWords in {
1320      if op.HAS_GFX10M then {
1321        def _V # addr.NumWords # _nsa_gfx10
1322          : MIMG_Sampler_nsa_gfx10<op, asm, dst_rc, addr.NumWords,
1323                                   !if(!and(enableDisasm, addr.Disassemble), "AMDGPU", "")>;
1324      }
1325    }
1326  }
1327
1328  foreach addr = MIMG_Sampler_AddrSizes<sample, isG16, 5/*MaxNSASize*/>.PartialNSAInstrs in {
1329    let VAddrDwords = addr.NumWords in {
1330      if op.HAS_GFX11 then {
1331        def _V # addr.NumWords # _nsa_gfx11
1332          : MIMG_Sampler_nsa_gfx11<op, asm, dst_rc, addr.NumWords, addr.RegClass,
1333                                   !if(!and(enableDisasm, addr.Disassemble), "AMDGPU", "")>;
1334      }
1335    }
1336  }
1337
1338  foreach addr = MIMG_Sampler_AddrSizes<sample, isG16, 4/*MaxNSASize*/, 1>.PartialNSAInstrs in {
1339    let VAddrDwords = addr.NumWords in {
1340      if op.HAS_GFX12 then {
1341        def _V # addr.NumWords # _gfx12
1342          : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, addr.NumWords, addr.RegClass,
1343                                  !if(!and(enableDisasm, addr.Disassemble), "GFX12", "")>;
1344      }
1345    }
1346  }
1347}
1348
1349class MIMG_Sampler_BaseOpcode<AMDGPUSampleVariant sample>
1350  : MIMGBaseOpcode {
1351  let Sampler = 1;
1352  let NumExtraArgs = !size(sample.ExtraAddrArgs);
1353  let Gradients = sample.Gradients;
1354  let LodOrClampOrMip = !ne(sample.LodOrClamp, "");
1355}
1356
1357multiclass MIMG_Sampler <mimgopc op, AMDGPUSampleVariant sample, bit wqm = 0,
1358                         bit isG16 = 0, bit isGetLod = 0,
1359                         string asm = "image_sample"#sample.LowerCaseMod#!if(isG16, "_g16", ""),
1360                         bit ExtendedImageInst = !ne(sample.LowerCaseMod, "")> {
1361  def "" : MIMG_Sampler_BaseOpcode<sample> {
1362    let HasD16 = !not(isGetLod);
1363    let G16 = isG16;
1364  }
1365
1366  let BaseOpcode = !cast<MIMGBaseOpcode>(NAME), WQM = wqm,
1367      mayLoad = !not(isGetLod) in {
1368    let VDataDwords = 1 in
1369    defm _V1 : MIMG_Sampler_Src_Helper<op, asm, sample, VGPR_32, 1, ExtendedImageInst, isG16>;
1370    let VDataDwords = 2 in
1371    defm _V2 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_64, 0, ExtendedImageInst, isG16>;
1372    let VDataDwords = 3 in
1373    defm _V3 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_96, 0, ExtendedImageInst, isG16>;
1374    let VDataDwords = 4 in
1375    defm _V4 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_128, 0, ExtendedImageInst, isG16>;
1376    let VDataDwords = 5 in
1377    defm _V5 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_160, 0, ExtendedImageInst, isG16>;
1378  }
1379}
1380
1381multiclass MIMG_Sampler_WQM <mimgopc op, AMDGPUSampleVariant sample>
1382    : MIMG_Sampler<op, sample, 1>;
1383
1384multiclass MIMG_Gather <mimgopc op, AMDGPUSampleVariant sample, bit wqm = 0,
1385                        string asm = "image_gather4"#sample.LowerCaseMod> {
1386  def "" : MIMG_Sampler_BaseOpcode<sample> {
1387    let HasD16 = 1;
1388    let Gather4 = 1;
1389  }
1390
1391  let BaseOpcode = !cast<MIMGBaseOpcode>(NAME), WQM = wqm,
1392      Gather4 = 1 in {
1393    let VDataDwords = 2 in
1394    defm _V2 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_64>; /* for packed D16 only */
1395    let VDataDwords = 4 in
1396    defm _V4 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_128, 1>;
1397    let VDataDwords = 5 in
1398    defm _V5 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_160>;
1399  }
1400}
1401
1402multiclass MIMG_Gather_WQM <mimgopc op, AMDGPUSampleVariant sample>
1403    : MIMG_Gather<op, sample, 1>;
1404
1405class MIMG_IntersectRay_Helper<bit Is64, bit IsA16> {
1406  int num_addrs = !if(Is64, !if(IsA16, 9, 12), !if(IsA16, 8, 11));
1407  RegisterClass RegClass = MIMGAddrSize<num_addrs, 0>.RegClass;
1408  int VAddrDwords = !srl(RegClass.Size, 5);
1409
1410  int GFX11PlusNSAAddrs = !if(IsA16, 4, 5);
1411  RegisterClass node_ptr_type = !if(Is64, VReg_64, VGPR_32);
1412  list<RegisterClass> GFX11PlusAddrTypes =
1413          !if(IsA16,
1414              [node_ptr_type, VGPR_32, VReg_96, VReg_96],
1415              [node_ptr_type, VGPR_32, VReg_96, VReg_96, VReg_96]);
1416}
1417
1418class MIMG_IntersectRay_gfx10<mimgopc op, string opcode, RegisterClass AddrRC>
1419    : MIMG_gfx10<op.GFX10M, (outs VReg_128:$vdata), "AMDGPU"> {
1420  let InOperandList = (ins AddrRC:$vaddr0, SReg_128:$srsrc, A16:$a16);
1421  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$a16";
1422
1423  let nsa = 0;
1424}
1425
1426class MIMG_IntersectRay_nsa_gfx10<mimgopc op, string opcode, int num_addrs>
1427    : MIMG_nsa_gfx10<op.GFX10M, (outs VReg_128:$vdata), num_addrs, "AMDGPU"> {
1428  let InOperandList = !con(nsah.AddrIns, (ins SReg_128:$srsrc, A16:$a16));
1429  let AsmString = opcode#" $vdata, "#nsah.AddrAsm#", $srsrc$a16";
1430}
1431
1432class MIMG_IntersectRay_gfx11<mimgopc op, string opcode, RegisterClass AddrRC>
1433    : MIMG_gfx11<op.GFX11, (outs VReg_128:$vdata), "AMDGPU"> {
1434  let InOperandList = (ins AddrRC:$vaddr0, SReg_128:$srsrc, A16:$a16);
1435  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$a16";
1436
1437  let nsa = 0;
1438}
1439
1440class MIMG_IntersectRay_nsa_gfx11<mimgopc op, string opcode, int num_addrs,
1441                                  list<RegisterClass> addr_types>
1442    : MIMG_nsa_gfx11<op.GFX11, (outs VReg_128:$vdata), num_addrs, "AMDGPU",
1443                     addr_types> {
1444  let InOperandList = !con(nsah.AddrIns, (ins SReg_128:$srsrc, A16:$a16));
1445  let AsmString = opcode#" $vdata, "#nsah.AddrAsm#", $srsrc$a16";
1446}
1447
1448class VIMAGE_IntersectRay_gfx12<mimgopc op, string opcode, int num_addrs,
1449                                list<RegisterClass> addr_types>
1450    : VIMAGE_gfx12<op.GFX12, (outs VReg_128:$vdata),
1451                   num_addrs, "GFX12", addr_types> {
1452  let InOperandList = !con(nsah.AddrIns, (ins SReg_128:$rsrc, A16:$a16));
1453  let AsmString = opcode#" $vdata, "#nsah.AddrAsm#", $rsrc$a16";
1454}
1455
1456multiclass MIMG_IntersectRay<mimgopc op, string opcode, bit Is64, bit IsA16> {
1457  defvar info = MIMG_IntersectRay_Helper<Is64, IsA16>;
1458  def "" : MIMGBaseOpcode {
1459    let BVH = 1;
1460    let A16 = IsA16;
1461  }
1462  let dmask = 0xf,
1463      d16 = 0,
1464      cpol = 0,
1465      tfe = 0,
1466      r128 = 1,
1467      dim = {0, 0, 0},
1468      a16 = IsA16,
1469      d16 = 0,
1470      BaseOpcode = !cast<MIMGBaseOpcode>(NAME),
1471      VDataDwords = 4 in {
1472    let unorm = 1,
1473        lwe = 0,
1474        ssamp = 0 in {
1475      if op.HAS_GFX10M then
1476      def _sa_gfx10 : MIMG_IntersectRay_gfx10<op, opcode, info.RegClass> {
1477        let VAddrDwords = info.VAddrDwords;
1478      }
1479      if op.HAS_GFX11 then
1480      def _sa_gfx11 : MIMG_IntersectRay_gfx11<op, opcode, info.RegClass> {
1481        let VAddrDwords = info.VAddrDwords;
1482      }
1483      if op.HAS_GFX10M then
1484      def _nsa_gfx10 : MIMG_IntersectRay_nsa_gfx10<op, opcode, info.num_addrs> {
1485        let VAddrDwords = info.num_addrs;
1486      }
1487      if op.HAS_GFX11 then
1488      def _nsa_gfx11 : MIMG_IntersectRay_nsa_gfx11<op, opcode,
1489                                                  info.GFX11PlusNSAAddrs,
1490                                                  info.GFX11PlusAddrTypes> {
1491        let VAddrDwords = info.num_addrs;
1492      }
1493    }
1494    def _gfx12 : VIMAGE_IntersectRay_gfx12<op, opcode, info.GFX11PlusNSAAddrs,
1495                                           info.GFX11PlusAddrTypes> {
1496      let VAddrDwords = info.num_addrs;
1497    }
1498  }
1499}
1500
1501multiclass MIMG_MSAA_Load <mimgopc op, string asm> {
1502  def "" : MIMGBaseOpcode {
1503    let HasD16 = 1;
1504    let Gather4 = 1; /* for appropriate dmask handling */
1505    let MSAA = 1;
1506  }
1507
1508  let BaseOpcode = !cast<MIMGBaseOpcode>(NAME),
1509    Gather4 = 1, hasPostISelHook = 0, mayLoad = 1 in {
1510    let VDataDwords = 2 in
1511    defm _V2 : MIMG_NoSampler_Src_Helper<op, asm, VReg_64, 0, 0, 1>; /* packed D16 */
1512    let VDataDwords = 3 in
1513    defm _V3 : MIMG_NoSampler_Src_Helper<op, asm, VReg_96, 0, 0, 1>; /* packed D16 + tfe */
1514    let VDataDwords = 4 in
1515    defm _V4 : MIMG_NoSampler_Src_Helper<op, asm, VReg_128, 1, 0, 1>;
1516    let VDataDwords = 5 in
1517    defm _V5 : MIMG_NoSampler_Src_Helper<op, asm, VReg_160, 0, 0, 1>;
1518  }
1519}
1520
1521//===----------------------------------------------------------------------===//
1522// MIMG Instructions
1523//===----------------------------------------------------------------------===//
1524let OtherPredicates = [HasImageInsts] in {
1525
1526defm IMAGE_LOAD                 : MIMG_NoSampler <mimgopc<0x00, 0x00, 0x00>, "image_load", 1>;
1527defm IMAGE_LOAD_MIP             : MIMG_NoSampler <mimgopc<0x01, 0x01, 0x01>, "image_load_mip", 1, 1>;
1528defm IMAGE_LOAD_PCK             : MIMG_NoSampler <mimgopc<0x02, 0x02, 0x02>, "image_load_pck", 0>;
1529defm IMAGE_LOAD_PCK_SGN         : MIMG_NoSampler <mimgopc<0x03, 0x03, 0x03>, "image_load_pck_sgn", 0>;
1530defm IMAGE_LOAD_MIP_PCK         : MIMG_NoSampler <mimgopc<0x04, 0x04, 0x04>, "image_load_mip_pck", 0, 1>;
1531defm IMAGE_LOAD_MIP_PCK_SGN     : MIMG_NoSampler <mimgopc<0x05, 0x05, 0x05>, "image_load_mip_pck_sgn", 0, 1>;
1532defm IMAGE_STORE                : MIMG_Store <mimgopc<0x06, 0x06, 0x08>, "image_store", 1>;
1533defm IMAGE_STORE_MIP            : MIMG_Store <mimgopc<0x07, 0x07, 0x09>, "image_store_mip", 1, 1>;
1534defm IMAGE_STORE_PCK            : MIMG_Store <mimgopc<0x08, 0x08, 0x0a>, "image_store_pck", 0>;
1535defm IMAGE_STORE_MIP_PCK        : MIMG_Store <mimgopc<0x09, 0x09, 0x0b>, "image_store_mip_pck", 0, 1>;
1536
1537defm IMAGE_GET_RESINFO          : MIMG_NoSampler <mimgopc<0x17, 0x17, 0x0e, 0x0e, 0x0e>, "image_get_resinfo", 0, 1, 1>;
1538
1539defm IMAGE_ATOMIC_SWAP          : MIMG_Atomic <mimgopc<0x0a, 0x0a, 0x0f, 0x10, 0x0f>, "image_atomic_swap">;
1540defm IMAGE_ATOMIC_CMPSWAP       : MIMG_Atomic <mimgopc<0x0b, 0x0b, 0x10, 0x11, 0x10>, "image_atomic_cmpswap", 1>;
1541defm IMAGE_ATOMIC_ADD           : MIMG_Atomic_Renamed <mimgopc<0x0c, 0x0c, 0x11, 0x12, 0x11>, "image_atomic_add", "image_atomic_add_uint">;
1542defm IMAGE_ATOMIC_SUB           : MIMG_Atomic_Renamed <mimgopc<0x0d, 0x0d, 0x12, 0x13, 0x12>, "image_atomic_sub", "image_atomic_sub_uint">;
1543defm IMAGE_ATOMIC_RSUB          : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, MIMG.NOP, MIMG.NOP, 0x13>, "image_atomic_rsub">;
1544defm IMAGE_ATOMIC_SMIN          : MIMG_Atomic_Renamed <mimgopc<0x0e, 0x0e, 0x14>, "image_atomic_smin", "image_atomic_min_int">;
1545defm IMAGE_ATOMIC_UMIN          : MIMG_Atomic_Renamed <mimgopc<0x0f, 0x0f, 0x15>, "image_atomic_umin", "image_atomic_min_uint">;
1546defm IMAGE_ATOMIC_SMAX          : MIMG_Atomic_Renamed <mimgopc<0x10, 0x10, 0x16>, "image_atomic_smax", "image_atomic_max_int">;
1547defm IMAGE_ATOMIC_UMAX          : MIMG_Atomic_Renamed <mimgopc<0x11, 0x11, 0x17>, "image_atomic_umax", "image_atomic_max_uint">;
1548defm IMAGE_ATOMIC_AND           : MIMG_Atomic <mimgopc<0x12, 0x12, 0x18>, "image_atomic_and">;
1549defm IMAGE_ATOMIC_OR            : MIMG_Atomic <mimgopc<0x13, 0x13, 0x19>, "image_atomic_or">;
1550defm IMAGE_ATOMIC_XOR           : MIMG_Atomic <mimgopc<0x14, 0x14, 0x1a>, "image_atomic_xor">;
1551defm IMAGE_ATOMIC_INC           : MIMG_Atomic_Renamed <mimgopc<0x15, 0x15, 0x1b>, "image_atomic_inc", "image_atomic_inc_uint">;
1552defm IMAGE_ATOMIC_DEC           : MIMG_Atomic_Renamed <mimgopc<0x16, 0x16, 0x1c>, "image_atomic_dec", "image_atomic_dec_uint">;
1553defm IMAGE_ATOMIC_FCMPSWAP      : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, 0x1d, MIMG.NOP>, "image_atomic_fcmpswap", 1, 1>;
1554defm IMAGE_ATOMIC_FMIN          : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, 0x1e, MIMG.NOP>, "image_atomic_fmin", 0, 1>;
1555defm IMAGE_ATOMIC_FMAX          : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, 0x1f, MIMG.NOP>, "image_atomic_fmax", 0, 1>;
1556defm IMAGE_ATOMIC_PK_ADD_F16    : MIMG_Atomic <mimgopc<0x86, MIMG.NOP, MIMG.NOP, MIMG.NOP, MIMG.NOP>, "image_atomic_pk_add_f16", 0, 1>;
1557defm IMAGE_ATOMIC_PK_ADD_BF16   : MIMG_Atomic <mimgopc<0x87, MIMG.NOP, MIMG.NOP, MIMG.NOP, MIMG.NOP>, "image_atomic_pk_add_bf16", 0, 1>;
1558defm IMAGE_ATOMIC_ADD_FLT       : MIMG_Atomic <mimgopc<0x83, MIMG.NOP, MIMG.NOP, MIMG.NOP>, "image_atomic_add_flt", 0, 1>;
1559defm IMAGE_ATOMIC_MIN_FLT       : MIMG_Atomic <mimgopc<0x84, MIMG.NOP, MIMG.NOP, MIMG.NOP>, "image_atomic_min_num_flt", 0, 1, "image_atomic_min_flt">;
1560defm IMAGE_ATOMIC_MAX_FLT       : MIMG_Atomic <mimgopc<0x85, MIMG.NOP, MIMG.NOP, MIMG.NOP>, "image_atomic_max_num_flt", 0, 1, "image_atomic_max_flt">;
1561
1562defm IMAGE_SAMPLE               : MIMG_Sampler_WQM <mimgopc<0x1b, 0x1b, 0x20>, AMDGPUSample>;
1563let OtherPredicates = [HasExtendedImageInsts] in {
1564defm IMAGE_SAMPLE_CL            : MIMG_Sampler_WQM <mimgopc<0x40, 0x40, 0x21>, AMDGPUSample_cl>;
1565defm IMAGE_SAMPLE_D             : MIMG_Sampler <mimgopc<0x1c, 0x1c, 0x22>, AMDGPUSample_d>;
1566defm IMAGE_SAMPLE_D_CL          : MIMG_Sampler <mimgopc<0x41, 0x41, 0x23>, AMDGPUSample_d_cl>;
1567defm IMAGE_SAMPLE_L             : MIMG_Sampler <mimgopc<0x1d, 0x1d, 0x24>, AMDGPUSample_l>;
1568defm IMAGE_SAMPLE_B             : MIMG_Sampler_WQM <mimgopc<0x1e, 0x1e, 0x25>, AMDGPUSample_b>;
1569defm IMAGE_SAMPLE_B_CL          : MIMG_Sampler_WQM <mimgopc<0x42, 0x42, 0x26>, AMDGPUSample_b_cl>;
1570defm IMAGE_SAMPLE_LZ            : MIMG_Sampler <mimgopc<0x1f, 0x1f, 0x27>, AMDGPUSample_lz>;
1571defm IMAGE_SAMPLE_C             : MIMG_Sampler_WQM <mimgopc<0x20, 0x20, 0x28>, AMDGPUSample_c>;
1572defm IMAGE_SAMPLE_C_CL          : MIMG_Sampler_WQM <mimgopc<0x43, 0x43, 0x29>, AMDGPUSample_c_cl>;
1573defm IMAGE_SAMPLE_C_D           : MIMG_Sampler <mimgopc<0x21, 0x21, 0x2a>, AMDGPUSample_c_d>;
1574defm IMAGE_SAMPLE_C_D_CL        : MIMG_Sampler <mimgopc<0x44, 0x44, 0x2b>, AMDGPUSample_c_d_cl>;
1575defm IMAGE_SAMPLE_C_L           : MIMG_Sampler <mimgopc<0x22, 0x22, 0x2c>, AMDGPUSample_c_l>;
1576defm IMAGE_SAMPLE_C_B           : MIMG_Sampler_WQM <mimgopc<0x23, 0x23, 0x2d>, AMDGPUSample_c_b>;
1577defm IMAGE_SAMPLE_C_B_CL        : MIMG_Sampler_WQM <mimgopc<0x45, 0x45, 0x2e>, AMDGPUSample_c_b_cl>;
1578defm IMAGE_SAMPLE_C_LZ          : MIMG_Sampler <mimgopc<0x24, 0x24, 0x2f>, AMDGPUSample_c_lz>;
1579defm IMAGE_SAMPLE_O             : MIMG_Sampler_WQM <mimgopc<0x25, 0x25, 0x30>, AMDGPUSample_o>;
1580defm IMAGE_SAMPLE_CL_O          : MIMG_Sampler_WQM <mimgopc<0x46, 0x46, 0x31>, AMDGPUSample_cl_o>;
1581defm IMAGE_SAMPLE_D_O           : MIMG_Sampler <mimgopc<0x26, 0x26, 0x32>, AMDGPUSample_d_o>;
1582defm IMAGE_SAMPLE_D_CL_O        : MIMG_Sampler <mimgopc<0x47, 0x47, 0x33>, AMDGPUSample_d_cl_o>;
1583defm IMAGE_SAMPLE_L_O           : MIMG_Sampler <mimgopc<0x27, 0x27, 0x34>, AMDGPUSample_l_o>;
1584defm IMAGE_SAMPLE_B_O           : MIMG_Sampler_WQM <mimgopc<0x28, 0x28, 0x35>, AMDGPUSample_b_o>;
1585defm IMAGE_SAMPLE_B_CL_O        : MIMG_Sampler_WQM <mimgopc<0x48, 0x48, 0x36>, AMDGPUSample_b_cl_o>;
1586defm IMAGE_SAMPLE_LZ_O          : MIMG_Sampler <mimgopc<0x29, 0x29, 0x37>, AMDGPUSample_lz_o>;
1587defm IMAGE_SAMPLE_C_O           : MIMG_Sampler_WQM <mimgopc<0x2a, 0x2a, 0x38>, AMDGPUSample_c_o>;
1588defm IMAGE_SAMPLE_C_CL_O        : MIMG_Sampler_WQM <mimgopc<0x49, 0x49, 0x39>, AMDGPUSample_c_cl_o>;
1589defm IMAGE_SAMPLE_C_D_O         : MIMG_Sampler <mimgopc<0x2b, 0x2b, 0x3a>, AMDGPUSample_c_d_o>;
1590defm IMAGE_SAMPLE_C_D_CL_O      : MIMG_Sampler <mimgopc<0x4a, 0x4a, 0x3b>, AMDGPUSample_c_d_cl_o>;
1591defm IMAGE_SAMPLE_C_L_O         : MIMG_Sampler <mimgopc<0x2c, 0x2c, 0x3c>, AMDGPUSample_c_l_o>;
1592defm IMAGE_SAMPLE_C_B_CL_O      : MIMG_Sampler_WQM <mimgopc<0x4b, 0x4b, 0x3e>, AMDGPUSample_c_b_cl_o>;
1593defm IMAGE_SAMPLE_C_B_O         : MIMG_Sampler_WQM <mimgopc<0x2d, 0x2d, 0x3d>, AMDGPUSample_c_b_o>;
1594defm IMAGE_SAMPLE_C_LZ_O        : MIMG_Sampler <mimgopc<0x2e, 0x2e, 0x3f>, AMDGPUSample_c_lz_o>;
1595defm IMAGE_GATHER4              : MIMG_Gather_WQM <mimgopc<0x2f, 0x2f, 0x40>, AMDGPUSample>;
1596defm IMAGE_GATHER4_CL           : MIMG_Gather_WQM <mimgopc<0x60, 0x60, 0x41>, AMDGPUSample_cl>;
1597defm IMAGE_GATHER4_L            : MIMG_Gather <mimgopc<0x30, 0x30, 0x44>, AMDGPUSample_l>;
1598defm IMAGE_GATHER4_B            : MIMG_Gather_WQM <mimgopc<0x31, 0x31, 0x45>, AMDGPUSample_b>;
1599defm IMAGE_GATHER4_B_CL         : MIMG_Gather_WQM <mimgopc<0x61, 0x61, 0x46>, AMDGPUSample_b_cl>;
1600defm IMAGE_GATHER4_LZ           : MIMG_Gather <mimgopc<0x32, 0x32, 0x47>, AMDGPUSample_lz>;
1601defm IMAGE_GATHER4_C            : MIMG_Gather_WQM <mimgopc<0x33, 0x33, 0x48>, AMDGPUSample_c>;
1602defm IMAGE_GATHER4_C_CL         : MIMG_Gather_WQM <mimgopc<0x62, 0x62, 0x49>, AMDGPUSample_c_cl>;
1603defm IMAGE_GATHER4_C_L          : MIMG_Gather <mimgopc<0x63, 0x63, 0x4c>, AMDGPUSample_c_l>;
1604defm IMAGE_GATHER4_C_B          : MIMG_Gather_WQM <mimgopc<0x64, 0x64, 0x4d>, AMDGPUSample_c_b>;
1605defm IMAGE_GATHER4_C_B_CL       : MIMG_Gather_WQM <mimgopc<0x65, 0x65, 0x4e>, AMDGPUSample_c_b_cl>;
1606defm IMAGE_GATHER4_C_LZ         : MIMG_Gather <mimgopc<0x34, 0x34, 0x4f>, AMDGPUSample_c_lz>;
1607defm IMAGE_GATHER4_O            : MIMG_Gather_WQM <mimgopc<0x35, 0x35, 0x50>, AMDGPUSample_o>;
1608defm IMAGE_GATHER4_CL_O         : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x51>, AMDGPUSample_cl_o>;
1609defm IMAGE_GATHER4_L_O          : MIMG_Gather <mimgopc<MIMG.NOP, MIMG.NOP, 0x54>, AMDGPUSample_l_o>;
1610defm IMAGE_GATHER4_B_O          : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x55>, AMDGPUSample_b_o>;
1611defm IMAGE_GATHER4_B_CL_O       : MIMG_Gather <mimgopc<MIMG.NOP, MIMG.NOP, 0x56>, AMDGPUSample_b_cl_o>;
1612defm IMAGE_GATHER4_LZ_O         : MIMG_Gather <mimgopc<0x36, 0x36, 0x57>, AMDGPUSample_lz_o>;
1613defm IMAGE_GATHER4_C_O          : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x58>, AMDGPUSample_c_o>;
1614defm IMAGE_GATHER4_C_CL_O       : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x59>, AMDGPUSample_c_cl_o>;
1615defm IMAGE_GATHER4_C_L_O        : MIMG_Gather <mimgopc<MIMG.NOP, MIMG.NOP, 0x5c>, AMDGPUSample_c_l_o>;
1616defm IMAGE_GATHER4_C_B_O        : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x5d>, AMDGPUSample_c_b_o>;
1617defm IMAGE_GATHER4_C_B_CL_O     : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x5e>, AMDGPUSample_c_b_cl_o>;
1618defm IMAGE_GATHER4_C_LZ_O       : MIMG_Gather <mimgopc<0x37, 0x37, 0x5f>, AMDGPUSample_c_lz_o>;
1619
1620let SubtargetPredicate = isGFX9Plus in
1621defm IMAGE_GATHER4H             : MIMG_Gather <mimgopc<0x90, 0x90, 0x61, 0x42>, AMDGPUSample, 1, "image_gather4h">;
1622
1623defm IMAGE_GET_LOD              : MIMG_Sampler <mimgopc<0x38, 0x38, 0x60>, AMDGPUSample, 1, 0, 1, "image_get_lod">;
1624
1625defm IMAGE_SAMPLE_CD            : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x68>, AMDGPUSample_cd>;
1626defm IMAGE_SAMPLE_CD_CL         : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x69>, AMDGPUSample_cd_cl>;
1627defm IMAGE_SAMPLE_C_CD          : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6a>, AMDGPUSample_c_cd>;
1628defm IMAGE_SAMPLE_C_CD_CL       : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6b>, AMDGPUSample_c_cd_cl>;
1629defm IMAGE_SAMPLE_CD_O          : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6c>, AMDGPUSample_cd_o>;
1630defm IMAGE_SAMPLE_CD_CL_O       : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6d>, AMDGPUSample_cd_cl_o>;
1631defm IMAGE_SAMPLE_C_CD_O        : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6e>, AMDGPUSample_c_cd_o>;
1632defm IMAGE_SAMPLE_C_CD_CL_O     : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6f>, AMDGPUSample_c_cd_cl_o>;
1633} // End OtherPredicates = [HasExtendedImageInsts]
1634
1635let OtherPredicates = [HasExtendedImageInsts,HasG16] in {
1636defm IMAGE_SAMPLE_D_G16         : MIMG_Sampler <mimgopc<0x39, 0x39, 0xa2>, AMDGPUSample_d, 0, 1>;
1637defm IMAGE_SAMPLE_D_CL_G16      : MIMG_Sampler <mimgopc<0x5f, 0x5f, 0xa3>, AMDGPUSample_d_cl, 0, 1>;
1638defm IMAGE_SAMPLE_C_D_G16       : MIMG_Sampler <mimgopc<0x3a, 0x3a, 0xaa>, AMDGPUSample_c_d, 0, 1>;
1639defm IMAGE_SAMPLE_C_D_CL_G16    : MIMG_Sampler <mimgopc<0x54, 0x54, 0xab>, AMDGPUSample_c_d_cl, 0, 1>;
1640defm IMAGE_SAMPLE_D_O_G16       : MIMG_Sampler <mimgopc<0x3b, 0x3b, 0xb2>, AMDGPUSample_d_o, 0, 1>;
1641defm IMAGE_SAMPLE_D_CL_O_G16    : MIMG_Sampler <mimgopc<0x55, 0x55, 0xb3>, AMDGPUSample_d_cl_o, 0, 1>;
1642defm IMAGE_SAMPLE_C_D_O_G16     : MIMG_Sampler <mimgopc<0x3c, 0x3c, 0xba>, AMDGPUSample_c_d_o, 0, 1>;
1643defm IMAGE_SAMPLE_C_D_CL_O_G16  : MIMG_Sampler <mimgopc<0x56, 0x56, 0xbb>, AMDGPUSample_c_d_cl_o, 0, 1>;
1644defm IMAGE_SAMPLE_CD_G16        : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xe8>, AMDGPUSample_cd, 0, 1>;
1645defm IMAGE_SAMPLE_CD_CL_G16     : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xe9>, AMDGPUSample_cd_cl, 0, 1>;
1646defm IMAGE_SAMPLE_C_CD_G16      : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xea>, AMDGPUSample_c_cd, 0, 1>;
1647defm IMAGE_SAMPLE_C_CD_CL_G16   : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xeb>, AMDGPUSample_c_cd_cl, 0, 1>;
1648defm IMAGE_SAMPLE_CD_O_G16      : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xec>, AMDGPUSample_cd_o, 0, 1>;
1649defm IMAGE_SAMPLE_CD_CL_O_G16   : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xed>, AMDGPUSample_cd_cl_o, 0, 1>;
1650defm IMAGE_SAMPLE_C_CD_O_G16    : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xee>, AMDGPUSample_c_cd_o, 0, 1>;
1651defm IMAGE_SAMPLE_C_CD_CL_O_G16 : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xef>, AMDGPUSample_c_cd_cl_o, 0, 1>;
1652} // End OtherPredicates = [HasExtendedImageInsts,HasG16]
1653
1654//def IMAGE_RSRC256 : MIMG_NoPattern_RSRC256 <"image_rsrc256", mimgopc<0x7e>>;
1655//def IMAGE_SAMPLER : MIMG_NoPattern_ <"image_sampler", mimgopc<0x7f>>;
1656
1657let SubtargetPredicate = isGFX10Only, OtherPredicates = [HasGFX10_AEncoding] in
1658defm IMAGE_MSAA_LOAD_X : MIMG_NoSampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x80>, "image_msaa_load", 1, 0, 0, 1>;
1659
1660let OtherPredicates = [HasGFX10_AEncoding] in
1661defm IMAGE_MSAA_LOAD : MIMG_MSAA_Load <mimgopc<0x18, 0x18, MIMG.NOP>, "image_msaa_load">;
1662
1663let OtherPredicates = [HasGFX10_AEncoding] in {
1664defm IMAGE_BVH_INTERSECT_RAY       : MIMG_IntersectRay<mimgopc<0x19, 0x19, 0xe6>, "image_bvh_intersect_ray", 0, 0>;
1665defm IMAGE_BVH_INTERSECT_RAY_a16   : MIMG_IntersectRay<mimgopc<0x19, 0x19, 0xe6>, "image_bvh_intersect_ray", 0, 1>;
1666defm IMAGE_BVH64_INTERSECT_RAY     : MIMG_IntersectRay<mimgopc<0x1a, 0x1a, 0xe7>, "image_bvh64_intersect_ray", 1, 0>;
1667defm IMAGE_BVH64_INTERSECT_RAY_a16 : MIMG_IntersectRay<mimgopc<0x1a, 0x1a, 0xe7>, "image_bvh64_intersect_ray", 1, 1>;
1668} // End OtherPredicates = [HasGFX10_AEncoding]
1669
1670} // End let OtherPredicates = [HasImageInsts]
1671
1672/********** ========================================= **********/
1673/********** Table of dimension-aware image intrinsics **********/
1674/********** ========================================= **********/
1675
1676class ImageDimIntrinsicInfo<AMDGPUImageDimIntrinsic I> {
1677  Intrinsic Intr = I;
1678  MIMGBaseOpcode BaseOpcode = !cast<MIMGBaseOpcode>(!strconcat("IMAGE_", I.P.OpMod));
1679  AMDGPUDimProps Dim = I.P.Dim;
1680  AMDGPUImageDimIntrinsicEval DimEval = AMDGPUImageDimIntrinsicEval<I.P>;
1681
1682  bits<8> NumOffsetArgs = DimEval.NumOffsetArgs;
1683  bits<8> NumBiasArgs = DimEval.NumBiasArgs;
1684  bits<8> NumZCompareArgs = DimEval.NumZCompareArgs;
1685  bits<8> NumGradients = DimEval.NumGradientArgs;
1686  bits<8> NumDmask = DimEval.NumDmaskArgs;
1687  bits<8> NumData = DimEval.NumDataArgs;
1688  bits<8> NumVAddrs = DimEval.NumVAddrArgs;
1689  bits<8> NumArgs = !add(DimEval.CachePolicyArgIndex, 1);
1690
1691  bits<8> DMaskIndex = DimEval.DmaskArgIndex;
1692  bits<8> VAddrStart = DimEval.VAddrArgIndex;
1693  bits<8> OffsetIndex = DimEval.OffsetArgIndex;
1694  bits<8> BiasIndex = DimEval.BiasArgIndex;
1695  bits<8> ZCompareIndex = DimEval.ZCompareArgIndex;
1696  bits<8> GradientStart = DimEval.GradientArgIndex;
1697  bits<8> CoordStart = DimEval.CoordArgIndex;
1698  bits<8> LodIndex = DimEval.LodArgIndex;
1699  bits<8> MipIndex = DimEval.MipArgIndex;
1700  bits<8> VAddrEnd = !add(DimEval.VAddrArgIndex, DimEval.NumVAddrArgs);
1701  bits<8> RsrcIndex = DimEval.RsrcArgIndex;
1702  bits<8> SampIndex = DimEval.SampArgIndex;
1703  bits<8> UnormIndex = DimEval.UnormArgIndex;
1704  bits<8> TexFailCtrlIndex = DimEval.TexFailCtrlArgIndex;
1705  bits<8> CachePolicyIndex = DimEval.CachePolicyArgIndex;
1706
1707  bits<8> BiasTyArg = !add(I.P.NumRetAndDataAnyTypes,
1708    !if(!eq(NumOffsetArgs, 0), 0, I.P.ExtraAddrArgs[0].Type.isAny));
1709  bits<8> GradientTyArg = !add(I.P.NumRetAndDataAnyTypes,
1710    !foldl(0, I.P.ExtraAddrArgs, cnt, arg, !add(cnt, arg.Type.isAny)));
1711  bits<8> CoordTyArg = !add(GradientTyArg, !if(I.P.Gradients, 1, 0));
1712}
1713
1714def ImageDimIntrinsicTable : GenericTable {
1715  let FilterClass = "ImageDimIntrinsicInfo";
1716  let Fields = ["Intr", "BaseOpcode", "Dim", "NumOffsetArgs", "NumBiasArgs", "NumZCompareArgs", "NumGradients", "NumDmask", "NumData", "NumVAddrs", "NumArgs",
1717    "DMaskIndex", "VAddrStart", "OffsetIndex", "BiasIndex", "ZCompareIndex", "GradientStart", "CoordStart", "LodIndex", "MipIndex", "VAddrEnd",
1718    "RsrcIndex", "SampIndex", "UnormIndex", "TexFailCtrlIndex", "CachePolicyIndex",
1719    "BiasTyArg", "GradientTyArg", "CoordTyArg"];
1720  string TypeOf_BaseOpcode = "MIMGBaseOpcode";
1721  string TypeOf_Dim = "MIMGDim";
1722
1723  let PrimaryKey = ["Intr"];
1724  let PrimaryKeyName = "getImageDimIntrinsicInfo";
1725  let PrimaryKeyEarlyOut = 1;
1726}
1727
1728def getImageDimIntrinsicByBaseOpcode : SearchIndex {
1729  let Table = ImageDimIntrinsicTable;
1730  let Key = ["BaseOpcode", "Dim"];
1731}
1732
1733foreach intr = !listconcat(AMDGPUImageDimIntrinsics,
1734                           AMDGPUImageDimAtomicIntrinsics) in {
1735  def : ImageDimIntrinsicInfo<intr>;
1736}
1737
1738// L to LZ Optimization Mapping
1739def : MIMGLZMapping<IMAGE_SAMPLE_L, IMAGE_SAMPLE_LZ>;
1740def : MIMGLZMapping<IMAGE_SAMPLE_C_L, IMAGE_SAMPLE_C_LZ>;
1741def : MIMGLZMapping<IMAGE_SAMPLE_L_O, IMAGE_SAMPLE_LZ_O>;
1742def : MIMGLZMapping<IMAGE_SAMPLE_C_L_O, IMAGE_SAMPLE_C_LZ_O>;
1743def : MIMGLZMapping<IMAGE_GATHER4_L, IMAGE_GATHER4_LZ>;
1744def : MIMGLZMapping<IMAGE_GATHER4_C_L, IMAGE_GATHER4_C_LZ>;
1745def : MIMGLZMapping<IMAGE_GATHER4_L_O, IMAGE_GATHER4_LZ_O>;
1746def : MIMGLZMapping<IMAGE_GATHER4_C_L_O, IMAGE_GATHER4_C_LZ_O>;
1747
1748// MIP to NONMIP Optimization Mapping
1749def : MIMGMIPMapping<IMAGE_LOAD_MIP, IMAGE_LOAD>;
1750def : MIMGMIPMapping<IMAGE_STORE_MIP, IMAGE_STORE>;
1751
1752// Bias to NoBias Optimization Mapping
1753def : MIMGBiasMapping<IMAGE_SAMPLE_B, IMAGE_SAMPLE>;
1754def : MIMGBiasMapping<IMAGE_SAMPLE_B_CL, IMAGE_SAMPLE_CL>;
1755def : MIMGBiasMapping<IMAGE_SAMPLE_C_B, IMAGE_SAMPLE_C>;
1756def : MIMGBiasMapping<IMAGE_SAMPLE_C_B_CL, IMAGE_SAMPLE_C_CL>;
1757def : MIMGBiasMapping<IMAGE_SAMPLE_B_O, IMAGE_SAMPLE_O>;
1758def : MIMGBiasMapping<IMAGE_SAMPLE_B_CL_O, IMAGE_SAMPLE_CL_O>;
1759def : MIMGBiasMapping<IMAGE_SAMPLE_C_B_O, IMAGE_SAMPLE_C_O>;
1760def : MIMGBiasMapping<IMAGE_SAMPLE_C_B_CL_O, IMAGE_SAMPLE_C_CL_O>;
1761def : MIMGBiasMapping<IMAGE_GATHER4_B, IMAGE_GATHER4>;
1762def : MIMGBiasMapping<IMAGE_GATHER4_B_CL, IMAGE_GATHER4_CL>;
1763def : MIMGBiasMapping<IMAGE_GATHER4_C_B, IMAGE_GATHER4_C>;
1764def : MIMGBiasMapping<IMAGE_GATHER4_C_B_CL, IMAGE_GATHER4_C_CL>;
1765def : MIMGBiasMapping<IMAGE_GATHER4_B_O, IMAGE_GATHER4_O>;
1766def : MIMGBiasMapping<IMAGE_GATHER4_B_CL_O, IMAGE_GATHER4_CL_O>;
1767def : MIMGBiasMapping<IMAGE_GATHER4_C_B_O, IMAGE_GATHER4_C_O>;
1768def : MIMGBiasMapping<IMAGE_GATHER4_C_B_CL_O, IMAGE_GATHER4_C_CL_O>;
1769
1770// Offset to NoOffset Optimization Mapping
1771def : MIMGOffsetMapping<IMAGE_SAMPLE_O, IMAGE_SAMPLE>;
1772def : MIMGOffsetMapping<IMAGE_SAMPLE_CL_O, IMAGE_SAMPLE_CL>;
1773def : MIMGOffsetMapping<IMAGE_SAMPLE_D_O, IMAGE_SAMPLE_D>;
1774def : MIMGOffsetMapping<IMAGE_SAMPLE_D_CL_O, IMAGE_SAMPLE_D_CL>;
1775def : MIMGOffsetMapping<IMAGE_SAMPLE_D_O_G16, IMAGE_SAMPLE_D_G16>;
1776def : MIMGOffsetMapping<IMAGE_SAMPLE_D_CL_O_G16, IMAGE_SAMPLE_D_CL_G16>;
1777def : MIMGOffsetMapping<IMAGE_SAMPLE_L_O, IMAGE_SAMPLE_L>;
1778def : MIMGOffsetMapping<IMAGE_SAMPLE_B_O, IMAGE_SAMPLE_B>;
1779def : MIMGOffsetMapping<IMAGE_SAMPLE_B_CL_O, IMAGE_SAMPLE_B_CL>;
1780def : MIMGOffsetMapping<IMAGE_SAMPLE_LZ_O, IMAGE_SAMPLE_LZ>;
1781def : MIMGOffsetMapping<IMAGE_SAMPLE_C_O, IMAGE_SAMPLE_C>;
1782def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CL_O, IMAGE_SAMPLE_C_CL>;
1783def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_O, IMAGE_SAMPLE_C_D>;
1784def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_CL_O, IMAGE_SAMPLE_C_D_CL>;
1785def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_O_G16, IMAGE_SAMPLE_C_D_G16>;
1786def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_CL_O_G16, IMAGE_SAMPLE_C_D_CL_G16>;
1787def : MIMGOffsetMapping<IMAGE_SAMPLE_C_L_O, IMAGE_SAMPLE_C_L>;
1788def : MIMGOffsetMapping<IMAGE_SAMPLE_C_B_CL_O, IMAGE_SAMPLE_C_B_CL>;
1789def : MIMGOffsetMapping<IMAGE_SAMPLE_C_B_O, IMAGE_SAMPLE_C_B>;
1790def : MIMGOffsetMapping<IMAGE_SAMPLE_C_LZ_O, IMAGE_SAMPLE_C_LZ>;
1791def : MIMGOffsetMapping<IMAGE_GATHER4_O, IMAGE_GATHER4>;
1792def : MIMGOffsetMapping<IMAGE_GATHER4_CL_O, IMAGE_GATHER4_CL>;
1793def : MIMGOffsetMapping<IMAGE_GATHER4_L_O, IMAGE_GATHER4_L>;
1794def : MIMGOffsetMapping<IMAGE_GATHER4_B_O, IMAGE_GATHER4_B>;
1795def : MIMGOffsetMapping<IMAGE_GATHER4_B_CL_O, IMAGE_GATHER4_B_CL>;
1796def : MIMGOffsetMapping<IMAGE_GATHER4_LZ_O, IMAGE_GATHER4_LZ>;
1797def : MIMGOffsetMapping<IMAGE_GATHER4_C_O, IMAGE_GATHER4_C>;
1798def : MIMGOffsetMapping<IMAGE_GATHER4_C_CL_O, IMAGE_GATHER4_C_CL>;
1799def : MIMGOffsetMapping<IMAGE_GATHER4_C_L_O, IMAGE_GATHER4_C_L>;
1800def : MIMGOffsetMapping<IMAGE_GATHER4_C_B_O, IMAGE_GATHER4_C_B>;
1801def : MIMGOffsetMapping<IMAGE_GATHER4_C_B_CL_O, IMAGE_GATHER4_C_B_CL>;
1802def : MIMGOffsetMapping<IMAGE_GATHER4_C_LZ_O, IMAGE_GATHER4_C_LZ>;
1803def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_O, IMAGE_SAMPLE_CD>;
1804def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_CL_O, IMAGE_SAMPLE_CD_CL>;
1805def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_O, IMAGE_SAMPLE_C_CD>;
1806def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_CL_O, IMAGE_SAMPLE_C_CD_CL>;
1807def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_O_G16, IMAGE_SAMPLE_CD_G16>;
1808def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_CL_O_G16, IMAGE_SAMPLE_CD_CL_G16>;
1809def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_O_G16, IMAGE_SAMPLE_C_CD_G16>;
1810def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_CL_O_G16, IMAGE_SAMPLE_C_CD_CL_G16>;
1811
1812// G to G16 Optimization Mapping
1813def : MIMGG16Mapping<IMAGE_SAMPLE_D, IMAGE_SAMPLE_D_G16>;
1814def : MIMGG16Mapping<IMAGE_SAMPLE_D_CL, IMAGE_SAMPLE_D_CL_G16>;
1815def : MIMGG16Mapping<IMAGE_SAMPLE_C_D, IMAGE_SAMPLE_C_D_G16>;
1816def : MIMGG16Mapping<IMAGE_SAMPLE_C_D_CL, IMAGE_SAMPLE_C_D_CL_G16>;
1817def : MIMGG16Mapping<IMAGE_SAMPLE_D_O, IMAGE_SAMPLE_D_O_G16>;
1818def : MIMGG16Mapping<IMAGE_SAMPLE_D_CL_O, IMAGE_SAMPLE_D_CL_O_G16>;
1819def : MIMGG16Mapping<IMAGE_SAMPLE_C_D_O, IMAGE_SAMPLE_C_D_O_G16>;
1820def : MIMGG16Mapping<IMAGE_SAMPLE_C_D_CL_O, IMAGE_SAMPLE_C_D_CL_O_G16>;
1821def : MIMGG16Mapping<IMAGE_SAMPLE_CD, IMAGE_SAMPLE_CD_G16>;
1822def : MIMGG16Mapping<IMAGE_SAMPLE_CD_CL, IMAGE_SAMPLE_CD_CL_G16>;
1823def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD, IMAGE_SAMPLE_C_CD_G16>;
1824def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_CL, IMAGE_SAMPLE_C_CD_CL_G16>;
1825def : MIMGG16Mapping<IMAGE_SAMPLE_CD_O, IMAGE_SAMPLE_CD_O_G16>;
1826def : MIMGG16Mapping<IMAGE_SAMPLE_CD_CL_O, IMAGE_SAMPLE_CD_CL_O_G16>;
1827def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_O, IMAGE_SAMPLE_C_CD_O_G16>;
1828def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_CL_O, IMAGE_SAMPLE_C_CD_CL_O_G16>;
1829