xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/MIMGInstructions.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
15ffd83dbSDimitry Andric//===-- MIMGInstructions.td - MIMG Instruction Definitions ----------------===//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric
90b57cec5SDimitry Andric// MIMG-specific encoding families to distinguish between semantically
100b57cec5SDimitry Andric// equivalent machine instructions with different encoding.
110b57cec5SDimitry Andric//
120b57cec5SDimitry Andric// - MIMGEncGfx6: encoding introduced with gfx6 (obsoleted for atomics in gfx8)
130b57cec5SDimitry Andric// - MIMGEncGfx8: encoding introduced with gfx8 for atomics
14fe6060f1SDimitry Andric// - MIMGEncGfx90a: encoding for gfx90a for atomics
15fe6060f1SDimitry Andric// - MIMGEncGfx10Default: gfx10 default (non-NSA) encoding
160b57cec5SDimitry Andric// - MIMGEncGfx10NSA: gfx10 NSA encoding
1781ad6265SDimitry Andric// - MIMGEncGfx11Default: gfx11 default (non-NSA) encoding
18*0fca6ea1SDimitry Andric// - MIMGEncGfx11NSA: gfx11 partial NSA encoding
19*0fca6ea1SDimitry Andric// - MIMGEncGfx12: gfx12 encoding (partial NSA)
200b57cec5SDimitry Andricclass MIMGEncoding;
210b57cec5SDimitry Andric
220b57cec5SDimitry Andricdef MIMGEncGfx6 : MIMGEncoding;
230b57cec5SDimitry Andricdef MIMGEncGfx8 : MIMGEncoding;
24fe6060f1SDimitry Andricdef MIMGEncGfx90a : MIMGEncoding;
250b57cec5SDimitry Andricdef MIMGEncGfx10Default : MIMGEncoding;
260b57cec5SDimitry Andricdef MIMGEncGfx10NSA : MIMGEncoding;
2781ad6265SDimitry Andricdef MIMGEncGfx11Default : MIMGEncoding;
2881ad6265SDimitry Andricdef MIMGEncGfx11NSA : MIMGEncoding;
295f757f3fSDimitry Andricdef MIMGEncGfx12 : MIMGEncoding;
300b57cec5SDimitry Andric
310b57cec5SDimitry Andricdef MIMGEncoding : GenericEnum {
320b57cec5SDimitry Andric  let FilterClass = "MIMGEncoding";
330b57cec5SDimitry Andric}
340b57cec5SDimitry Andric
350b57cec5SDimitry Andric// Represent an ISA-level opcode, independent of the encoding and the
360b57cec5SDimitry Andric// vdata/vaddr size.
378bcb0991SDimitry Andricclass MIMGBaseOpcode : PredicateControl {
380b57cec5SDimitry Andric  MIMGBaseOpcode BaseOpcode = !cast<MIMGBaseOpcode>(NAME);
390b57cec5SDimitry Andric  bit Store = 0;
400b57cec5SDimitry Andric  bit Atomic = 0;
410b57cec5SDimitry Andric  bit AtomicX2 = 0; // (f)cmpswap
420b57cec5SDimitry Andric  bit Sampler = 0;
430b57cec5SDimitry Andric  bit Gather4 = 0;
440b57cec5SDimitry Andric  bits<8> NumExtraArgs = 0;
450b57cec5SDimitry Andric  bit Gradients = 0;
465ffd83dbSDimitry Andric  bit G16 = 0;
470b57cec5SDimitry Andric  bit Coordinates = 1;
480b57cec5SDimitry Andric  bit LodOrClampOrMip = 0;
490b57cec5SDimitry Andric  bit HasD16 = 0;
50fe6060f1SDimitry Andric  bit IsAtomicRet = 0;
51fe6060f1SDimitry Andric  bit MSAA = 0;
52349cc55cSDimitry Andric  bit BVH = 0;
5306c3fb27SDimitry Andric  bit A16 = 0;
54*0fca6ea1SDimitry Andric  bit NoReturn = 0;
550b57cec5SDimitry Andric}
560b57cec5SDimitry Andric
570b57cec5SDimitry Andricdef MIMGBaseOpcode : GenericEnum {
580b57cec5SDimitry Andric  let FilterClass = "MIMGBaseOpcode";
590b57cec5SDimitry Andric}
600b57cec5SDimitry Andric
610b57cec5SDimitry Andricdef MIMGBaseOpcodesTable : GenericTable {
620b57cec5SDimitry Andric  let FilterClass = "MIMGBaseOpcode";
630b57cec5SDimitry Andric  let CppTypeName = "MIMGBaseOpcodeInfo";
645ffd83dbSDimitry Andric  let Fields = ["BaseOpcode", "Store", "Atomic", "AtomicX2", "Sampler",
655ffd83dbSDimitry Andric                "Gather4", "NumExtraArgs", "Gradients", "G16", "Coordinates",
66*0fca6ea1SDimitry Andric                "LodOrClampOrMip", "HasD16", "MSAA", "BVH", "A16", "NoReturn"];
67e8d8bef9SDimitry Andric  string TypeOf_BaseOpcode = "MIMGBaseOpcode";
680b57cec5SDimitry Andric
690b57cec5SDimitry Andric  let PrimaryKey = ["BaseOpcode"];
700b57cec5SDimitry Andric  let PrimaryKeyName = "getMIMGBaseOpcodeInfo";
710b57cec5SDimitry Andric}
720b57cec5SDimitry Andric
730b57cec5SDimitry Andricdef MIMGDim : GenericEnum {
740b57cec5SDimitry Andric  let FilterClass = "AMDGPUDimProps";
750b57cec5SDimitry Andric}
760b57cec5SDimitry Andric
770b57cec5SDimitry Andricdef MIMGDimInfoTable : GenericTable {
780b57cec5SDimitry Andric  let FilterClass = "AMDGPUDimProps";
790b57cec5SDimitry Andric  let CppTypeName = "MIMGDimInfo";
80fe6060f1SDimitry Andric  let Fields = ["Dim", "NumCoords", "NumGradients", "MSAA", "DA", "Encoding", "AsmSuffix"];
81e8d8bef9SDimitry Andric  string TypeOf_Dim = "MIMGDim";
820b57cec5SDimitry Andric
830b57cec5SDimitry Andric  let PrimaryKey = ["Dim"];
840b57cec5SDimitry Andric  let PrimaryKeyName = "getMIMGDimInfo";
850b57cec5SDimitry Andric}
860b57cec5SDimitry Andric
870b57cec5SDimitry Andricdef getMIMGDimInfoByEncoding : SearchIndex {
880b57cec5SDimitry Andric  let Table = MIMGDimInfoTable;
890b57cec5SDimitry Andric  let Key = ["Encoding"];
900b57cec5SDimitry Andric}
910b57cec5SDimitry Andric
920b57cec5SDimitry Andricdef getMIMGDimInfoByAsmSuffix : SearchIndex {
930b57cec5SDimitry Andric  let Table = MIMGDimInfoTable;
940b57cec5SDimitry Andric  let Key = ["AsmSuffix"];
950b57cec5SDimitry Andric}
960b57cec5SDimitry Andric
97fe6060f1SDimitry Andricdef MIMG {
98fe6060f1SDimitry Andric  int NOP = -1;
99fe6060f1SDimitry Andric}
100fe6060f1SDimitry Andric
1015f757f3fSDimitry Andricclass mimgopc <int gfx12, int gfx11, int gfx10m, int vi = gfx10m, int si = gfx10m> {
1025f757f3fSDimitry Andric  field bits<8> GFX12 = gfx12;
10381ad6265SDimitry Andric  field bits<8> GFX11 = gfx11;
10481ad6265SDimitry Andric  field bits<8> GFX10M = gfx10m; // GFX10minus for all but atomics
105bdd1243dSDimitry Andric  field bits<8> VI = vi; // VI is only used for atomic/sampler/gather instructions
106fe6060f1SDimitry Andric  field bits<8> SI = si; // SI is only used for atomic instructions
1075f757f3fSDimitry Andric  bit HAS_GFX12 = !ne(gfx12, MIMG.NOP);
10881ad6265SDimitry Andric  bit HAS_GFX11 = !ne(gfx11, MIMG.NOP);
10981ad6265SDimitry Andric  bit HAS_GFX10M = !ne(gfx10m, MIMG.NOP);
110fe6060f1SDimitry Andric  bit HAS_VI = !ne(vi, MIMG.NOP);
111fe6060f1SDimitry Andric  bit HAS_SI = !ne(si, MIMG.NOP);
1120b57cec5SDimitry Andric}
1130b57cec5SDimitry Andric
1140b57cec5SDimitry Andricclass MIMGLZMapping<MIMGBaseOpcode l, MIMGBaseOpcode lz> {
1150b57cec5SDimitry Andric  MIMGBaseOpcode L = l;
1160b57cec5SDimitry Andric  MIMGBaseOpcode LZ = lz;
1170b57cec5SDimitry Andric}
1180b57cec5SDimitry Andric
1190b57cec5SDimitry Andricdef MIMGLZMappingTable : GenericTable {
1200b57cec5SDimitry Andric  let FilterClass = "MIMGLZMapping";
1210b57cec5SDimitry Andric  let CppTypeName = "MIMGLZMappingInfo";
1220b57cec5SDimitry Andric  let Fields = ["L", "LZ"];
123e8d8bef9SDimitry Andric  string TypeOf_L = "MIMGBaseOpcode";
124e8d8bef9SDimitry Andric  string TypeOf_LZ = "MIMGBaseOpcode";
1250b57cec5SDimitry Andric
1260b57cec5SDimitry Andric  let PrimaryKey = ["L"];
1270b57cec5SDimitry Andric  let PrimaryKeyName = "getMIMGLZMappingInfo";
1280b57cec5SDimitry Andric}
1290b57cec5SDimitry Andric
1300b57cec5SDimitry Andricclass MIMGMIPMapping<MIMGBaseOpcode mip, MIMGBaseOpcode nonmip> {
1310b57cec5SDimitry Andric  MIMGBaseOpcode MIP = mip;
1320b57cec5SDimitry Andric  MIMGBaseOpcode NONMIP = nonmip;
1330b57cec5SDimitry Andric}
1340b57cec5SDimitry Andric
1350b57cec5SDimitry Andricdef MIMGMIPMappingTable : GenericTable {
1360b57cec5SDimitry Andric  let FilterClass = "MIMGMIPMapping";
1370b57cec5SDimitry Andric  let CppTypeName = "MIMGMIPMappingInfo";
1380b57cec5SDimitry Andric  let Fields = ["MIP", "NONMIP"];
139e8d8bef9SDimitry Andric  string TypeOf_MIP = "MIMGBaseOpcode";
140e8d8bef9SDimitry Andric  string TypeOf_NONMIP = "MIMGBaseOpcode";
1410b57cec5SDimitry Andric
1420b57cec5SDimitry Andric  let PrimaryKey = ["MIP"];
1430b57cec5SDimitry Andric  let PrimaryKeyName = "getMIMGMIPMappingInfo";
1440b57cec5SDimitry Andric}
1450b57cec5SDimitry Andric
14604eeddc0SDimitry Andricclass MIMGBiasMapping<MIMGBaseOpcode bias, MIMGBaseOpcode nobias> {
14704eeddc0SDimitry Andric  MIMGBaseOpcode Bias = bias;
14804eeddc0SDimitry Andric  MIMGBaseOpcode NoBias = nobias;
14904eeddc0SDimitry Andric}
15004eeddc0SDimitry Andric
15104eeddc0SDimitry Andricdef MIMGBiasMappingTable : GenericTable {
15204eeddc0SDimitry Andric  let FilterClass = "MIMGBiasMapping";
15304eeddc0SDimitry Andric  let CppTypeName = "MIMGBiasMappingInfo";
15404eeddc0SDimitry Andric  let Fields = ["Bias", "NoBias"];
15504eeddc0SDimitry Andric  string TypeOf_Bias = "MIMGBaseOpcode";
15604eeddc0SDimitry Andric  string TypeOf_NoBias = "MIMGBaseOpcode";
15704eeddc0SDimitry Andric
15804eeddc0SDimitry Andric  let PrimaryKey = ["Bias"];
15904eeddc0SDimitry Andric  let PrimaryKeyName = "getMIMGBiasMappingInfo";
16004eeddc0SDimitry Andric}
16104eeddc0SDimitry Andric
16204eeddc0SDimitry Andricclass MIMGOffsetMapping<MIMGBaseOpcode offset, MIMGBaseOpcode nooffset> {
16304eeddc0SDimitry Andric  MIMGBaseOpcode Offset = offset;
16404eeddc0SDimitry Andric  MIMGBaseOpcode NoOffset = nooffset;
16504eeddc0SDimitry Andric}
16604eeddc0SDimitry Andric
16704eeddc0SDimitry Andricdef MIMGOffsetMappingTable : GenericTable {
16804eeddc0SDimitry Andric  let FilterClass = "MIMGOffsetMapping";
16904eeddc0SDimitry Andric  let CppTypeName = "MIMGOffsetMappingInfo";
17004eeddc0SDimitry Andric  let Fields = ["Offset", "NoOffset"];
17104eeddc0SDimitry Andric  string TypeOf_Offset = "MIMGBaseOpcode";
17204eeddc0SDimitry Andric  string TypeOf_NoOffset = "MIMGBaseOpcode";
17304eeddc0SDimitry Andric
17404eeddc0SDimitry Andric  let PrimaryKey = ["Offset"];
17504eeddc0SDimitry Andric  let PrimaryKeyName = "getMIMGOffsetMappingInfo";
17604eeddc0SDimitry Andric}
17704eeddc0SDimitry Andric
1785ffd83dbSDimitry Andricclass MIMGG16Mapping<MIMGBaseOpcode g, MIMGBaseOpcode g16> {
1795ffd83dbSDimitry Andric  MIMGBaseOpcode G = g;
1805ffd83dbSDimitry Andric  MIMGBaseOpcode G16 = g16;
1815ffd83dbSDimitry Andric}
1825ffd83dbSDimitry Andric
1835ffd83dbSDimitry Andricdef MIMGG16MappingTable : GenericTable {
1845ffd83dbSDimitry Andric  let FilterClass = "MIMGG16Mapping";
1855ffd83dbSDimitry Andric  let CppTypeName = "MIMGG16MappingInfo";
1865ffd83dbSDimitry Andric  let Fields = ["G", "G16"];
187e8d8bef9SDimitry Andric  string TypeOf_G = "MIMGBaseOpcode";
188e8d8bef9SDimitry Andric  string TypeOf_G16 = "MIMGBaseOpcode";
1895ffd83dbSDimitry Andric
1905ffd83dbSDimitry Andric  let PrimaryKey = ["G"];
1915ffd83dbSDimitry Andric  let PrimaryKeyName = "getMIMGG16MappingInfo";
1925ffd83dbSDimitry Andric}
1935ffd83dbSDimitry Andric
1940b57cec5SDimitry Andricclass MIMG_Base <dag outs, string dns = "">
1950b57cec5SDimitry Andric  : InstSI <outs, (ins), "", []> {
1960b57cec5SDimitry Andric
1970b57cec5SDimitry Andric  let VM_CNT = 1;
1980b57cec5SDimitry Andric  let EXP_CNT = 1;
1990b57cec5SDimitry Andric  let MIMG = 1;
2000b57cec5SDimitry Andric  let Uses = [EXEC];
2010b57cec5SDimitry Andric  let mayLoad = 1;
2020b57cec5SDimitry Andric  let mayStore = 0;
2030b57cec5SDimitry Andric  let SchedRW = [WriteVMEM];
2040b57cec5SDimitry Andric  let UseNamedOperandTable = 1;
2050b57cec5SDimitry Andric  let hasSideEffects = 0; // XXX ????
2060b57cec5SDimitry Andric
2070b57cec5SDimitry Andric  let DecoderNamespace = dns;
208e8d8bef9SDimitry Andric  let isAsmParserOnly = !eq(dns, "");
2090b57cec5SDimitry Andric}
2100b57cec5SDimitry Andric
2110b57cec5SDimitry Andricclass MIMG <dag outs, string dns = "">
2120b57cec5SDimitry Andric  : MIMG_Base <outs, dns> {
2130b57cec5SDimitry Andric
2140b57cec5SDimitry Andric  let hasPostISelHook = 1;
215*0fca6ea1SDimitry Andric  let usesCustomInserter = 1;
2160b57cec5SDimitry Andric
2170b57cec5SDimitry Andric  Instruction Opcode = !cast<Instruction>(NAME);
2180b57cec5SDimitry Andric  MIMGBaseOpcode BaseOpcode;
2190b57cec5SDimitry Andric  MIMGEncoding MIMGEncoding;
2200b57cec5SDimitry Andric  bits<8> VDataDwords;
2210b57cec5SDimitry Andric  bits<8> VAddrDwords;
22281ad6265SDimitry Andric
22381ad6265SDimitry Andric  // If NSA is used this counts number of operands VAddrDwords is split into.
22481ad6265SDimitry Andric  bits<8> VAddrOperands;
2250b57cec5SDimitry Andric}
2260b57cec5SDimitry Andric
2275f757f3fSDimitry Andricclass VIMAGE <dag outs, string dns = ""> : MIMG<outs, dns> {
2285f757f3fSDimitry Andric  let MIMG = 0;
2295f757f3fSDimitry Andric  let VIMAGE = 1;
2305f757f3fSDimitry Andric}
2315f757f3fSDimitry Andric
2325f757f3fSDimitry Andricclass VSAMPLE <dag outs, string dns = ""> : MIMG<outs, dns> {
2335f757f3fSDimitry Andric  let MIMG = 0;
2345f757f3fSDimitry Andric  let VSAMPLE = 1;
2355f757f3fSDimitry Andric}
2365f757f3fSDimitry Andric
2370b57cec5SDimitry Andricdef MIMGInfoTable : GenericTable {
2380b57cec5SDimitry Andric  let FilterClass = "MIMG";
2390b57cec5SDimitry Andric  let CppTypeName = "MIMGInfo";
24081ad6265SDimitry Andric  let Fields = ["Opcode", "BaseOpcode", "MIMGEncoding", "VDataDwords",
24181ad6265SDimitry Andric                "VAddrDwords", "VAddrOperands"];
242e8d8bef9SDimitry Andric  string TypeOf_BaseOpcode = "MIMGBaseOpcode";
243e8d8bef9SDimitry Andric  string TypeOf_MIMGEncoding = "MIMGEncoding";
2440b57cec5SDimitry Andric
2450b57cec5SDimitry Andric  let PrimaryKey = ["BaseOpcode", "MIMGEncoding", "VDataDwords", "VAddrDwords"];
2460b57cec5SDimitry Andric  let PrimaryKeyName = "getMIMGOpcodeHelper";
2470b57cec5SDimitry Andric}
2480b57cec5SDimitry Andric
2490b57cec5SDimitry Andricdef getMIMGInfo : SearchIndex {
2500b57cec5SDimitry Andric  let Table = MIMGInfoTable;
2510b57cec5SDimitry Andric  let Key = ["Opcode"];
2520b57cec5SDimitry Andric}
2530b57cec5SDimitry Andric
25406c3fb27SDimitry Andricclass NSAHelper {
25506c3fb27SDimitry Andric  dag AddrIns;
25606c3fb27SDimitry Andric  string AddrAsm;
25706c3fb27SDimitry Andric  int NSA;
25806c3fb27SDimitry Andric}
2590b57cec5SDimitry Andric
26006c3fb27SDimitry Andricclass MIMGNSAHelper<int num_addrs,
26106c3fb27SDimitry Andric                    list<RegisterClass> addr_types=!listsplat(VGPR_32, num_addrs)>
26206c3fb27SDimitry Andric  : NSAHelper<> {
26306c3fb27SDimitry Andric  list<string> AddrAsmNames = !foreach(i, !range(num_addrs), "vaddr" # i);
26406c3fb27SDimitry Andric  let AddrIns = !dag(ins, addr_types, AddrAsmNames);
26506c3fb27SDimitry Andric  let AddrAsm = "[$" # !interleave(AddrAsmNames, ", $") # "]";
26606c3fb27SDimitry Andric
26706c3fb27SDimitry Andric  let NSA = !if(!le(num_addrs, 1), ?,
2680b57cec5SDimitry Andric            !if(!le(num_addrs, 5), 1,
2690b57cec5SDimitry Andric            !if(!le(num_addrs, 9), 2,
2700b57cec5SDimitry Andric            !if(!le(num_addrs, 13), 3, ?))));
2710b57cec5SDimitry Andric}
2720b57cec5SDimitry Andric
27306c3fb27SDimitry Andricclass PartialNSAHelper<int num_addrs, int max_addr, RegisterClass LastAddrRC>
27406c3fb27SDimitry Andric  : NSAHelper<> {
27506c3fb27SDimitry Andric
27606c3fb27SDimitry Andric  list<RegisterClass> addr_types =
27706c3fb27SDimitry Andric    !if(!ge(num_addrs, max_addr),
27806c3fb27SDimitry Andric      !listconcat(!listsplat(VGPR_32, !sub(max_addr, 1)), [LastAddrRC]),
27906c3fb27SDimitry Andric      !listsplat(VGPR_32, num_addrs));
28006c3fb27SDimitry Andric
28106c3fb27SDimitry Andric  int VAddrCount = !if(!gt(num_addrs, max_addr), max_addr, num_addrs);
28206c3fb27SDimitry Andric  list<string> AddrAsmNames =  !foreach(i, !range(VAddrCount), "vaddr" # i);
28306c3fb27SDimitry Andric
28406c3fb27SDimitry Andric  let AddrIns = !dag(ins, addr_types, AddrAsmNames);
28506c3fb27SDimitry Andric  let AddrAsm = "[$" # !interleave(AddrAsmNames, ", $") # "]";
28606c3fb27SDimitry Andric  let NSA = 1;
28706c3fb27SDimitry Andric}
28806c3fb27SDimitry Andric
2890b57cec5SDimitry Andric// Base class of all pre-gfx10 MIMG instructions.
2900b57cec5SDimitry Andricclass MIMG_gfx6789<bits<8> op, dag outs, string dns = "">
2910b57cec5SDimitry Andric  : MIMG<outs, dns>, MIMGe_gfx6789<op> {
292fe6060f1SDimitry Andric  let SubtargetPredicate = isGFX6GFX7GFX8GFX9NotGFX90A;
293fe6060f1SDimitry Andric  let AssemblerPredicate = isGFX6GFX7GFX8GFX9NotGFX90A;
2940b57cec5SDimitry Andric
2950b57cec5SDimitry Andric  let MIMGEncoding = MIMGEncGfx6;
29681ad6265SDimitry Andric  let VAddrOperands = 1;
2970b57cec5SDimitry Andric
2980b57cec5SDimitry Andric  let d16 = !if(BaseOpcode.HasD16, ?, 0);
2990b57cec5SDimitry Andric}
3000b57cec5SDimitry Andric
301fe6060f1SDimitry Andricclass MIMG_gfx90a<bits<8> op, dag outs, string dns = "">
302fe6060f1SDimitry Andric  : MIMG<outs, dns>, MIMGe_gfx90a<op> {
303fe6060f1SDimitry Andric  let SubtargetPredicate = isGFX90APlus;
304fe6060f1SDimitry Andric  let AssemblerPredicate = isGFX90APlus;
305fe6060f1SDimitry Andric
306fe6060f1SDimitry Andric  let MIMGEncoding = MIMGEncGfx90a;
30781ad6265SDimitry Andric  let VAddrOperands = 1;
308fe6060f1SDimitry Andric
309fe6060f1SDimitry Andric  let d16 = !if(BaseOpcode.HasD16, ?, 0);
310fe6060f1SDimitry Andric}
311fe6060f1SDimitry Andric
3120b57cec5SDimitry Andric// Base class of all non-NSA gfx10 MIMG instructions.
3130b57cec5SDimitry Andricclass MIMG_gfx10<int op, dag outs, string dns = "">
3140b57cec5SDimitry Andric  : MIMG<outs, dns>, MIMGe_gfx10<op> {
31581ad6265SDimitry Andric  let SubtargetPredicate = isGFX10Only;
31681ad6265SDimitry Andric  let AssemblerPredicate = isGFX10Only;
3170b57cec5SDimitry Andric
3180b57cec5SDimitry Andric  let MIMGEncoding = MIMGEncGfx10Default;
31981ad6265SDimitry Andric  let VAddrOperands = 1;
3200b57cec5SDimitry Andric
3210b57cec5SDimitry Andric  let d16 = !if(BaseOpcode.HasD16, ?, 0);
3220b57cec5SDimitry Andric  let nsa = 0;
3230b57cec5SDimitry Andric}
3240b57cec5SDimitry Andric
325fe6060f1SDimitry Andric// Base class for all NSA MIMG instructions.
326fe6060f1SDimitry Andric// Note that 1-dword addresses always use non-NSA variants.
3270b57cec5SDimitry Andricclass MIMG_nsa_gfx10<int op, dag outs, int num_addrs, string dns="">
3280b57cec5SDimitry Andric  : MIMG<outs, dns>, MIMGe_gfx10<op> {
32981ad6265SDimitry Andric  let SubtargetPredicate = isGFX10Only;
33081ad6265SDimitry Andric  let AssemblerPredicate = isGFX10Only;
3310b57cec5SDimitry Andric
3320b57cec5SDimitry Andric  let MIMGEncoding = MIMGEncGfx10NSA;
33381ad6265SDimitry Andric  let VAddrOperands = num_addrs;
3340b57cec5SDimitry Andric
3350b57cec5SDimitry Andric  MIMGNSAHelper nsah = MIMGNSAHelper<num_addrs>;
3360b57cec5SDimitry Andric  dag AddrIns = nsah.AddrIns;
3370b57cec5SDimitry Andric  string AddrAsm = nsah.AddrAsm;
3380b57cec5SDimitry Andric
3390b57cec5SDimitry Andric  let d16 = !if(BaseOpcode.HasD16, ?, 0);
3400b57cec5SDimitry Andric  let nsa = nsah.NSA;
3410b57cec5SDimitry Andric}
3420b57cec5SDimitry Andric
34381ad6265SDimitry Andric// Base class of all non-NSA gfx11 MIMG instructions.
34481ad6265SDimitry Andricclass MIMG_gfx11<int op, dag outs, string dns = "">
34581ad6265SDimitry Andric  : MIMG<outs, dns>, MIMGe_gfx11<op> {
3465f757f3fSDimitry Andric  let SubtargetPredicate = isGFX11Only;
3475f757f3fSDimitry Andric  let AssemblerPredicate = isGFX11Only;
34881ad6265SDimitry Andric
34981ad6265SDimitry Andric  let MIMGEncoding = MIMGEncGfx11Default;
35081ad6265SDimitry Andric  let VAddrOperands = 1;
35181ad6265SDimitry Andric
35281ad6265SDimitry Andric  let d16 = !if(BaseOpcode.HasD16, ?, 0);
35381ad6265SDimitry Andric  let nsa = 0;
35481ad6265SDimitry Andric}
35581ad6265SDimitry Andric
35681ad6265SDimitry Andric// Base class for all NSA MIMG instructions.
35781ad6265SDimitry Andric// Note that 1-dword addresses always use non-NSA variants.
35881ad6265SDimitry Andricclass MIMG_nsa_gfx11<int op, dag outs, int num_addrs, string dns="",
35906c3fb27SDimitry Andric                     list<RegisterClass> addr_types=[],
36006c3fb27SDimitry Andric                     RegisterClass LastAddrRC = VGPR_32>
36181ad6265SDimitry Andric  : MIMG<outs, dns>, MIMGe_gfx11<op> {
3625f757f3fSDimitry Andric  let SubtargetPredicate = isGFX11Only;
3635f757f3fSDimitry Andric  let AssemblerPredicate = isGFX11Only;
36481ad6265SDimitry Andric
36581ad6265SDimitry Andric  let MIMGEncoding = MIMGEncGfx11NSA;
36681ad6265SDimitry Andric  let VAddrOperands = num_addrs;
36781ad6265SDimitry Andric
36806c3fb27SDimitry Andric  NSAHelper nsah = !if(!empty(addr_types),
36906c3fb27SDimitry Andric                        PartialNSAHelper<num_addrs, 5, LastAddrRC>,
37081ad6265SDimitry Andric                        MIMGNSAHelper<num_addrs, addr_types>);
37181ad6265SDimitry Andric  dag AddrIns = nsah.AddrIns;
37281ad6265SDimitry Andric  string AddrAsm = nsah.AddrAsm;
37381ad6265SDimitry Andric
37481ad6265SDimitry Andric  let d16 = !if(BaseOpcode.HasD16, ?, 0);
37581ad6265SDimitry Andric  let nsa = nsah.NSA;
37681ad6265SDimitry Andric}
37781ad6265SDimitry Andric
3785f757f3fSDimitry Andricclass VIMAGE_gfx12<int op, dag outs, int num_addrs, string dns="",
3795f757f3fSDimitry Andric                   list<RegisterClass> addr_types=[]>
3805f757f3fSDimitry Andric  : VIMAGE<outs, dns>, VIMAGEe<op> {
3815f757f3fSDimitry Andric  let SubtargetPredicate = isGFX12Plus;
3825f757f3fSDimitry Andric  let AssemblerPredicate = isGFX12Plus;
3835f757f3fSDimitry Andric
3845f757f3fSDimitry Andric  let MIMGEncoding = MIMGEncGfx12;
3855f757f3fSDimitry Andric  let VAddrOperands = num_addrs;
3865f757f3fSDimitry Andric
3875f757f3fSDimitry Andric  MIMGNSAHelper nsah = !if(!empty(addr_types),
3885f757f3fSDimitry Andric                           MIMGNSAHelper<num_addrs>,
3895f757f3fSDimitry Andric                           MIMGNSAHelper<num_addrs, addr_types>);
3905f757f3fSDimitry Andric  dag AddrIns = nsah.AddrIns;
3915f757f3fSDimitry Andric  string AddrAsm = !if(!eq(num_addrs, 1), "$vaddr0", nsah.AddrAsm);
3925f757f3fSDimitry Andric
3935f757f3fSDimitry Andric  let d16 = !if(BaseOpcode.HasD16, ?, 0);
3945f757f3fSDimitry Andric  let vaddr1 = !if(!lt(num_addrs, 2), 0, ?);
3955f757f3fSDimitry Andric  let vaddr2 = !if(!lt(num_addrs, 3), 0, ?);
3965f757f3fSDimitry Andric  let vaddr3 = !if(!lt(num_addrs, 4), 0, ?);
3975f757f3fSDimitry Andric  let vaddr4 = !if(!lt(num_addrs, 5), 0, ?);
3985f757f3fSDimitry Andric}
3995f757f3fSDimitry Andric
4005f757f3fSDimitry Andricclass VSAMPLE_gfx12<int op, dag outs, int num_addrs, string dns="",
4015f757f3fSDimitry Andric                    RegisterClass Addr3RC>
4025f757f3fSDimitry Andric  : VSAMPLE<outs, dns>, VSAMPLEe<op> {
4035f757f3fSDimitry Andric  let SubtargetPredicate = isGFX12Plus;
4045f757f3fSDimitry Andric  let AssemblerPredicate = isGFX12Plus;
4055f757f3fSDimitry Andric
4065f757f3fSDimitry Andric  let MIMGEncoding = MIMGEncGfx12;
4075f757f3fSDimitry Andric  let VAddrOperands = num_addrs;
4085f757f3fSDimitry Andric
4095f757f3fSDimitry Andric  PartialNSAHelper nsah = PartialNSAHelper<num_addrs, 4, Addr3RC>;
4105f757f3fSDimitry Andric
4115f757f3fSDimitry Andric  dag AddrIns = nsah.AddrIns;
4125f757f3fSDimitry Andric  string AddrAsm = !if(!eq(num_addrs, 1), "$vaddr0", nsah.AddrAsm);
4135f757f3fSDimitry Andric
4145f757f3fSDimitry Andric  let d16 = !if(BaseOpcode.HasD16, ?, 0);
4155f757f3fSDimitry Andric  let vaddr1 = !if(!lt(num_addrs, 2), 0, ?);
4165f757f3fSDimitry Andric  let vaddr2 = !if(!lt(num_addrs, 3), 0, ?);
4175f757f3fSDimitry Andric  let vaddr3 = !if(!lt(num_addrs, 4), 0, ?);
4185f757f3fSDimitry Andric}
4195f757f3fSDimitry Andric
420fe6060f1SDimitry Andricclass MIMG_NoSampler_Helper <mimgopc op, string asm,
4210b57cec5SDimitry Andric                             RegisterClass dst_rc,
4220b57cec5SDimitry Andric                             RegisterClass addr_rc,
4230b57cec5SDimitry Andric                             string dns="">
42481ad6265SDimitry Andric  : MIMG_gfx6789 <op.GFX10M, (outs dst_rc:$vdata), dns> {
4250b57cec5SDimitry Andric  let InOperandList = !con((ins addr_rc:$vaddr, SReg_256:$srsrc,
426fe6060f1SDimitry Andric                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
4270b57cec5SDimitry Andric                                R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
4280b57cec5SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
429fe6060f1SDimitry Andric  let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$tfe$lwe$da"
4300b57cec5SDimitry Andric                      #!if(BaseOpcode.HasD16, "$d16", "");
4310b57cec5SDimitry Andric}
4320b57cec5SDimitry Andric
433fe6060f1SDimitry Andricclass MIMG_NoSampler_Helper_gfx90a <mimgopc op, string asm,
434fe6060f1SDimitry Andric                                    RegisterClass dst_rc,
435fe6060f1SDimitry Andric                                    RegisterClass addr_rc,
436fe6060f1SDimitry Andric                                    string dns="">
43781ad6265SDimitry Andric  : MIMG_gfx90a <op.GFX10M, (outs getLdStRegisterOperand<dst_rc>.ret:$vdata), dns> {
438fe6060f1SDimitry Andric  let InOperandList = !con((ins addr_rc:$vaddr, SReg_256:$srsrc,
439fe6060f1SDimitry Andric                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
440fe6060f1SDimitry Andric                                R128A16:$r128, LWE:$lwe, DA:$da),
441fe6060f1SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
442fe6060f1SDimitry Andric  let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$lwe$da"
443fe6060f1SDimitry Andric                      #!if(BaseOpcode.HasD16, "$d16", "");
444fe6060f1SDimitry Andric}
445fe6060f1SDimitry Andric
446fe6060f1SDimitry Andricclass MIMG_NoSampler_gfx10<mimgopc op, string opcode,
4470b57cec5SDimitry Andric                           RegisterClass DataRC, RegisterClass AddrRC,
4480b57cec5SDimitry Andric                           string dns="">
44981ad6265SDimitry Andric  : MIMG_gfx10<op.GFX10M, (outs DataRC:$vdata), dns> {
4500b57cec5SDimitry Andric  let InOperandList = !con((ins AddrRC:$vaddr0, SReg_256:$srsrc, DMask:$dmask,
451fe6060f1SDimitry Andric                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
452bdd1243dSDimitry Andric                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
4530b57cec5SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
454fe6060f1SDimitry Andric  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
4550b57cec5SDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
4560b57cec5SDimitry Andric}
4570b57cec5SDimitry Andric
458fe6060f1SDimitry Andricclass MIMG_NoSampler_nsa_gfx10<mimgopc op, string opcode,
4590b57cec5SDimitry Andric                               RegisterClass DataRC, int num_addrs,
4600b57cec5SDimitry Andric                               string dns="">
46181ad6265SDimitry Andric  : MIMG_nsa_gfx10<op.GFX10M, (outs DataRC:$vdata), num_addrs, dns> {
46281ad6265SDimitry Andric  let InOperandList = !con(AddrIns,
46381ad6265SDimitry Andric                           (ins SReg_256:$srsrc, DMask:$dmask,
46481ad6265SDimitry Andric                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
465bdd1243dSDimitry Andric                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
46681ad6265SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
46781ad6265SDimitry Andric  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
46881ad6265SDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
46981ad6265SDimitry Andric}
47081ad6265SDimitry Andric
47181ad6265SDimitry Andricclass MIMG_NoSampler_gfx11<mimgopc op, string opcode,
47281ad6265SDimitry Andric                           RegisterClass DataRC, RegisterClass AddrRC,
47381ad6265SDimitry Andric                           string dns="">
47481ad6265SDimitry Andric  : MIMG_gfx11<op.GFX11, (outs DataRC:$vdata), dns> {
47581ad6265SDimitry Andric  let InOperandList = !con((ins AddrRC:$vaddr0, SReg_256:$srsrc, DMask:$dmask,
47681ad6265SDimitry Andric                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
477bdd1243dSDimitry Andric                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
47881ad6265SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
47981ad6265SDimitry Andric  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
48081ad6265SDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
48181ad6265SDimitry Andric}
48281ad6265SDimitry Andric
48381ad6265SDimitry Andricclass MIMG_NoSampler_nsa_gfx11<mimgopc op, string opcode,
48481ad6265SDimitry Andric                               RegisterClass DataRC, int num_addrs,
48581ad6265SDimitry Andric                               string dns="">
48681ad6265SDimitry Andric  : MIMG_nsa_gfx11<op.GFX11, (outs DataRC:$vdata), num_addrs, dns> {
4870b57cec5SDimitry Andric  let InOperandList = !con(AddrIns,
4880b57cec5SDimitry Andric                           (ins SReg_256:$srsrc, DMask:$dmask,
489fe6060f1SDimitry Andric                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
490bdd1243dSDimitry Andric                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
4910b57cec5SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
492fe6060f1SDimitry Andric  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
4930b57cec5SDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
4940b57cec5SDimitry Andric}
4950b57cec5SDimitry Andric
4965f757f3fSDimitry Andricclass VIMAGE_NoSampler_gfx12<mimgopc op, string opcode,
4975f757f3fSDimitry Andric                             RegisterClass DataRC, int num_addrs,
4985f757f3fSDimitry Andric                             string dns="">
499*0fca6ea1SDimitry Andric  : VIMAGE_gfx12<op.GFX12, (outs DataRC:$vdata), num_addrs, dns> {
5005f757f3fSDimitry Andric  let InOperandList = !con(AddrIns,
5015f757f3fSDimitry Andric                           (ins SReg_256:$rsrc, DMask:$dmask, Dim:$dim,
5025f757f3fSDimitry Andric                                CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe),
5035f757f3fSDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
5045f757f3fSDimitry Andric  let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc$dmask$dim$cpol$r128$a16$tfe"
5055f757f3fSDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
5065f757f3fSDimitry Andric}
5075f757f3fSDimitry Andric
5085f757f3fSDimitry Andricclass VSAMPLE_Sampler_gfx12<mimgopc op, string opcode, RegisterClass DataRC,
5095f757f3fSDimitry Andric                            int num_addrs, RegisterClass Addr3RC = VGPR_32,
5105f757f3fSDimitry Andric                            string dns="">
5115f757f3fSDimitry Andric  : VSAMPLE_gfx12<op.GFX12, (outs DataRC:$vdata), num_addrs, dns, Addr3RC> {
5125f757f3fSDimitry Andric  let InOperandList = !con(AddrIns,
5135f757f3fSDimitry Andric                           (ins SReg_256:$rsrc),
5145f757f3fSDimitry Andric                           !if(BaseOpcode.Sampler, (ins SReg_128:$samp), (ins)),
5155f757f3fSDimitry Andric                           (ins DMask:$dmask, Dim:$dim, UNorm:$unorm,
5165f757f3fSDimitry Andric                                CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe,
5175f757f3fSDimitry Andric                                LWE:$lwe),
5185f757f3fSDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
5195f757f3fSDimitry Andric  let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc"
5205f757f3fSDimitry Andric                    #!if(BaseOpcode.Sampler, ", $samp", "")
5215f757f3fSDimitry Andric                    #"$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
5225f757f3fSDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
5235f757f3fSDimitry Andric}
5245f757f3fSDimitry Andric
525*0fca6ea1SDimitry Andricclass VSAMPLE_Sampler_nortn_gfx12<mimgopc op, string opcode,
526*0fca6ea1SDimitry Andric                            int num_addrs, RegisterClass Addr3RC = VGPR_32,
527*0fca6ea1SDimitry Andric                            string dns="">
528*0fca6ea1SDimitry Andric  : VSAMPLE_gfx12<op.GFX12, (outs), num_addrs, dns, Addr3RC> {
529*0fca6ea1SDimitry Andric  let InOperandList = !con(AddrIns,
530*0fca6ea1SDimitry Andric                           (ins SReg_256:$rsrc),
531*0fca6ea1SDimitry Andric                           !if(BaseOpcode.Sampler, (ins SReg_128:$samp), (ins)),
532*0fca6ea1SDimitry Andric                           (ins DMask:$dmask, Dim:$dim, UNorm:$unorm,
533*0fca6ea1SDimitry Andric                                CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe,
534*0fca6ea1SDimitry Andric                                LWE:$lwe),
535*0fca6ea1SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
536*0fca6ea1SDimitry Andric  let AsmString = opcode#" off, "#AddrAsm#", $rsrc"
537*0fca6ea1SDimitry Andric                    #!if(BaseOpcode.Sampler, ", $samp", "")
538*0fca6ea1SDimitry Andric                    #"$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
539*0fca6ea1SDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
540*0fca6ea1SDimitry Andric  // Force vdata to VGPR0 as no result will be returned.
541*0fca6ea1SDimitry Andric  let vdata = 0;
542*0fca6ea1SDimitry Andric}
543*0fca6ea1SDimitry Andric
544fe6060f1SDimitry Andricmulticlass MIMG_NoSampler_Src_Helper <mimgopc op, string asm,
5455f757f3fSDimitry Andric                                      RegisterClass dst_rc, bit enableDisasm,
5465f757f3fSDimitry Andric                                      bit ExtendedImageInst = 1,
5475f757f3fSDimitry Andric                                      bit isVSample = 0> {
5480b57cec5SDimitry Andric  let VAddrDwords = 1 in {
5495f757f3fSDimitry Andric    let ssamp = 0 in {
55081ad6265SDimitry Andric      if op.HAS_GFX10M then {
5510b57cec5SDimitry Andric        def _V1 : MIMG_NoSampler_Helper <op, asm, dst_rc, VGPR_32,
552*0fca6ea1SDimitry Andric                                         !if(enableDisasm, "GFX8", "")>;
553fe6060f1SDimitry Andric        if !not(ExtendedImageInst) then
554fe6060f1SDimitry Andric        def _V1_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VGPR_32,
555fe6060f1SDimitry Andric                                       !if(enableDisasm, "GFX90A", "")>;
5560b57cec5SDimitry Andric        def _V1_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VGPR_32,
557*0fca6ea1SDimitry Andric                                             !if(enableDisasm, "GFX10", "")>;
5580b57cec5SDimitry Andric      }
55981ad6265SDimitry Andric      if op.HAS_GFX11 then {
56081ad6265SDimitry Andric        def _V1_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VGPR_32,
561*0fca6ea1SDimitry Andric                                             !if(enableDisasm, "GFX11", "")>;
56281ad6265SDimitry Andric      }
563fe6060f1SDimitry Andric    }
5645f757f3fSDimitry Andric    if op.HAS_GFX12 then {
5655f757f3fSDimitry Andric      if isVSample then {
5665f757f3fSDimitry Andric        let samp = 0 in
5675f757f3fSDimitry Andric          def _V1_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 1>;
5685f757f3fSDimitry Andric      }
5695f757f3fSDimitry Andric      else {
5705f757f3fSDimitry Andric        def _V1_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 1,
5715f757f3fSDimitry Andric                                               !if(enableDisasm, "GFX12", "")>;
5725f757f3fSDimitry Andric      }
5735f757f3fSDimitry Andric    }
5745f757f3fSDimitry Andric  }
5750b57cec5SDimitry Andric  let VAddrDwords = 2 in {
5765f757f3fSDimitry Andric    let ssamp = 0 in {
57781ad6265SDimitry Andric      if op.HAS_GFX10M then {
5780b57cec5SDimitry Andric        def _V2 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_64>;
579fe6060f1SDimitry Andric        if !not(ExtendedImageInst) then
580fe6060f1SDimitry Andric        def _V2_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VReg_64>;
5810b57cec5SDimitry Andric        def _V2_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VReg_64>;
5820b57cec5SDimitry Andric        def _V2_nsa_gfx10 : MIMG_NoSampler_nsa_gfx10<op, asm, dst_rc, 2>;
5830b57cec5SDimitry Andric      }
58481ad6265SDimitry Andric      if op.HAS_GFX11 then {
58581ad6265SDimitry Andric        def _V2_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VReg_64>;
58681ad6265SDimitry Andric        def _V2_nsa_gfx11 : MIMG_NoSampler_nsa_gfx11<op, asm, dst_rc, 2>;
58781ad6265SDimitry Andric      }
588fe6060f1SDimitry Andric    }
5895f757f3fSDimitry Andric    if op.HAS_GFX12 then {
5905f757f3fSDimitry Andric      if isVSample then {
5915f757f3fSDimitry Andric        let samp = 0 in
5925f757f3fSDimitry Andric          def _V2_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 2>;
5935f757f3fSDimitry Andric      }
5945f757f3fSDimitry Andric      else {
5955f757f3fSDimitry Andric        def _V2_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 2>;
5965f757f3fSDimitry Andric      }
5975f757f3fSDimitry Andric    }
5985f757f3fSDimitry Andric  }
5990b57cec5SDimitry Andric  let VAddrDwords = 3 in {
6005f757f3fSDimitry Andric    let ssamp = 0 in {
60181ad6265SDimitry Andric      if op.HAS_GFX10M then {
6020b57cec5SDimitry Andric        def _V3 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_96>;
603fe6060f1SDimitry Andric        if !not(ExtendedImageInst) then
604fe6060f1SDimitry Andric        def _V3_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VReg_96>;
6050b57cec5SDimitry Andric        def _V3_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VReg_96>;
6060b57cec5SDimitry Andric        def _V3_nsa_gfx10 : MIMG_NoSampler_nsa_gfx10<op, asm, dst_rc, 3>;
6070b57cec5SDimitry Andric      }
60881ad6265SDimitry Andric      if op.HAS_GFX11 then {
60981ad6265SDimitry Andric        def _V3_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VReg_96>;
61081ad6265SDimitry Andric        def _V3_nsa_gfx11 : MIMG_NoSampler_nsa_gfx11<op, asm, dst_rc, 3>;
61181ad6265SDimitry Andric      }
612fe6060f1SDimitry Andric    }
6135f757f3fSDimitry Andric    if op.HAS_GFX12 then {
6145f757f3fSDimitry Andric      if isVSample then {
6155f757f3fSDimitry Andric        let samp = 0 in
6165f757f3fSDimitry Andric          def _V3_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 3>;
6175f757f3fSDimitry Andric      }
6185f757f3fSDimitry Andric      else {
6195f757f3fSDimitry Andric        def _V3_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 3>;
6205f757f3fSDimitry Andric      }
6215f757f3fSDimitry Andric    }
6225f757f3fSDimitry Andric  }
6230b57cec5SDimitry Andric  let VAddrDwords = 4 in {
6245f757f3fSDimitry Andric    let ssamp = 0 in {
62581ad6265SDimitry Andric      if op.HAS_GFX10M then {
6260b57cec5SDimitry Andric        def _V4 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_128>;
627fe6060f1SDimitry Andric        if !not(ExtendedImageInst) then
628fe6060f1SDimitry Andric        def _V4_gfx90a : MIMG_NoSampler_Helper_gfx90a <op, asm, dst_rc, VReg_128>;
6290b57cec5SDimitry Andric        def _V4_gfx10 : MIMG_NoSampler_gfx10<op, asm, dst_rc, VReg_128>;
6300b57cec5SDimitry Andric        def _V4_nsa_gfx10 : MIMG_NoSampler_nsa_gfx10<op, asm, dst_rc, 4,
631*0fca6ea1SDimitry Andric                                                     !if(enableDisasm, "GFX10", "")>;
6320b57cec5SDimitry Andric      }
63381ad6265SDimitry Andric      if op.HAS_GFX11 then {
63481ad6265SDimitry Andric        def _V4_gfx11 : MIMG_NoSampler_gfx11<op, asm, dst_rc, VReg_128>;
63581ad6265SDimitry Andric        def _V4_nsa_gfx11 : MIMG_NoSampler_nsa_gfx11<op, asm, dst_rc, 4,
636*0fca6ea1SDimitry Andric                                                     !if(enableDisasm, "GFX11", "")>;
63781ad6265SDimitry Andric      }
6380b57cec5SDimitry Andric    }
6395f757f3fSDimitry Andric    if op.HAS_GFX12 then {
6405f757f3fSDimitry Andric      if isVSample then {
6415f757f3fSDimitry Andric        let samp = 0 in
6425f757f3fSDimitry Andric          def _V4_gfx12 : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, 4, VGPR_32,
6435f757f3fSDimitry Andric                                                !if(enableDisasm, "GFX12", "")>;
6445f757f3fSDimitry Andric      }
6455f757f3fSDimitry Andric      else {
6465f757f3fSDimitry Andric        def _V4_gfx12 : VIMAGE_NoSampler_gfx12<op, asm, dst_rc, 4,
6475f757f3fSDimitry Andric                                               !if(enableDisasm, "GFX12", "")>;
6485f757f3fSDimitry Andric      }
6495f757f3fSDimitry Andric    }
6500b57cec5SDimitry Andric  }
651fe6060f1SDimitry Andric}
6520b57cec5SDimitry Andric
653fe6060f1SDimitry Andricmulticlass MIMG_NoSampler <mimgopc op, string asm, bit has_d16, bit mip = 0,
654fe6060f1SDimitry Andric                           bit isResInfo = 0,
655fe6060f1SDimitry Andric                           bit msaa = 0> {
6568bcb0991SDimitry Andric  def "" : MIMGBaseOpcode {
657e8d8bef9SDimitry Andric    let Coordinates = !not(isResInfo);
6580b57cec5SDimitry Andric    let LodOrClampOrMip = mip;
6590b57cec5SDimitry Andric    let HasD16 = has_d16;
660fe6060f1SDimitry Andric    let MSAA = msaa;
6610b57cec5SDimitry Andric  }
6620b57cec5SDimitry Andric
6630b57cec5SDimitry Andric  let BaseOpcode = !cast<MIMGBaseOpcode>(NAME),
664e8d8bef9SDimitry Andric      mayLoad = !not(isResInfo) in {
6650b57cec5SDimitry Andric    let VDataDwords = 1 in
666fe6060f1SDimitry Andric    defm _V1 : MIMG_NoSampler_Src_Helper <op, asm, VGPR_32, 1, msaa>;
6670b57cec5SDimitry Andric    let VDataDwords = 2 in
668fe6060f1SDimitry Andric    defm _V2 : MIMG_NoSampler_Src_Helper <op, asm, VReg_64, 0, msaa>;
6690b57cec5SDimitry Andric    let VDataDwords = 3 in
670fe6060f1SDimitry Andric    defm _V3 : MIMG_NoSampler_Src_Helper <op, asm, VReg_96, 0, msaa>;
6710b57cec5SDimitry Andric    let VDataDwords = 4 in
672fe6060f1SDimitry Andric    defm _V4 : MIMG_NoSampler_Src_Helper <op, asm, VReg_128, 0, msaa>;
6730b57cec5SDimitry Andric    let VDataDwords = 5 in
674fe6060f1SDimitry Andric    defm _V5 : MIMG_NoSampler_Src_Helper <op, asm, VReg_160, 0, msaa>;
6750b57cec5SDimitry Andric  }
6760b57cec5SDimitry Andric}
6770b57cec5SDimitry Andric
678fe6060f1SDimitry Andricclass MIMG_Store_Helper <mimgopc op, string asm,
6790b57cec5SDimitry Andric                         RegisterClass data_rc,
6800b57cec5SDimitry Andric                         RegisterClass addr_rc,
6810b57cec5SDimitry Andric                         string dns = "">
68281ad6265SDimitry Andric  : MIMG_gfx6789<op.GFX10M, (outs), dns> {
6830b57cec5SDimitry Andric  let InOperandList = !con((ins data_rc:$vdata, addr_rc:$vaddr, SReg_256:$srsrc,
684fe6060f1SDimitry Andric                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
6850b57cec5SDimitry Andric                                R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
6860b57cec5SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
687fe6060f1SDimitry Andric  let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$tfe$lwe$da"
6880b57cec5SDimitry Andric                      #!if(BaseOpcode.HasD16, "$d16", "");
6890b57cec5SDimitry Andric}
6900b57cec5SDimitry Andric
691fe6060f1SDimitry Andricclass MIMG_Store_Helper_gfx90a <mimgopc op, string asm,
692fe6060f1SDimitry Andric                                RegisterClass data_rc,
693fe6060f1SDimitry Andric                                RegisterClass addr_rc,
694fe6060f1SDimitry Andric                                string dns = "">
69581ad6265SDimitry Andric  : MIMG_gfx90a<op.GFX10M, (outs), dns> {
696fe6060f1SDimitry Andric  let InOperandList = !con((ins getLdStRegisterOperand<data_rc>.ret:$vdata,
697fe6060f1SDimitry Andric                                addr_rc:$vaddr, SReg_256:$srsrc,
698fe6060f1SDimitry Andric                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
699fe6060f1SDimitry Andric                                R128A16:$r128, LWE:$lwe, DA:$da),
700fe6060f1SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
701fe6060f1SDimitry Andric  let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$cpol$r128$lwe$da"
702fe6060f1SDimitry Andric                      #!if(BaseOpcode.HasD16, "$d16", "");
703fe6060f1SDimitry Andric}
704fe6060f1SDimitry Andric
705fe6060f1SDimitry Andricclass MIMG_Store_gfx10<mimgopc op, string opcode,
7060b57cec5SDimitry Andric                       RegisterClass DataRC, RegisterClass AddrRC,
7070b57cec5SDimitry Andric                       string dns="">
70881ad6265SDimitry Andric  : MIMG_gfx10<op.GFX10M, (outs), dns> {
7090b57cec5SDimitry Andric  let InOperandList = !con((ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
710fe6060f1SDimitry Andric                                DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
711bdd1243dSDimitry Andric                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
7120b57cec5SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
713fe6060f1SDimitry Andric  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
7140b57cec5SDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
7150b57cec5SDimitry Andric}
7160b57cec5SDimitry Andric
717fe6060f1SDimitry Andricclass MIMG_Store_nsa_gfx10<mimgopc op, string opcode,
7180b57cec5SDimitry Andric                           RegisterClass DataRC, int num_addrs,
7190b57cec5SDimitry Andric                           string dns="">
72081ad6265SDimitry Andric  : MIMG_nsa_gfx10<op.GFX10M, (outs), num_addrs, dns> {
72181ad6265SDimitry Andric  let InOperandList = !con((ins DataRC:$vdata),
72281ad6265SDimitry Andric                           AddrIns,
72381ad6265SDimitry Andric                           (ins SReg_256:$srsrc, DMask:$dmask,
72481ad6265SDimitry Andric                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
725bdd1243dSDimitry Andric                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
72681ad6265SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
72781ad6265SDimitry Andric  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
72881ad6265SDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
72981ad6265SDimitry Andric}
73081ad6265SDimitry Andric
73181ad6265SDimitry Andricclass MIMG_Store_gfx11<mimgopc op, string opcode,
73281ad6265SDimitry Andric                       RegisterClass DataRC, RegisterClass AddrRC,
73381ad6265SDimitry Andric                       string dns="">
73481ad6265SDimitry Andric  : MIMG_gfx11<op.GFX11, (outs), dns> {
73581ad6265SDimitry Andric  let InOperandList = !con((ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
73681ad6265SDimitry Andric                                DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
737bdd1243dSDimitry Andric                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
73881ad6265SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
73981ad6265SDimitry Andric  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
74081ad6265SDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
74181ad6265SDimitry Andric}
74281ad6265SDimitry Andric
74381ad6265SDimitry Andricclass MIMG_Store_nsa_gfx11<mimgopc op, string opcode,
74481ad6265SDimitry Andric                           RegisterClass DataRC, int num_addrs,
74581ad6265SDimitry Andric                           string dns="">
74681ad6265SDimitry Andric  : MIMG_nsa_gfx11<op.GFX11, (outs), num_addrs, dns> {
7470b57cec5SDimitry Andric  let InOperandList = !con((ins DataRC:$vdata),
7480b57cec5SDimitry Andric                           AddrIns,
7490b57cec5SDimitry Andric                           (ins SReg_256:$srsrc, DMask:$dmask,
750fe6060f1SDimitry Andric                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
751bdd1243dSDimitry Andric                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
7520b57cec5SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
753fe6060f1SDimitry Andric  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe"
7540b57cec5SDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
7550b57cec5SDimitry Andric}
7560b57cec5SDimitry Andric
7575f757f3fSDimitry Andricclass VIMAGE_Store_gfx12<mimgopc op, string opcode,
7585f757f3fSDimitry Andric                         RegisterClass DataRC, int num_addrs,
7595f757f3fSDimitry Andric                         string dns="">
7605f757f3fSDimitry Andric  : VIMAGE_gfx12<op.GFX12, (outs), num_addrs, dns> {
7615f757f3fSDimitry Andric  let InOperandList = !con((ins DataRC:$vdata),
7625f757f3fSDimitry Andric                           AddrIns,
7635f757f3fSDimitry Andric                           (ins SReg_256:$rsrc, DMask:$dmask, Dim:$dim,
7645f757f3fSDimitry Andric                                CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe),
7655f757f3fSDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
7665f757f3fSDimitry Andric  let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc$dmask$dim$cpol$r128$a16$tfe"
7675f757f3fSDimitry Andric                    #!if(BaseOpcode.HasD16, "$d16", "");
7685f757f3fSDimitry Andric}
7695f757f3fSDimitry Andric
770fe6060f1SDimitry Andricmulticlass MIMG_Store_Addr_Helper <mimgopc op, string asm,
7710b57cec5SDimitry Andric                                  RegisterClass data_rc,
7720b57cec5SDimitry Andric                                  bit enableDisasm> {
7730b57cec5SDimitry Andric  let mayLoad = 0, mayStore = 1, hasSideEffects = 0, hasPostISelHook = 0,
7745f757f3fSDimitry Andric      DisableWQM = 1 in {
7750b57cec5SDimitry Andric    let VAddrDwords = 1 in {
7765f757f3fSDimitry Andric      let ssamp = 0 in {
77781ad6265SDimitry Andric        if op.HAS_GFX10M then {
7780b57cec5SDimitry Andric          def _V1 : MIMG_Store_Helper <op, asm, data_rc, VGPR_32,
779*0fca6ea1SDimitry Andric                                      !if(enableDisasm, "GFX8", "")>;
78081ad6265SDimitry Andric          let hasPostISelHook = 1 in
781fe6060f1SDimitry Andric          def _V1_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VGPR_32,
782fe6060f1SDimitry Andric                                      !if(enableDisasm, "GFX90A", "")>;
7830b57cec5SDimitry Andric          def _V1_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VGPR_32,
784*0fca6ea1SDimitry Andric                                            !if(enableDisasm, "GFX10", "")>;
7850b57cec5SDimitry Andric        }
78681ad6265SDimitry Andric        if op.HAS_GFX11 then {
78781ad6265SDimitry Andric          def _V1_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VGPR_32,
788*0fca6ea1SDimitry Andric                                            !if(enableDisasm, "GFX11", "")>;
78981ad6265SDimitry Andric        }
790fe6060f1SDimitry Andric      }
7915f757f3fSDimitry Andric      if op.HAS_GFX12 then {
7925f757f3fSDimitry Andric        def _V1_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 1,
7935f757f3fSDimitry Andric                                            !if(enableDisasm, "GFX12", "")>;
7945f757f3fSDimitry Andric      }
7955f757f3fSDimitry Andric    }
7960b57cec5SDimitry Andric    let VAddrDwords = 2 in {
7975f757f3fSDimitry Andric      let ssamp = 0 in {
79881ad6265SDimitry Andric        if op.HAS_GFX10M then {
7990b57cec5SDimitry Andric          def _V2 : MIMG_Store_Helper <op, asm, data_rc, VReg_64>;
800fe6060f1SDimitry Andric          def _V2_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VReg_64>;
8010b57cec5SDimitry Andric          def _V2_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VReg_64>;
8020b57cec5SDimitry Andric          def _V2_nsa_gfx10 : MIMG_Store_nsa_gfx10 <op, asm, data_rc, 2>;
8030b57cec5SDimitry Andric        }
80481ad6265SDimitry Andric        if op.HAS_GFX11 then {
80581ad6265SDimitry Andric          def _V2_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VReg_64>;
80681ad6265SDimitry Andric          def _V2_nsa_gfx11 : MIMG_Store_nsa_gfx11 <op, asm, data_rc, 2>;
80781ad6265SDimitry Andric        }
808fe6060f1SDimitry Andric      }
8095f757f3fSDimitry Andric      if op.HAS_GFX12 then {
8105f757f3fSDimitry Andric        def _V2_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 2>;
8115f757f3fSDimitry Andric      }
8125f757f3fSDimitry Andric    }
8130b57cec5SDimitry Andric    let VAddrDwords = 3 in {
8145f757f3fSDimitry Andric      let ssamp = 0 in {
81581ad6265SDimitry Andric        if op.HAS_GFX10M then {
8160b57cec5SDimitry Andric          def _V3 : MIMG_Store_Helper <op, asm, data_rc, VReg_96>;
817fe6060f1SDimitry Andric          def _V3_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VReg_96>;
8180b57cec5SDimitry Andric          def _V3_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VReg_96>;
8190b57cec5SDimitry Andric          def _V3_nsa_gfx10 : MIMG_Store_nsa_gfx10 <op, asm, data_rc, 3>;
8200b57cec5SDimitry Andric        }
82181ad6265SDimitry Andric        if op.HAS_GFX11 then {
82281ad6265SDimitry Andric          def _V3_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VReg_96>;
82381ad6265SDimitry Andric          def _V3_nsa_gfx11 : MIMG_Store_nsa_gfx11 <op, asm, data_rc, 3>;
82481ad6265SDimitry Andric        }
825fe6060f1SDimitry Andric      }
8265f757f3fSDimitry Andric      if op.HAS_GFX12 then {
8275f757f3fSDimitry Andric        def _V3_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 3>;
8285f757f3fSDimitry Andric      }
8295f757f3fSDimitry Andric    }
8300b57cec5SDimitry Andric    let VAddrDwords = 4 in {
8315f757f3fSDimitry Andric      let ssamp = 0 in {
83281ad6265SDimitry Andric        if op.HAS_GFX10M then {
8330b57cec5SDimitry Andric          def _V4 : MIMG_Store_Helper <op, asm, data_rc, VReg_128>;
834fe6060f1SDimitry Andric          def _V4_gfx90a : MIMG_Store_Helper_gfx90a <op, asm, data_rc, VReg_128>;
8350b57cec5SDimitry Andric          def _V4_gfx10 : MIMG_Store_gfx10 <op, asm, data_rc, VReg_128>;
8360b57cec5SDimitry Andric          def _V4_nsa_gfx10 : MIMG_Store_nsa_gfx10 <op, asm, data_rc, 4,
837*0fca6ea1SDimitry Andric                                                          !if(enableDisasm, "GFX10", "")>;
8380b57cec5SDimitry Andric        }
83981ad6265SDimitry Andric        if op.HAS_GFX11 then {
84081ad6265SDimitry Andric          def _V4_gfx11 : MIMG_Store_gfx11 <op, asm, data_rc, VReg_128>;
84181ad6265SDimitry Andric          def _V4_nsa_gfx11 : MIMG_Store_nsa_gfx11 <op, asm, data_rc, 4,
842*0fca6ea1SDimitry Andric                                                          !if(enableDisasm, "GFX11", "")>;
84381ad6265SDimitry Andric        }
8440b57cec5SDimitry Andric      }
8455f757f3fSDimitry Andric      if op.HAS_GFX12 then {
8465f757f3fSDimitry Andric        def _V4_gfx12 : VIMAGE_Store_gfx12 <op, asm, data_rc, 4,
8475f757f3fSDimitry Andric                                            !if(enableDisasm, "GFX12", "")>;
8485f757f3fSDimitry Andric      }
8495f757f3fSDimitry Andric    }
8500b57cec5SDimitry Andric  }
851fe6060f1SDimitry Andric}
8520b57cec5SDimitry Andric
853fe6060f1SDimitry Andricmulticlass MIMG_Store <mimgopc op, string asm, bit has_d16, bit mip = 0> {
8540b57cec5SDimitry Andric  def "" : MIMGBaseOpcode {
8550b57cec5SDimitry Andric    let Store = 1;
8560b57cec5SDimitry Andric    let LodOrClampOrMip = mip;
8570b57cec5SDimitry Andric    let HasD16 = has_d16;
858*0fca6ea1SDimitry Andric    let NoReturn = 1;
8590b57cec5SDimitry Andric  }
8600b57cec5SDimitry Andric
8610b57cec5SDimitry Andric  let BaseOpcode = !cast<MIMGBaseOpcode>(NAME) in {
8620b57cec5SDimitry Andric    let VDataDwords = 1 in
8630b57cec5SDimitry Andric    defm _V1 : MIMG_Store_Addr_Helper <op, asm, VGPR_32, 1>;
8640b57cec5SDimitry Andric    let VDataDwords = 2 in
8650b57cec5SDimitry Andric    defm _V2 : MIMG_Store_Addr_Helper <op, asm, VReg_64, 0>;
8660b57cec5SDimitry Andric    let VDataDwords = 3 in
8670b57cec5SDimitry Andric    defm _V3 : MIMG_Store_Addr_Helper <op, asm, VReg_96, 0>;
8680b57cec5SDimitry Andric    let VDataDwords = 4 in
8690b57cec5SDimitry Andric    defm _V4 : MIMG_Store_Addr_Helper <op, asm, VReg_128, 0>;
870e8d8bef9SDimitry Andric    let VDataDwords = 5 in
871e8d8bef9SDimitry Andric    defm _V5 : MIMG_Store_Addr_Helper <op, asm, VReg_160, 0>;
8720b57cec5SDimitry Andric  }
8730b57cec5SDimitry Andric}
8740b57cec5SDimitry Andric
8750b57cec5SDimitry Andricclass MIMG_Atomic_gfx6789_base <bits<8> op, string asm, RegisterClass data_rc,
8760b57cec5SDimitry Andric                                RegisterClass addr_rc, string dns="">
8770b57cec5SDimitry Andric  : MIMG_gfx6789 <op, (outs data_rc:$vdst), dns> {
8780b57cec5SDimitry Andric  let Constraints = "$vdst = $vdata";
8790b57cec5SDimitry Andric
8800b57cec5SDimitry Andric  let InOperandList = (ins data_rc:$vdata, addr_rc:$vaddr, SReg_256:$srsrc,
881fe6060f1SDimitry Andric                           DMask:$dmask, UNorm:$unorm, CPol:$cpol,
8820b57cec5SDimitry Andric                           R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da);
883fe6060f1SDimitry Andric  let AsmString = asm#" $vdst, $vaddr, $srsrc$dmask$unorm$cpol$r128$tfe$lwe$da";
8840b57cec5SDimitry Andric}
8850b57cec5SDimitry Andric
886fe6060f1SDimitry Andricclass MIMG_Atomic_gfx90a_base <bits<8> op, string asm, RegisterClass data_rc,
887fe6060f1SDimitry Andric                               RegisterClass addr_rc, string dns="">
888fe6060f1SDimitry Andric  : MIMG_gfx90a <op, (outs getLdStRegisterOperand<data_rc>.ret:$vdst), dns> {
889fe6060f1SDimitry Andric  let Constraints = "$vdst = $vdata";
890fe6060f1SDimitry Andric
891fe6060f1SDimitry Andric  let InOperandList = (ins getLdStRegisterOperand<data_rc>.ret:$vdata,
892fe6060f1SDimitry Andric                           addr_rc:$vaddr, SReg_256:$srsrc,
893fe6060f1SDimitry Andric                           DMask:$dmask, UNorm:$unorm, CPol:$cpol,
894fe6060f1SDimitry Andric                           R128A16:$r128, LWE:$lwe, DA:$da);
895fe6060f1SDimitry Andric  let AsmString = asm#" $vdst, $vaddr, $srsrc$dmask$unorm$cpol$r128$lwe$da";
896fe6060f1SDimitry Andric}
897fe6060f1SDimitry Andric
898fe6060f1SDimitry Andricclass MIMG_Atomic_si<mimgopc op, string asm, RegisterClass data_rc,
8990b57cec5SDimitry Andric                     RegisterClass addr_rc, bit enableDasm = 0>
900fe6060f1SDimitry Andric  : MIMG_Atomic_gfx6789_base<op.SI, asm, data_rc, addr_rc,
9010b57cec5SDimitry Andric                             !if(enableDasm, "GFX6GFX7", "")> {
902480093f4SDimitry Andric  let AssemblerPredicate = isGFX6GFX7;
9030b57cec5SDimitry Andric}
9040b57cec5SDimitry Andric
905fe6060f1SDimitry Andricclass MIMG_Atomic_vi<mimgopc op, string asm, RegisterClass data_rc,
9060b57cec5SDimitry Andric                     RegisterClass addr_rc, bit enableDasm = 0>
9070b57cec5SDimitry Andric  : MIMG_Atomic_gfx6789_base<op.VI, asm, data_rc, addr_rc, !if(enableDasm, "GFX8", "")> {
908fe6060f1SDimitry Andric  let AssemblerPredicate = isGFX8GFX9NotGFX90A;
9090b57cec5SDimitry Andric  let MIMGEncoding = MIMGEncGfx8;
9100b57cec5SDimitry Andric}
9110b57cec5SDimitry Andric
912fe6060f1SDimitry Andricclass MIMG_Atomic_gfx90a<mimgopc op, string asm, RegisterClass data_rc,
913fe6060f1SDimitry Andric                         RegisterClass addr_rc, bit enableDasm = 0>
914fe6060f1SDimitry Andric  : MIMG_Atomic_gfx90a_base<op.VI, asm, data_rc, addr_rc, !if(enableDasm, "GFX90A", "")> {
915fe6060f1SDimitry Andric  let AssemblerPredicate = isGFX90APlus;
916fe6060f1SDimitry Andric  let MIMGEncoding = MIMGEncGfx90a;
917fe6060f1SDimitry Andric}
918fe6060f1SDimitry Andric
919fe6060f1SDimitry Andricclass MIMG_Atomic_gfx10<mimgopc op, string opcode,
9200b57cec5SDimitry Andric                        RegisterClass DataRC, RegisterClass AddrRC,
9210b57cec5SDimitry Andric                        bit enableDisasm = 0>
92281ad6265SDimitry Andric  : MIMG_gfx10<!cast<int>(op.GFX10M), (outs DataRC:$vdst),
923*0fca6ea1SDimitry Andric               !if(enableDisasm, "GFX10", "")> {
9240b57cec5SDimitry Andric  let Constraints = "$vdst = $vdata";
9250b57cec5SDimitry Andric
9260b57cec5SDimitry Andric  let InOperandList = (ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
927fe6060f1SDimitry Andric                           DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
928bdd1243dSDimitry Andric                           R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe);
929fe6060f1SDimitry Andric  let AsmString = opcode#" $vdst, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
9300b57cec5SDimitry Andric}
9310b57cec5SDimitry Andric
932fe6060f1SDimitry Andricclass MIMG_Atomic_nsa_gfx10<mimgopc op, string opcode,
9330b57cec5SDimitry Andric                            RegisterClass DataRC, int num_addrs,
9340b57cec5SDimitry Andric                            bit enableDisasm = 0>
93581ad6265SDimitry Andric  : MIMG_nsa_gfx10<!cast<int>(op.GFX10M), (outs DataRC:$vdst), num_addrs,
936*0fca6ea1SDimitry Andric                   !if(enableDisasm, "GFX10", "")> {
93781ad6265SDimitry Andric  let Constraints = "$vdst = $vdata";
93881ad6265SDimitry Andric
93981ad6265SDimitry Andric  let InOperandList = !con((ins DataRC:$vdata),
94081ad6265SDimitry Andric                           AddrIns,
94181ad6265SDimitry Andric                           (ins SReg_256:$srsrc, DMask:$dmask,
94281ad6265SDimitry Andric                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
943bdd1243dSDimitry Andric                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe));
94481ad6265SDimitry Andric  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
94581ad6265SDimitry Andric}
94681ad6265SDimitry Andric
94781ad6265SDimitry Andricclass MIMG_Atomic_gfx11<mimgopc op, string opcode,
94881ad6265SDimitry Andric                        RegisterClass DataRC, RegisterClass AddrRC,
94981ad6265SDimitry Andric                        bit enableDisasm = 0>
95081ad6265SDimitry Andric  : MIMG_gfx11<!cast<int>(op.GFX11), (outs DataRC:$vdst),
951*0fca6ea1SDimitry Andric               !if(enableDisasm, "GFX11", "")> {
95281ad6265SDimitry Andric  let Constraints = "$vdst = $vdata";
95381ad6265SDimitry Andric
95481ad6265SDimitry Andric  let InOperandList = (ins DataRC:$vdata, AddrRC:$vaddr0, SReg_256:$srsrc,
95581ad6265SDimitry Andric                           DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
956bdd1243dSDimitry Andric                           R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe);
95781ad6265SDimitry Andric  let AsmString = opcode#" $vdst, $vaddr0, $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
95881ad6265SDimitry Andric}
95981ad6265SDimitry Andric
96081ad6265SDimitry Andricclass MIMG_Atomic_nsa_gfx11<mimgopc op, string opcode,
96181ad6265SDimitry Andric                            RegisterClass DataRC, int num_addrs,
96281ad6265SDimitry Andric                            bit enableDisasm = 0>
96381ad6265SDimitry Andric  : MIMG_nsa_gfx11<!cast<int>(op.GFX11), (outs DataRC:$vdst), num_addrs,
964*0fca6ea1SDimitry Andric                   !if(enableDisasm, "GFX11", "")> {
9650b57cec5SDimitry Andric  let Constraints = "$vdst = $vdata";
9660b57cec5SDimitry Andric
9670b57cec5SDimitry Andric  let InOperandList = !con((ins DataRC:$vdata),
9680b57cec5SDimitry Andric                           AddrIns,
9690b57cec5SDimitry Andric                           (ins SReg_256:$srsrc, DMask:$dmask,
970fe6060f1SDimitry Andric                                Dim:$dim, UNorm:$unorm, CPol:$cpol,
971bdd1243dSDimitry Andric                                R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe));
972fe6060f1SDimitry Andric  let AsmString = opcode#" $vdata, "#AddrAsm#", $srsrc$dmask$dim$unorm$cpol$r128$a16$tfe$lwe";
9730b57cec5SDimitry Andric}
9740b57cec5SDimitry Andric
9755f757f3fSDimitry Andricclass VIMAGE_Atomic_gfx12<mimgopc op, string opcode, RegisterClass DataRC,
9765f757f3fSDimitry Andric                          int num_addrs, bit enableDisasm = 0>
9775f757f3fSDimitry Andric  : VIMAGE_gfx12<!cast<int>(op.GFX12), (outs DataRC:$vdst), num_addrs,
9785f757f3fSDimitry Andric                  !if(enableDisasm, "GFX12", "")> {
9795f757f3fSDimitry Andric  let Constraints = "$vdst = $vdata";
9805f757f3fSDimitry Andric
9815f757f3fSDimitry Andric  let InOperandList = !con((ins DataRC:$vdata),
9825f757f3fSDimitry Andric                           AddrIns,
9835f757f3fSDimitry Andric                           (ins SReg_256:$rsrc, DMask:$dmask, Dim:$dim,
9845f757f3fSDimitry Andric                                 CPol:$cpol, R128A16:$r128, A16:$a16, TFE:$tfe));
9855f757f3fSDimitry Andric  let AsmString = opcode#" $vdata, "#AddrAsm#", $rsrc$dmask$dim$cpol$r128$a16$tfe";
9865f757f3fSDimitry Andric}
9875f757f3fSDimitry Andric
988*0fca6ea1SDimitry Andricclass VIMAGE_Atomic_gfx12_Renamed<mimgopc op, string renamed,
9895f757f3fSDimitry Andric                                  RegisterClass DataRC, int num_addrs,
9905f757f3fSDimitry Andric                                  bit enableDisasm = 0>
991*0fca6ea1SDimitry Andric  : VIMAGE_Atomic_gfx12<op, renamed, DataRC, num_addrs, enableDisasm>;
9925f757f3fSDimitry Andric
993fe6060f1SDimitry Andricmulticlass MIMG_Atomic_Addr_Helper_m <mimgopc op, string asm,
9940b57cec5SDimitry Andric                                      RegisterClass data_rc,
995fe6060f1SDimitry Andric                                      bit enableDasm = 0,
9965f757f3fSDimitry Andric                                      bit isFP = 0,
9975f757f3fSDimitry Andric                                      string renamed = ""> {
9980b57cec5SDimitry Andric  let hasSideEffects = 1, // FIXME: remove this
9990b57cec5SDimitry Andric      mayLoad = 1, mayStore = 1, hasPostISelHook = 0, DisableWQM = 1,
10005f757f3fSDimitry Andric      FPAtomic = isFP in {
10010b57cec5SDimitry Andric    let VAddrDwords = 1 in {
10025f757f3fSDimitry Andric      let ssamp = 0 in {
1003fe6060f1SDimitry Andric        if op.HAS_SI then {
10040b57cec5SDimitry Andric          def _V1_si : MIMG_Atomic_si <op, asm, data_rc, VGPR_32, enableDasm>;
1005fe6060f1SDimitry Andric        }
1006fe6060f1SDimitry Andric        if op.HAS_VI then {
10070b57cec5SDimitry Andric          def _V1_vi : MIMG_Atomic_vi <op, asm, data_rc, VGPR_32, enableDasm>;
100881ad6265SDimitry Andric          let hasPostISelHook = 1 in
1009fe6060f1SDimitry Andric          def _V1_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VGPR_32, enableDasm>;
1010fe6060f1SDimitry Andric        }
101181ad6265SDimitry Andric        if op.HAS_GFX10M then {
10120b57cec5SDimitry Andric          def _V1_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VGPR_32, enableDasm>;
10130b57cec5SDimitry Andric        }
101481ad6265SDimitry Andric        if op.HAS_GFX11 then {
101581ad6265SDimitry Andric          def _V1_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VGPR_32, enableDasm>;
101681ad6265SDimitry Andric        }
1017fe6060f1SDimitry Andric      }
10185f757f3fSDimitry Andric      if op.HAS_GFX12 then {
10195f757f3fSDimitry Andric        if !empty(renamed) then
10205f757f3fSDimitry Andric          def _V1_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 1, enableDasm>;
10215f757f3fSDimitry Andric        else
1022*0fca6ea1SDimitry Andric          def _V1_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, renamed, data_rc, 1, enableDasm>;
10235f757f3fSDimitry Andric      }
10245f757f3fSDimitry Andric    }
10250b57cec5SDimitry Andric    let VAddrDwords = 2 in {
10265f757f3fSDimitry Andric      let ssamp = 0 in {
1027fe6060f1SDimitry Andric        if op.HAS_SI then {
10280b57cec5SDimitry Andric          def _V2_si : MIMG_Atomic_si <op, asm, data_rc, VReg_64, 0>;
1029fe6060f1SDimitry Andric        }
1030fe6060f1SDimitry Andric        if op.HAS_VI then {
10310b57cec5SDimitry Andric          def _V2_vi : MIMG_Atomic_vi <op, asm, data_rc, VReg_64, 0>;
1032fe6060f1SDimitry Andric          def _V2_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VReg_64, 0>;
1033fe6060f1SDimitry Andric        }
103481ad6265SDimitry Andric        if op.HAS_GFX10M then {
10350b57cec5SDimitry Andric          def _V2_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VReg_64, 0>;
10360b57cec5SDimitry Andric          def _V2_nsa_gfx10 : MIMG_Atomic_nsa_gfx10 <op, asm, data_rc, 2, 0>;
10370b57cec5SDimitry Andric        }
103881ad6265SDimitry Andric        if op.HAS_GFX11 then {
103981ad6265SDimitry Andric          def _V2_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VReg_64, 0>;
104081ad6265SDimitry Andric          def _V2_nsa_gfx11 : MIMG_Atomic_nsa_gfx11 <op, asm, data_rc, 2, 0>;
104181ad6265SDimitry Andric        }
1042fe6060f1SDimitry Andric      }
10435f757f3fSDimitry Andric      if op.HAS_GFX12 then {
10445f757f3fSDimitry Andric        if !empty(renamed) then
10455f757f3fSDimitry Andric          def _V2_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 2, 0>;
10465f757f3fSDimitry Andric        else
1047*0fca6ea1SDimitry Andric          def _V2_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, renamed, data_rc, 2, 0>;
10485f757f3fSDimitry Andric      }
10495f757f3fSDimitry Andric    }
10500b57cec5SDimitry Andric    let VAddrDwords = 3 in {
10515f757f3fSDimitry Andric      let ssamp = 0 in {
1052fe6060f1SDimitry Andric        if op.HAS_SI then {
10530b57cec5SDimitry Andric          def _V3_si : MIMG_Atomic_si <op, asm, data_rc, VReg_96, 0>;
1054fe6060f1SDimitry Andric        }
1055fe6060f1SDimitry Andric        if op.HAS_VI then {
10560b57cec5SDimitry Andric          def _V3_vi : MIMG_Atomic_vi <op, asm, data_rc, VReg_96, 0>;
1057fe6060f1SDimitry Andric          def _V3_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VReg_96, 0>;
1058fe6060f1SDimitry Andric        }
105981ad6265SDimitry Andric        if op.HAS_GFX10M then {
10600b57cec5SDimitry Andric          def _V3_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VReg_96, 0>;
10610b57cec5SDimitry Andric          def _V3_nsa_gfx10 : MIMG_Atomic_nsa_gfx10 <op, asm, data_rc, 3, 0>;
10620b57cec5SDimitry Andric        }
106381ad6265SDimitry Andric        if op.HAS_GFX11 then {
106481ad6265SDimitry Andric          def _V3_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VReg_96, 0>;
106581ad6265SDimitry Andric          def _V3_nsa_gfx11 : MIMG_Atomic_nsa_gfx11 <op, asm, data_rc, 3, 0>;
106681ad6265SDimitry Andric        }
1067fe6060f1SDimitry Andric      }
10685f757f3fSDimitry Andric      if op.HAS_GFX12 then {
10695f757f3fSDimitry Andric        if !empty(renamed) then
10705f757f3fSDimitry Andric          def _V3_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 3, 0>;
10715f757f3fSDimitry Andric        else
1072*0fca6ea1SDimitry Andric          def _V3_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, renamed, data_rc, 3, 0>;
10735f757f3fSDimitry Andric      }
10745f757f3fSDimitry Andric    }
10750b57cec5SDimitry Andric    let VAddrDwords = 4 in {
10765f757f3fSDimitry Andric      let ssamp = 0 in {
1077fe6060f1SDimitry Andric        if op.HAS_SI then {
10780b57cec5SDimitry Andric          def _V4_si : MIMG_Atomic_si <op, asm, data_rc, VReg_128, 0>;
1079fe6060f1SDimitry Andric        }
1080fe6060f1SDimitry Andric        if op.HAS_VI then {
10810b57cec5SDimitry Andric          def _V4_vi : MIMG_Atomic_vi <op, asm, data_rc, VReg_128, 0>;
1082fe6060f1SDimitry Andric          def _V4_gfx90a : MIMG_Atomic_gfx90a <op, asm, data_rc, VReg_128, 0>;
1083fe6060f1SDimitry Andric        }
108481ad6265SDimitry Andric        if op.HAS_GFX10M then {
10850b57cec5SDimitry Andric          def _V4_gfx10 : MIMG_Atomic_gfx10 <op, asm, data_rc, VReg_128, 0>;
10860b57cec5SDimitry Andric          def _V4_nsa_gfx10 : MIMG_Atomic_nsa_gfx10 <op, asm, data_rc, 4, enableDasm>;
10870b57cec5SDimitry Andric        }
108881ad6265SDimitry Andric        if op.HAS_GFX11 then {
108981ad6265SDimitry Andric          def _V4_gfx11 : MIMG_Atomic_gfx11 <op, asm, data_rc, VReg_128, 0>;
109081ad6265SDimitry Andric          def _V4_nsa_gfx11 : MIMG_Atomic_nsa_gfx11 <op, asm, data_rc, 4, enableDasm>;
109181ad6265SDimitry Andric        }
10920b57cec5SDimitry Andric      }
10935f757f3fSDimitry Andric      if op.HAS_GFX12 then {
10945f757f3fSDimitry Andric        if !empty(renamed) then
10955f757f3fSDimitry Andric          def _V4_gfx12 : VIMAGE_Atomic_gfx12 <op, asm, data_rc, 4, enableDasm>;
10965f757f3fSDimitry Andric        else
1097*0fca6ea1SDimitry Andric          def _V4_gfx12 : VIMAGE_Atomic_gfx12_Renamed <op, renamed, data_rc, 4, enableDasm>;
10985f757f3fSDimitry Andric      }
10995f757f3fSDimitry Andric    }
11000b57cec5SDimitry Andric  }
1101*0fca6ea1SDimitry Andric  if !and(op.HAS_GFX12, !not(!empty(renamed))) then
1102*0fca6ea1SDimitry Andric    def : AMDGPUMnemonicAlias<asm, renamed> {
1103*0fca6ea1SDimitry Andric      let AssemblerPredicate = isGFX12Plus;
1104*0fca6ea1SDimitry Andric      bit IsAtomicRet; // Unused
1105*0fca6ea1SDimitry Andric      MIMGBaseOpcode BaseOpcode; // Unused
1106*0fca6ea1SDimitry Andric      int VDataDwords; // Unused
1107*0fca6ea1SDimitry Andric    }
1108fe6060f1SDimitry Andric}
11090b57cec5SDimitry Andric
11105f757f3fSDimitry Andricmulticlass MIMG_Atomic <mimgopc op, string asm, bit isCmpSwap = 0, bit isFP = 0,
11115f757f3fSDimitry Andric                        string renamed = ""> { // 64-bit atomics
1112fe6060f1SDimitry Andric  let IsAtomicRet = 1 in {
11130b57cec5SDimitry Andric    def "" : MIMGBaseOpcode {
11140b57cec5SDimitry Andric      let Atomic = 1;
11150b57cec5SDimitry Andric      let AtomicX2 = isCmpSwap;
11160b57cec5SDimitry Andric    }
11170b57cec5SDimitry Andric
11180b57cec5SDimitry Andric    let BaseOpcode = !cast<MIMGBaseOpcode>(NAME) in {
11190b57cec5SDimitry Andric      // _V* variants have different dst size, but the size is encoded implicitly,
11200b57cec5SDimitry Andric      // using dmask and tfe. Only 32-bit variant is registered with disassembler.
11210b57cec5SDimitry Andric      // Other variants are reconstructed by disassembler using dmask and tfe.
11220b57cec5SDimitry Andric      let VDataDwords = !if(isCmpSwap, 2, 1) in
11235f757f3fSDimitry Andric      defm _V1 : MIMG_Atomic_Addr_Helper_m <op, asm, !if(isCmpSwap, VReg_64, VGPR_32), 1, isFP, renamed>;
11240b57cec5SDimitry Andric      let VDataDwords = !if(isCmpSwap, 4, 2) in
11255f757f3fSDimitry Andric      defm _V2 : MIMG_Atomic_Addr_Helper_m <op, asm, !if(isCmpSwap, VReg_128, VReg_64), 0, isFP, renamed>;
1126*0fca6ea1SDimitry Andric      let VDataDwords = !if(isCmpSwap, 2, 2) in
1127*0fca6ea1SDimitry Andric      defm _V3 : MIMG_Atomic_Addr_Helper_m <op, asm, VReg_96, 0, isFP, renamed>;
1128*0fca6ea1SDimitry Andric      let VDataDwords = !if(isCmpSwap, 4, 4) in
1129*0fca6ea1SDimitry Andric      defm _V4 : MIMG_Atomic_Addr_Helper_m <op, asm, VReg_160, 0, isFP, renamed>;
11300b57cec5SDimitry Andric    }
1131fe6060f1SDimitry Andric  } // End IsAtomicRet = 1
11320b57cec5SDimitry Andric}
11330b57cec5SDimitry Andric
11345f757f3fSDimitry Andricmulticlass MIMG_Atomic_Renamed <mimgopc op, string asm, string renamed,
11355f757f3fSDimitry Andric                                bit isCmpSwap = 0, bit isFP = 0>
11365f757f3fSDimitry Andric  : MIMG_Atomic <op, asm, isCmpSwap, isFP, renamed>;
11375f757f3fSDimitry Andric
1138fe6060f1SDimitry Andricclass MIMG_Sampler_Helper <mimgopc op, string asm, RegisterClass dst_rc,
11390b57cec5SDimitry Andric                           RegisterClass src_rc, string dns="">
1140bdd1243dSDimitry Andric  : MIMG_gfx6789 <op.VI, (outs dst_rc:$vdata), dns> {
11410b57cec5SDimitry Andric  let InOperandList = !con((ins src_rc:$vaddr, SReg_256:$srsrc, SReg_128:$ssamp,
1142fe6060f1SDimitry Andric                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
11430b57cec5SDimitry Andric                                R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
11440b57cec5SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
1145fe6060f1SDimitry Andric  let AsmString = asm#" $vdata, $vaddr, $srsrc, $ssamp$dmask$unorm$cpol$r128$tfe$lwe$da"
11460b57cec5SDimitry Andric                      #!if(BaseOpcode.HasD16, "$d16", "");
11470b57cec5SDimitry Andric}
11480b57cec5SDimitry Andric
1149fe6060f1SDimitry Andricclass MIMG_Sampler_gfx90a<mimgopc op, string asm, RegisterClass dst_rc,
1150fe6060f1SDimitry Andric                          RegisterClass src_rc, string dns="">
115181ad6265SDimitry Andric  : MIMG_gfx90a<op.GFX10M, (outs getLdStRegisterOperand<dst_rc>.ret:$vdata), dns> {
1152fe6060f1SDimitry Andric  let InOperandList = !con((ins src_rc:$vaddr, SReg_256:$srsrc, SReg_128:$ssamp,
1153fe6060f1SDimitry Andric                                DMask:$dmask, UNorm:$unorm, CPol:$cpol,
1154fe6060f1SDimitry Andric                                R128A16:$r128, LWE:$lwe, DA:$da),
1155fe6060f1SDimitry Andric                           !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
1156fe6060f1SDimitry Andric  let AsmString = asm#" $vdata, $vaddr, $srsrc, $ssamp$dmask$unorm$cpol$r128$lwe$da"
1157fe6060f1SDimitry Andric                      #!if(BaseOpcode.HasD16, "$d16", "");
1158fe6060f1SDimitry Andric}
1159fe6060f1SDimitry Andric
1160*0fca6ea1SDimitry Andricclass MIMG_Sampler_OpList_gfx10p<dag OpPrefix, bit HasD16> {
1161*0fca6ea1SDimitry Andric  dag ret = !con(OpPrefix,
1162*0fca6ea1SDimitry Andric                 (ins SReg_256:$srsrc, SReg_128:$ssamp,
1163*0fca6ea1SDimitry Andric                  DMask:$dmask, Dim:$dim, UNorm:$unorm, CPol:$cpol,
1164*0fca6ea1SDimitry Andric                  R128A16:$r128, A16:$a16, TFE:$tfe, LWE:$lwe),
1165*0fca6ea1SDimitry Andric                 !if(HasD16, (ins D16:$d16), (ins)));
1166*0fca6ea1SDimitry Andric}
1167*0fca6ea1SDimitry Andric
1168*0fca6ea1SDimitry Andricclass MIMG_Sampler_Asm_gfx10p<string opcode, string AsmPrefix, bit HasD16> {
1169*0fca6ea1SDimitry Andric  string ret = opcode#" "#AsmPrefix#", $srsrc, $ssamp$dmask$dim$unorm"
1170*0fca6ea1SDimitry Andric               #"$cpol$r128$a16$tfe$lwe"
1171*0fca6ea1SDimitry Andric               #!if(HasD16, "$d16", "");
1172*0fca6ea1SDimitry Andric}
1173*0fca6ea1SDimitry Andric
1174fe6060f1SDimitry Andricclass MIMG_Sampler_gfx10<mimgopc op, string opcode,
11750b57cec5SDimitry Andric                         RegisterClass DataRC, RegisterClass AddrRC,
11760b57cec5SDimitry Andric                         string dns="">
117781ad6265SDimitry Andric  : MIMG_gfx10<op.GFX10M, (outs DataRC:$vdata), dns> {
1178*0fca6ea1SDimitry Andric  let InOperandList = MIMG_Sampler_OpList_gfx10p<(ins AddrRC:$vaddr0), BaseOpcode.HasD16>.ret;
1179*0fca6ea1SDimitry Andric  let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, "$vdata, $vaddr0", BaseOpcode.HasD16>.ret;
11800b57cec5SDimitry Andric}
11810b57cec5SDimitry Andric
1182fe6060f1SDimitry Andricclass MIMG_Sampler_nsa_gfx10<mimgopc op, string opcode,
11830b57cec5SDimitry Andric                             RegisterClass DataRC, int num_addrs,
11840b57cec5SDimitry Andric                             string dns="">
118581ad6265SDimitry Andric  : MIMG_nsa_gfx10<op.GFX10M, (outs DataRC:$vdata), num_addrs, dns> {
1186*0fca6ea1SDimitry Andric  let InOperandList = MIMG_Sampler_OpList_gfx10p<AddrIns, BaseOpcode.HasD16>.ret;
1187*0fca6ea1SDimitry Andric  let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, " $vdata, "#AddrAsm, BaseOpcode.HasD16>.ret;
1188*0fca6ea1SDimitry Andric}
1189*0fca6ea1SDimitry Andric
1190*0fca6ea1SDimitry Andricclass MIMG_Sampler_nortn_gfx10<mimgopc op, string opcode,
1191*0fca6ea1SDimitry Andric                         RegisterClass AddrRC,
1192*0fca6ea1SDimitry Andric                         string dns="">
1193*0fca6ea1SDimitry Andric  : MIMG_gfx10<op.GFX10M, (outs), dns> {
1194*0fca6ea1SDimitry Andric  let InOperandList = MIMG_Sampler_OpList_gfx10p<(ins AddrRC:$vaddr0), BaseOpcode.HasD16>.ret;
1195*0fca6ea1SDimitry Andric  let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, "off, $vaddr0", BaseOpcode.HasD16>.ret;
1196*0fca6ea1SDimitry Andric  // Force vdata to VGPR0 as no result will be returned.
1197*0fca6ea1SDimitry Andric  let vdata = 0;
1198*0fca6ea1SDimitry Andric}
1199*0fca6ea1SDimitry Andric
1200*0fca6ea1SDimitry Andricclass MIMG_Sampler_nortn_nsa_gfx10<mimgopc op, string opcode,
1201*0fca6ea1SDimitry Andric                         int num_addrs,
1202*0fca6ea1SDimitry Andric                         string dns="">
1203*0fca6ea1SDimitry Andric  : MIMG_nsa_gfx10<op.GFX10M, (outs), num_addrs, dns> {
1204*0fca6ea1SDimitry Andric  let InOperandList = MIMG_Sampler_OpList_gfx10p<AddrIns, BaseOpcode.HasD16>.ret;
1205*0fca6ea1SDimitry Andric  let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, " off, "#AddrAsm, BaseOpcode.HasD16>.ret;
1206*0fca6ea1SDimitry Andric  // Force vdata to VGPR0 as no result will be returned.
1207*0fca6ea1SDimitry Andric  let vdata = 0;
120881ad6265SDimitry Andric}
120981ad6265SDimitry Andric
121081ad6265SDimitry Andricclass MIMG_Sampler_gfx11<mimgopc op, string opcode,
121181ad6265SDimitry Andric                         RegisterClass DataRC, RegisterClass AddrRC,
121281ad6265SDimitry Andric                         string dns="">
121381ad6265SDimitry Andric  : MIMG_gfx11<op.GFX11, (outs DataRC:$vdata), dns> {
1214*0fca6ea1SDimitry Andric  let InOperandList = MIMG_Sampler_OpList_gfx10p<(ins AddrRC:$vaddr0), BaseOpcode.HasD16>.ret;
1215*0fca6ea1SDimitry Andric  let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, "$vdata, $vaddr0", BaseOpcode.HasD16>.ret;
121681ad6265SDimitry Andric}
121781ad6265SDimitry Andric
121881ad6265SDimitry Andricclass MIMG_Sampler_nsa_gfx11<mimgopc op, string opcode,
121981ad6265SDimitry Andric                             RegisterClass DataRC, int num_addrs,
122006c3fb27SDimitry Andric                             RegisterClass LastVAddrSize, string dns="">
122106c3fb27SDimitry Andric  : MIMG_nsa_gfx11<op.GFX11, (outs DataRC:$vdata), num_addrs, dns, [],
122206c3fb27SDimitry Andric                   LastVAddrSize> {
1223*0fca6ea1SDimitry Andric  let InOperandList = MIMG_Sampler_OpList_gfx10p<AddrIns, BaseOpcode.HasD16>.ret;
1224*0fca6ea1SDimitry Andric  let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, " $vdata, "#AddrAsm, BaseOpcode.HasD16>.ret;
1225*0fca6ea1SDimitry Andric}
1226*0fca6ea1SDimitry Andric
1227*0fca6ea1SDimitry Andricclass MIMG_Sampler_nortn_gfx11<mimgopc op, string opcode,
1228*0fca6ea1SDimitry Andric                                  RegisterClass AddrRC,
1229*0fca6ea1SDimitry Andric                                  string dns="">
1230*0fca6ea1SDimitry Andric  : MIMG_gfx11<op.GFX11, (outs), dns> {
1231*0fca6ea1SDimitry Andric  let InOperandList = MIMG_Sampler_OpList_gfx10p<(ins AddrRC:$vaddr0), BaseOpcode.HasD16>.ret;
1232*0fca6ea1SDimitry Andric  let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, "off, $vaddr0", BaseOpcode.HasD16>.ret;
1233*0fca6ea1SDimitry Andric  let vdata = 0;
1234*0fca6ea1SDimitry Andric}
1235*0fca6ea1SDimitry Andric
1236*0fca6ea1SDimitry Andricclass MIMG_Sampler_nortn_nsa_gfx11<mimgopc op, string opcode,
1237*0fca6ea1SDimitry Andric                                      int num_addrs,
1238*0fca6ea1SDimitry Andric                                      RegisterClass LastVAddrSize, string dns="">
1239*0fca6ea1SDimitry Andric  : MIMG_nsa_gfx11<op.GFX11, (outs), num_addrs, dns, [], LastVAddrSize> {
1240*0fca6ea1SDimitry Andric  let InOperandList = MIMG_Sampler_OpList_gfx10p<AddrIns, BaseOpcode.HasD16>.ret;
1241*0fca6ea1SDimitry Andric  let AsmString = MIMG_Sampler_Asm_gfx10p<opcode, "off, "#AddrAsm, BaseOpcode.HasD16>.ret;
1242*0fca6ea1SDimitry Andric  let vdata = 0;
12430b57cec5SDimitry Andric}
12440b57cec5SDimitry Andric
124506c3fb27SDimitry Andricclass MIMGAddrSize<int dw, bit enable_disasm, int AddrDW = dw> {
12460b57cec5SDimitry Andric  int NumWords = dw;
12470b57cec5SDimitry Andric
124806c3fb27SDimitry Andric  RegisterClass RegClass = !if(!le(AddrDW, 0), ?,
124906c3fb27SDimitry Andric                           !if(!eq(AddrDW, 1), VGPR_32,
125006c3fb27SDimitry Andric                           !if(!eq(AddrDW, 2), VReg_64,
125106c3fb27SDimitry Andric                           !if(!eq(AddrDW, 3), VReg_96,
125206c3fb27SDimitry Andric                           !if(!eq(AddrDW, 4), VReg_128,
125306c3fb27SDimitry Andric                           !if(!eq(AddrDW, 5), VReg_160,
125406c3fb27SDimitry Andric                           !if(!eq(AddrDW, 6), VReg_192,
125506c3fb27SDimitry Andric                           !if(!eq(AddrDW, 7), VReg_224,
125606c3fb27SDimitry Andric                           !if(!eq(AddrDW, 8), VReg_256,
125706c3fb27SDimitry Andric                           !if(!eq(AddrDW, 9), VReg_288,
125806c3fb27SDimitry Andric                           !if(!eq(AddrDW, 10), VReg_320,
125906c3fb27SDimitry Andric                           !if(!eq(AddrDW, 11), VReg_352,
126006c3fb27SDimitry Andric                           !if(!eq(AddrDW, 12), VReg_384,
126106c3fb27SDimitry Andric                           !if(!le(AddrDW, 16), VReg_512, ?))))))))))))));
12620b57cec5SDimitry Andric
12630b57cec5SDimitry Andric  // Whether the instruction variant with this vaddr size should be enabled for
12640b57cec5SDimitry Andric  // the auto-generated disassembler.
12650b57cec5SDimitry Andric  bit Disassemble = enable_disasm;
12660b57cec5SDimitry Andric}
12670b57cec5SDimitry Andric
126806c3fb27SDimitry Andric// Returns the MIMGAddrSize with the size of last VAddr for partial NSA
126906c3fb27SDimitry Andricclass LastVAddrSize <int dw, int max_idx, bit enable_disasm>
127006c3fb27SDimitry Andric  : MIMGAddrSize<dw, enable_disasm,
127106c3fb27SDimitry Andric                 !if(!gt(dw, max_idx), !sub(dw, max_idx), 0)>;
127206c3fb27SDimitry Andric
12730b57cec5SDimitry Andric// Return whether x is in lst.
12740b57cec5SDimitry Andricclass isIntInList<int x, list<int> lst> {
12750b57cec5SDimitry Andric  bit ret = !foldl(0, lst, lhs, y, !or(lhs, !eq(x, y)));
12760b57cec5SDimitry Andric}
12770b57cec5SDimitry Andric
12780b57cec5SDimitry Andric// Return whether a value inside the range [min, max] (endpoints inclusive)
12790b57cec5SDimitry Andric// is in the given list.
12800b57cec5SDimitry Andricclass isRangeInList<int min, int max, list<int> lst> {
12810b57cec5SDimitry Andric  bit ret = !foldl(0, lst, lhs, y, !or(lhs, !and(!le(min, y), !le(y, max))));
12820b57cec5SDimitry Andric}
12830b57cec5SDimitry Andric
1284fe6060f1SDimitry Andricclass MIMGAddrSizes_dw_range<list<int> range> {
1285fe6060f1SDimitry Andric  int Min = !head(range);
1286fe6060f1SDimitry Andric  int Max = !if(!empty(!tail(range)), Min, !head(!tail(range)));
12870b57cec5SDimitry Andric}
12880b57cec5SDimitry Andric
128906c3fb27SDimitry Andricclass MIMG_Sampler_AddrSizes<AMDGPUSampleVariant sample, bit isG16,
12905f757f3fSDimitry Andric                             int nsa_max_addr = 5, bit includeNSA1 = 0> {
12910b57cec5SDimitry Andric  // List of all possible numbers of address words, taking all combinations of
12920b57cec5SDimitry Andric  // A16 and image dimension into account (note: no MSAA, since this is for
12930b57cec5SDimitry Andric  // sample/gather ops).
12940b57cec5SDimitry Andric  list<int> AllNumAddrWords =
12950b57cec5SDimitry Andric    !foreach(dw, !if(sample.Gradients,
1296bdd1243dSDimitry Andric                     !if(isG16,
1297bdd1243dSDimitry Andric                         !if(!eq(sample.LodOrClamp, ""),
1298bdd1243dSDimitry Andric                             [2, 3, 4, 5, 6, 7],
1299bdd1243dSDimitry Andric                             [2, 3, 4, 5, 6, 7, 8]),
13000b57cec5SDimitry Andric                         !if(!eq(sample.LodOrClamp, ""),
1301fe6060f1SDimitry Andric                             [2, 3, 4, 5, 6, 7, 8, 9],
1302bdd1243dSDimitry Andric                             [2, 3, 4, 5, 6, 7, 8, 9, 10])),
13030b57cec5SDimitry Andric                     !if(!eq(sample.LodOrClamp, ""),
13040b57cec5SDimitry Andric                         [1, 2, 3],
13050b57cec5SDimitry Andric                         [1, 2, 3, 4])),
13060b57cec5SDimitry Andric             !add(dw, !size(sample.ExtraAddrArgs)));
13070b57cec5SDimitry Andric
13080b57cec5SDimitry Andric  // Generate machine instructions based on possible register classes for the
13090b57cec5SDimitry Andric  // required numbers of address words. The disassembler defaults to the
13100b57cec5SDimitry Andric  // smallest register class.
13110b57cec5SDimitry Andric  list<MIMGAddrSize> MachineInstrs =
1312fe6060f1SDimitry Andric    !foldl([]<MIMGAddrSize>,
1313fe6060f1SDimitry Andric           !foreach(range,
1314fe6060f1SDimitry Andric                    // V4 is generated for V3 and V4
1315fe6060f1SDimitry Andric                    // V8 is generated for V5 through V8
1316bdd1243dSDimitry Andric                    // V16 is generated for V13 through V16
1317bdd1243dSDimitry Andric                    [[1],[2],[3],[3,4],[5],[6],[7],[5,8],[9],[10],[11],[12],[13,16]],
1318fe6060f1SDimitry Andric                    MIMGAddrSizes_dw_range<range>),
1319fe6060f1SDimitry Andric           lhs, dw,
1320fe6060f1SDimitry Andric           !if(isRangeInList<dw.Min, dw.Max, AllNumAddrWords>.ret,
1321fe6060f1SDimitry Andric               !listconcat(lhs, [MIMGAddrSize<dw.Max, !empty(lhs)>]),
1322fe6060f1SDimitry Andric               lhs));
13230b57cec5SDimitry Andric
13240b57cec5SDimitry Andric  // For NSA, generate machine instructions for all possible numbers of words
13250b57cec5SDimitry Andric  // except 1 (which is already covered by the non-NSA case).
13260b57cec5SDimitry Andric  // The disassembler defaults to the largest number of arguments among the
13270b57cec5SDimitry Andric  // variants with the same number of NSA words, and custom code then derives
13280b57cec5SDimitry Andric  // the exact variant based on the sample variant and the image dimension.
13290b57cec5SDimitry Andric  list<MIMGAddrSize> NSAInstrs =
13300b57cec5SDimitry Andric    !foldl([]<MIMGAddrSize>, [[12, 11, 10], [9, 8, 7, 6], [5, 4, 3, 2]], prev, nsa_group,
13310b57cec5SDimitry Andric           !listconcat(prev,
13320b57cec5SDimitry Andric                       !foldl([]<MIMGAddrSize>, nsa_group, lhs, dw,
13330b57cec5SDimitry Andric                              !if(isIntInList<dw, AllNumAddrWords>.ret,
13340b57cec5SDimitry Andric                                  !listconcat(lhs, [MIMGAddrSize<dw, !empty(lhs)>]),
13350b57cec5SDimitry Andric                                  lhs))));
133606c3fb27SDimitry Andric
133706c3fb27SDimitry Andric  // In NSA format if there is a requirement for more VGPRs than the format
133806c3fb27SDimitry Andric  // supports, then the rest are sequential after the last one. Generate
133906c3fb27SDimitry Andric  // machine instructions for all possible number of words. The disassembler
134006c3fb27SDimitry Andric  // defaults to the largest number of arguments but no larger than max nsa
134106c3fb27SDimitry Andric  // size. List is generated with the register class needed for last vaddr since
134206c3fb27SDimitry Andric  // it is the only one that could have a register other than VGPR32.
134306c3fb27SDimitry Andric  int EnableDisasmNum = !foldl(!head(AllNumAddrWords), !tail(AllNumAddrWords),
134406c3fb27SDimitry Andric                               acc, var, !if(!le(var, nsa_max_addr), var, acc));
13455f757f3fSDimitry Andric  list<int> PossibleVariants =
13465f757f3fSDimitry Andric    !listconcat([12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2], !if(includeNSA1, [1], []));
134706c3fb27SDimitry Andric  list<LastVAddrSize> PartialNSAInstrs =
13485f757f3fSDimitry Andric        !foldl([]<LastVAddrSize>, PossibleVariants, lhs, dw,
134906c3fb27SDimitry Andric               !if(isIntInList<dw, AllNumAddrWords>.ret,
135006c3fb27SDimitry Andric                   !listconcat(lhs, [LastVAddrSize<dw, !sub(nsa_max_addr, 1),
135106c3fb27SDimitry Andric                                                   !eq(dw, EnableDisasmNum)>]),
135206c3fb27SDimitry Andric                   lhs));
13530b57cec5SDimitry Andric}
13540b57cec5SDimitry Andric
1355fe6060f1SDimitry Andricmulticlass MIMG_Sampler_Src_Helper <mimgopc op, string asm,
13560b57cec5SDimitry Andric                                    AMDGPUSampleVariant sample, RegisterClass dst_rc,
1357fe6060f1SDimitry Andric                                    bit enableDisasm = 0,
1358bdd1243dSDimitry Andric                                    bit ExtendedImageInst = 1, bit isG16 = 0> {
1359bdd1243dSDimitry Andric  foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.MachineInstrs in {
13600b57cec5SDimitry Andric    let VAddrDwords = addr.NumWords in {
136181ad6265SDimitry Andric      if op.HAS_GFX10M then {
13620b57cec5SDimitry Andric        def _V # addr.NumWords
13630b57cec5SDimitry Andric          : MIMG_Sampler_Helper <op, asm, dst_rc, addr.RegClass,
1364*0fca6ea1SDimitry Andric                                 !if(!and(enableDisasm, addr.Disassemble), "GFX8", "")>;
1365fe6060f1SDimitry Andric        if !not(ExtendedImageInst) then
1366fe6060f1SDimitry Andric        def _V # addr.NumWords # _gfx90a
1367fe6060f1SDimitry Andric          : MIMG_Sampler_gfx90a <op, asm, dst_rc, addr.RegClass,
1368fe6060f1SDimitry Andric                                 !if(!and(enableDisasm, addr.Disassemble), "GFX90A", "")>;
13690b57cec5SDimitry Andric        def _V # addr.NumWords # _gfx10
13700b57cec5SDimitry Andric          : MIMG_Sampler_gfx10 <op, asm, dst_rc, addr.RegClass,
1371*0fca6ea1SDimitry Andric                                 !if(!and(enableDisasm, addr.Disassemble), "GFX10", "")>;
13720b57cec5SDimitry Andric      }
137381ad6265SDimitry Andric      if op.HAS_GFX11 then {
137481ad6265SDimitry Andric        def _V # addr.NumWords # _gfx11
137581ad6265SDimitry Andric          : MIMG_Sampler_gfx11 <op, asm, dst_rc, addr.RegClass,
1376*0fca6ea1SDimitry Andric                                 !if(!and(enableDisasm, addr.Disassemble), "GFX11", "")>;
137781ad6265SDimitry Andric      }
13780b57cec5SDimitry Andric    }
1379fe6060f1SDimitry Andric  }
13800b57cec5SDimitry Andric
1381bdd1243dSDimitry Andric  foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.NSAInstrs in {
13820b57cec5SDimitry Andric    let VAddrDwords = addr.NumWords in {
138381ad6265SDimitry Andric      if op.HAS_GFX10M then {
13840b57cec5SDimitry Andric        def _V # addr.NumWords # _nsa_gfx10
13850b57cec5SDimitry Andric          : MIMG_Sampler_nsa_gfx10<op, asm, dst_rc, addr.NumWords,
1386*0fca6ea1SDimitry Andric                                   !if(!and(enableDisasm, addr.Disassemble), "GFX10", "")>;
13870b57cec5SDimitry Andric      }
138806c3fb27SDimitry Andric    }
138906c3fb27SDimitry Andric  }
139006c3fb27SDimitry Andric
139106c3fb27SDimitry Andric  foreach addr = MIMG_Sampler_AddrSizes<sample, isG16, 5/*MaxNSASize*/>.PartialNSAInstrs in {
139206c3fb27SDimitry Andric    let VAddrDwords = addr.NumWords in {
139306c3fb27SDimitry Andric      if op.HAS_GFX11 then {
139481ad6265SDimitry Andric        def _V # addr.NumWords # _nsa_gfx11
139506c3fb27SDimitry Andric          : MIMG_Sampler_nsa_gfx11<op, asm, dst_rc, addr.NumWords, addr.RegClass,
1396*0fca6ea1SDimitry Andric                                   !if(!and(enableDisasm, addr.Disassemble), "GFX11", "")>;
139781ad6265SDimitry Andric      }
13980b57cec5SDimitry Andric    }
13990b57cec5SDimitry Andric  }
14005f757f3fSDimitry Andric
14015f757f3fSDimitry Andric  foreach addr = MIMG_Sampler_AddrSizes<sample, isG16, 4/*MaxNSASize*/, 1>.PartialNSAInstrs in {
14025f757f3fSDimitry Andric    let VAddrDwords = addr.NumWords in {
14035f757f3fSDimitry Andric      if op.HAS_GFX12 then {
14045f757f3fSDimitry Andric        def _V # addr.NumWords # _gfx12
14055f757f3fSDimitry Andric          : VSAMPLE_Sampler_gfx12<op, asm, dst_rc, addr.NumWords, addr.RegClass,
14065f757f3fSDimitry Andric                                  !if(!and(enableDisasm, addr.Disassemble), "GFX12", "")>;
14075f757f3fSDimitry Andric      }
14085f757f3fSDimitry Andric    }
14095f757f3fSDimitry Andric  }
1410fe6060f1SDimitry Andric}
14110b57cec5SDimitry Andric
14120b57cec5SDimitry Andricclass MIMG_Sampler_BaseOpcode<AMDGPUSampleVariant sample>
14130b57cec5SDimitry Andric  : MIMGBaseOpcode {
14140b57cec5SDimitry Andric  let Sampler = 1;
14150b57cec5SDimitry Andric  let NumExtraArgs = !size(sample.ExtraAddrArgs);
14160b57cec5SDimitry Andric  let Gradients = sample.Gradients;
14170b57cec5SDimitry Andric  let LodOrClampOrMip = !ne(sample.LodOrClamp, "");
14180b57cec5SDimitry Andric}
14190b57cec5SDimitry Andric
1420*0fca6ea1SDimitry Andricmulticlass MIMG_Sampler_NoReturn <mimgopc op, AMDGPUSampleVariant sample, bit wqm = 0, bit isG16, string asm> {
1421*0fca6ea1SDimitry Andric  def "" : MIMG_Sampler_BaseOpcode<sample> {
1422*0fca6ea1SDimitry Andric    let HasD16 = 1;
1423*0fca6ea1SDimitry Andric    let G16 = isG16;
1424*0fca6ea1SDimitry Andric    let NoReturn = 1;
1425*0fca6ea1SDimitry Andric  }
1426*0fca6ea1SDimitry Andric
1427*0fca6ea1SDimitry Andric  let BaseOpcode = !cast<MIMGBaseOpcode>(NAME), WQM = wqm,
1428*0fca6ea1SDimitry Andric      mayLoad = 1, mayStore = 1, VDataDwords = 0 in {
1429*0fca6ea1SDimitry Andric    foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.MachineInstrs in {
1430*0fca6ea1SDimitry Andric      let VAddrDwords = addr.NumWords in {
1431*0fca6ea1SDimitry Andric        if op.HAS_GFX10M then {
1432*0fca6ea1SDimitry Andric          def _V # addr.NumWords # _gfx10
1433*0fca6ea1SDimitry Andric            : MIMG_Sampler_nortn_gfx10 <op, asm, addr.RegClass>;
1434*0fca6ea1SDimitry Andric        }
1435*0fca6ea1SDimitry Andric        if op.HAS_GFX11 then {
1436*0fca6ea1SDimitry Andric          def _V # addr.NumWords # _gfx11
1437*0fca6ea1SDimitry Andric            : MIMG_Sampler_nortn_gfx11 <op, asm, addr.RegClass>;
1438*0fca6ea1SDimitry Andric        }
1439*0fca6ea1SDimitry Andric      }
1440*0fca6ea1SDimitry Andric    }
1441*0fca6ea1SDimitry Andric
1442*0fca6ea1SDimitry Andric    foreach addr = MIMG_Sampler_AddrSizes<sample, isG16>.NSAInstrs in {
1443*0fca6ea1SDimitry Andric      let VAddrDwords = addr.NumWords in {
1444*0fca6ea1SDimitry Andric        if op.HAS_GFX10M then {
1445*0fca6ea1SDimitry Andric          def _V # addr.NumWords # _nsa_gfx10
1446*0fca6ea1SDimitry Andric            : MIMG_Sampler_nortn_nsa_gfx10<op, asm, addr.NumWords>;
1447*0fca6ea1SDimitry Andric        }
1448*0fca6ea1SDimitry Andric      }
1449*0fca6ea1SDimitry Andric    }
1450*0fca6ea1SDimitry Andric
1451*0fca6ea1SDimitry Andric    foreach addr = MIMG_Sampler_AddrSizes<sample, isG16, 5/*MaxNSASize*/>.PartialNSAInstrs in {
1452*0fca6ea1SDimitry Andric      let VAddrDwords = addr.NumWords in {
1453*0fca6ea1SDimitry Andric        if op.HAS_GFX11 then {
1454*0fca6ea1SDimitry Andric          def _V # addr.NumWords # _nsa_gfx11
1455*0fca6ea1SDimitry Andric            : MIMG_Sampler_nortn_nsa_gfx11<op, asm, addr.NumWords, addr.RegClass>;
1456*0fca6ea1SDimitry Andric        }
1457*0fca6ea1SDimitry Andric      }
1458*0fca6ea1SDimitry Andric    }
1459*0fca6ea1SDimitry Andric
1460*0fca6ea1SDimitry Andric    foreach addr = MIMG_Sampler_AddrSizes<sample, isG16, 4/*MaxNSASize*/, 1>.PartialNSAInstrs in {
1461*0fca6ea1SDimitry Andric      let VAddrDwords = addr.NumWords in {
1462*0fca6ea1SDimitry Andric        if op.HAS_GFX12 then {
1463*0fca6ea1SDimitry Andric          def _V # addr.NumWords # _gfx12
1464*0fca6ea1SDimitry Andric            : VSAMPLE_Sampler_nortn_gfx12<op, asm, addr.NumWords, addr.RegClass>;
1465*0fca6ea1SDimitry Andric        }
1466*0fca6ea1SDimitry Andric      }
1467*0fca6ea1SDimitry Andric    }
1468*0fca6ea1SDimitry Andric  }
1469*0fca6ea1SDimitry Andric}
1470*0fca6ea1SDimitry Andric
1471fe6060f1SDimitry Andricmulticlass MIMG_Sampler <mimgopc op, AMDGPUSampleVariant sample, bit wqm = 0,
14725ffd83dbSDimitry Andric                         bit isG16 = 0, bit isGetLod = 0,
1473fe6060f1SDimitry Andric                         string asm = "image_sample"#sample.LowerCaseMod#!if(isG16, "_g16", ""),
1474fe6060f1SDimitry Andric                         bit ExtendedImageInst = !ne(sample.LowerCaseMod, "")> {
14750b57cec5SDimitry Andric  def "" : MIMG_Sampler_BaseOpcode<sample> {
1476e8d8bef9SDimitry Andric    let HasD16 = !not(isGetLod);
14775ffd83dbSDimitry Andric    let G16 = isG16;
14780b57cec5SDimitry Andric  }
14790b57cec5SDimitry Andric
14800b57cec5SDimitry Andric  let BaseOpcode = !cast<MIMGBaseOpcode>(NAME), WQM = wqm,
1481e8d8bef9SDimitry Andric      mayLoad = !not(isGetLod) in {
14820b57cec5SDimitry Andric    let VDataDwords = 1 in
1483bdd1243dSDimitry Andric    defm _V1 : MIMG_Sampler_Src_Helper<op, asm, sample, VGPR_32, 1, ExtendedImageInst, isG16>;
14840b57cec5SDimitry Andric    let VDataDwords = 2 in
1485bdd1243dSDimitry Andric    defm _V2 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_64, 0, ExtendedImageInst, isG16>;
14860b57cec5SDimitry Andric    let VDataDwords = 3 in
1487bdd1243dSDimitry Andric    defm _V3 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_96, 0, ExtendedImageInst, isG16>;
14880b57cec5SDimitry Andric    let VDataDwords = 4 in
1489bdd1243dSDimitry Andric    defm _V4 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_128, 0, ExtendedImageInst, isG16>;
14900b57cec5SDimitry Andric    let VDataDwords = 5 in
1491bdd1243dSDimitry Andric    defm _V5 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_160, 0, ExtendedImageInst, isG16>;
14920b57cec5SDimitry Andric  }
1493*0fca6ea1SDimitry Andric
1494*0fca6ea1SDimitry Andric  if !not(isGetLod) then
1495*0fca6ea1SDimitry Andric  defm "_nortn" : MIMG_Sampler_NoReturn <op, sample, wqm, isG16, asm>;
14960b57cec5SDimitry Andric}
14970b57cec5SDimitry Andric
1498fe6060f1SDimitry Andricmulticlass MIMG_Sampler_WQM <mimgopc op, AMDGPUSampleVariant sample>
14990b57cec5SDimitry Andric    : MIMG_Sampler<op, sample, 1>;
15000b57cec5SDimitry Andric
1501fe6060f1SDimitry Andricmulticlass MIMG_Gather <mimgopc op, AMDGPUSampleVariant sample, bit wqm = 0,
15020b57cec5SDimitry Andric                        string asm = "image_gather4"#sample.LowerCaseMod> {
15030b57cec5SDimitry Andric  def "" : MIMG_Sampler_BaseOpcode<sample> {
15040b57cec5SDimitry Andric    let HasD16 = 1;
15050b57cec5SDimitry Andric    let Gather4 = 1;
15060b57cec5SDimitry Andric  }
15070b57cec5SDimitry Andric
15080b57cec5SDimitry Andric  let BaseOpcode = !cast<MIMGBaseOpcode>(NAME), WQM = wqm,
1509fe6060f1SDimitry Andric      Gather4 = 1 in {
15100b57cec5SDimitry Andric    let VDataDwords = 2 in
15110b57cec5SDimitry Andric    defm _V2 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_64>; /* for packed D16 only */
15120b57cec5SDimitry Andric    let VDataDwords = 4 in
15130b57cec5SDimitry Andric    defm _V4 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_128, 1>;
15140b57cec5SDimitry Andric    let VDataDwords = 5 in
15150b57cec5SDimitry Andric    defm _V5 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_160>;
15160b57cec5SDimitry Andric  }
15170b57cec5SDimitry Andric}
15180b57cec5SDimitry Andric
1519fe6060f1SDimitry Andricmulticlass MIMG_Gather_WQM <mimgopc op, AMDGPUSampleVariant sample>
15200b57cec5SDimitry Andric    : MIMG_Gather<op, sample, 1>;
15210b57cec5SDimitry Andric
1522bdd1243dSDimitry Andricclass MIMG_IntersectRay_Helper<bit Is64, bit IsA16> {
1523bdd1243dSDimitry Andric  int num_addrs = !if(Is64, !if(IsA16, 9, 12), !if(IsA16, 8, 11));
1524349cc55cSDimitry Andric  RegisterClass RegClass = MIMGAddrSize<num_addrs, 0>.RegClass;
1525349cc55cSDimitry Andric  int VAddrDwords = !srl(RegClass.Size, 5);
152681ad6265SDimitry Andric
15275f757f3fSDimitry Andric  int GFX11PlusNSAAddrs = !if(IsA16, 4, 5);
152881ad6265SDimitry Andric  RegisterClass node_ptr_type = !if(Is64, VReg_64, VGPR_32);
15295f757f3fSDimitry Andric  list<RegisterClass> GFX11PlusAddrTypes =
1530bdd1243dSDimitry Andric          !if(IsA16,
153181ad6265SDimitry Andric              [node_ptr_type, VGPR_32, VReg_96, VReg_96],
153281ad6265SDimitry Andric              [node_ptr_type, VGPR_32, VReg_96, VReg_96, VReg_96]);
1533349cc55cSDimitry Andric}
1534349cc55cSDimitry Andric
153506c3fb27SDimitry Andricclass MIMG_IntersectRay_gfx10<mimgopc op, string opcode, RegisterClass AddrRC>
1536*0fca6ea1SDimitry Andric    : MIMG_gfx10<op.GFX10M, (outs VReg_128:$vdata), "GFX10"> {
153706c3fb27SDimitry Andric  let InOperandList = (ins AddrRC:$vaddr0, SReg_128:$srsrc, A16:$a16);
153806c3fb27SDimitry Andric  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$a16";
1539e8d8bef9SDimitry Andric
1540e8d8bef9SDimitry Andric  let nsa = 0;
1541e8d8bef9SDimitry Andric}
1542e8d8bef9SDimitry Andric
154306c3fb27SDimitry Andricclass MIMG_IntersectRay_nsa_gfx10<mimgopc op, string opcode, int num_addrs>
1544*0fca6ea1SDimitry Andric    : MIMG_nsa_gfx10<op.GFX10M, (outs VReg_128:$vdata), num_addrs, "GFX10"> {
154506c3fb27SDimitry Andric  let InOperandList = !con(nsah.AddrIns, (ins SReg_128:$srsrc, A16:$a16));
154606c3fb27SDimitry Andric  let AsmString = opcode#" $vdata, "#nsah.AddrAsm#", $srsrc$a16";
154781ad6265SDimitry Andric}
154881ad6265SDimitry Andric
154906c3fb27SDimitry Andricclass MIMG_IntersectRay_gfx11<mimgopc op, string opcode, RegisterClass AddrRC>
1550*0fca6ea1SDimitry Andric    : MIMG_gfx11<op.GFX11, (outs VReg_128:$vdata), "GFX11"> {
155106c3fb27SDimitry Andric  let InOperandList = (ins AddrRC:$vaddr0, SReg_128:$srsrc, A16:$a16);
155206c3fb27SDimitry Andric  let AsmString = opcode#" $vdata, $vaddr0, $srsrc$a16";
155381ad6265SDimitry Andric
155481ad6265SDimitry Andric  let nsa = 0;
155581ad6265SDimitry Andric}
155681ad6265SDimitry Andric
155781ad6265SDimitry Andricclass MIMG_IntersectRay_nsa_gfx11<mimgopc op, string opcode, int num_addrs,
155806c3fb27SDimitry Andric                                  list<RegisterClass> addr_types>
1559*0fca6ea1SDimitry Andric    : MIMG_nsa_gfx11<op.GFX11, (outs VReg_128:$vdata), num_addrs, "GFX11",
156081ad6265SDimitry Andric                     addr_types> {
156106c3fb27SDimitry Andric  let InOperandList = !con(nsah.AddrIns, (ins SReg_128:$srsrc, A16:$a16));
156206c3fb27SDimitry Andric  let AsmString = opcode#" $vdata, "#nsah.AddrAsm#", $srsrc$a16";
1563e8d8bef9SDimitry Andric}
1564e8d8bef9SDimitry Andric
15655f757f3fSDimitry Andricclass VIMAGE_IntersectRay_gfx12<mimgopc op, string opcode, int num_addrs,
15665f757f3fSDimitry Andric                                list<RegisterClass> addr_types>
15675f757f3fSDimitry Andric    : VIMAGE_gfx12<op.GFX12, (outs VReg_128:$vdata),
15685f757f3fSDimitry Andric                   num_addrs, "GFX12", addr_types> {
15695f757f3fSDimitry Andric  let InOperandList = !con(nsah.AddrIns, (ins SReg_128:$rsrc, A16:$a16));
15705f757f3fSDimitry Andric  let AsmString = opcode#" $vdata, "#nsah.AddrAsm#", $rsrc$a16";
15715f757f3fSDimitry Andric}
15725f757f3fSDimitry Andric
1573bdd1243dSDimitry Andricmulticlass MIMG_IntersectRay<mimgopc op, string opcode, bit Is64, bit IsA16> {
1574bdd1243dSDimitry Andric  defvar info = MIMG_IntersectRay_Helper<Is64, IsA16>;
1575349cc55cSDimitry Andric  def "" : MIMGBaseOpcode {
1576349cc55cSDimitry Andric    let BVH = 1;
157706c3fb27SDimitry Andric    let A16 = IsA16;
1578349cc55cSDimitry Andric  }
157906c3fb27SDimitry Andric  let dmask = 0xf,
1580e8d8bef9SDimitry Andric      d16 = 0,
1581fe6060f1SDimitry Andric      cpol = 0,
1582e8d8bef9SDimitry Andric      tfe = 0,
1583e8d8bef9SDimitry Andric      r128 = 1,
1584e8d8bef9SDimitry Andric      dim = {0, 0, 0},
1585bdd1243dSDimitry Andric      a16 = IsA16,
1586e8d8bef9SDimitry Andric      d16 = 0,
1587e8d8bef9SDimitry Andric      BaseOpcode = !cast<MIMGBaseOpcode>(NAME),
1588e8d8bef9SDimitry Andric      VDataDwords = 4 in {
15895f757f3fSDimitry Andric    let unorm = 1,
15905f757f3fSDimitry Andric        lwe = 0,
15915f757f3fSDimitry Andric        ssamp = 0 in {
15925f757f3fSDimitry Andric      if op.HAS_GFX10M then
159306c3fb27SDimitry Andric      def _sa_gfx10 : MIMG_IntersectRay_gfx10<op, opcode, info.RegClass> {
1594349cc55cSDimitry Andric        let VAddrDwords = info.VAddrDwords;
1595e8d8bef9SDimitry Andric      }
15965f757f3fSDimitry Andric      if op.HAS_GFX11 then
159706c3fb27SDimitry Andric      def _sa_gfx11 : MIMG_IntersectRay_gfx11<op, opcode, info.RegClass> {
159881ad6265SDimitry Andric        let VAddrDwords = info.VAddrDwords;
159981ad6265SDimitry Andric      }
16005f757f3fSDimitry Andric      if op.HAS_GFX10M then
160106c3fb27SDimitry Andric      def _nsa_gfx10 : MIMG_IntersectRay_nsa_gfx10<op, opcode, info.num_addrs> {
1602349cc55cSDimitry Andric        let VAddrDwords = info.num_addrs;
1603e8d8bef9SDimitry Andric      }
16045f757f3fSDimitry Andric      if op.HAS_GFX11 then
160581ad6265SDimitry Andric      def _nsa_gfx11 : MIMG_IntersectRay_nsa_gfx11<op, opcode,
16065f757f3fSDimitry Andric                                                  info.GFX11PlusNSAAddrs,
16075f757f3fSDimitry Andric                                                  info.GFX11PlusAddrTypes> {
16085f757f3fSDimitry Andric        let VAddrDwords = info.num_addrs;
16095f757f3fSDimitry Andric      }
16105f757f3fSDimitry Andric    }
16115f757f3fSDimitry Andric    def _gfx12 : VIMAGE_IntersectRay_gfx12<op, opcode, info.GFX11PlusNSAAddrs,
16125f757f3fSDimitry Andric                                           info.GFX11PlusAddrTypes> {
161381ad6265SDimitry Andric      let VAddrDwords = info.num_addrs;
161481ad6265SDimitry Andric    }
161581ad6265SDimitry Andric  }
161681ad6265SDimitry Andric}
161781ad6265SDimitry Andric
161881ad6265SDimitry Andricmulticlass MIMG_MSAA_Load <mimgopc op, string asm> {
161981ad6265SDimitry Andric  def "" : MIMGBaseOpcode {
162081ad6265SDimitry Andric    let HasD16 = 1;
162181ad6265SDimitry Andric    let Gather4 = 1; /* for appropriate dmask handling */
162281ad6265SDimitry Andric    let MSAA = 1;
162381ad6265SDimitry Andric  }
162481ad6265SDimitry Andric
162581ad6265SDimitry Andric  let BaseOpcode = !cast<MIMGBaseOpcode>(NAME),
162681ad6265SDimitry Andric    Gather4 = 1, hasPostISelHook = 0, mayLoad = 1 in {
162781ad6265SDimitry Andric    let VDataDwords = 2 in
16285f757f3fSDimitry Andric    defm _V2 : MIMG_NoSampler_Src_Helper<op, asm, VReg_64, 0, 0, 1>; /* packed D16 */
162981ad6265SDimitry Andric    let VDataDwords = 3 in
16305f757f3fSDimitry Andric    defm _V3 : MIMG_NoSampler_Src_Helper<op, asm, VReg_96, 0, 0, 1>; /* packed D16 + tfe */
163181ad6265SDimitry Andric    let VDataDwords = 4 in
16325f757f3fSDimitry Andric    defm _V4 : MIMG_NoSampler_Src_Helper<op, asm, VReg_128, 1, 0, 1>;
163381ad6265SDimitry Andric    let VDataDwords = 5 in
16345f757f3fSDimitry Andric    defm _V5 : MIMG_NoSampler_Src_Helper<op, asm, VReg_160, 0, 0, 1>;
1635e8d8bef9SDimitry Andric  }
1636e8d8bef9SDimitry Andric}
1637e8d8bef9SDimitry Andric
16380b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
16390b57cec5SDimitry Andric// MIMG Instructions
16400b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
164181ad6265SDimitry Andriclet OtherPredicates = [HasImageInsts] in {
16420b57cec5SDimitry Andric
16435f757f3fSDimitry Andricdefm IMAGE_LOAD                 : MIMG_NoSampler <mimgopc<0x00, 0x00, 0x00>, "image_load", 1>;
16445f757f3fSDimitry Andricdefm IMAGE_LOAD_MIP             : MIMG_NoSampler <mimgopc<0x01, 0x01, 0x01>, "image_load_mip", 1, 1>;
16455f757f3fSDimitry Andricdefm IMAGE_LOAD_PCK             : MIMG_NoSampler <mimgopc<0x02, 0x02, 0x02>, "image_load_pck", 0>;
16465f757f3fSDimitry Andricdefm IMAGE_LOAD_PCK_SGN         : MIMG_NoSampler <mimgopc<0x03, 0x03, 0x03>, "image_load_pck_sgn", 0>;
16475f757f3fSDimitry Andricdefm IMAGE_LOAD_MIP_PCK         : MIMG_NoSampler <mimgopc<0x04, 0x04, 0x04>, "image_load_mip_pck", 0, 1>;
16485f757f3fSDimitry Andricdefm IMAGE_LOAD_MIP_PCK_SGN     : MIMG_NoSampler <mimgopc<0x05, 0x05, 0x05>, "image_load_mip_pck_sgn", 0, 1>;
16495f757f3fSDimitry Andricdefm IMAGE_STORE                : MIMG_Store <mimgopc<0x06, 0x06, 0x08>, "image_store", 1>;
16505f757f3fSDimitry Andricdefm IMAGE_STORE_MIP            : MIMG_Store <mimgopc<0x07, 0x07, 0x09>, "image_store_mip", 1, 1>;
16515f757f3fSDimitry Andricdefm IMAGE_STORE_PCK            : MIMG_Store <mimgopc<0x08, 0x08, 0x0a>, "image_store_pck", 0>;
16525f757f3fSDimitry Andricdefm IMAGE_STORE_MIP_PCK        : MIMG_Store <mimgopc<0x09, 0x09, 0x0b>, "image_store_mip_pck", 0, 1>;
16530b57cec5SDimitry Andric
16545f757f3fSDimitry Andricdefm IMAGE_GET_RESINFO          : MIMG_NoSampler <mimgopc<0x17, 0x17, 0x0e, 0x0e, 0x0e>, "image_get_resinfo", 0, 1, 1>;
16550b57cec5SDimitry Andric
16565f757f3fSDimitry Andricdefm IMAGE_ATOMIC_SWAP          : MIMG_Atomic <mimgopc<0x0a, 0x0a, 0x0f, 0x10, 0x0f>, "image_atomic_swap">;
16575f757f3fSDimitry Andricdefm IMAGE_ATOMIC_CMPSWAP       : MIMG_Atomic <mimgopc<0x0b, 0x0b, 0x10, 0x11, 0x10>, "image_atomic_cmpswap", 1>;
16585f757f3fSDimitry Andricdefm IMAGE_ATOMIC_ADD           : MIMG_Atomic_Renamed <mimgopc<0x0c, 0x0c, 0x11, 0x12, 0x11>, "image_atomic_add", "image_atomic_add_uint">;
16595f757f3fSDimitry Andricdefm IMAGE_ATOMIC_SUB           : MIMG_Atomic_Renamed <mimgopc<0x0d, 0x0d, 0x12, 0x13, 0x12>, "image_atomic_sub", "image_atomic_sub_uint">;
16605f757f3fSDimitry Andricdefm IMAGE_ATOMIC_RSUB          : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, MIMG.NOP, MIMG.NOP, 0x13>, "image_atomic_rsub">;
16615f757f3fSDimitry Andricdefm IMAGE_ATOMIC_SMIN          : MIMG_Atomic_Renamed <mimgopc<0x0e, 0x0e, 0x14>, "image_atomic_smin", "image_atomic_min_int">;
16625f757f3fSDimitry Andricdefm IMAGE_ATOMIC_UMIN          : MIMG_Atomic_Renamed <mimgopc<0x0f, 0x0f, 0x15>, "image_atomic_umin", "image_atomic_min_uint">;
16635f757f3fSDimitry Andricdefm IMAGE_ATOMIC_SMAX          : MIMG_Atomic_Renamed <mimgopc<0x10, 0x10, 0x16>, "image_atomic_smax", "image_atomic_max_int">;
16645f757f3fSDimitry Andricdefm IMAGE_ATOMIC_UMAX          : MIMG_Atomic_Renamed <mimgopc<0x11, 0x11, 0x17>, "image_atomic_umax", "image_atomic_max_uint">;
16655f757f3fSDimitry Andricdefm IMAGE_ATOMIC_AND           : MIMG_Atomic <mimgopc<0x12, 0x12, 0x18>, "image_atomic_and">;
16665f757f3fSDimitry Andricdefm IMAGE_ATOMIC_OR            : MIMG_Atomic <mimgopc<0x13, 0x13, 0x19>, "image_atomic_or">;
16675f757f3fSDimitry Andricdefm IMAGE_ATOMIC_XOR           : MIMG_Atomic <mimgopc<0x14, 0x14, 0x1a>, "image_atomic_xor">;
16685f757f3fSDimitry Andricdefm IMAGE_ATOMIC_INC           : MIMG_Atomic_Renamed <mimgopc<0x15, 0x15, 0x1b>, "image_atomic_inc", "image_atomic_inc_uint">;
16695f757f3fSDimitry Andricdefm IMAGE_ATOMIC_DEC           : MIMG_Atomic_Renamed <mimgopc<0x16, 0x16, 0x1c>, "image_atomic_dec", "image_atomic_dec_uint">;
16705f757f3fSDimitry Andricdefm IMAGE_ATOMIC_FCMPSWAP      : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, 0x1d, MIMG.NOP>, "image_atomic_fcmpswap", 1, 1>;
16715f757f3fSDimitry Andricdefm IMAGE_ATOMIC_FMIN          : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, 0x1e, MIMG.NOP>, "image_atomic_fmin", 0, 1>;
16725f757f3fSDimitry Andricdefm IMAGE_ATOMIC_FMAX          : MIMG_Atomic <mimgopc<MIMG.NOP, MIMG.NOP, 0x1f, MIMG.NOP>, "image_atomic_fmax", 0, 1>;
16737a6dacacSDimitry Andricdefm IMAGE_ATOMIC_PK_ADD_F16    : MIMG_Atomic <mimgopc<0x86, MIMG.NOP, MIMG.NOP, MIMG.NOP, MIMG.NOP>, "image_atomic_pk_add_f16", 0, 1>;
16747a6dacacSDimitry Andricdefm IMAGE_ATOMIC_PK_ADD_BF16   : MIMG_Atomic <mimgopc<0x87, MIMG.NOP, MIMG.NOP, MIMG.NOP, MIMG.NOP>, "image_atomic_pk_add_bf16", 0, 1>;
16757a6dacacSDimitry Andricdefm IMAGE_ATOMIC_ADD_FLT       : MIMG_Atomic <mimgopc<0x83, MIMG.NOP, MIMG.NOP, MIMG.NOP>, "image_atomic_add_flt", 0, 1>;
16767a6dacacSDimitry Andricdefm 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">;
16777a6dacacSDimitry Andricdefm 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">;
167881ad6265SDimitry Andric
16795f757f3fSDimitry Andricdefm IMAGE_SAMPLE               : MIMG_Sampler_WQM <mimgopc<0x1b, 0x1b, 0x20>, AMDGPUSample>;
1680*0fca6ea1SDimitry Andriclet OtherPredicates = [HasImageInsts, HasExtendedImageInsts] in {
16815f757f3fSDimitry Andricdefm IMAGE_SAMPLE_CL            : MIMG_Sampler_WQM <mimgopc<0x40, 0x40, 0x21>, AMDGPUSample_cl>;
16825f757f3fSDimitry Andricdefm IMAGE_SAMPLE_D             : MIMG_Sampler <mimgopc<0x1c, 0x1c, 0x22>, AMDGPUSample_d>;
16835f757f3fSDimitry Andricdefm IMAGE_SAMPLE_D_CL          : MIMG_Sampler <mimgopc<0x41, 0x41, 0x23>, AMDGPUSample_d_cl>;
16845f757f3fSDimitry Andricdefm IMAGE_SAMPLE_L             : MIMG_Sampler <mimgopc<0x1d, 0x1d, 0x24>, AMDGPUSample_l>;
16855f757f3fSDimitry Andricdefm IMAGE_SAMPLE_B             : MIMG_Sampler_WQM <mimgopc<0x1e, 0x1e, 0x25>, AMDGPUSample_b>;
16865f757f3fSDimitry Andricdefm IMAGE_SAMPLE_B_CL          : MIMG_Sampler_WQM <mimgopc<0x42, 0x42, 0x26>, AMDGPUSample_b_cl>;
16875f757f3fSDimitry Andricdefm IMAGE_SAMPLE_LZ            : MIMG_Sampler <mimgopc<0x1f, 0x1f, 0x27>, AMDGPUSample_lz>;
16885f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C             : MIMG_Sampler_WQM <mimgopc<0x20, 0x20, 0x28>, AMDGPUSample_c>;
16895f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_CL          : MIMG_Sampler_WQM <mimgopc<0x43, 0x43, 0x29>, AMDGPUSample_c_cl>;
16905f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_D           : MIMG_Sampler <mimgopc<0x21, 0x21, 0x2a>, AMDGPUSample_c_d>;
16915f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_D_CL        : MIMG_Sampler <mimgopc<0x44, 0x44, 0x2b>, AMDGPUSample_c_d_cl>;
16925f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_L           : MIMG_Sampler <mimgopc<0x22, 0x22, 0x2c>, AMDGPUSample_c_l>;
16935f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_B           : MIMG_Sampler_WQM <mimgopc<0x23, 0x23, 0x2d>, AMDGPUSample_c_b>;
16945f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_B_CL        : MIMG_Sampler_WQM <mimgopc<0x45, 0x45, 0x2e>, AMDGPUSample_c_b_cl>;
16955f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_LZ          : MIMG_Sampler <mimgopc<0x24, 0x24, 0x2f>, AMDGPUSample_c_lz>;
16965f757f3fSDimitry Andricdefm IMAGE_SAMPLE_O             : MIMG_Sampler_WQM <mimgopc<0x25, 0x25, 0x30>, AMDGPUSample_o>;
16975f757f3fSDimitry Andricdefm IMAGE_SAMPLE_CL_O          : MIMG_Sampler_WQM <mimgopc<0x46, 0x46, 0x31>, AMDGPUSample_cl_o>;
16985f757f3fSDimitry Andricdefm IMAGE_SAMPLE_D_O           : MIMG_Sampler <mimgopc<0x26, 0x26, 0x32>, AMDGPUSample_d_o>;
16995f757f3fSDimitry Andricdefm IMAGE_SAMPLE_D_CL_O        : MIMG_Sampler <mimgopc<0x47, 0x47, 0x33>, AMDGPUSample_d_cl_o>;
17005f757f3fSDimitry Andricdefm IMAGE_SAMPLE_L_O           : MIMG_Sampler <mimgopc<0x27, 0x27, 0x34>, AMDGPUSample_l_o>;
17015f757f3fSDimitry Andricdefm IMAGE_SAMPLE_B_O           : MIMG_Sampler_WQM <mimgopc<0x28, 0x28, 0x35>, AMDGPUSample_b_o>;
17025f757f3fSDimitry Andricdefm IMAGE_SAMPLE_B_CL_O        : MIMG_Sampler_WQM <mimgopc<0x48, 0x48, 0x36>, AMDGPUSample_b_cl_o>;
17035f757f3fSDimitry Andricdefm IMAGE_SAMPLE_LZ_O          : MIMG_Sampler <mimgopc<0x29, 0x29, 0x37>, AMDGPUSample_lz_o>;
17045f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_O           : MIMG_Sampler_WQM <mimgopc<0x2a, 0x2a, 0x38>, AMDGPUSample_c_o>;
17055f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_CL_O        : MIMG_Sampler_WQM <mimgopc<0x49, 0x49, 0x39>, AMDGPUSample_c_cl_o>;
17065f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_D_O         : MIMG_Sampler <mimgopc<0x2b, 0x2b, 0x3a>, AMDGPUSample_c_d_o>;
17075f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_D_CL_O      : MIMG_Sampler <mimgopc<0x4a, 0x4a, 0x3b>, AMDGPUSample_c_d_cl_o>;
17085f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_L_O         : MIMG_Sampler <mimgopc<0x2c, 0x2c, 0x3c>, AMDGPUSample_c_l_o>;
17095f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_B_CL_O      : MIMG_Sampler_WQM <mimgopc<0x4b, 0x4b, 0x3e>, AMDGPUSample_c_b_cl_o>;
17105f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_B_O         : MIMG_Sampler_WQM <mimgopc<0x2d, 0x2d, 0x3d>, AMDGPUSample_c_b_o>;
17115f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_LZ_O        : MIMG_Sampler <mimgopc<0x2e, 0x2e, 0x3f>, AMDGPUSample_c_lz_o>;
17125f757f3fSDimitry Andricdefm IMAGE_GATHER4              : MIMG_Gather_WQM <mimgopc<0x2f, 0x2f, 0x40>, AMDGPUSample>;
17135f757f3fSDimitry Andricdefm IMAGE_GATHER4_CL           : MIMG_Gather_WQM <mimgopc<0x60, 0x60, 0x41>, AMDGPUSample_cl>;
17145f757f3fSDimitry Andricdefm IMAGE_GATHER4_L            : MIMG_Gather <mimgopc<0x30, 0x30, 0x44>, AMDGPUSample_l>;
17155f757f3fSDimitry Andricdefm IMAGE_GATHER4_B            : MIMG_Gather_WQM <mimgopc<0x31, 0x31, 0x45>, AMDGPUSample_b>;
17165f757f3fSDimitry Andricdefm IMAGE_GATHER4_B_CL         : MIMG_Gather_WQM <mimgopc<0x61, 0x61, 0x46>, AMDGPUSample_b_cl>;
17175f757f3fSDimitry Andricdefm IMAGE_GATHER4_LZ           : MIMG_Gather <mimgopc<0x32, 0x32, 0x47>, AMDGPUSample_lz>;
17185f757f3fSDimitry Andricdefm IMAGE_GATHER4_C            : MIMG_Gather_WQM <mimgopc<0x33, 0x33, 0x48>, AMDGPUSample_c>;
17195f757f3fSDimitry Andricdefm IMAGE_GATHER4_C_CL         : MIMG_Gather_WQM <mimgopc<0x62, 0x62, 0x49>, AMDGPUSample_c_cl>;
17205f757f3fSDimitry Andricdefm IMAGE_GATHER4_C_L          : MIMG_Gather <mimgopc<0x63, 0x63, 0x4c>, AMDGPUSample_c_l>;
17215f757f3fSDimitry Andricdefm IMAGE_GATHER4_C_B          : MIMG_Gather_WQM <mimgopc<0x64, 0x64, 0x4d>, AMDGPUSample_c_b>;
17225f757f3fSDimitry Andricdefm IMAGE_GATHER4_C_B_CL       : MIMG_Gather_WQM <mimgopc<0x65, 0x65, 0x4e>, AMDGPUSample_c_b_cl>;
17235f757f3fSDimitry Andricdefm IMAGE_GATHER4_C_LZ         : MIMG_Gather <mimgopc<0x34, 0x34, 0x4f>, AMDGPUSample_c_lz>;
17245f757f3fSDimitry Andricdefm IMAGE_GATHER4_O            : MIMG_Gather_WQM <mimgopc<0x35, 0x35, 0x50>, AMDGPUSample_o>;
17255f757f3fSDimitry Andricdefm IMAGE_GATHER4_CL_O         : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x51>, AMDGPUSample_cl_o>;
17265f757f3fSDimitry Andricdefm IMAGE_GATHER4_L_O          : MIMG_Gather <mimgopc<MIMG.NOP, MIMG.NOP, 0x54>, AMDGPUSample_l_o>;
17275f757f3fSDimitry Andricdefm IMAGE_GATHER4_B_O          : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x55>, AMDGPUSample_b_o>;
17285f757f3fSDimitry Andricdefm IMAGE_GATHER4_B_CL_O       : MIMG_Gather <mimgopc<MIMG.NOP, MIMG.NOP, 0x56>, AMDGPUSample_b_cl_o>;
17295f757f3fSDimitry Andricdefm IMAGE_GATHER4_LZ_O         : MIMG_Gather <mimgopc<0x36, 0x36, 0x57>, AMDGPUSample_lz_o>;
17305f757f3fSDimitry Andricdefm IMAGE_GATHER4_C_O          : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x58>, AMDGPUSample_c_o>;
17315f757f3fSDimitry Andricdefm IMAGE_GATHER4_C_CL_O       : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x59>, AMDGPUSample_c_cl_o>;
17325f757f3fSDimitry Andricdefm IMAGE_GATHER4_C_L_O        : MIMG_Gather <mimgopc<MIMG.NOP, MIMG.NOP, 0x5c>, AMDGPUSample_c_l_o>;
17335f757f3fSDimitry Andricdefm IMAGE_GATHER4_C_B_O        : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x5d>, AMDGPUSample_c_b_o>;
17345f757f3fSDimitry Andricdefm IMAGE_GATHER4_C_B_CL_O     : MIMG_Gather_WQM <mimgopc<MIMG.NOP, MIMG.NOP, 0x5e>, AMDGPUSample_c_b_cl_o>;
17355f757f3fSDimitry Andricdefm IMAGE_GATHER4_C_LZ_O       : MIMG_Gather <mimgopc<0x37, 0x37, 0x5f>, AMDGPUSample_c_lz_o>;
1736bdd1243dSDimitry Andric
1737*0fca6ea1SDimitry Andriclet OtherPredicates = [HasImageInsts, HasExtendedImageInsts, isGFX9Plus] in
17385f757f3fSDimitry Andricdefm IMAGE_GATHER4H             : MIMG_Gather <mimgopc<0x90, 0x90, 0x61, 0x42>, AMDGPUSample, 1, "image_gather4h">;
17390b57cec5SDimitry Andric
17405f757f3fSDimitry Andricdefm IMAGE_GET_LOD              : MIMG_Sampler <mimgopc<0x38, 0x38, 0x60>, AMDGPUSample, 1, 0, 1, "image_get_lod">;
1741fe6060f1SDimitry Andric
17425f757f3fSDimitry Andricdefm IMAGE_SAMPLE_CD            : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x68>, AMDGPUSample_cd>;
17435f757f3fSDimitry Andricdefm IMAGE_SAMPLE_CD_CL         : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x69>, AMDGPUSample_cd_cl>;
17445f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_CD          : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6a>, AMDGPUSample_c_cd>;
17455f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_CD_CL       : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6b>, AMDGPUSample_c_cd_cl>;
17465f757f3fSDimitry Andricdefm IMAGE_SAMPLE_CD_O          : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6c>, AMDGPUSample_cd_o>;
17475f757f3fSDimitry Andricdefm IMAGE_SAMPLE_CD_CL_O       : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6d>, AMDGPUSample_cd_cl_o>;
17485f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_CD_O        : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6e>, AMDGPUSample_c_cd_o>;
17495f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_CD_CL_O     : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x6f>, AMDGPUSample_c_cd_cl_o>;
1750*0fca6ea1SDimitry Andric} // End OtherPredicates = [HasImageInsts, HasExtendedImageInsts]
17510b57cec5SDimitry Andric
1752*0fca6ea1SDimitry Andriclet OtherPredicates = [HasImageInsts, HasExtendedImageInsts, HasG16] in {
17535f757f3fSDimitry Andricdefm IMAGE_SAMPLE_D_G16         : MIMG_Sampler <mimgopc<0x39, 0x39, 0xa2>, AMDGPUSample_d, 0, 1>;
17545f757f3fSDimitry Andricdefm IMAGE_SAMPLE_D_CL_G16      : MIMG_Sampler <mimgopc<0x5f, 0x5f, 0xa3>, AMDGPUSample_d_cl, 0, 1>;
17555f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_D_G16       : MIMG_Sampler <mimgopc<0x3a, 0x3a, 0xaa>, AMDGPUSample_c_d, 0, 1>;
17565f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_D_CL_G16    : MIMG_Sampler <mimgopc<0x54, 0x54, 0xab>, AMDGPUSample_c_d_cl, 0, 1>;
17575f757f3fSDimitry Andricdefm IMAGE_SAMPLE_D_O_G16       : MIMG_Sampler <mimgopc<0x3b, 0x3b, 0xb2>, AMDGPUSample_d_o, 0, 1>;
17585f757f3fSDimitry Andricdefm IMAGE_SAMPLE_D_CL_O_G16    : MIMG_Sampler <mimgopc<0x55, 0x55, 0xb3>, AMDGPUSample_d_cl_o, 0, 1>;
17595f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_D_O_G16     : MIMG_Sampler <mimgopc<0x3c, 0x3c, 0xba>, AMDGPUSample_c_d_o, 0, 1>;
17605f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_D_CL_O_G16  : MIMG_Sampler <mimgopc<0x56, 0x56, 0xbb>, AMDGPUSample_c_d_cl_o, 0, 1>;
17615f757f3fSDimitry Andricdefm IMAGE_SAMPLE_CD_G16        : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xe8>, AMDGPUSample_cd, 0, 1>;
17625f757f3fSDimitry Andricdefm IMAGE_SAMPLE_CD_CL_G16     : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xe9>, AMDGPUSample_cd_cl, 0, 1>;
17635f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_CD_G16      : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xea>, AMDGPUSample_c_cd, 0, 1>;
17645f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_CD_CL_G16   : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xeb>, AMDGPUSample_c_cd_cl, 0, 1>;
17655f757f3fSDimitry Andricdefm IMAGE_SAMPLE_CD_O_G16      : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xec>, AMDGPUSample_cd_o, 0, 1>;
17665f757f3fSDimitry Andricdefm IMAGE_SAMPLE_CD_CL_O_G16   : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xed>, AMDGPUSample_cd_cl_o, 0, 1>;
17675f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_CD_O_G16    : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xee>, AMDGPUSample_c_cd_o, 0, 1>;
17685f757f3fSDimitry Andricdefm IMAGE_SAMPLE_C_CD_CL_O_G16 : MIMG_Sampler <mimgopc<MIMG.NOP, MIMG.NOP, 0xef>, AMDGPUSample_c_cd_cl_o, 0, 1>;
1769*0fca6ea1SDimitry Andric} // End OtherPredicates = [HasImageInsts, HasExtendedImageInsts, HasG16]
17705ffd83dbSDimitry Andric
177181ad6265SDimitry Andric//def IMAGE_RSRC256 : MIMG_NoPattern_RSRC256 <"image_rsrc256", mimgopc<0x7e>>;
177281ad6265SDimitry Andric//def IMAGE_SAMPLER : MIMG_NoPattern_ <"image_sampler", mimgopc<0x7f>>;
177381ad6265SDimitry Andric
1774*0fca6ea1SDimitry Andriclet OtherPredicates = [HasImageInsts, HasGFX10_AEncoding, isGFX10Only] in
17755f757f3fSDimitry Andricdefm IMAGE_MSAA_LOAD_X : MIMG_NoSampler <mimgopc<MIMG.NOP, MIMG.NOP, 0x80>, "image_msaa_load", 1, 0, 0, 1>;
177681ad6265SDimitry Andric
1777*0fca6ea1SDimitry Andriclet OtherPredicates = [HasImageInsts, HasGFX10_AEncoding] in {
17785f757f3fSDimitry Andricdefm IMAGE_MSAA_LOAD : MIMG_MSAA_Load <mimgopc<0x18, 0x18, MIMG.NOP>, "image_msaa_load">;
177981ad6265SDimitry Andric
17805f757f3fSDimitry Andricdefm IMAGE_BVH_INTERSECT_RAY       : MIMG_IntersectRay<mimgopc<0x19, 0x19, 0xe6>, "image_bvh_intersect_ray", 0, 0>;
17815f757f3fSDimitry Andricdefm IMAGE_BVH_INTERSECT_RAY_a16   : MIMG_IntersectRay<mimgopc<0x19, 0x19, 0xe6>, "image_bvh_intersect_ray", 0, 1>;
17825f757f3fSDimitry Andricdefm IMAGE_BVH64_INTERSECT_RAY     : MIMG_IntersectRay<mimgopc<0x1a, 0x1a, 0xe7>, "image_bvh64_intersect_ray", 1, 0>;
17835f757f3fSDimitry Andricdefm IMAGE_BVH64_INTERSECT_RAY_a16 : MIMG_IntersectRay<mimgopc<0x1a, 0x1a, 0xe7>, "image_bvh64_intersect_ray", 1, 1>;
1784*0fca6ea1SDimitry Andric} // End OtherPredicates = [HasImageInsts, HasGFX10_AEncoding]
178581ad6265SDimitry Andric
178681ad6265SDimitry Andric} // End let OtherPredicates = [HasImageInsts]
1787e8d8bef9SDimitry Andric
17880b57cec5SDimitry Andric/********** ========================================= **********/
17890b57cec5SDimitry Andric/********** Table of dimension-aware image intrinsics **********/
17900b57cec5SDimitry Andric/********** ========================================= **********/
17910b57cec5SDimitry Andric
17920b57cec5SDimitry Andricclass ImageDimIntrinsicInfo<AMDGPUImageDimIntrinsic I> {
17930b57cec5SDimitry Andric  Intrinsic Intr = I;
17940b57cec5SDimitry Andric  MIMGBaseOpcode BaseOpcode = !cast<MIMGBaseOpcode>(!strconcat("IMAGE_", I.P.OpMod));
17950b57cec5SDimitry Andric  AMDGPUDimProps Dim = I.P.Dim;
1796e8d8bef9SDimitry Andric  AMDGPUImageDimIntrinsicEval DimEval = AMDGPUImageDimIntrinsicEval<I.P>;
1797e8d8bef9SDimitry Andric
179804eeddc0SDimitry Andric  bits<8> NumOffsetArgs = DimEval.NumOffsetArgs;
179904eeddc0SDimitry Andric  bits<8> NumBiasArgs = DimEval.NumBiasArgs;
180004eeddc0SDimitry Andric  bits<8> NumZCompareArgs = DimEval.NumZCompareArgs;
1801e8d8bef9SDimitry Andric  bits<8> NumGradients = DimEval.NumGradientArgs;
1802e8d8bef9SDimitry Andric  bits<8> NumDmask = DimEval.NumDmaskArgs;
1803e8d8bef9SDimitry Andric  bits<8> NumData = DimEval.NumDataArgs;
1804e8d8bef9SDimitry Andric  bits<8> NumVAddrs = DimEval.NumVAddrArgs;
1805e8d8bef9SDimitry Andric  bits<8> NumArgs = !add(DimEval.CachePolicyArgIndex, 1);
1806e8d8bef9SDimitry Andric
1807e8d8bef9SDimitry Andric  bits<8> DMaskIndex = DimEval.DmaskArgIndex;
1808e8d8bef9SDimitry Andric  bits<8> VAddrStart = DimEval.VAddrArgIndex;
180904eeddc0SDimitry Andric  bits<8> OffsetIndex = DimEval.OffsetArgIndex;
181004eeddc0SDimitry Andric  bits<8> BiasIndex = DimEval.BiasArgIndex;
181104eeddc0SDimitry Andric  bits<8> ZCompareIndex = DimEval.ZCompareArgIndex;
1812e8d8bef9SDimitry Andric  bits<8> GradientStart = DimEval.GradientArgIndex;
1813e8d8bef9SDimitry Andric  bits<8> CoordStart = DimEval.CoordArgIndex;
1814e8d8bef9SDimitry Andric  bits<8> LodIndex = DimEval.LodArgIndex;
1815e8d8bef9SDimitry Andric  bits<8> MipIndex = DimEval.MipArgIndex;
1816e8d8bef9SDimitry Andric  bits<8> VAddrEnd = !add(DimEval.VAddrArgIndex, DimEval.NumVAddrArgs);
1817e8d8bef9SDimitry Andric  bits<8> RsrcIndex = DimEval.RsrcArgIndex;
1818e8d8bef9SDimitry Andric  bits<8> SampIndex = DimEval.SampArgIndex;
1819e8d8bef9SDimitry Andric  bits<8> UnormIndex = DimEval.UnormArgIndex;
1820e8d8bef9SDimitry Andric  bits<8> TexFailCtrlIndex = DimEval.TexFailCtrlArgIndex;
1821e8d8bef9SDimitry Andric  bits<8> CachePolicyIndex = DimEval.CachePolicyArgIndex;
1822e8d8bef9SDimitry Andric
182304eeddc0SDimitry Andric  bits<8> BiasTyArg = !add(I.P.NumRetAndDataAnyTypes,
182404eeddc0SDimitry Andric    !if(!eq(NumOffsetArgs, 0), 0, I.P.ExtraAddrArgs[0].Type.isAny));
1825e8d8bef9SDimitry Andric  bits<8> GradientTyArg = !add(I.P.NumRetAndDataAnyTypes,
1826e8d8bef9SDimitry Andric    !foldl(0, I.P.ExtraAddrArgs, cnt, arg, !add(cnt, arg.Type.isAny)));
1827e8d8bef9SDimitry Andric  bits<8> CoordTyArg = !add(GradientTyArg, !if(I.P.Gradients, 1, 0));
18280b57cec5SDimitry Andric}
18290b57cec5SDimitry Andric
18300b57cec5SDimitry Andricdef ImageDimIntrinsicTable : GenericTable {
18310b57cec5SDimitry Andric  let FilterClass = "ImageDimIntrinsicInfo";
183204eeddc0SDimitry Andric  let Fields = ["Intr", "BaseOpcode", "Dim", "NumOffsetArgs", "NumBiasArgs", "NumZCompareArgs", "NumGradients", "NumDmask", "NumData", "NumVAddrs", "NumArgs",
183304eeddc0SDimitry Andric    "DMaskIndex", "VAddrStart", "OffsetIndex", "BiasIndex", "ZCompareIndex", "GradientStart", "CoordStart", "LodIndex", "MipIndex", "VAddrEnd",
1834e8d8bef9SDimitry Andric    "RsrcIndex", "SampIndex", "UnormIndex", "TexFailCtrlIndex", "CachePolicyIndex",
183504eeddc0SDimitry Andric    "BiasTyArg", "GradientTyArg", "CoordTyArg"];
1836e8d8bef9SDimitry Andric  string TypeOf_BaseOpcode = "MIMGBaseOpcode";
1837e8d8bef9SDimitry Andric  string TypeOf_Dim = "MIMGDim";
18380b57cec5SDimitry Andric
18390b57cec5SDimitry Andric  let PrimaryKey = ["Intr"];
18400b57cec5SDimitry Andric  let PrimaryKeyName = "getImageDimIntrinsicInfo";
18410b57cec5SDimitry Andric  let PrimaryKeyEarlyOut = 1;
18420b57cec5SDimitry Andric}
18430b57cec5SDimitry Andric
1844349cc55cSDimitry Andricdef getImageDimIntrinsicByBaseOpcode : SearchIndex {
18455ffd83dbSDimitry Andric  let Table = ImageDimIntrinsicTable;
18465ffd83dbSDimitry Andric  let Key = ["BaseOpcode", "Dim"];
18475ffd83dbSDimitry Andric}
18485ffd83dbSDimitry Andric
18490b57cec5SDimitry Andricforeach intr = !listconcat(AMDGPUImageDimIntrinsics,
18500b57cec5SDimitry Andric                           AMDGPUImageDimAtomicIntrinsics) in {
18510b57cec5SDimitry Andric  def : ImageDimIntrinsicInfo<intr>;
18520b57cec5SDimitry Andric}
18530b57cec5SDimitry Andric
18540b57cec5SDimitry Andric// L to LZ Optimization Mapping
18550b57cec5SDimitry Andricdef : MIMGLZMapping<IMAGE_SAMPLE_L, IMAGE_SAMPLE_LZ>;
18560b57cec5SDimitry Andricdef : MIMGLZMapping<IMAGE_SAMPLE_C_L, IMAGE_SAMPLE_C_LZ>;
18570b57cec5SDimitry Andricdef : MIMGLZMapping<IMAGE_SAMPLE_L_O, IMAGE_SAMPLE_LZ_O>;
18580b57cec5SDimitry Andricdef : MIMGLZMapping<IMAGE_SAMPLE_C_L_O, IMAGE_SAMPLE_C_LZ_O>;
18590b57cec5SDimitry Andricdef : MIMGLZMapping<IMAGE_GATHER4_L, IMAGE_GATHER4_LZ>;
18600b57cec5SDimitry Andricdef : MIMGLZMapping<IMAGE_GATHER4_C_L, IMAGE_GATHER4_C_LZ>;
18610b57cec5SDimitry Andricdef : MIMGLZMapping<IMAGE_GATHER4_L_O, IMAGE_GATHER4_LZ_O>;
18620b57cec5SDimitry Andricdef : MIMGLZMapping<IMAGE_GATHER4_C_L_O, IMAGE_GATHER4_C_LZ_O>;
1863*0fca6ea1SDimitry Andricdef : MIMGLZMapping<IMAGE_SAMPLE_L_nortn, IMAGE_SAMPLE_LZ_nortn>;
1864*0fca6ea1SDimitry Andricdef : MIMGLZMapping<IMAGE_SAMPLE_C_L_nortn, IMAGE_SAMPLE_C_LZ_nortn>;
1865*0fca6ea1SDimitry Andricdef : MIMGLZMapping<IMAGE_SAMPLE_L_O_nortn, IMAGE_SAMPLE_LZ_O_nortn>;
1866*0fca6ea1SDimitry Andricdef : MIMGLZMapping<IMAGE_SAMPLE_C_L_O_nortn, IMAGE_SAMPLE_C_LZ_O_nortn>;
18670b57cec5SDimitry Andric
18680b57cec5SDimitry Andric// MIP to NONMIP Optimization Mapping
18690b57cec5SDimitry Andricdef : MIMGMIPMapping<IMAGE_LOAD_MIP, IMAGE_LOAD>;
18700b57cec5SDimitry Andricdef : MIMGMIPMapping<IMAGE_STORE_MIP, IMAGE_STORE>;
18715ffd83dbSDimitry Andric
187204eeddc0SDimitry Andric// Bias to NoBias Optimization Mapping
187304eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_B, IMAGE_SAMPLE>;
187404eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_B_CL, IMAGE_SAMPLE_CL>;
187504eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_C_B, IMAGE_SAMPLE_C>;
187604eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_C_B_CL, IMAGE_SAMPLE_C_CL>;
187704eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_B_O, IMAGE_SAMPLE_O>;
187804eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_B_CL_O, IMAGE_SAMPLE_CL_O>;
187904eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_C_B_O, IMAGE_SAMPLE_C_O>;
188004eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_C_B_CL_O, IMAGE_SAMPLE_C_CL_O>;
188104eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_GATHER4_B, IMAGE_GATHER4>;
188204eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_GATHER4_B_CL, IMAGE_GATHER4_CL>;
188304eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_GATHER4_C_B, IMAGE_GATHER4_C>;
188404eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_GATHER4_C_B_CL, IMAGE_GATHER4_C_CL>;
188504eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_GATHER4_B_O, IMAGE_GATHER4_O>;
188604eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_GATHER4_B_CL_O, IMAGE_GATHER4_CL_O>;
188704eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_GATHER4_C_B_O, IMAGE_GATHER4_C_O>;
188804eeddc0SDimitry Andricdef : MIMGBiasMapping<IMAGE_GATHER4_C_B_CL_O, IMAGE_GATHER4_C_CL_O>;
1889*0fca6ea1SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_B_nortn, IMAGE_SAMPLE_nortn>;
1890*0fca6ea1SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_B_CL_nortn, IMAGE_SAMPLE_CL_nortn>;
1891*0fca6ea1SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_C_B_nortn, IMAGE_SAMPLE_C_nortn>;
1892*0fca6ea1SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_C_B_CL_nortn, IMAGE_SAMPLE_C_CL_nortn>;
1893*0fca6ea1SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_B_O_nortn, IMAGE_SAMPLE_O_nortn>;
1894*0fca6ea1SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_B_CL_O_nortn, IMAGE_SAMPLE_CL_O_nortn>;
1895*0fca6ea1SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_C_B_O_nortn, IMAGE_SAMPLE_C_O_nortn>;
1896*0fca6ea1SDimitry Andricdef : MIMGBiasMapping<IMAGE_SAMPLE_C_B_CL_O_nortn, IMAGE_SAMPLE_C_CL_O_nortn>;
189704eeddc0SDimitry Andric
189804eeddc0SDimitry Andric// Offset to NoOffset Optimization Mapping
189904eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_O, IMAGE_SAMPLE>;
190004eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_CL_O, IMAGE_SAMPLE_CL>;
190104eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_D_O, IMAGE_SAMPLE_D>;
190204eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_D_CL_O, IMAGE_SAMPLE_D_CL>;
190304eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_D_O_G16, IMAGE_SAMPLE_D_G16>;
190404eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_D_CL_O_G16, IMAGE_SAMPLE_D_CL_G16>;
190504eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_L_O, IMAGE_SAMPLE_L>;
190604eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_B_O, IMAGE_SAMPLE_B>;
190704eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_B_CL_O, IMAGE_SAMPLE_B_CL>;
190804eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_LZ_O, IMAGE_SAMPLE_LZ>;
190904eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_O, IMAGE_SAMPLE_C>;
191004eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_CL_O, IMAGE_SAMPLE_C_CL>;
191104eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_O, IMAGE_SAMPLE_C_D>;
191204eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_CL_O, IMAGE_SAMPLE_C_D_CL>;
191304eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_O_G16, IMAGE_SAMPLE_C_D_G16>;
191404eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_CL_O_G16, IMAGE_SAMPLE_C_D_CL_G16>;
191504eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_L_O, IMAGE_SAMPLE_C_L>;
191604eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_B_CL_O, IMAGE_SAMPLE_C_B_CL>;
191704eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_B_O, IMAGE_SAMPLE_C_B>;
191804eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_LZ_O, IMAGE_SAMPLE_C_LZ>;
191904eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_O, IMAGE_GATHER4>;
192004eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_CL_O, IMAGE_GATHER4_CL>;
192104eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_L_O, IMAGE_GATHER4_L>;
192204eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_B_O, IMAGE_GATHER4_B>;
192304eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_B_CL_O, IMAGE_GATHER4_B_CL>;
192404eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_LZ_O, IMAGE_GATHER4_LZ>;
192504eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_C_O, IMAGE_GATHER4_C>;
192604eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_C_CL_O, IMAGE_GATHER4_C_CL>;
192704eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_C_L_O, IMAGE_GATHER4_C_L>;
192804eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_C_B_O, IMAGE_GATHER4_C_B>;
192904eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_C_B_CL_O, IMAGE_GATHER4_C_B_CL>;
193004eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_GATHER4_C_LZ_O, IMAGE_GATHER4_C_LZ>;
193104eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_CD_O, IMAGE_SAMPLE_CD>;
193204eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_CD_CL_O, IMAGE_SAMPLE_CD_CL>;
193304eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_O, IMAGE_SAMPLE_C_CD>;
193404eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_CL_O, IMAGE_SAMPLE_C_CD_CL>;
193504eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_CD_O_G16, IMAGE_SAMPLE_CD_G16>;
193604eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_CD_CL_O_G16, IMAGE_SAMPLE_CD_CL_G16>;
193704eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_O_G16, IMAGE_SAMPLE_C_CD_G16>;
193804eeddc0SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_CL_O_G16, IMAGE_SAMPLE_C_CD_CL_G16>;
1939*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_O_nortn, IMAGE_SAMPLE_nortn>;
1940*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_CL_O_nortn, IMAGE_SAMPLE_CL_nortn>;
1941*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_D_O_nortn, IMAGE_SAMPLE_D_nortn>;
1942*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_D_CL_O_nortn, IMAGE_SAMPLE_D_CL_nortn>;
1943*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_D_O_G16_nortn, IMAGE_SAMPLE_D_G16_nortn>;
1944*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_D_CL_O_G16_nortn, IMAGE_SAMPLE_D_CL_G16_nortn>;
1945*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_L_O_nortn, IMAGE_SAMPLE_L_nortn>;
1946*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_B_O_nortn, IMAGE_SAMPLE_B_nortn>;
1947*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_B_CL_O_nortn, IMAGE_SAMPLE_B_CL_nortn>;
1948*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_LZ_O_nortn, IMAGE_SAMPLE_LZ_nortn>;
1949*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_O_nortn, IMAGE_SAMPLE_C_nortn>;
1950*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_CL_O_nortn, IMAGE_SAMPLE_C_CL_nortn>;
1951*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_O_nortn, IMAGE_SAMPLE_C_D_nortn>;
1952*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_CL_O_nortn, IMAGE_SAMPLE_C_D_CL_nortn>;
1953*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_O_G16_nortn, IMAGE_SAMPLE_C_D_G16_nortn>;
1954*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_D_CL_O_G16_nortn, IMAGE_SAMPLE_C_D_CL_G16_nortn>;
1955*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_L_O_nortn, IMAGE_SAMPLE_C_L_nortn>;
1956*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_B_CL_O_nortn, IMAGE_SAMPLE_C_B_CL_nortn>;
1957*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_B_O_nortn, IMAGE_SAMPLE_C_B_nortn>;
1958*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_LZ_O_nortn, IMAGE_SAMPLE_C_LZ_nortn>;
1959*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_CD_O_nortn, IMAGE_SAMPLE_CD>;
1960*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_CD_CL_O_nortn, IMAGE_SAMPLE_CD_CL_nortn>;
1961*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_O_nortn, IMAGE_SAMPLE_C_CD_nortn>;
1962*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_CL_O_nortn, IMAGE_SAMPLE_C_CD_CL_nortn>;
1963*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_CD_O_G16_nortn, IMAGE_SAMPLE_CD_G16_nortn>;
1964*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_CD_CL_O_G16_nortn, IMAGE_SAMPLE_CD_CL_G16_nortn>;
1965*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_O_G16_nortn, IMAGE_SAMPLE_C_CD_G16_nortn>;
1966*0fca6ea1SDimitry Andricdef : MIMGOffsetMapping<IMAGE_SAMPLE_C_CD_CL_O_G16_nortn, IMAGE_SAMPLE_C_CD_CL_G16_nortn>;
196704eeddc0SDimitry Andric
19685ffd83dbSDimitry Andric// G to G16 Optimization Mapping
19695ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_D, IMAGE_SAMPLE_D_G16>;
19705ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_D_CL, IMAGE_SAMPLE_D_CL_G16>;
19715ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_D, IMAGE_SAMPLE_C_D_G16>;
19725ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_D_CL, IMAGE_SAMPLE_C_D_CL_G16>;
19735ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_D_O, IMAGE_SAMPLE_D_O_G16>;
19745ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_D_CL_O, IMAGE_SAMPLE_D_CL_O_G16>;
19755ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_D_O, IMAGE_SAMPLE_C_D_O_G16>;
19765ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_D_CL_O, IMAGE_SAMPLE_C_D_CL_O_G16>;
19775ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_CD, IMAGE_SAMPLE_CD_G16>;
19785ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_CD_CL, IMAGE_SAMPLE_CD_CL_G16>;
19795ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_CD, IMAGE_SAMPLE_C_CD_G16>;
19805ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_CL, IMAGE_SAMPLE_C_CD_CL_G16>;
19815ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_CD_O, IMAGE_SAMPLE_CD_O_G16>;
19825ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_CD_CL_O, IMAGE_SAMPLE_CD_CL_O_G16>;
19835ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_O, IMAGE_SAMPLE_C_CD_O_G16>;
19845ffd83dbSDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_CL_O, IMAGE_SAMPLE_C_CD_CL_O_G16>;
1985*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_D_nortn, IMAGE_SAMPLE_D_G16_nortn>;
1986*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_D_CL_nortn, IMAGE_SAMPLE_D_CL_G16_nortn>;
1987*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_D_nortn, IMAGE_SAMPLE_C_D_G16_nortn>;
1988*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_D_CL_nortn, IMAGE_SAMPLE_C_D_CL_G16_nortn>;
1989*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_D_O_nortn, IMAGE_SAMPLE_D_O_G16_nortn>;
1990*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_D_CL_O_nortn, IMAGE_SAMPLE_D_CL_O_G16_nortn>;
1991*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_D_O_nortn, IMAGE_SAMPLE_C_D_O_G16_nortn>;
1992*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_D_CL_O_nortn, IMAGE_SAMPLE_C_D_CL_O_G16_nortn>;
1993*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_CD_nortn, IMAGE_SAMPLE_CD_G16_nortn>;
1994*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_CD_CL_nortn, IMAGE_SAMPLE_CD_CL_G16_nortn>;
1995*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_nortn, IMAGE_SAMPLE_C_CD_G16_nortn>;
1996*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_CL_nortn, IMAGE_SAMPLE_C_CD_CL_G16_nortn>;
1997*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_CD_O_nortn, IMAGE_SAMPLE_CD_O_G16_nortn>;
1998*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_CD_CL_O_nortn, IMAGE_SAMPLE_CD_CL_O_G16_nortn>;
1999*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_O_nortn, IMAGE_SAMPLE_C_CD_O_G16_nortn>;
2000*0fca6ea1SDimitry Andricdef : MIMGG16Mapping<IMAGE_SAMPLE_C_CD_CL_O_nortn, IMAGE_SAMPLE_C_CD_CL_O_G16_nortn>;
2001