1 //===-- MIMGInstructions.td - MIMG Instruction Definitions ----------------===//
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
7 //===----------------------------------------------------------------------===//
9 // MIMG-specific encoding families to distinguish between semantically
10 // equivalent machine instructions with different encoding.
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 partial NSA encoding
19 // - MIMGEncGfx12: gfx12 encoding (partial NSA)
22 def MIMGEncGfx6 : MIMGEncoding;
23 def MIMGEncGfx8 : MIMGEncoding;
24 def MIMGEncGfx90a : MIMGEncoding;
25 def MIMGEncGfx10Default : MIMGEncoding;
26 def MIMGEncGfx10NSA : MIMGEncoding;
27 def MIMGEncGfx11Default : MIMGEncoding;
28 def MIMGEncGfx11NSA : MIMGEncoding;
29 def MIMGEncGfx12 : MIMGEncoding;
31 def MIMGEncoding : GenericEnum {
32 let FilterClass = "MIMGEncoding";
35 // Represent an ISA-level opcode, independent of the encoding and the
37 class MIMGBaseOpcode : PredicateControl {
38 MIMGBaseOpcode BaseOpcode = !cast<MIMGBaseOpcode>(NAME);
41 bit AtomicX2 = 0; // (f)cmpswap
44 bits<8> NumExtraArgs = 0;
48 bit LodOrClampOrMip = 0;
57 def MIMGBaseOpcode : GenericEnum {
58 let FilterClass = "MIMGBaseOpcode";
61 def MIMGBaseOpcodesTable : GenericTable {
62 let FilterClass = "MIMGBaseOpcode";
63 let CppTypeName = "MIMGBaseOpcodeInfo";
64 let Fields = ["BaseOpcode", "Store", "Atomic", "AtomicX2", "Sampler",
65 "Gather4", "NumExtraArgs", "Gradients", "G16", "Coordinates",
66 "LodOrClampOrMip", "HasD16", "MSAA", "BVH", "A16", "NoReturn"];
67 string TypeOf_BaseOpcode = "MIMGBaseOpcode";
69 let PrimaryKey = ["BaseOpcode"];
70 let PrimaryKeyName = "getMIMGBaseOpcodeInfo";
73 def MIMGDim : GenericEnum {
74 let FilterClass = "AMDGPUDimProps";
77 def MIMGDimInfoTable : GenericTable {
78 let FilterClass = "AMDGPUDimProps";
79 let CppTypeName = "MIMGDimInfo";
80 let Fields = ["Dim", "NumCoords", "NumGradients", "MSAA", "DA", "Encoding", "AsmSuffix"];
81 string TypeOf_Dim = "MIMGDim";
83 let PrimaryKey = ["Dim"];
84 let PrimaryKeyName = "getMIMGDimInfo";
87 def getMIMGDimInfoByEncoding : SearchIndex {
88 let Table = MIMGDimInfoTable;
89 let Key = ["Encoding"];
92 def getMIMGDimInfoByAsmSuffix : SearchIndex {
93 let Table = MIMGDimInfoTable;
94 let Key = ["AsmSuffix"];
101 class mimgopc <int gfx12, int gfx11, int gfx10m, int vi = gfx10m, int si = gfx10m> {
102 field bits<8> GFX12 = gfx12;
103 field bits<8> GFX11 = gfx11;
104 field bits<8> GFX10M = gfx10m; // GFX10minus for all but atomics
105 field bits<8> VI = vi; // VI is only used for atomic/sampler/gather instructions
106 field bits<8> SI = si; // SI is only used for atomic instructions
107 bit HAS_GFX12 = !ne(gfx12, MIMG.NOP);
108 bit HAS_GFX11 = !ne(gfx11, MIMG.NOP);
109 bit HAS_GFX10M = !ne(gfx10m, MIMG.NOP);
110 bit HAS_VI = !ne(vi, MIMG.NOP);
111 bit HAS_SI = !ne(si, MIMG.NOP);
114 class MIMGLZMapping<MIMGBaseOpcode l, MIMGBaseOpcode lz> {
115 MIMGBaseOpcode L = l;
116 MIMGBaseOpcode LZ = lz;
119 def MIMGLZMappingTable : GenericTable {
120 let FilterClass = "MIMGLZMapping";
121 let CppTypeName = "MIMGLZMappingInfo";
122 let Fields = ["L", "LZ"];
123 string TypeOf_L = "MIMGBaseOpcode";
124 string TypeOf_LZ = "MIMGBaseOpcode";
126 let PrimaryKey = ["L"];
127 let PrimaryKeyName = "getMIMGLZMappingInfo";
130 class MIMGMIPMapping<MIMGBaseOpcode mip, MIMGBaseOpcode nonmip> {
131 MIMGBaseOpcode MIP = mip;
132 MIMGBaseOpcode NONMIP = nonmip;
135 def MIMGMIPMappingTable : GenericTable {
136 let FilterClass = "MIMGMIPMapping";
137 let CppTypeName = "MIMGMIPMappingInfo";
138 let Fields = ["MIP", "NONMIP"];
139 string TypeOf_MIP = "MIMGBaseOpcode";
140 string TypeOf_NONMIP = "MIMGBaseOpcode";
142 let PrimaryKey = ["MIP"];
143 let PrimaryKeyName = "getMIMGMIPMappingInfo";
146 class MIMGBiasMapping<MIMGBaseOpcode bias, MIMGBaseOpcode nobias> {
147 MIMGBaseOpcode Bias = bias;
148 MIMGBaseOpcode NoBias = nobias;
151 def MIMGBiasMappingTable : GenericTable {
152 let FilterClass = "MIMGBiasMapping";
153 let CppTypeName = "MIMGBiasMappingInfo";
154 let Fields = ["Bias", "NoBias"];
155 string TypeOf_Bias = "MIMGBaseOpcode";
156 string TypeOf_NoBias = "MIMGBaseOpcode";
158 let PrimaryKey = ["Bias"];
159 let PrimaryKeyName = "getMIMGBiasMappingInfo";
162 class MIMGOffsetMapping<MIMGBaseOpcode offset, MIMGBaseOpcode nooffset> {
163 MIMGBaseOpcode Offset = offset;
164 MIMGBaseOpcode NoOffset = nooffset;
167 def MIMGOffsetMappingTable : GenericTable {
168 let FilterClass = "MIMGOffsetMapping";
169 let CppTypeName = "MIMGOffsetMappingInfo";
170 let Fields = ["Offset", "NoOffset"];
171 string TypeOf_Offset = "MIMGBaseOpcode";
172 string TypeOf_NoOffset = "MIMGBaseOpcode";
174 let PrimaryKey = ["Offset"];
175 let PrimaryKeyName = "getMIMGOffsetMappingInfo";
178 class MIMGG16Mapping<MIMGBaseOpcode g, MIMGBaseOpcode g16> {
179 MIMGBaseOpcode G = g;
180 MIMGBaseOpcode G16 = g16;
183 def MIMGG16MappingTable : GenericTable {
184 let FilterClass = "MIMGG16Mapping";
185 let CppTypeName = "MIMGG16MappingInfo";
186 let Fields = ["G", "G16"];
187 string TypeOf_G = "MIMGBaseOpcode";
188 string TypeOf_G16 = "MIMGBaseOpcode";
190 let PrimaryKey = ["G"];
191 let PrimaryKeyName = "getMIMGG16MappingInfo";
194 class MIMG_Base <dag outs, string dns = "">
195 : InstSI <outs, (ins), "", []> {
203 let SchedRW = [WriteVMEM];
204 let UseNamedOperandTable = 1;
205 let hasSideEffects = 0; // XXX ????
207 let DecoderNamespace = dns;
208 let isAsmParserOnly = !eq(dns, "");
211 class MIMG <dag outs, string dns = "">
212 : MIMG_Base <outs, dns> {
214 let hasPostISelHook = 1;
215 let usesCustomInserter = 1;
217 Instruction Opcode = !cast<Instruction>(NAME);
218 MIMGBaseOpcode BaseOpcode;
219 MIMGEncoding MIMGEncoding;
223 // If NSA is used this counts number of operands VAddrDwords is split into.
224 bits<8> VAddrOperands;
227 class VIMAGE <dag outs, string dns = ""> : MIMG<outs, dns> {
232 class VSAMPLE <dag outs, string dns = ""> : MIMG<outs, dns> {
237 def MIMGInfoTable : GenericTable {
238 let FilterClass = "MIMG";
239 let CppTypeName = "MIMGInfo";
240 let Fields = ["Opcode", "BaseOpcode", "MIMGEncoding", "VDataDwords",
241 "VAddrDwords", "VAddrOperands"];
242 string TypeOf_BaseOpcode = "MIMGBaseOpcode";
243 string TypeOf_MIMGEncoding = "MIMGEncoding";
245 let PrimaryKey = ["BaseOpcode", "MIMGEncoding", "VDataDwords", "VAddrDwords"];
246 let PrimaryKeyName = "getMIMGOpcodeHelper";
249 def getMIMGInfo : SearchIndex {
250 let Table = MIMGInfoTable;
251 let Key = ["Opcode"];
260 class MIMGNSAHelper<int num_addrs,
261 list<RegisterClass> addr_types=!listsplat(VGPR_32, num_addrs)>
263 list<string> AddrAsmNames = !foreach(i, !range(num_addrs), "vaddr" # i);
264 let AddrIns = !dag(ins, addr_types, AddrAsmNames);
265 let AddrAsm = "[$" # !interleave(AddrAsmNames, ", $") # "]";
267 let NSA = !if(!le(num_addrs, 1), ?,
268 !if(!le(num_addrs, 5), 1,
269 !if(!le(num_addrs, 9), 2,
270 !if(!le(num_addrs, 13), 3, ?))));
273 class PartialNSAHelper<int num_addrs, int max_addr, RegisterClass LastAddrRC>
276 list<RegisterClass> addr_types =
277 !if(!ge(num_addrs, max_addr),
278 !listconcat(!listsplat(VGPR_32, !sub(max_addr, 1)), [LastAddrRC]),
279 !listsplat(VGPR_32, num_addrs));
281 int VAddrCount = !if(!gt(num_addrs, max_addr), max_addr, num_addrs);
282 list<string> AddrAsmNames = !foreach(i, !range(VAddrCount), "vaddr" # i);
284 let AddrIns = !dag(ins, addr_types, AddrAsmNames);
285 let AddrAsm = "[$" # !interleave(AddrAsmNames, ", $") # "]";
289 // Base class of all pre-gfx10 MIMG instructions.
290 class MIMG_gfx6789<bits<8> op, dag outs, string dns = "">
291 : MIMG<outs, dns>, MIMGe_gfx6789<op> {
292 let SubtargetPredicate = isGFX6GFX7GFX8GFX9NotGFX90A;
293 let AssemblerPredicate = isGFX6GFX7GFX8GFX9NotGFX90A;
295 let MIMGEncoding = MIMGEncGfx6;
296 let VAddrOperands = 1;
298 let d16 = !if(BaseOpcode.HasD16, ?, 0);
301 class MIMG_gfx90a<bits<8> op, dag outs, string dns = "">
302 : MIMG<outs, dns>, MIMGe_gfx90a<op> {
303 let SubtargetPredicate = isGFX90APlus;
304 let AssemblerPredicate = isGFX90APlus;
306 let MIMGEncoding = MIMGEncGfx90a;
307 let VAddrOperands = 1;
309 let d16 = !if(BaseOpcode.HasD16, ?, 0);
312 // Base class of all non-NSA gfx10 MIMG instructions.
313 class MIMG_gfx10<int op, dag outs, string dns = "">
314 : MIMG<outs, dns>, MIMGe_gfx10<op> {
315 let SubtargetPredicate = isGFX10Only;
316 let AssemblerPredicate = isGFX10Only;
318 let MIMGEncoding = MIMGEncGfx10Default;
319 let VAddrOperands = 1;
321 let d16 = !if(BaseOpcode.HasD16, ?, 0);
325 // Base class for all NSA MIMG instructions.
326 // Note that 1-dword addresses always use non-NSA variants.
327 class MIMG_nsa_gfx10<int op, dag outs, int num_addrs, string dns="">
328 : MIMG<outs, dns>, MIMGe_gfx10<op> {
329 let SubtargetPredicate = isGFX10Only;
330 let AssemblerPredicate = isGFX10Only;
332 let MIMGEncoding = MIMGEncGfx10NSA;
333 let VAddrOperands = num_addrs;
335 MIMGNSAHelper nsah = MIMGNSAHelper<num_addrs>;
336 dag AddrIns = nsah.AddrIns;
337 string AddrAsm = nsah.AddrAsm;
339 let d16 = !if(BaseOpcode.HasD16, ?, 0);
343 // Base class of all non-NSA gfx11 MIMG instructions.
344 class MIMG_gfx11<int op, dag outs, string dns = "">
345 : MIMG<outs, dns>, MIMGe_gfx11<op> {
346 let SubtargetPredicate = isGFX11Only;
347 let AssemblerPredicate = isGFX11Only;
349 let MIMGEncoding = MIMGEncGfx11Default;
350 let VAddrOperands = 1;
352 let d16 = !if(BaseOpcode.HasD16, ?, 0);
356 // Base class for all NSA MIMG instructions.
357 // Note that 1-dword addresses always use non-NSA variants.
358 class MIMG_nsa_gfx11<int op, dag outs, int num_addrs, string dns="",
359 list<RegisterClass> addr_types=[],
360 RegisterClass LastAddrRC = VGPR_32>
361 : MIMG<outs, dns>, MIMGe_gfx11<op> {
362 let SubtargetPredicate = isGFX11Only;
363 let AssemblerPredicate = isGFX11Only;
365 let MIMGEncoding = MIMGEncGfx11NSA;
366 let VAddrOperands = num_addrs;
368 NSAHelper nsah = !if(!empty(addr_types),
369 PartialNSAHelper<num_addrs, 5, LastAddrRC>,
370 MIMGNSAHelper<num_addrs, addr_types>);
371 dag AddrIns = nsah.AddrIns;
372 string AddrAsm = nsah.AddrAsm;
374 let d16 = !if(BaseOpcode.HasD16, ?, 0);
378 class VIMAGE_gfx12<int op, dag outs, int num_addrs, string dns="",
379 list<RegisterClass> addr_types=[]>
380 : VIMAGE<outs, dns>, VIMAGEe<op> {
381 let SubtargetPredicate = isGFX12Plus;
382 let AssemblerPredicate = isGFX12Plus;
384 let MIMGEncoding = MIMGEncGfx12;
385 let VAddrOperands = num_addrs;
387 MIMGNSAHelper nsah = !if(!empty(addr_types),
388 MIMGNSAHelper<num_addrs>,
389 MIMGNSAHelper<num_addrs, addr_types>);
390 dag AddrIns = nsah.AddrIns;
391 string AddrAsm = !if(!eq(num_addrs, 1), "$vaddr0", nsah.AddrAsm);
393 let d16 = !if(BaseOpcode.HasD16, ?, 0);
394 let vaddr1 = !if(!lt(num_addrs, 2), 0, ?);
395 let vaddr2 = !if(!lt(num_addrs, 3), 0, ?);
396 let vaddr3 = !if(!lt(num_addrs, 4), 0, ?);
397 let vaddr4 = !if(!lt(num_addrs, 5), 0, ?);
400 class VSAMPLE_gfx12<int op, dag outs, int num_addrs, string dns="",
401 RegisterClass Addr3RC>
402 : VSAMPLE<outs, dns>, VSAMPLEe<op> {
403 let SubtargetPredicate = isGFX12Plus;
404 let AssemblerPredicate = isGFX12Plus;
406 let MIMGEncoding = MIMGEncGfx12;
407 let VAddrOperands = num_addrs;
409 PartialNSAHelper nsah = PartialNSAHelper<num_addrs, 4, Addr3RC>;
411 dag AddrIns = nsah.AddrIns;
412 string AddrAsm = !if(!eq(num_addrs, 1), "$vaddr0", nsah.AddrAsm);
414 let d16 = !if(BaseOpcode.HasD16, ?, 0);
415 let vaddr1 = !if(!lt(num_addrs, 2), 0, ?);
416 let vaddr2 = !if(!lt(num_addrs, 3), 0, ?);
417 let vaddr3 = !if(!lt(num_addrs, 4), 0, ?);
420 class MIMG_NoSampler_Helper <mimgopc op, string asm,
421 RegisterClass dst_rc,
422 RegisterClass addr_rc,
424 : MIMG_gfx6789 <op.GFX10M, (outs dst_rc:$vdata), dns> {
425 let InOperandList = !con((ins addr_rc:$vaddr, SReg_256:$srsrc,
426 DMask:$dmask, UNorm:$unorm, CPol:$cpol,
427 R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
428 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
429 let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$tfe$lwe$da"
430 #!if(BaseOpcode.HasD16, "$d16", "");
433 class MIMG_NoSampler_Helper_gfx90a <mimgopc op, string asm,
434 RegisterClass dst_rc,
435 RegisterClass addr_rc,
437 : MIMG_gfx90a <op.GFX10M, (outs getLdStRegisterOperand<dst_rc>.ret:$vdata), dns> {
438 let InOperandList = !con((ins addr_rc:$vaddr, SReg_256:$srsrc,
439 DMask:$dmask, UNorm:$unorm, CPol:$cpol,
440 R128A16:$r128, LWE:$lwe, DA:$da),
441 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
442 let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$lwe$da"
443 #!if(BaseOpcode.HasD16, "$d16", "");
446 class MIMG_NoSampler_gfx10<mimgopc op, string opcode,
447 RegisterClass DataRC, RegisterClass AddrRC,
449 : MIMG_gfx10<op.GFX10M, (outs DataRC:$vdata), dns> {
450 let InOperandList = !con((ins AddrRC:$vaddr0, SReg_256:$srsrc, DMask:$dmask,
451 Dim:$dim, UNorm:$unorm, CPol:$cpol,
452 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
453 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
454 let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
455 #!if(BaseOpcode.HasD16, "$d16", "");
458 class MIMG_NoSampler_nsa_gfx10<mimgopc op, string opcode,
459 RegisterClass DataRC, int num_addrs,
461 : MIMG_nsa_gfx10<op.GFX10M, (outs DataRC:$vdata), num_addrs, dns> {
462 let InOperandList = !con(AddrIns,
463 (ins SReg_256:$srsrc, DMask:$dmask,
464 Dim:$dim, UNorm:$unorm, CPol:$cpol,
465 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
466 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
467 let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
468 #!if(BaseOpcode.HasD16, "$d16", "");
471 class MIMG_NoSampler_gfx11<mimgopc op, string opcode,
472 RegisterClass DataRC, RegisterClass AddrRC,
474 : MIMG_gfx11<op.GFX11, (outs DataRC:$vdata), dns> {
475 let InOperandList = !con((ins AddrRC:$vaddr0, SReg_256:$srsrc, DMask:$dmask,
476 Dim:$dim, UNorm:$unorm, CPol:$cpol,
477 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
478 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
479 let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
480 #!if(BaseOpcode.HasD16, "$d16", "");
483 class MIMG_NoSampler_nsa_gfx11<mimgopc op, string opcode,
484 RegisterClass DataRC, int num_addrs,
486 : MIMG_nsa_gfx11<op.GFX11, (outs DataRC:$vdata), num_addrs, dns> {
487 let InOperandList = !con(AddrIns,
488 (ins SReg_256:$srsrc, DMask:$dmask,
489 Dim:$dim, UNorm:$unorm, CPol:$cpol,
490 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
491 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
492 let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
493 #!if(BaseOpcode.HasD16, "$d16", "");
496 class VIMAGE_NoSampler_gfx12<mimgopc op, string opcode,
497 RegisterClass DataRC, int num_addrs,
499 : VIMAGE_gfx12<op.GFX12, (outs DataRC:$vdata), num_addrs, dns> {
500 let InOperandList = !con(AddrIns,
501 (ins SReg_256:$rsrc, DMask:$dmask, Dim:$dim,
502 CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe),
503 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
504 let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc$dmask$dim$cpol$r128$a16$tfe"
505 #!if(BaseOpcode.HasD16, "$d16", "");
508 class VSAMPLE_Sampler_gfx12<mimgopc op, string opcode, RegisterClass DataRC,
509 int num_addrs, RegisterClass Addr3RC = VGPR_32,
511 : VSAMPLE_gfx12<op.GFX12, (outs DataRC:$vdata), num_addrs, dns, Addr3RC> {
512 let InOperandList = !con(AddrIns,
513 (ins SReg_256:$rsrc),
514 !if(BaseOpcode.Sampler, (ins SReg_128:$samp), (ins)),
515 (ins DMask:$dmask, Dim:$dim, UNorm:$unorm,
516 CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe,
518 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
519 let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc"
520 #!if(BaseOpcode.Sampler, ", $samp", "")
521 #"$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
522 #!if(BaseOpcode.HasD16, "$d16", "");
525 class VSAMPLE_Sampler_nortn_gfx12<mimgopc op, string opcode,
526 int num_addrs, RegisterClass Addr3RC = VGPR_32,
528 : VSAMPLE_gfx12<op.GFX12, (outs), num_addrs, dns, Addr3RC> {
529 let InOperandList = !con(AddrIns,
530 (ins SReg_256:$rsrc),
531 !if(BaseOpcode.Sampler, (ins SReg_128:$samp), (ins)),
532 (ins DMask:$dmask, Dim:$dim, UNorm:$unorm,
533 CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe,
535 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
536 let AsmString = opcode#" off, "#AddrAsm#", $rsrc"
537 #!if(BaseOpcode.Sampler, ", $samp", "")
538 #"$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
539 #!if(BaseOpcode.HasD16, "$d16", "");
540 // Force vdata to VGPR0 as no result will be returned.
544 multiclass MIMG_NoSampler_Src_Helper <mimgopc op, string asm,
545 RegisterClass dst_rc, bit enableDisasm,
546 bit ExtendedImageInst = 1,
548 let VAddrDwords = 1 in {
550 if op.HAS_GFX10M then {
551 def _V1 : MIMG_NoSampler_Helper <op, asm, dst_rc, VGPR_32,
552 !if(enableDisasm, "GFX8", "")>;
553 if !not(ExtendedImageInst) then
554 def _V1_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VGPR_32,
555 !if(enableDisasm, "GFX90A", "")>;
556 def _V1_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VGPR_32,
557 !if(enableDisasm, "GFX10", "")>;
559 if op.HAS_GFX11 then {
560 def _V1_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VGPR_32,
561 !if(enableDisasm, "GFX11", "")>;
564 if op.HAS_GFX12 then {
567 def _V1_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 1>;
570 def _V1_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 1,
571 !if(enableDisasm, "GFX12", "")>;
575 let VAddrDwords = 2 in {
577 if op.HAS_GFX10M then {
578 def _V2 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_64>;
579 if !not(ExtendedImageInst) then
580 def _V2_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VReg_64>;
581 def _V2_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VReg_64>;
582 def _V2_nsa_gfx10 : MIMG_NoSampler_nsa_gfx10<op, asm, dst_rc, 2>;
584 if op.HAS_GFX11 then {
585 def _V2_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VReg_64>;
586 def _V2_nsa_gfx11 : MIMG_NoSampler_nsa_gfx11<op, asm, dst_rc, 2>;
589 if op.HAS_GFX12 then {
592 def _V2_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 2>;
595 def _V2_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 2>;
599 let VAddrDwords = 3 in {
601 if op.HAS_GFX10M then {
602 def _V3 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_96>;
603 if !not(ExtendedImageInst) then
604 def _V3_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VReg_96>;
605 def _V3_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VReg_96>;
606 def _V3_nsa_gfx10 : MIMG_NoSampler_nsa_gfx10<op, asm, dst_rc, 3>;
608 if op.HAS_GFX11 then {
609 def _V3_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VReg_96>;
610 def _V3_nsa_gfx11 : MIMG_NoSampler_nsa_gfx11<op, asm, dst_rc, 3>;
613 if op.HAS_GFX12 then {
616 def _V3_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 3>;
619 def _V3_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 3>;
623 let VAddrDwords = 4 in {
625 if op.HAS_GFX10M then {
626 def _V4 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_128>;
627 if !not(ExtendedImageInst) then
628 def _V4_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VReg_128>;
629 def _V4_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VReg_128>;
630 def _V4_nsa_gfx10 : MIMG_NoSampler_nsa_gfx10<op, asm, dst_rc, 4,
631 !if(enableDisasm, "GFX10", "")>;
633 if op.HAS_GFX11 then {
634 def _V4_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VReg_128>;
635 def _V4_nsa_gfx11 : MIMG_NoSampler_nsa_gfx11<op, asm, dst_rc, 4,
636 !if(enableDisasm, "GFX11", "")>;
639 if op.HAS_GFX12 then {
642 def _V4_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 4, VGPR_32,
643 !if(enableDisasm, "GFX12", "")>;
646 def _V4_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 4,
647 !if(enableDisasm, "GFX12", "")>;
653 multiclass MIMG_NoSampler <mimgopc op, string asm, bit has_d16, bit mip = 0,
656 def "" : MIMGBaseOpcode {
657 let Coordinates = !not(isResInfo);
658 let LodOrClampOrMip = mip;
659 let HasD16 = has_d16;
663 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME),
664 mayLoad = !not(isResInfo) in {
665 let VDataDwords = 1 in
666 defm _V1 : MIMG_NoSampler_Src_Helper <op, asm, VGPR_32, 1, msaa>;
667 let VDataDwords = 2 in
668 defm _V2 : MIMG_NoSampler_Src_Helper <op, asm, VReg_64, 0, msaa>;
669 let VDataDwords = 3 in
670 defm _V3 : MIMG_NoSampler_Src_Helper <op, asm, VReg_96, 0, msaa>;
671 let VDataDwords = 4 in
672 defm _V4 : MIMG_NoSampler_Src_Helper <op, asm, VReg_128, 0, msaa>;
673 let VDataDwords = 5 in
674 defm _V5 : MIMG_NoSampler_Src_Helper <op, asm, VReg_160, 0, msaa>;
678 class MIMG_Store_Helper <mimgopc op, string asm,
679 RegisterClass data_rc,
680 RegisterClass addr_rc,
682 : MIMG_gfx6789<op.GFX10M, (outs), dns> {
683 let InOperandList = !con((ins data_rc:$vdata, addr_rc:$vaddr, SReg_256:$srsrc,
684 DMask:$dmask, UNorm:$unorm, CPol:$cpol,
685 R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
686 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
687 let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$tfe$lwe$da"
688 #!if(BaseOpcode.HasD16, "$d16", "");
691 class MIMG_Store_Helper_gfx90a <mimgopc op, string asm,
692 RegisterClass data_rc,
693 RegisterClass addr_rc,
695 : MIMG_gfx90a<op.GFX10M, (outs), dns> {
696 let InOperandList = !con((ins getLdStRegisterOperand<data_rc>.ret:$vdata,
697 addr_rc:$vaddr, SReg_256:$srsrc,
698 DMask:$dmask, UNorm:$unorm, CPol:$cpol,
699 R128A16:$r128, LWE:$lwe, DA:$da),
700 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
701 let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$lwe$da"
702 #!if(BaseOpcode.HasD16, "$d16", "");
705 class MIMG_Store_gfx10<mimgopc op, string opcode,
706 RegisterClass DataRC, RegisterClass AddrRC,
708 : MIMG_gfx10<op.GFX10M, (outs), dns> {
709 let InOperandList = !con((ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
710 DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
711 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
712 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
713 let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
714 #!if(BaseOpcode.HasD16, "$d16", "");
717 class MIMG_Store_nsa_gfx10<mimgopc op, string opcode,
718 RegisterClass DataRC, int num_addrs,
720 : MIMG_nsa_gfx10<op.GFX10M, (outs), num_addrs, dns> {
721 let InOperandList = !con((ins DataRC:$vdata),
723 (ins SReg_256:$srsrc, DMask:$dmask,
724 Dim:$dim, UNorm:$unorm, CPol:$cpol,
725 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
726 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
727 let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
728 #!if(BaseOpcode.HasD16, "$d16", "");
731 class MIMG_Store_gfx11<mimgopc op, string opcode,
732 RegisterClass DataRC, RegisterClass AddrRC,
734 : MIMG_gfx11<op.GFX11, (outs), dns> {
735 let InOperandList = !con((ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
736 DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
737 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
738 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
739 let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
740 #!if(BaseOpcode.HasD16, "$d16", "");
743 class MIMG_Store_nsa_gfx11<mimgopc op, string opcode,
744 RegisterClass DataRC, int num_addrs,
746 : MIMG_nsa_gfx11<op.GFX11, (outs), num_addrs, dns> {
747 let InOperandList = !con((ins DataRC:$vdata),
749 (ins SReg_256:$srsrc, DMask:$dmask,
750 Dim:$dim, UNorm:$unorm, CPol:$cpol,
751 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
752 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
753 let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
754 #!if(BaseOpcode.HasD16, "$d16", "");
757 class VIMAGE_Store_gfx12<mimgopc op, string opcode,
758 RegisterClass DataRC, int num_addrs,
760 : VIMAGE_gfx12<op.GFX12, (outs), num_addrs, dns> {
761 let InOperandList = !con((ins DataRC:$vdata),
763 (ins SReg_256:$rsrc, DMask:$dmask, Dim:$dim,
764 CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe),
765 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
766 let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc$dmask$dim$cpol$r128$a16$tfe"
767 #!if(BaseOpcode.HasD16, "$d16", "");
770 multiclass MIMG_Store_Addr_Helper <mimgopc op, string asm,
771 RegisterClass data_rc,
773 let mayLoad = 0, mayStore = 1, hasSideEffects = 0, hasPostISelHook = 0,
775 let VAddrDwords = 1 in {
777 if op.HAS_GFX10M then {
778 def _V1 : MIMG_Store_Helper <op, asm, data_rc, VGPR_32,
779 !if(enableDisasm, "GFX8", "")>;
780 let hasPostISelHook = 1 in
781 def _V1_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VGPR_32,
782 !if(enableDisasm, "GFX90A", "")>;
783 def _V1_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VGPR_32,
784 !if(enableDisasm, "GFX10", "")>;
786 if op.HAS_GFX11 then {
787 def _V1_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VGPR_32,
788 !if(enableDisasm, "GFX11", "")>;
791 if op.HAS_GFX12 then {
792 def _V1_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 1,
793 !if(enableDisasm, "GFX12", "")>;
796 let VAddrDwords = 2 in {
798 if op.HAS_GFX10M then {
799 def _V2 : MIMG_Store_Helper <op, asm, data_rc, VReg_64>;
800 def _V2_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VReg_64>;
801 def _V2_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VReg_64>;
802 def _V2_nsa_gfx10 : MIMG_Store_nsa_gfx10 <op, asm, data_rc, 2>;
804 if op.HAS_GFX11 then {
805 def _V2_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VReg_64>;
806 def _V2_nsa_gfx11 : MIMG_Store_nsa_gfx11 <op, asm, data_rc, 2>;
809 if op.HAS_GFX12 then {
810 def _V2_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 2>;
813 let VAddrDwords = 3 in {
815 if op.HAS_GFX10M then {
816 def _V3 : MIMG_Store_Helper <op, asm, data_rc, VReg_96>;
817 def _V3_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VReg_96>;
818 def _V3_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VReg_96>;
819 def _V3_nsa_gfx10 : MIMG_Store_nsa_gfx10 <op, asm, data_rc, 3>;
821 if op.HAS_GFX11 then {
822 def _V3_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VReg_96>;
823 def _V3_nsa_gfx11 : MIMG_Store_nsa_gfx11 <op, asm, data_rc, 3>;
826 if op.HAS_GFX12 then {
827 def _V3_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 3>;
830 let VAddrDwords = 4 in {
832 if op.HAS_GFX10M then {
833 def _V4 : MIMG_Store_Helper <op, asm, data_rc, VReg_128>;
834 def _V4_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VReg_128>;
835 def _V4_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VReg_128>;
836 def _V4_nsa_gfx10 : MIMG_Store_nsa_gfx10 <op, asm, data_rc, 4,
837 !if(enableDisasm, "GFX10", "")>;
839 if op.HAS_GFX11 then {
840 def _V4_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VReg_128>;
841 def _V4_nsa_gfx11 : MIMG_Store_nsa_gfx11 <op, asm, data_rc, 4,
842 !if(enableDisasm, "GFX11", "")>;
845 if op.HAS_GFX12 then {
846 def _V4_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 4,
847 !if(enableDisasm, "GFX12", "")>;
853 multiclass MIMG_Store <mimgopc op, string asm, bit has_d16, bit mip = 0> {
854 def "" : MIMGBaseOpcode {
856 let LodOrClampOrMip = mip;
857 let HasD16 = has_d16;
861 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME) in {
862 let VDataDwords = 1 in
863 defm _V1 : MIMG_Store_Addr_Helper <op, asm, VGPR_32, 1>;
864 let VDataDwords = 2 in
865 defm _V2 : MIMG_Store_Addr_Helper <op, asm, VReg_64, 0>;
866 let VDataDwords = 3 in
867 defm _V3 : MIMG_Store_Addr_Helper <op, asm, VReg_96, 0>;
868 let VDataDwords = 4 in
869 defm _V4 : MIMG_Store_Addr_Helper <op, asm, VReg_128, 0>;
870 let VDataDwords = 5 in
871 defm _V5 : MIMG_Store_Addr_Helper <op, asm, VReg_160, 0>;
875 class MIMG_Atomic_gfx6789_base <bits<8> op, string asm, RegisterClass data_rc,
876 RegisterClass addr_rc, string dns="">
877 : MIMG_gfx6789 <op, (outs data_rc:$vdst), dns> {
878 let Constraints = "$vdst = $vdata";
880 let InOperandList = (ins data_rc:$vdata, addr_rc:$vaddr, SReg_256:$srsrc,
881 DMask:$dmask, UNorm:$unorm, CPol:$cpol,
882 R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da);
883 let AsmString = asm#" $vdst, $vaddr, $srsrc$dmask$unorm$cpol$r128$tfe$lwe$da";
886 class MIMG_Atomic_gfx90a_base <bits<8> op, string asm, RegisterClass data_rc,
887 RegisterClass addr_rc, string dns="">
888 : MIMG_gfx90a <op, (outs getLdStRegisterOperand<data_rc>.ret:$vdst), dns> {
889 let Constraints = "$vdst = $vdata";
891 let InOperandList = (ins getLdStRegisterOperand<data_rc>.ret:$vdata,
892 addr_rc:$vaddr, SReg_256:$srsrc,
893 DMask:$dmask, UNorm:$unorm, CPol:$cpol,
894 R128A16:$r128, LWE:$lwe, DA:$da);
895 let AsmString = asm#" $vdst, $vaddr, $srsrc$dmask$unorm$cpol$r128$lwe$da";
898 class MIMG_Atomic_si<mimgopc op, string asm, RegisterClass data_rc,
899 RegisterClass addr_rc, bit enableDasm = 0>
900 : MIMG_Atomic_gfx6789_base<op.SI, asm, data_rc, addr_rc,
901 !if(enableDasm, "GFX6GFX7", "")> {
902 let AssemblerPredicate = isGFX6GFX7;
905 class MIMG_Atomic_vi<mimgopc op, string asm, RegisterClass data_rc,
906 RegisterClass addr_rc, bit enableDasm = 0>
907 : MIMG_Atomic_gfx6789_base<op.VI, asm, data_rc, addr_rc, !if(enableDasm, "GFX8", "")> {
908 let AssemblerPredicate = isGFX8GFX9NotGFX90A;
909 let MIMGEncoding = MIMGEncGfx8;
912 class MIMG_Atomic_gfx90a<mimgopc op, string asm, RegisterClass data_rc,
913 RegisterClass addr_rc, bit enableDasm = 0>
914 : MIMG_Atomic_gfx90a_base<op.VI, asm, data_rc, addr_rc, !if(enableDasm, "GFX90A", "")> {
915 let AssemblerPredicate = isGFX90APlus;
916 let MIMGEncoding = MIMGEncGfx90a;
919 class MIMG_Atomic_gfx10<mimgopc op, string opcode,
920 RegisterClass DataRC, RegisterClass AddrRC,
921 bit enableDisasm = 0>
922 : MIMG_gfx10<!cast<int>(op.GFX10M), (outs DataRC:$vdst),
923 !if(enableDisasm, "GFX10", "")> {
924 let Constraints = "$vdst = $vdata";
926 let InOperandList = (ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
927 DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
928 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe);
929 let AsmString = opcode#" $vdst, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
932 class MIMG_Atomic_nsa_gfx10<mimgopc op, string opcode,
933 RegisterClass DataRC, int num_addrs,
934 bit enableDisasm = 0>
935 : MIMG_nsa_gfx10<!cast<int>(op.GFX10M), (outs DataRC:$vdst), num_addrs,
936 !if(enableDisasm, "GFX10", "")> {
937 let Constraints = "$vdst = $vdata";
939 let InOperandList = !con((ins DataRC:$vdata),
941 (ins SReg_256:$srsrc, DMask:$dmask,
942 Dim:$dim, UNorm:$unorm, CPol:$cpol,
943 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe));
944 let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
947 class MIMG_Atomic_gfx11<mimgopc op, string opcode,
948 RegisterClass DataRC, RegisterClass AddrRC,
949 bit enableDisasm = 0>
950 : MIMG_gfx11<!cast<int>(op.GFX11), (outs DataRC:$vdst),
951 !if(enableDisasm, "GFX11", "")> {
952 let Constraints = "$vdst = $vdata";
954 let InOperandList = (ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
955 DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
956 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe);
957 let AsmString = opcode#" $vdst, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
960 class MIMG_Atomic_nsa_gfx11<mimgopc op, string opcode,
961 RegisterClass DataRC, int num_addrs,
962 bit enableDisasm = 0>
963 : MIMG_nsa_gfx11<!cast<int>(op.GFX11), (outs DataRC:$vdst), num_addrs,
964 !if(enableDisasm, "GFX11", "")> {
965 let Constraints = "$vdst = $vdata";
967 let InOperandList = !con((ins DataRC:$vdata),
969 (ins SReg_256:$srsrc, DMask:$dmask,
970 Dim:$dim, UNorm:$unorm, CPol:$cpol,
971 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe));
972 let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
975 class VIMAGE_Atomic_gfx12<mimgopc op, string opcode, RegisterClass DataRC,
976 int num_addrs, bit enableDisasm = 0>
977 : VIMAGE_gfx12<!cast<int>(op.GFX12), (outs DataRC:$vdst), num_addrs,
978 !if(enableDisasm, "GFX12", "")> {
979 let Constraints = "$vdst = $vdata";
981 let InOperandList = !con((ins DataRC:$vdata),
983 (ins SReg_256:$rsrc, DMask:$dmask, Dim:$dim,
984 CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe));
985 let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc$dmask$dim$cpol$r128$a16$tfe";
988 class VIMAGE_Atomic_gfx12_Renamed<mimgopc op, string renamed,
989 RegisterClass DataRC, int num_addrs,
990 bit enableDisasm = 0>
991 : VIMAGE_Atomic_gfx12<op, renamed, DataRC, num_addrs, enableDisasm>;
993 multiclass MIMG_Atomic_Addr_Helper_m <mimgopc op, string asm,
994 RegisterClass data_rc,
997 string renamed = ""> {
998 let hasSideEffects = 1, // FIXME: remove this
999 mayLoad = 1, mayStore = 1, hasPostISelHook = 0, DisableWQM = 1,
1000 FPAtomic = isFP in {
1001 let VAddrDwords = 1 in {
1004 def _V1_si : MIMG_Atomic_si <op, asm, data_rc, VGPR_32, enableDasm>;
1007 def _V1_vi : MIMG_Atomic_vi <op, asm, data_rc, VGPR_32, enableDasm>;
1008 let hasPostISelHook = 1 in
1009 def _V1_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VGPR_32, enableDasm>;
1011 if op.HAS_GFX10M then {
1012 def _V1_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VGPR_32, enableDasm>;
1014 if op.HAS_GFX11 then {
1015 def _V1_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VGPR_32, enableDasm>;
1018 if op.HAS_GFX12 then {
1019 if !empty(renamed) then
1020 def _V1_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 1, enableDasm>;
1022 def _V1_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, renamed, data_rc, 1, enableDasm>;
1025 let VAddrDwords = 2 in {
1028 def _V2_si : MIMG_Atomic_si <op, asm, data_rc, VReg_64, 0>;
1031 def _V2_vi : MIMG_Atomic_vi <op, asm, data_rc, VReg_64, 0>;
1032 def _V2_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VReg_64, 0>;
1034 if op.HAS_GFX10M then {
1035 def _V2_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VReg_64, 0>;
1036 def _V2_nsa_gfx10 : MIMG_Atomic_nsa_gfx10 <op, asm, data_rc, 2, 0>;
1038 if op.HAS_GFX11 then {
1039 def _V2_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VReg_64, 0>;
1040 def _V2_nsa_gfx11 : MIMG_Atomic_nsa_gfx11 <op, asm, data_rc, 2, 0>;
1043 if op.HAS_GFX12 then {
1044 if !empty(renamed) then
1045 def _V2_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 2, 0>;
1047 def _V2_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, renamed, data_rc, 2, 0>;
1050 let VAddrDwords = 3 in {
1053 def _V3_si : MIMG_Atomic_si <op, asm, data_rc, VReg_96, 0>;
1056 def _V3_vi : MIMG_Atomic_vi <op, asm, data_rc, VReg_96, 0>;
1057 def _V3_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VReg_96, 0>;
1059 if op.HAS_GFX10M then {
1060 def _V3_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VReg_96, 0>;
1061 def _V3_nsa_gfx10 : MIMG_Atomic_nsa_gfx10 <op, asm, data_rc, 3, 0>;
1063 if op.HAS_GFX11 then {
1064 def _V3_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VReg_96, 0>;
1065 def _V3_nsa_gfx11 : MIMG_Atomic_nsa_gfx11 <op, asm, data_rc, 3, 0>;
1068 if op.HAS_GFX12 then {
1069 if !empty(renamed) then
1070 def _V3_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 3, 0>;
1072 def _V3_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, renamed, data_rc, 3, 0>;
1075 let VAddrDwords = 4 in {
1078 def _V4_si : MIMG_Atomic_si <op, asm, data_rc, VReg_128, 0>;
1081 def _V4_vi : MIMG_Atomic_vi <op, asm, data_rc, VReg_128, 0>;
1082 def _V4_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VReg_128, 0>;
1084 if op.HAS_GFX10M then {
1085 def _V4_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VReg_128, 0>;
1086 def _V4_nsa_gfx10 : MIMG_Atomic_nsa_gfx10 <op, asm, data_rc, 4, enableDasm>;
1088 if op.HAS_GFX11 then {
1089 def _V4_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VReg_128, 0>;
1090 def _V4_nsa_gfx11 : MIMG_Atomic_nsa_gfx11 <op, asm, data_rc, 4, enableDasm>;
1093 if op.HAS_GFX12 then {
1094 if !empty(renamed) then
1095 def _V4_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 4, enableDasm>;
1097 def _V4_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, renamed, data_rc, 4, enableDasm>;
1101 if !and(op.HAS_GFX12, !not(!empty(renamed))) then
1102 def : AMDGPUMnemonicAlias<asm, renamed> {
1103 let AssemblerPredicate = isGFX12Plus;
1104 bit IsAtomicRet; // Unused
1105 MIMGBaseOpcode BaseOpcode; // Unused
1106 int VDataDwords; // Unused
1110 multiclass MIMG_Atomic <mimgopc op, string asm, bit isCmpSwap = 0, bit isFP = 0,
1111 string renamed = ""> { // 64-bit atomics
1112 let IsAtomicRet = 1 in {
1113 def "" : MIMGBaseOpcode {
1115 let AtomicX2 = isCmpSwap;
1118 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME) in {
1119 // _V* variants have different dst size, but the size is encoded implicitly,
1120 // using dmask and tfe. Only 32-bit variant is registered with disassembler.
1121 // Other variants are reconstructed by disassembler using dmask and tfe.
1122 let VDataDwords = !if(isCmpSwap, 2, 1) in
1123 defm _V1 : MIMG_Atomic_Addr_Helper_m <op, asm, !if(isCmpSwap, VReg_64, VGPR_32), 1, isFP, renamed>;
1124 let VDataDwords = !if(isCmpSwap, 4, 2) in
1125 defm _V2 : MIMG_Atomic_Addr_Helper_m <op, asm, !if(isCmpSwap, VReg_128, VReg_64), 0, isFP, renamed>;
1126 let VDataDwords = !if(isCmpSwap, 2, 2) in
1127 defm _V3 : MIMG_Atomic_Addr_Helper_m <op, asm, VReg_96, 0, isFP, renamed>;
1128 let VDataDwords = !if(isCmpSwap, 4, 4) in
1129 defm _V4 : MIMG_Atomic_Addr_Helper_m <op, asm, VReg_160, 0, isFP, renamed>;
1131 } // End IsAtomicRet = 1
1134 multiclass MIMG_Atomic_Renamed <mimgopc op, string asm, string renamed,
1135 bit isCmpSwap = 0, bit isFP = 0>
1136 : MIMG_Atomic <op, asm, isCmpSwap, isFP, renamed>;
1138 class MIMG_Sampler_Helper <mimgopc op, string asm, RegisterClass dst_rc,
1139 RegisterClass src_rc, string dns="">
1140 : MIMG_gfx6789 <op.VI, (outs dst_rc:$vdata), dns> {
1141 let InOperandList = !con((ins src_rc:$vaddr, SReg_256:$srsrc, SReg_128:$ssamp,
1142 DMask:$dmask, UNorm:$unorm, CPol:$cpol,
1143 R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
1144 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
1145 let AsmString = asm#" $vdata, $vaddr, $srsrc, $ssamp$dmask$unorm$cpol$r128$tfe$lwe$da"
1146 #!if(BaseOpcode.HasD16, "$d16", "");
1149 class MIMG_Sampler_gfx90a<mimgopc op, string asm, RegisterClass dst_rc,
1150 RegisterClass src_rc, string dns="">
1151 : MIMG_gfx90a<op.GFX10M, (outs getLdStRegisterOperand<dst_rc>.ret:$vdata), dns> {
1152 let InOperandList = !con((ins src_rc:$vaddr, SReg_256:$srsrc, SReg_128:$ssamp,
1153 DMask:$dmask, UNorm:$unorm, CPol:$cpol,
1154 R128A16:$r128, LWE:$lwe, DA:$da),
1155 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
1156 let AsmString = asm#" $vdata, $vaddr, $srsrc, $ssamp$dmask$unorm$cpol$r128$lwe$da"
1157 #!if(BaseOpcode.HasD16, "$d16", "");
1160 class MIMG_Sampler_OpList_gfx10p<dag OpPrefix, bit HasD16> {
1161 dag ret = !con(OpPrefix,
1162 (ins SReg_256:$srsrc, SReg_128:$ssamp,
1163 DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
1164 R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
1165 !if(HasD16, (ins D16:$d16), (ins)));
1168 class MIMG_Sampler_Asm_gfx10p<string opcode, string AsmPrefix, bit HasD16> {
1169 string ret = opcode#" "#AsmPrefix#", $srsrc, $ssamp$dmask$dim$unorm"
1170 #"$cpol$r128$a16$tfe$lwe"
1171 #!if(HasD16, "$d16", "");
1174 class MIMG_Sampler_gfx10<mimgopc op, string opcode,
1175 RegisterClass DataRC, RegisterClass AddrRC,
1177 : MIMG_gfx10<op.GFX10M, (outs DataRC:$vdata), dns> {
1178 let InOperandList = MIMG_Sampler_OpList_gfx10p<(ins AddrRC:$vaddr0), BaseOpcode.HasD16>.ret;
1179 let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, "$vdata, $vaddr0", BaseOpcode.HasD16>.ret;
1182 class MIMG_Sampler_nsa_gfx10<mimgopc op, string opcode,
1183 RegisterClass DataRC, int num_addrs,
1185 : MIMG_nsa_gfx10<op.GFX10M, (outs DataRC:$vdata), num_addrs, dns> {
1186 let InOperandList = MIMG_Sampler_OpList_gfx10p<AddrIns, BaseOpcode.HasD16>.ret;
1187 let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, " $vdata, "#AddrAsm, BaseOpcode.HasD16>.ret;
1190 class MIMG_Sampler_nortn_gfx10<mimgopc op, string opcode,
1191 RegisterClass AddrRC,
1193 : MIMG_gfx10<op.GFX10M, (outs), dns> {
1194 let InOperandList = MIMG_Sampler_OpList_gfx10p<(ins AddrRC:$vaddr0), BaseOpcode.HasD16>.ret;
1195 let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, "off, $vaddr0", BaseOpcode.HasD16>.ret;
1196 // Force vdata to VGPR0 as no result will be returned.
1200 class MIMG_Sampler_nortn_nsa_gfx10<mimgopc op, string opcode,
1203 : MIMG_nsa_gfx10<op.GFX10M, (outs), num_addrs, dns> {
1204 let InOperandList = MIMG_Sampler_OpList_gfx10p<AddrIns, BaseOpcode.HasD16>.ret;
1205 let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, " off, "#AddrAsm, BaseOpcode.HasD16>.ret;
1206 // Force vdata to VGPR0 as no result will be returned.
1210 class MIMG_Sampler_gfx11<mimgopc op, string opcode,
1211 RegisterClass DataRC, RegisterClass AddrRC,
1213 : MIMG_gfx11<op.GFX11, (outs DataRC:$vdata), dns> {
1214 let InOperandList = MIMG_Sampler_OpList_gfx10p<(ins AddrRC:$vaddr0), BaseOpcode.HasD16>.ret;
1215 let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, "$vdata, $vaddr0", BaseOpcode.HasD16>.ret;
1218 class MIMG_Sampler_nsa_gfx11<mimgopc op, string opcode,
1219 RegisterClass DataRC, int num_addrs,
1220 RegisterClass LastVAddrSize, string dns="">
1221 : MIMG_nsa_gfx11<op.GFX11, (outs DataRC:$vdata), num_addrs, dns, [],
1223 let InOperandList = MIMG_Sampler_OpList_gfx10p<AddrIns, BaseOpcode.HasD16>.ret;
1224 let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, " $vdata, "#AddrAsm, BaseOpcode.HasD16>.ret;
1227 class MIMG_Sampler_nortn_gfx11<mimgopc op, string opcode,
1228 RegisterClass AddrRC,
1230 : MIMG_gfx11<op.GFX11, (outs), dns> {
1231 let InOperandList = MIMG_Sampler_OpList_gfx10p<(ins AddrRC:$vaddr0), BaseOpcode.HasD16>.ret;
1232 let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, "off, $vaddr0", BaseOpcode.HasD16>.ret;
1236 class MIMG_Sampler_nortn_nsa_gfx11<mimgopc op, string opcode,
1238 RegisterClass LastVAddrSize, string dns="">
1239 : MIMG_nsa_gfx11<op.GFX11, (outs), num_addrs, dns, [], LastVAddrSize> {
1240 let InOperandList = MIMG_Sampler_OpList_gfx10p<AddrIns, BaseOpcode.HasD16>.ret;
1241 let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, "off, "#AddrAsm, BaseOpcode.HasD16>.ret;
1245 class MIMGAddrSize<int dw, bit enable_disasm, int AddrDW = dw> {
1248 RegisterClass RegClass = !if(!le(AddrDW, 0), ?,
1249 !if(!eq(AddrDW, 1), VGPR_32,
1250 !if(!eq(AddrDW, 2), VReg_64,
1251 !if(!eq(AddrDW, 3), VReg_96,
1252 !if(!eq(AddrDW, 4), VReg_128,
1253 !if(!eq(AddrDW, 5), VReg_160,
1254 !if(!eq(AddrDW, 6), VReg_192,
1255 !if(!eq(AddrDW, 7), VReg_224,
1256 !if(!eq(AddrDW, 8), VReg_256,
1257 !if(!eq(AddrDW, 9), VReg_288,
1258 !if(!eq(AddrDW, 10), VReg_320,
1259 !if(!eq(AddrDW, 11), VReg_352,
1260 !if(!eq(AddrDW, 12), VReg_384,
1261 !if(!le(AddrDW, 16), VReg_512, ?))))))))))))));
1263 // Whether the instruction variant with this vaddr size should be enabled for
1264 // the auto-generated disassembler.
1265 bit Disassemble = enable_disasm;
1268 // Returns the MIMGAddrSize with the size of last VAddr for partial NSA
1269 class LastVAddrSize <int dw, int max_idx, bit enable_disasm>
1270 : MIMGAddrSize<dw, enable_disasm,
1271 !if(!gt(dw, max_idx), !sub(dw, max_idx), 0)>;
1273 // Return whether x is in lst.
1274 class isIntInList<int x, list<int> lst> {
1275 bit ret = !foldl(0, lst, lhs, y, !or(lhs, !eq(x, y)));
1278 // Return whether a value inside the range [min, max] (endpoints inclusive)
1279 // is in the given list.
1280 class isRangeInList<int min, int max, list<int> lst> {
1281 bit ret = !foldl(0, lst, lhs, y, !or(lhs, !and(!le(min, y), !le(y, max))));
1284 class MIMGAddrSizes_dw_range<list<int> range> {
1285 int Min = !head(range);
1286 int Max = !if(!empty(!tail(range)), Min, !head(!tail(range)));
1289 class MIMG_Sampler_AddrSizes<AMDGPUSampleVariant sample, bit isG16,
1290 int nsa_max_addr = 5, bit includeNSA1 = 0> {
1291 // List of all possible numbers of address words, taking all combinations of
1292 // A16 and image dimension into account (note: no MSAA, since this is for
1293 // sample/gather ops).
1294 list<int> AllNumAddrWords =
1295 !foreach(dw, !if(sample.Gradients,
1297 !if(!eq(sample.LodOrClamp, ""),
1299 [2, 3, 4, 5, 6, 7, 8]),
1300 !if(!eq(sample.LodOrClamp, ""),
1301 [2, 3, 4, 5, 6, 7, 8, 9],
1302 [2, 3, 4, 5, 6, 7, 8, 9, 10])),
1303 !if(!eq(sample.LodOrClamp, ""),
1306 !add(dw, !size(sample.ExtraAddrArgs)));
1308 // Generate machine instructions based on possible register classes for the
1309 // required numbers of address words. The disassembler defaults to the
1310 // smallest register class.
1311 list<MIMGAddrSize> MachineInstrs =
1312 !foldl([]<MIMGAddrSize>,
1314 // V4 is generated for V3 and V4
1315 // V8 is generated for V5 through V8
1316 // V16 is generated for V13 through V16
1317 [[1],[2],[3],[3,4],[5],[6],[7],[5,8],[9],[10],[11],[12],[13,16]],
1318 MIMGAddrSizes_dw_range<range>),
1320 !if(isRangeInList<dw.Min, dw.Max, AllNumAddrWords>.ret,
1321 !listconcat(lhs, [MIMGAddrSize<dw.Max, !empty(lhs)>]),
1324 // For NSA, generate machine instructions for all possible numbers of words
1325 // except 1 (which is already covered by the non-NSA case).
1326 // The disassembler defaults to the largest number of arguments among the
1327 // variants with the same number of NSA words, and custom code then derives
1328 // the exact variant based on the sample variant and the image dimension.
1329 list<MIMGAddrSize> NSAInstrs =
1330 !foldl([]<MIMGAddrSize>, [[12, 11, 10], [9, 8, 7, 6], [5, 4, 3, 2]], prev, nsa_group,
1332 !foldl([]<MIMGAddrSize>, nsa_group, lhs, dw,
1333 !if(isIntInList<dw, AllNumAddrWords>.ret,
1334 !listconcat(lhs, [MIMGAddrSize<dw, !empty(lhs)>]),
1337 // In NSA format if there is a requirement for more VGPRs than the format
1338 // supports, then the rest are sequential after the last one. Generate
1339 // machine instructions for all possible number of words. The disassembler
1340 // defaults to the largest number of arguments but no larger than max nsa
1341 // size. List is generated with the register class needed for last vaddr since
1342 // it is the only one that could have a register other than VGPR32.
1343 int EnableDisasmNum = !foldl(!head(AllNumAddrWords), !tail(AllNumAddrWords),
1344 acc, var, !if(!le(var, nsa_max_addr), var, acc));
1345 list<int> PossibleVariants =
1346 !listconcat([12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2], !if(includeNSA1, [1], []));
1347 list<LastVAddrSize> PartialNSAInstrs =
1348 !foldl([]<LastVAddrSize>, PossibleVariants, lhs, dw,
1349 !if(isIntInList<dw, AllNumAddrWords>.ret,
1350 !listconcat(lhs, [LastVAddrSize<dw, !sub(nsa_max_addr, 1),
1351 !eq(dw, EnableDisasmNum)>]),
1355 multiclass MIMG_Sampler_Src_Helper <mimgopc op, string asm,
1356 AMDGPUSampleVariant sample, RegisterClass dst_rc,
1357 bit enableDisasm = 0,
1358 bit ExtendedImageInst = 1, bit isG16 = 0> {
1359 foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.MachineInstrs in {
1360 let VAddrDwords = addr.NumWords in {
1361 if op.HAS_GFX10M then {
1362 def _V # addr.NumWords
1363 : MIMG_Sampler_Helper <op, asm, dst_rc, addr.RegClass,
1364 !if(!and(enableDisasm, addr.Disassemble), "GFX8", "")>;
1365 if !not(ExtendedImageInst) then
1366 def _V # addr.NumWords # _gfx90a
1367 : MIMG_Sampler_gfx90a <op, asm, dst_rc, addr.RegClass,
1368 !if(!and(enableDisasm, addr.Disassemble), "GFX90A", "")>;
1369 def _V # addr.NumWords # _gfx10
1370 : MIMG_Sampler_gfx10 <op, asm, dst_rc, addr.RegClass,
1371 !if(!and(enableDisasm, addr.Disassemble), "GFX10", "")>;
1373 if op.HAS_GFX11 then {
1374 def _V # addr.NumWords # _gfx11
1375 : MIMG_Sampler_gfx11 <op, asm, dst_rc, addr.RegClass,
1376 !if(!and(enableDisasm, addr.Disassemble), "GFX11", "")>;
1381 foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.NSAInstrs in {
1382 let VAddrDwords = addr.NumWords in {
1383 if op.HAS_GFX10M then {
1384 def _V # addr.NumWords # _nsa_gfx10
1385 : MIMG_Sampler_nsa_gfx10<op, asm, dst_rc, addr.NumWords,
1386 !if(!and(enableDisasm, addr.Disassemble), "GFX10", "")>;
1391 foreach addr = MIMG_Sampler_AddrSizes<sample, isG16, 5/*MaxNSASize*/>.PartialNSAInstrs in {
1392 let VAddrDwords = addr.NumWords in {
1393 if op.HAS_GFX11 then {
1394 def _V # addr.NumWords # _nsa_gfx11
1395 : MIMG_Sampler_nsa_gfx11<op, asm, dst_rc, addr.NumWords, addr.RegClass,
1396 !if(!and(enableDisasm, addr.Disassemble), "GFX11", "")>;
1401 foreach addr = MIMG_Sampler_AddrSizes<sample, isG16, 4/*MaxNSASize*/, 1>.PartialNSAInstrs in {
1402 let VAddrDwords = addr.NumWords in {
1403 if op.HAS_GFX12 then {
1404 def _V # addr.NumWords # _gfx12
1405 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, addr.NumWords, addr.RegClass,
1406 !if(!and(enableDisasm, addr.Disassemble), "GFX12", "")>;
1412 class MIMG_Sampler_BaseOpcode<AMDGPUSampleVariant sample>
1415 let NumExtraArgs = !size(sample.ExtraAddrArgs);
1416 let Gradients = sample.Gradients;
1417 let LodOrClampOrMip = !ne(sample.LodOrClamp, "");
1420 multiclass MIMG_Sampler_NoReturn <mimgopc op, AMDGPUSampleVariant sample, bit wqm = 0, bit isG16, string asm> {
1421 def "" : MIMG_Sampler_BaseOpcode<sample> {
1427 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME), WQM = wqm,
1428 mayLoad = 1, mayStore = 1, VDataDwords = 0 in {
1429 foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.MachineInstrs in {
1430 let VAddrDwords = addr.NumWords in {
1431 if op.HAS_GFX10M then {
1432 def _V # addr.NumWords # _gfx10
1433 : MIMG_Sampler_nortn_gfx10 <op, asm, addr.RegClass>;
1435 if op.HAS_GFX11 then {
1436 def _V # addr.NumWords # _gfx11
1437 : MIMG_Sampler_nortn_gfx11 <op, asm, addr.RegClass>;
1442 foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.NSAInstrs in {
1443 let VAddrDwords = addr.NumWords in {
1444 if op.HAS_GFX10M then {
1445 def _V # addr.NumWords # _nsa_gfx10
1446 : MIMG_Sampler_nortn_nsa_gfx10<op, asm, addr.NumWords>;
1451 foreach addr = MIMG_Sampler_AddrSizes<sample, isG16, 5/*MaxNSASize*/>.PartialNSAInstrs in {
1452 let VAddrDwords = addr.NumWords in {
1453 if op.HAS_GFX11 then {
1454 def _V # addr.NumWords # _nsa_gfx11
1455 : MIMG_Sampler_nortn_nsa_gfx11<op, asm, addr.NumWords, addr.RegClass>;
1460 foreach addr = MIMG_Sampler_AddrSizes<sample, isG16, 4/*MaxNSASize*/, 1>.PartialNSAInstrs in {
1461 let VAddrDwords = addr.NumWords in {
1462 if op.HAS_GFX12 then {
1463 def _V # addr.NumWords # _gfx12
1464 : VSAMPLE_Sampler_nortn_gfx12<op, asm, addr.NumWords, addr.RegClass>;
1471 multiclass MIMG_Sampler <mimgopc op, AMDGPUSampleVariant sample, bit wqm = 0,
1472 bit isG16 = 0, bit isGetLod = 0,
1473 string asm = "image_sample"#sample.LowerCaseMod#!if(isG16, "_g16", ""),
1474 bit ExtendedImageInst = !ne(sample.LowerCaseMod, "")> {
1475 def "" : MIMG_Sampler_BaseOpcode<sample> {
1476 let HasD16 = !not(isGetLod);
1480 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME), WQM = wqm,
1481 mayLoad = !not(isGetLod) in {
1482 let VDataDwords = 1 in
1483 defm _V1 : MIMG_Sampler_Src_Helper<op, asm, sample, VGPR_32, 1, ExtendedImageInst, isG16>;
1484 let VDataDwords = 2 in
1485 defm _V2 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_64, 0, ExtendedImageInst, isG16>;
1486 let VDataDwords = 3 in
1487 defm _V3 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_96, 0, ExtendedImageInst, isG16>;
1488 let VDataDwords = 4 in
1489 defm _V4 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_128, 0, ExtendedImageInst, isG16>;
1490 let VDataDwords = 5 in
1491 defm _V5 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_160, 0, ExtendedImageInst, isG16>;
1494 if !not(isGetLod) then
1495 defm "_nortn" : MIMG_Sampler_NoReturn <op, sample, wqm, isG16, asm>;
1498 multiclass MIMG_Sampler_WQM <mimgopc op, AMDGPUSampleVariant sample>
1499 : MIMG_Sampler<op, sample, 1>;
1501 multiclass MIMG_Gather <mimgopc op, AMDGPUSampleVariant sample, bit wqm = 0,
1502 string asm = "image_gather4"#sample.LowerCaseMod> {
1503 def "" : MIMG_Sampler_BaseOpcode<sample> {
1508 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME), WQM = wqm,
1510 let VDataDwords = 2 in
1511 defm _V2 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_64>; /* for packed D16 only */
1512 let VDataDwords = 4 in
1513 defm _V4 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_128, 1>;
1514 let VDataDwords = 5 in
1515 defm _V5 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_160>;
1519 multiclass MIMG_Gather_WQM <mimgopc op, AMDGPUSampleVariant sample>
1520 : MIMG_Gather<op, sample, 1>;
1522 class MIMG_IntersectRay_Helper<bit Is64, bit IsA16> {
1523 int num_addrs = !if(Is64, !if(IsA16, 9, 12), !if(IsA16, 8, 11));
1524 RegisterClass RegClass = MIMGAddrSize<num_addrs, 0>.RegClass;
1525 int VAddrDwords = !srl(RegClass.Size, 5);
1527 int GFX11PlusNSAAddrs = !if(IsA16, 4, 5);
1528 RegisterClass node_ptr_type = !if(Is64, VReg_64, VGPR_32);
1529 list<RegisterClass> GFX11PlusAddrTypes =
1531 [node_ptr_type, VGPR_32, VReg_96, VReg_96],
1532 [node_ptr_type, VGPR_32, VReg_96, VReg_96, VReg_96]);
1535 class MIMG_IntersectRay_gfx10<mimgopc op, string opcode, RegisterClass AddrRC>
1536 : MIMG_gfx10<op.GFX10M, (outs VReg_128:$vdata), "GFX10"> {
1537 let InOperandList = (ins AddrRC:$vaddr0, SReg_128:$srsrc, A16:$a16);
1538 let AsmString = opcode#" $vdata, $vaddr0, $srsrc$a16";
1543 class MIMG_IntersectRay_nsa_gfx10<mimgopc op, string opcode, int num_addrs>
1544 : MIMG_nsa_gfx10<op.GFX10M, (outs VReg_128:$vdata), num_addrs, "GFX10"> {
1545 let InOperandList = !con(nsah.AddrIns, (ins SReg_128:$srsrc, A16:$a16));
1546 let AsmString = opcode#" $vdata, "#nsah.AddrAsm#", $srsrc$a16";
1549 class MIMG_IntersectRay_gfx11<mimgopc op, string opcode, RegisterClass AddrRC>
1550 : MIMG_gfx11<op.GFX11, (outs VReg_128:$vdata), "GFX11"> {
1551 let InOperandList = (ins AddrRC:$vaddr0, SReg_128:$srsrc, A16:$a16);
1552 let AsmString = opcode#" $vdata, $vaddr0, $srsrc$a16";
1557 class MIMG_IntersectRay_nsa_gfx11<mimgopc op, string opcode, int num_addrs,
1558 list<RegisterClass> addr_types>
1559 : MIMG_nsa_gfx11<op.GFX11, (outs VReg_128:$vdata), num_addrs, "GFX11",
1561 let InOperandList = !con(nsah.AddrIns, (ins SReg_128:$srsrc, A16:$a16));
1562 let AsmString = opcode#" $vdata, "#nsah.AddrAsm#", $srsrc$a16";
1565 class VIMAGE_IntersectRay_gfx12<mimgopc op, string opcode, int num_addrs,
1566 list<RegisterClass> addr_types>
1567 : VIMAGE_gfx12<op.GFX12, (outs VReg_128:$vdata),
1568 num_addrs, "GFX12", addr_types> {
1569 let InOperandList = !con(nsah.AddrIns, (ins SReg_128:$rsrc, A16:$a16));
1570 let AsmString = opcode#" $vdata, "#nsah.AddrAsm#", $rsrc$a16";
1573 multiclass MIMG_IntersectRay<mimgopc op, string opcode, bit Is64, bit IsA16> {
1574 defvar info = MIMG_IntersectRay_Helper<Is64, IsA16>;
1575 def "" : MIMGBaseOpcode {
1587 BaseOpcode = !cast<MIMGBaseOpcode>(NAME),
1588 VDataDwords = 4 in {
1592 if op.HAS_GFX10M then
1593 def _sa_gfx10 : MIMG_IntersectRay_gfx10<op, opcode, info.RegClass> {
1594 let VAddrDwords = info.VAddrDwords;
1596 if op.HAS_GFX11 then
1597 def _sa_gfx11 : MIMG_IntersectRay_gfx11<op, opcode, info.RegClass> {
1598 let VAddrDwords = info.VAddrDwords;
1600 if op.HAS_GFX10M then
1601 def _nsa_gfx10 : MIMG_IntersectRay_nsa_gfx10<op, opcode, info.num_addrs> {
1602 let VAddrDwords = info.num_addrs;
1604 if op.HAS_GFX11 then
1605 def _nsa_gfx11 : MIMG_IntersectRay_nsa_gfx11<op, opcode,
1606 info.GFX11PlusNSAAddrs,
1607 info.GFX11PlusAddrTypes> {
1608 let VAddrDwords = info.num_addrs;
1611 def _gfx12 : VIMAGE_IntersectRay_gfx12<op, opcode, info.GFX11PlusNSAAddrs,
1612 info.GFX11PlusAddrTypes> {
1613 let VAddrDwords = info.num_addrs;
1618 multiclass MIMG_MSAA_Load <mimgopc op, string asm> {
1619 def "" : MIMGBaseOpcode {
1621 let Gather4 = 1; /* for appropriate dmask handling */
1625 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME),
1626 Gather4 = 1, hasPostISelHook = 0, mayLoad = 1 in {
1627 let VDataDwords = 2 in
1628 defm _V2 : MIMG_NoSampler_Src_Helper<op, asm, VReg_64, 0, 0, 1>; /* packed D16 */
1629 let VDataDwords = 3 in
1630 defm _V3 : MIMG_NoSampler_Src_Helper<op, asm, VReg_96, 0, 0, 1>; /* packed D16 + tfe */
1631 let VDataDwords = 4 in
1632 defm _V4 : MIMG_NoSampler_Src_Helper<op, asm, VReg_128, 1, 0, 1>;
1633 let VDataDwords = 5 in
1634 defm _V5 : MIMG_NoSampler_Src_Helper<op, asm, VReg_160, 0, 0, 1>;
1638 //===----------------------------------------------------------------------===//
1639 // MIMG Instructions
1640 //===----------------------------------------------------------------------===//
1641 let OtherPredicates = [HasImageInsts] in {
1643 defm IMAGE_LOAD : MIMG_NoSampler <mimgopc<0x00, 0x00, 0x00>, "image_load", 1>;
1644 defm IMAGE_LOAD_MIP : MIMG_NoSampler <mimgopc<0x01, 0x01, 0x01>, "image_load_mip", 1, 1>;
1645 defm IMAGE_LOAD_PCK : MIMG_NoSampler <mimgopc<0x02, 0x02, 0x02>, "image_load_pck", 0>;
1646 defm IMAGE_LOAD_PCK_SGN : MIMG_NoSampler <mimgopc<0x03, 0x03, 0x03>, "image_load_pck_sgn", 0>;
1647 defm IMAGE_LOAD_MIP_PCK : MIMG_NoSampler <mimgopc<0x04, 0x04, 0x04>, "image_load_mip_pck", 0, 1>;
1648 defm IMAGE_LOAD_MIP_PCK_SGN : MIMG_NoSampler <mimgopc<0x05, 0x05, 0x05>, "image_load_mip_pck_sgn", 0, 1>;
1649 defm IMAGE_STORE : MIMG_Store <mimgopc<0x06, 0x06, 0x08>, "image_store", 1>;
1650 defm IMAGE_STORE_MIP : MIMG_Store <mimgopc<0x07, 0x07, 0x09>, "image_store_mip", 1, 1>;
1651 defm IMAGE_STORE_PCK : MIMG_Store <mimgopc<0x08, 0x08, 0x0a>, "image_store_pck", 0>;
1652 defm IMAGE_STORE_MIP_PCK : MIMG_Store <mimgopc<0x09, 0x09, 0x0b>, "image_store_mip_pck", 0, 1>;
1654 defm IMAGE_GET_RESINFO : MIMG_NoSampler <mimgopc<0x17, 0x17, 0x0e, 0x0e, 0x0e>, "image_get_resinfo", 0, 1, 1>;
1656 defm IMAGE_ATOMIC_SWAP : MIMG_Atomic <mimgopc<0x0a, 0x0a, 0x0f, 0x10, 0x0f>, "image_atomic_swap">;
1657 defm IMAGE_ATOMIC_CMPSWAP : MIMG_Atomic <mimgopc<0x0b, 0x0b, 0x10, 0x11, 0x10>, "image_atomic_cmpswap", 1>;
1658 defm IMAGE_ATOMIC_ADD : MIMG_Atomic_Renamed <mimgopc<0x0c, 0x0c, 0x11, 0x12, 0x11>, "image_atomic_add", "image_atomic_add_uint">;
1659 defm IMAGE_ATOMIC_SUB : MIMG_Atomic_Renamed <mimgopc<0x0d, 0x0d, 0x12, 0x13, 0x12>, "image_atomic_sub", "image_atomic_sub_uint">;
1660 defm IMAGE_ATOMIC_RSUB : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, MIMG.NOP, MIMG.NOP, 0x13>, "image_atomic_rsub">;
1661 defm IMAGE_ATOMIC_SMIN : MIMG_Atomic_Renamed <mimgopc<0x0e, 0x0e, 0x14>, "image_atomic_smin", "image_atomic_min_int">;
1662 defm IMAGE_ATOMIC_UMIN : MIMG_Atomic_Renamed <mimgopc<0x0f, 0x0f, 0x15>, "image_atomic_umin", "image_atomic_min_uint">;
1663 defm IMAGE_ATOMIC_SMAX : MIMG_Atomic_Renamed <mimgopc<0x10, 0x10, 0x16>, "image_atomic_smax", "image_atomic_max_int">;
1664 defm IMAGE_ATOMIC_UMAX : MIMG_Atomic_Renamed <mimgopc<0x11, 0x11, 0x17>, "image_atomic_umax", "image_atomic_max_uint">;
1665 defm IMAGE_ATOMIC_AND : MIMG_Atomic <mimgopc<0x12, 0x12, 0x18>, "image_atomic_and">;
1666 defm IMAGE_ATOMIC_OR : MIMG_Atomic <mimgopc<0x13, 0x13, 0x19>, "image_atomic_or">;
1667 defm IMAGE_ATOMIC_XOR : MIMG_Atomic <mimgopc<0x14, 0x14, 0x1a>, "image_atomic_xor">;
1668 defm IMAGE_ATOMIC_INC : MIMG_Atomic_Renamed <mimgopc<0x15, 0x15, 0x1b>, "image_atomic_inc", "image_atomic_inc_uint">;
1669 defm IMAGE_ATOMIC_DEC : MIMG_Atomic_Renamed <mimgopc<0x16, 0x16, 0x1c>, "image_atomic_dec", "image_atomic_dec_uint">;
1670 defm IMAGE_ATOMIC_FCMPSWAP : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, 0x1d, MIMG.NOP>, "image_atomic_fcmpswap", 1, 1>;
1671 defm IMAGE_ATOMIC_FMIN : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, 0x1e, MIMG.NOP>, "image_atomic_fmin", 0, 1>;
1672 defm IMAGE_ATOMIC_FMAX : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, 0x1f, MIMG.NOP>, "image_atomic_fmax", 0, 1>;
1673 defm IMAGE_ATOMIC_PK_ADD_F16 : MIMG_Atomic <mimgopc<0x86, MIMG.NOP, MIMG.NOP, MIMG.NOP, MIMG.NOP>, "image_atomic_pk_add_f16", 0, 1>;
1674 defm IMAGE_ATOMIC_PK_ADD_BF16 : MIMG_Atomic <mimgopc<0x87, MIMG.NOP, MIMG.NOP, MIMG.NOP, MIMG.NOP>, "image_atomic_pk_add_bf16", 0, 1>;
1675 defm IMAGE_ATOMIC_ADD_FLT : MIMG_Atomic <mimgopc<0x83, MIMG.NOP, MIMG.NOP, MIMG.NOP>, "image_atomic_add_flt", 0, 1>;
1676 defm 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">;
1677 defm 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">;
1679 defm IMAGE_SAMPLE : MIMG_Sampler_WQM <mimgopc<0x1b, 0x1b, 0x20>, AMDGPUSample>;
1680 let OtherPredicates = [HasImageInsts, HasExtendedImageInsts] in {
1681 defm IMAGE_SAMPLE_CL : MIMG_Sampler_WQM <mimgopc<0x40, 0x40, 0x21>, AMDGPUSample_cl>;
1682 defm IMAGE_SAMPLE_D : MIMG_Sampler <mimgopc<0x1c, 0x1c, 0x22>, AMDGPUSample_d>;
1683 defm IMAGE_SAMPLE_D_CL : MIMG_Sampler <mimgopc<0x41, 0x41, 0x23>, AMDGPUSample_d_cl>;
1684 defm IMAGE_SAMPLE_L : MIMG_Sampler <mimgopc<0x1d, 0x1d, 0x24>, AMDGPUSample_l>;
1685 defm IMAGE_SAMPLE_B : MIMG_Sampler_WQM <mimgopc<0x1e, 0x1e, 0x25>, AMDGPUSample_b>;
1686 defm IMAGE_SAMPLE_B_CL : MIMG_Sampler_WQM <mimgopc<0x42, 0x42, 0x26>, AMDGPUSample_b_cl>;
1687 defm IMAGE_SAMPLE_LZ : MIMG_Sampler <mimgopc<0x1f, 0x1f, 0x27>, AMDGPUSample_lz>;
1688 defm IMAGE_SAMPLE_C : MIMG_Sampler_WQM <mimgopc<0x20, 0x20, 0x28>, AMDGPUSample_c>;
1689 defm IMAGE_SAMPLE_C_CL : MIMG_Sampler_WQM <mimgopc<0x43, 0x43, 0x29>, AMDGPUSample_c_cl>;
1690 defm IMAGE_SAMPLE_C_D : MIMG_Sampler <mimgopc<0x21, 0x21, 0x2a>, AMDGPUSample_c_d>;
1691 defm IMAGE_SAMPLE_C_D_CL : MIMG_Sampler <mimgopc<0x44, 0x44, 0x2b>, AMDGPUSample_c_d_cl>;
1692 defm IMAGE_SAMPLE_C_L : MIMG_Sampler <mimgopc<0x22, 0x22, 0x2c>, AMDGPUSample_c_l>;
1693 defm IMAGE_SAMPLE_C_B : MIMG_Sampler_WQM <mimgopc<0x23, 0x23, 0x2d>, AMDGPUSample_c_b>;
1694 defm IMAGE_SAMPLE_C_B_CL : MIMG_Sampler_WQM <mimgopc<0x45, 0x45, 0x2e>, AMDGPUSample_c_b_cl>;
1695 defm IMAGE_SAMPLE_C_LZ : MIMG_Sampler <mimgopc<0x24, 0x24, 0x2f>, AMDGPUSample_c_lz>;
1696 defm IMAGE_SAMPLE_O : MIMG_Sampler_WQM <mimgopc<0x25, 0x25, 0x30>, AMDGPUSample_o>;
1697 defm IMAGE_SAMPLE_CL_O : MIMG_Sampler_WQM <mimgopc<0x46, 0x46, 0x31>, AMDGPUSample_cl_o>;
1698 defm IMAGE_SAMPLE_D_O : MIMG_Sampler <mimgopc<0x26, 0x26, 0x32>, AMDGPUSample_d_o>;
1699 defm IMAGE_SAMPLE_D_CL_O : MIMG_Sampler <mimgopc<0x47, 0x47, 0x33>, AMDGPUSample_d_cl_o>;
1700 defm IMAGE_SAMPLE_L_O : MIMG_Sampler <mimgopc<0x27, 0x27, 0x34>, AMDGPUSample_l_o>;
1701 defm IMAGE_SAMPLE_B_O : MIMG_Sampler_WQM <mimgopc<0x28, 0x28, 0x35>, AMDGPUSample_b_o>;
1702 defm IMAGE_SAMPLE_B_CL_O : MIMG_Sampler_WQM <mimgopc<0x48, 0x48, 0x36>, AMDGPUSample_b_cl_o>;
1703 defm IMAGE_SAMPLE_LZ_O : MIMG_Sampler <mimgopc<0x29, 0x29, 0x37>, AMDGPUSample_lz_o>;
1704 defm IMAGE_SAMPLE_C_O : MIMG_Sampler_WQM <mimgopc<0x2a, 0x2a, 0x38>, AMDGPUSample_c_o>;
1705 defm IMAGE_SAMPLE_C_CL_O : MIMG_Sampler_WQM <mimgopc<0x49, 0x49, 0x39>, AMDGPUSample_c_cl_o>;
1706 defm IMAGE_SAMPLE_C_D_O : MIMG_Sampler <mimgopc<0x2b, 0x2b, 0x3a>, AMDGPUSample_c_d_o>;
1707 defm IMAGE_SAMPLE_C_D_CL_O : MIMG_Sampler <mimgopc<0x4a, 0x4a, 0x3b>, AMDGPUSample_c_d_cl_o>;
1708 defm IMAGE_SAMPLE_C_L_O : MIMG_Sampler <mimgopc<0x2c, 0x2c, 0x3c>, AMDGPUSample_c_l_o>;
1709 defm IMAGE_SAMPLE_C_B_CL_O : MIMG_Sampler_WQM <mimgopc<0x4b, 0x4b, 0x3e>, AMDGPUSample_c_b_cl_o>;
1710 defm IMAGE_SAMPLE_C_B_O : MIMG_Sampler_WQM <mimgopc<0x2d, 0x2d, 0x3d>, AMDGPUSample_c_b_o>;
1711 defm IMAGE_SAMPLE_C_LZ_O : MIMG_Sampler <mimgopc<0x2e, 0x2e, 0x3f>, AMDGPUSample_c_lz_o>;
1712 defm IMAGE_GATHER4 : MIMG_Gather_WQM <mimgopc<0x2f, 0x2f, 0x40>, AMDGPUSample>;
1713 defm IMAGE_GATHER4_CL : MIMG_Gather_WQM <mimgopc<0x60, 0x60, 0x41>, AMDGPUSample_cl>;
1714 defm IMAGE_GATHER4_L : MIMG_Gather <mimgopc<0x30, 0x30, 0x44>, AMDGPUSample_l>;
1715 defm IMAGE_GATHER4_B : MIMG_Gather_WQM <mimgopc<0x31, 0x31, 0x45>, AMDGPUSample_b>;
1716 defm IMAGE_GATHER4_B_CL : MIMG_Gather_WQM <mimgopc<0x61, 0x61, 0x46>, AMDGPUSample_b_cl>;
1717 defm IMAGE_GATHER4_LZ : MIMG_Gather <mimgopc<0x32, 0x32, 0x47>, AMDGPUSample_lz>;
1718 defm IMAGE_GATHER4_C : MIMG_Gather_WQM <mimgopc<0x33, 0x33, 0x48>, AMDGPUSample_c>;
1719 defm IMAGE_GATHER4_C_CL : MIMG_Gather_WQM <mimgopc<0x62, 0x62, 0x49>, AMDGPUSample_c_cl>;
1720 defm IMAGE_GATHER4_C_L : MIMG_Gather <mimgopc<0x63, 0x63, 0x4c>, AMDGPUSample_c_l>;
1721 defm IMAGE_GATHER4_C_B : MIMG_Gather_WQM <mimgopc<0x64, 0x64, 0x4d>, AMDGPUSample_c_b>;
1722 defm IMAGE_GATHER4_C_B_CL : MIMG_Gather_WQM <mimgopc<0x65, 0x65, 0x4e>, AMDGPUSample_c_b_cl>;
1723 defm IMAGE_GATHER4_C_LZ : MIMG_Gather <mimgopc<0x34, 0x34, 0x4f>, AMDGPUSample_c_lz>;
1724 defm IMAGE_GATHER4_O : MIMG_Gather_WQM <mimgopc<0x35, 0x35, 0x50>, AMDGPUSample_o>;
1725 defm IMAGE_GATHER4_CL_O : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x51>, AMDGPUSample_cl_o>;
1726 defm IMAGE_GATHER4_L_O : MIMG_Gather <mimgopc<MIMG.NOP, MIMG.NOP, 0x54>, AMDGPUSample_l_o>;
1727 defm IMAGE_GATHER4_B_O : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x55>, AMDGPUSample_b_o>;
1728 defm IMAGE_GATHER4_B_CL_O : MIMG_Gather <mimgopc<MIMG.NOP, MIMG.NOP, 0x56>, AMDGPUSample_b_cl_o>;
1729 defm IMAGE_GATHER4_LZ_O : MIMG_Gather <mimgopc<0x36, 0x36, 0x57>, AMDGPUSample_lz_o>;
1730 defm IMAGE_GATHER4_C_O : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x58>, AMDGPUSample_c_o>;
1731 defm IMAGE_GATHER4_C_CL_O : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x59>, AMDGPUSample_c_cl_o>;
1732 defm IMAGE_GATHER4_C_L_O : MIMG_Gather <mimgopc<MIMG.NOP, MIMG.NOP, 0x5c>, AMDGPUSample_c_l_o>;
1733 defm IMAGE_GATHER4_C_B_O : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x5d>, AMDGPUSample_c_b_o>;
1734 defm IMAGE_GATHER4_C_B_CL_O : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x5e>, AMDGPUSample_c_b_cl_o>;
1735 defm IMAGE_GATHER4_C_LZ_O : MIMG_Gather <mimgopc<0x37, 0x37, 0x5f>, AMDGPUSample_c_lz_o>;
1737 let OtherPredicates = [HasImageInsts, HasExtendedImageInsts, isGFX9Plus] in
1738 defm IMAGE_GATHER4H : MIMG_Gather <mimgopc<0x90, 0x90, 0x61, 0x42>, AMDGPUSample, 1, "image_gather4h">;
1740 defm IMAGE_GET_LOD : MIMG_Sampler <mimgopc<0x38, 0x38, 0x60>, AMDGPUSample, 1, 0, 1, "image_get_lod">;
1742 defm IMAGE_SAMPLE_CD : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x68>, AMDGPUSample_cd>;
1743 defm IMAGE_SAMPLE_CD_CL : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x69>, AMDGPUSample_cd_cl>;
1744 defm IMAGE_SAMPLE_C_CD : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6a>, AMDGPUSample_c_cd>;
1745 defm IMAGE_SAMPLE_C_CD_CL : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6b>, AMDGPUSample_c_cd_cl>;
1746 defm IMAGE_SAMPLE_CD_O : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6c>, AMDGPUSample_cd_o>;
1747 defm IMAGE_SAMPLE_CD_CL_O : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6d>, AMDGPUSample_cd_cl_o>;
1748 defm IMAGE_SAMPLE_C_CD_O : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6e>, AMDGPUSample_c_cd_o>;
1749 defm IMAGE_SAMPLE_C_CD_CL_O : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6f>, AMDGPUSample_c_cd_cl_o>;
1750 } // End OtherPredicates = [HasImageInsts, HasExtendedImageInsts]
1752 let OtherPredicates = [HasImageInsts, HasExtendedImageInsts, HasG16] in {
1753 defm IMAGE_SAMPLE_D_G16 : MIMG_Sampler <mimgopc<0x39, 0x39, 0xa2>, AMDGPUSample_d, 0, 1>;
1754 defm IMAGE_SAMPLE_D_CL_G16 : MIMG_Sampler <mimgopc<0x5f, 0x5f, 0xa3>, AMDGPUSample_d_cl, 0, 1>;
1755 defm IMAGE_SAMPLE_C_D_G16 : MIMG_Sampler <mimgopc<0x3a, 0x3a, 0xaa>, AMDGPUSample_c_d, 0, 1>;
1756 defm IMAGE_SAMPLE_C_D_CL_G16 : MIMG_Sampler <mimgopc<0x54, 0x54, 0xab>, AMDGPUSample_c_d_cl, 0, 1>;
1757 defm IMAGE_SAMPLE_D_O_G16 : MIMG_Sampler <mimgopc<0x3b, 0x3b, 0xb2>, AMDGPUSample_d_o, 0, 1>;
1758 defm IMAGE_SAMPLE_D_CL_O_G16 : MIMG_Sampler <mimgopc<0x55, 0x55, 0xb3>, AMDGPUSample_d_cl_o, 0, 1>;
1759 defm IMAGE_SAMPLE_C_D_O_G16 : MIMG_Sampler <mimgopc<0x3c, 0x3c, 0xba>, AMDGPUSample_c_d_o, 0, 1>;
1760 defm IMAGE_SAMPLE_C_D_CL_O_G16 : MIMG_Sampler <mimgopc<0x56, 0x56, 0xbb>, AMDGPUSample_c_d_cl_o, 0, 1>;
1761 defm IMAGE_SAMPLE_CD_G16 : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xe8>, AMDGPUSample_cd, 0, 1>;
1762 defm IMAGE_SAMPLE_CD_CL_G16 : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xe9>, AMDGPUSample_cd_cl, 0, 1>;
1763 defm IMAGE_SAMPLE_C_CD_G16 : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xea>, AMDGPUSample_c_cd, 0, 1>;
1764 defm IMAGE_SAMPLE_C_CD_CL_G16 : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xeb>, AMDGPUSample_c_cd_cl, 0, 1>;
1765 defm IMAGE_SAMPLE_CD_O_G16 : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xec>, AMDGPUSample_cd_o, 0, 1>;
1766 defm IMAGE_SAMPLE_CD_CL_O_G16 : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xed>, AMDGPUSample_cd_cl_o, 0, 1>;
1767 defm IMAGE_SAMPLE_C_CD_O_G16 : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xee>, AMDGPUSample_c_cd_o, 0, 1>;
1768 defm IMAGE_SAMPLE_C_CD_CL_O_G16 : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xef>, AMDGPUSample_c_cd_cl_o, 0, 1>;
1769 } // End OtherPredicates = [HasImageInsts, HasExtendedImageInsts, HasG16]
1771 //def IMAGE_RSRC256 : MIMG_NoPattern_RSRC256 <"image_rsrc256", mimgopc<0x7e>>;
1772 //def IMAGE_SAMPLER : MIMG_NoPattern_ <"image_sampler", mimgopc<0x7f>>;
1774 let OtherPredicates = [HasImageInsts, HasGFX10_AEncoding, isGFX10Only] in
1775 defm IMAGE_MSAA_LOAD_X : MIMG_NoSampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x80>, "image_msaa_load", 1, 0, 0, 1>;
1777 let OtherPredicates = [HasImageInsts, HasGFX10_AEncoding] in {
1778 defm IMAGE_MSAA_LOAD : MIMG_MSAA_Load <mimgopc<0x18, 0x18, MIMG.NOP>, "image_msaa_load">;
1780 defm IMAGE_BVH_INTERSECT_RAY : MIMG_IntersectRay<mimgopc<0x19, 0x19, 0xe6>, "image_bvh_intersect_ray", 0, 0>;
1781 defm IMAGE_BVH_INTERSECT_RAY_a16 : MIMG_IntersectRay<mimgopc<0x19, 0x19, 0xe6>, "image_bvh_intersect_ray", 0, 1>;
1782 defm IMAGE_BVH64_INTERSECT_RAY : MIMG_IntersectRay<mimgopc<0x1a, 0x1a, 0xe7>, "image_bvh64_intersect_ray", 1, 0>;
1783 defm IMAGE_BVH64_INTERSECT_RAY_a16 : MIMG_IntersectRay<mimgopc<0x1a, 0x1a, 0xe7>, "image_bvh64_intersect_ray", 1, 1>;
1784 } // End OtherPredicates = [HasImageInsts, HasGFX10_AEncoding]
1786 } // End let OtherPredicates = [HasImageInsts]
1788 /********** ========================================= **********/
1789 /********** Table of dimension-aware image intrinsics **********/
1790 /********** ========================================= **********/
1792 class ImageDimIntrinsicInfo<AMDGPUImageDimIntrinsic I> {
1794 MIMGBaseOpcode BaseOpcode = !cast<MIMGBaseOpcode>(!strconcat("IMAGE_", I.P.OpMod));
1795 AMDGPUDimProps Dim = I.P.Dim;
1796 AMDGPUImageDimIntrinsicEval DimEval = AMDGPUImageDimIntrinsicEval<I.P>;
1798 bits<8> NumOffsetArgs = DimEval.NumOffsetArgs;
1799 bits<8> NumBiasArgs = DimEval.NumBiasArgs;
1800 bits<8> NumZCompareArgs = DimEval.NumZCompareArgs;
1801 bits<8> NumGradients = DimEval.NumGradientArgs;
1802 bits<8> NumDmask = DimEval.NumDmaskArgs;
1803 bits<8> NumData = DimEval.NumDataArgs;
1804 bits<8> NumVAddrs = DimEval.NumVAddrArgs;
1805 bits<8> NumArgs = !add(DimEval.CachePolicyArgIndex, 1);
1807 bits<8> DMaskIndex = DimEval.DmaskArgIndex;
1808 bits<8> VAddrStart = DimEval.VAddrArgIndex;
1809 bits<8> OffsetIndex = DimEval.OffsetArgIndex;
1810 bits<8> BiasIndex = DimEval.BiasArgIndex;
1811 bits<8> ZCompareIndex = DimEval.ZCompareArgIndex;
1812 bits<8> GradientStart = DimEval.GradientArgIndex;
1813 bits<8> CoordStart = DimEval.CoordArgIndex;
1814 bits<8> LodIndex = DimEval.LodArgIndex;
1815 bits<8> MipIndex = DimEval.MipArgIndex;
1816 bits<8> VAddrEnd = !add(DimEval.VAddrArgIndex, DimEval.NumVAddrArgs);
1817 bits<8> RsrcIndex = DimEval.RsrcArgIndex;
1818 bits<8> SampIndex = DimEval.SampArgIndex;
1819 bits<8> UnormIndex = DimEval.UnormArgIndex;
1820 bits<8> TexFailCtrlIndex = DimEval.TexFailCtrlArgIndex;
1821 bits<8> CachePolicyIndex = DimEval.CachePolicyArgIndex;
1823 bits<8> BiasTyArg = !add(I.P.NumRetAndDataAnyTypes,
1824 !if(!eq(NumOffsetArgs, 0), 0, I.P.ExtraAddrArgs[0].Type.isAny));
1825 bits<8> GradientTyArg = !add(I.P.NumRetAndDataAnyTypes,
1826 !foldl(0, I.P.ExtraAddrArgs, cnt, arg, !add(cnt, arg.Type.isAny)));
1827 bits<8> CoordTyArg = !add(GradientTyArg, !if(I.P.Gradients, 1, 0));
1830 def ImageDimIntrinsicTable : GenericTable {
1831 let FilterClass = "ImageDimIntrinsicInfo";
1832 let Fields = ["Intr", "BaseOpcode", "Dim", "NumOffsetArgs", "NumBiasArgs", "NumZCompareArgs", "NumGradients", "NumDmask", "NumData", "NumVAddrs", "NumArgs",
1833 "DMaskIndex", "VAddrStart", "OffsetIndex", "BiasIndex", "ZCompareIndex", "GradientStart", "CoordStart", "LodIndex", "MipIndex", "VAddrEnd",
1834 "RsrcIndex", "SampIndex", "UnormIndex", "TexFailCtrlIndex", "CachePolicyIndex",
1835 "BiasTyArg", "GradientTyArg", "CoordTyArg"];
1836 string TypeOf_BaseOpcode = "MIMGBaseOpcode";
1837 string TypeOf_Dim = "MIMGDim";
1839 let PrimaryKey = ["Intr"];
1840 let PrimaryKeyName = "getImageDimIntrinsicInfo";
1841 let PrimaryKeyEarlyOut = 1;
1844 def getImageDimIntrinsicByBaseOpcode : SearchIndex {
1845 let Table = ImageDimIntrinsicTable;
1846 let Key = ["BaseOpcode", "Dim"];
1849 foreach intr = !listconcat(AMDGPUImageDimIntrinsics,
1850 AMDGPUImageDimAtomicIntrinsics) in {
1851 def : ImageDimIntrinsicInfo<intr>;
1854 // L to LZ Optimization Mapping
1855 def : MIMGLZMapping<IMAGE_SAMPLE_L, IMAGE_SAMPLE_LZ>;
1856 def : MIMGLZMapping<IMAGE_SAMPLE_C_L, IMAGE_SAMPLE_C_LZ>;
1857 def : MIMGLZMapping<IMAGE_SAMPLE_L_O, IMAGE_SAMPLE_LZ_O>;
1858 def : MIMGLZMapping<IMAGE_SAMPLE_C_L_O, IMAGE_SAMPLE_C_LZ_O>;
1859 def : MIMGLZMapping<IMAGE_GATHER4_L, IMAGE_GATHER4_LZ>;
1860 def : MIMGLZMapping<IMAGE_GATHER4_C_L, IMAGE_GATHER4_C_LZ>;
1861 def : MIMGLZMapping<IMAGE_GATHER4_L_O, IMAGE_GATHER4_LZ_O>;
1862 def : MIMGLZMapping<IMAGE_GATHER4_C_L_O, IMAGE_GATHER4_C_LZ_O>;
1863 def : MIMGLZMapping<IMAGE_SAMPLE_L_nortn, IMAGE_SAMPLE_LZ_nortn>;
1864 def : MIMGLZMapping<IMAGE_SAMPLE_C_L_nortn, IMAGE_SAMPLE_C_LZ_nortn>;
1865 def : MIMGLZMapping<IMAGE_SAMPLE_L_O_nortn, IMAGE_SAMPLE_LZ_O_nortn>;
1866 def : MIMGLZMapping<IMAGE_SAMPLE_C_L_O_nortn, IMAGE_SAMPLE_C_LZ_O_nortn>;
1868 // MIP to NONMIP Optimization Mapping
1869 def : MIMGMIPMapping<IMAGE_LOAD_MIP, IMAGE_LOAD>;
1870 def : MIMGMIPMapping<IMAGE_STORE_MIP, IMAGE_STORE>;
1872 // Bias to NoBias Optimization Mapping
1873 def : MIMGBiasMapping<IMAGE_SAMPLE_B, IMAGE_SAMPLE>;
1874 def : MIMGBiasMapping<IMAGE_SAMPLE_B_CL, IMAGE_SAMPLE_CL>;
1875 def : MIMGBiasMapping<IMAGE_SAMPLE_C_B, IMAGE_SAMPLE_C>;
1876 def : MIMGBiasMapping<IMAGE_SAMPLE_C_B_CL, IMAGE_SAMPLE_C_CL>;
1877 def : MIMGBiasMapping<IMAGE_SAMPLE_B_O, IMAGE_SAMPLE_O>;
1878 def : MIMGBiasMapping<IMAGE_SAMPLE_B_CL_O, IMAGE_SAMPLE_CL_O>;
1879 def : MIMGBiasMapping<IMAGE_SAMPLE_C_B_O, IMAGE_SAMPLE_C_O>;
1880 def : MIMGBiasMapping<IMAGE_SAMPLE_C_B_CL_O, IMAGE_SAMPLE_C_CL_O>;
1881 def : MIMGBiasMapping<IMAGE_GATHER4_B, IMAGE_GATHER4>;
1882 def : MIMGBiasMapping<IMAGE_GATHER4_B_CL, IMAGE_GATHER4_CL>;
1883 def : MIMGBiasMapping<IMAGE_GATHER4_C_B, IMAGE_GATHER4_C>;
1884 def : MIMGBiasMapping<IMAGE_GATHER4_C_B_CL, IMAGE_GATHER4_C_CL>;
1885 def : MIMGBiasMapping<IMAGE_GATHER4_B_O, IMAGE_GATHER4_O>;
1886 def : MIMGBiasMapping<IMAGE_GATHER4_B_CL_O, IMAGE_GATHER4_CL_O>;
1887 def : MIMGBiasMapping<IMAGE_GATHER4_C_B_O, IMAGE_GATHER4_C_O>;
1888 def : MIMGBiasMapping<IMAGE_GATHER4_C_B_CL_O, IMAGE_GATHER4_C_CL_O>;
1889 def : MIMGBiasMapping<IMAGE_SAMPLE_B_nortn, IMAGE_SAMPLE_nortn>;
1890 def : MIMGBiasMapping<IMAGE_SAMPLE_B_CL_nortn, IMAGE_SAMPLE_CL_nortn>;
1891 def : MIMGBiasMapping<IMAGE_SAMPLE_C_B_nortn, IMAGE_SAMPLE_C_nortn>;
1892 def : MIMGBiasMapping<IMAGE_SAMPLE_C_B_CL_nortn, IMAGE_SAMPLE_C_CL_nortn>;
1893 def : MIMGBiasMapping<IMAGE_SAMPLE_B_O_nortn, IMAGE_SAMPLE_O_nortn>;
1894 def : MIMGBiasMapping<IMAGE_SAMPLE_B_CL_O_nortn, IMAGE_SAMPLE_CL_O_nortn>;
1895 def : MIMGBiasMapping<IMAGE_SAMPLE_C_B_O_nortn, IMAGE_SAMPLE_C_O_nortn>;
1896 def : MIMGBiasMapping<IMAGE_SAMPLE_C_B_CL_O_nortn, IMAGE_SAMPLE_C_CL_O_nortn>;
1898 // Offset to NoOffset Optimization Mapping
1899 def : MIMGOffsetMapping<IMAGE_SAMPLE_O, IMAGE_SAMPLE>;
1900 def : MIMGOffsetMapping<IMAGE_SAMPLE_CL_O, IMAGE_SAMPLE_CL>;
1901 def : MIMGOffsetMapping<IMAGE_SAMPLE_D_O, IMAGE_SAMPLE_D>;
1902 def : MIMGOffsetMapping<IMAGE_SAMPLE_D_CL_O, IMAGE_SAMPLE_D_CL>;
1903 def : MIMGOffsetMapping<IMAGE_SAMPLE_D_O_G16, IMAGE_SAMPLE_D_G16>;
1904 def : MIMGOffsetMapping<IMAGE_SAMPLE_D_CL_O_G16, IMAGE_SAMPLE_D_CL_G16>;
1905 def : MIMGOffsetMapping<IMAGE_SAMPLE_L_O, IMAGE_SAMPLE_L>;
1906 def : MIMGOffsetMapping<IMAGE_SAMPLE_B_O, IMAGE_SAMPLE_B>;
1907 def : MIMGOffsetMapping<IMAGE_SAMPLE_B_CL_O, IMAGE_SAMPLE_B_CL>;
1908 def : MIMGOffsetMapping<IMAGE_SAMPLE_LZ_O, IMAGE_SAMPLE_LZ>;
1909 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_O, IMAGE_SAMPLE_C>;
1910 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CL_O, IMAGE_SAMPLE_C_CL>;
1911 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_O, IMAGE_SAMPLE_C_D>;
1912 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_CL_O, IMAGE_SAMPLE_C_D_CL>;
1913 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_O_G16, IMAGE_SAMPLE_C_D_G16>;
1914 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_CL_O_G16, IMAGE_SAMPLE_C_D_CL_G16>;
1915 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_L_O, IMAGE_SAMPLE_C_L>;
1916 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_B_CL_O, IMAGE_SAMPLE_C_B_CL>;
1917 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_B_O, IMAGE_SAMPLE_C_B>;
1918 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_LZ_O, IMAGE_SAMPLE_C_LZ>;
1919 def : MIMGOffsetMapping<IMAGE_GATHER4_O, IMAGE_GATHER4>;
1920 def : MIMGOffsetMapping<IMAGE_GATHER4_CL_O, IMAGE_GATHER4_CL>;
1921 def : MIMGOffsetMapping<IMAGE_GATHER4_L_O, IMAGE_GATHER4_L>;
1922 def : MIMGOffsetMapping<IMAGE_GATHER4_B_O, IMAGE_GATHER4_B>;
1923 def : MIMGOffsetMapping<IMAGE_GATHER4_B_CL_O, IMAGE_GATHER4_B_CL>;
1924 def : MIMGOffsetMapping<IMAGE_GATHER4_LZ_O, IMAGE_GATHER4_LZ>;
1925 def : MIMGOffsetMapping<IMAGE_GATHER4_C_O, IMAGE_GATHER4_C>;
1926 def : MIMGOffsetMapping<IMAGE_GATHER4_C_CL_O, IMAGE_GATHER4_C_CL>;
1927 def : MIMGOffsetMapping<IMAGE_GATHER4_C_L_O, IMAGE_GATHER4_C_L>;
1928 def : MIMGOffsetMapping<IMAGE_GATHER4_C_B_O, IMAGE_GATHER4_C_B>;
1929 def : MIMGOffsetMapping<IMAGE_GATHER4_C_B_CL_O, IMAGE_GATHER4_C_B_CL>;
1930 def : MIMGOffsetMapping<IMAGE_GATHER4_C_LZ_O, IMAGE_GATHER4_C_LZ>;
1931 def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_O, IMAGE_SAMPLE_CD>;
1932 def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_CL_O, IMAGE_SAMPLE_CD_CL>;
1933 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_O, IMAGE_SAMPLE_C_CD>;
1934 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_CL_O, IMAGE_SAMPLE_C_CD_CL>;
1935 def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_O_G16, IMAGE_SAMPLE_CD_G16>;
1936 def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_CL_O_G16, IMAGE_SAMPLE_CD_CL_G16>;
1937 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_O_G16, IMAGE_SAMPLE_C_CD_G16>;
1938 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_CL_O_G16, IMAGE_SAMPLE_C_CD_CL_G16>;
1939 def : MIMGOffsetMapping<IMAGE_SAMPLE_O_nortn, IMAGE_SAMPLE_nortn>;
1940 def : MIMGOffsetMapping<IMAGE_SAMPLE_CL_O_nortn, IMAGE_SAMPLE_CL_nortn>;
1941 def : MIMGOffsetMapping<IMAGE_SAMPLE_D_O_nortn, IMAGE_SAMPLE_D_nortn>;
1942 def : MIMGOffsetMapping<IMAGE_SAMPLE_D_CL_O_nortn, IMAGE_SAMPLE_D_CL_nortn>;
1943 def : MIMGOffsetMapping<IMAGE_SAMPLE_D_O_G16_nortn, IMAGE_SAMPLE_D_G16_nortn>;
1944 def : MIMGOffsetMapping<IMAGE_SAMPLE_D_CL_O_G16_nortn, IMAGE_SAMPLE_D_CL_G16_nortn>;
1945 def : MIMGOffsetMapping<IMAGE_SAMPLE_L_O_nortn, IMAGE_SAMPLE_L_nortn>;
1946 def : MIMGOffsetMapping<IMAGE_SAMPLE_B_O_nortn, IMAGE_SAMPLE_B_nortn>;
1947 def : MIMGOffsetMapping<IMAGE_SAMPLE_B_CL_O_nortn, IMAGE_SAMPLE_B_CL_nortn>;
1948 def : MIMGOffsetMapping<IMAGE_SAMPLE_LZ_O_nortn, IMAGE_SAMPLE_LZ_nortn>;
1949 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_O_nortn, IMAGE_SAMPLE_C_nortn>;
1950 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CL_O_nortn, IMAGE_SAMPLE_C_CL_nortn>;
1951 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_O_nortn, IMAGE_SAMPLE_C_D_nortn>;
1952 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_CL_O_nortn, IMAGE_SAMPLE_C_D_CL_nortn>;
1953 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_O_G16_nortn, IMAGE_SAMPLE_C_D_G16_nortn>;
1954 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_CL_O_G16_nortn, IMAGE_SAMPLE_C_D_CL_G16_nortn>;
1955 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_L_O_nortn, IMAGE_SAMPLE_C_L_nortn>;
1956 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_B_CL_O_nortn, IMAGE_SAMPLE_C_B_CL_nortn>;
1957 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_B_O_nortn, IMAGE_SAMPLE_C_B_nortn>;
1958 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_LZ_O_nortn, IMAGE_SAMPLE_C_LZ_nortn>;
1959 def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_O_nortn, IMAGE_SAMPLE_CD>;
1960 def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_CL_O_nortn, IMAGE_SAMPLE_CD_CL_nortn>;
1961 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_O_nortn, IMAGE_SAMPLE_C_CD_nortn>;
1962 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_CL_O_nortn, IMAGE_SAMPLE_C_CD_CL_nortn>;
1963 def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_O_G16_nortn, IMAGE_SAMPLE_CD_G16_nortn>;
1964 def : MIMGOffsetMapping<IMAGE_SAMPLE_CD_CL_O_G16_nortn, IMAGE_SAMPLE_CD_CL_G16_nortn>;
1965 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_O_G16_nortn, IMAGE_SAMPLE_C_CD_G16_nortn>;
1966 def : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_CL_O_G16_nortn, IMAGE_SAMPLE_C_CD_CL_G16_nortn>;
1968 // G to G16 Optimization Mapping
1969 def : MIMGG16Mapping<IMAGE_SAMPLE_D, IMAGE_SAMPLE_D_G16>;
1970 def : MIMGG16Mapping<IMAGE_SAMPLE_D_CL, IMAGE_SAMPLE_D_CL_G16>;
1971 def : MIMGG16Mapping<IMAGE_SAMPLE_C_D, IMAGE_SAMPLE_C_D_G16>;
1972 def : MIMGG16Mapping<IMAGE_SAMPLE_C_D_CL, IMAGE_SAMPLE_C_D_CL_G16>;
1973 def : MIMGG16Mapping<IMAGE_SAMPLE_D_O, IMAGE_SAMPLE_D_O_G16>;
1974 def : MIMGG16Mapping<IMAGE_SAMPLE_D_CL_O, IMAGE_SAMPLE_D_CL_O_G16>;
1975 def : MIMGG16Mapping<IMAGE_SAMPLE_C_D_O, IMAGE_SAMPLE_C_D_O_G16>;
1976 def : MIMGG16Mapping<IMAGE_SAMPLE_C_D_CL_O, IMAGE_SAMPLE_C_D_CL_O_G16>;
1977 def : MIMGG16Mapping<IMAGE_SAMPLE_CD, IMAGE_SAMPLE_CD_G16>;
1978 def : MIMGG16Mapping<IMAGE_SAMPLE_CD_CL, IMAGE_SAMPLE_CD_CL_G16>;
1979 def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD, IMAGE_SAMPLE_C_CD_G16>;
1980 def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_CL, IMAGE_SAMPLE_C_CD_CL_G16>;
1981 def : MIMGG16Mapping<IMAGE_SAMPLE_CD_O, IMAGE_SAMPLE_CD_O_G16>;
1982 def : MIMGG16Mapping<IMAGE_SAMPLE_CD_CL_O, IMAGE_SAMPLE_CD_CL_O_G16>;
1983 def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_O, IMAGE_SAMPLE_C_CD_O_G16>;
1984 def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_CL_O, IMAGE_SAMPLE_C_CD_CL_O_G16>;
1985 def : MIMGG16Mapping<IMAGE_SAMPLE_D_nortn, IMAGE_SAMPLE_D_G16_nortn>;
1986 def : MIMGG16Mapping<IMAGE_SAMPLE_D_CL_nortn, IMAGE_SAMPLE_D_CL_G16_nortn>;
1987 def : MIMGG16Mapping<IMAGE_SAMPLE_C_D_nortn, IMAGE_SAMPLE_C_D_G16_nortn>;
1988 def : MIMGG16Mapping<IMAGE_SAMPLE_C_D_CL_nortn, IMAGE_SAMPLE_C_D_CL_G16_nortn>;
1989 def : MIMGG16Mapping<IMAGE_SAMPLE_D_O_nortn, IMAGE_SAMPLE_D_O_G16_nortn>;
1990 def : MIMGG16Mapping<IMAGE_SAMPLE_D_CL_O_nortn, IMAGE_SAMPLE_D_CL_O_G16_nortn>;
1991 def : MIMGG16Mapping<IMAGE_SAMPLE_C_D_O_nortn, IMAGE_SAMPLE_C_D_O_G16_nortn>;
1992 def : MIMGG16Mapping<IMAGE_SAMPLE_C_D_CL_O_nortn, IMAGE_SAMPLE_C_D_CL_O_G16_nortn>;
1993 def : MIMGG16Mapping<IMAGE_SAMPLE_CD_nortn, IMAGE_SAMPLE_CD_G16_nortn>;
1994 def : MIMGG16Mapping<IMAGE_SAMPLE_CD_CL_nortn, IMAGE_SAMPLE_CD_CL_G16_nortn>;
1995 def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_nortn, IMAGE_SAMPLE_C_CD_G16_nortn>;
1996 def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_CL_nortn, IMAGE_SAMPLE_C_CD_CL_G16_nortn>;
1997 def : MIMGG16Mapping<IMAGE_SAMPLE_CD_O_nortn, IMAGE_SAMPLE_CD_O_G16_nortn>;
1998 def : MIMGG16Mapping<IMAGE_SAMPLE_CD_CL_O_nortn, IMAGE_SAMPLE_CD_CL_O_G16_nortn>;
1999 def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_O_nortn, IMAGE_SAMPLE_C_CD_O_G16_nortn>;
2000 def : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_CL_O_nortn, IMAGE_SAMPLE_C_CD_CL_O_G16_nortn>;