1 //===-- MIMGInstructions.td - MIMG Instruction Defintions -----------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // MIMG-specific encoding families to distinguish between semantically
10 // equivalent machine instructions with different encoding.
12 // - MIMGEncGfx6: encoding introduced with gfx6 (obsoleted for atomics in gfx8)
13 // - MIMGEncGfx8: encoding introduced with gfx8 for atomics
16 def MIMGEncGfx6 : MIMGEncoding;
17 def MIMGEncGfx8 : MIMGEncoding;
19 def MIMGEncoding : GenericEnum {
20 let FilterClass = "MIMGEncoding";
23 // Represent an ISA-level opcode, independent of the encoding and the
25 class MIMGBaseOpcode {
26 MIMGBaseOpcode BaseOpcode = !cast<MIMGBaseOpcode>(NAME);
29 bit AtomicX2 = 0; // (f)cmpswap
32 bits<8> NumExtraArgs = 0;
35 bit LodOrClampOrMip = 0;
39 def MIMGBaseOpcode : GenericEnum {
40 let FilterClass = "MIMGBaseOpcode";
43 def MIMGBaseOpcodesTable : GenericTable {
44 let FilterClass = "MIMGBaseOpcode";
45 let CppTypeName = "MIMGBaseOpcodeInfo";
46 let Fields = ["BaseOpcode", "Store", "Atomic", "AtomicX2", "Sampler", "Gather4",
47 "NumExtraArgs", "Gradients", "Coordinates", "LodOrClampOrMip",
49 GenericEnum TypeOf_BaseOpcode = MIMGBaseOpcode;
51 let PrimaryKey = ["BaseOpcode"];
52 let PrimaryKeyName = "getMIMGBaseOpcodeInfo";
55 def MIMGDim : GenericEnum {
56 let FilterClass = "AMDGPUDimProps";
59 def MIMGDimInfoTable : GenericTable {
60 let FilterClass = "AMDGPUDimProps";
61 let CppTypeName = "MIMGDimInfo";
62 let Fields = ["Dim", "NumCoords", "NumGradients", "DA"];
63 GenericEnum TypeOf_Dim = MIMGDim;
65 let PrimaryKey = ["Dim"];
66 let PrimaryKeyName = "getMIMGDimInfo";
69 class MIMGLZMapping<MIMGBaseOpcode l, MIMGBaseOpcode lz> {
71 MIMGBaseOpcode LZ = lz;
74 def MIMGLZMappingTable : GenericTable {
75 let FilterClass = "MIMGLZMapping";
76 let CppTypeName = "MIMGLZMappingInfo";
77 let Fields = ["L", "LZ"];
78 GenericEnum TypeOf_L = MIMGBaseOpcode;
79 GenericEnum TypeOf_LZ = MIMGBaseOpcode;
81 let PrimaryKey = ["L"];
82 let PrimaryKeyName = "getMIMGLZMappingInfo";
85 class mimg <bits<7> si, bits<7> vi = si> {
86 field bits<7> SI = si;
87 field bits<7> VI = vi;
90 class MIMG <dag outs, string dns = "">
91 : InstSI <outs, (ins), "", []> {
99 let hasPostISelHook = 1;
100 let SchedRW = [WriteVMEM];
101 let UseNamedOperandTable = 1;
102 let hasSideEffects = 0; // XXX ????
104 let DecoderNamespace = dns;
105 let isAsmParserOnly = !if(!eq(dns,""), 1, 0);
106 let AsmMatchConverter = "cvtMIMG";
107 let usesCustomInserter = 1;
109 Instruction Opcode = !cast<Instruction>(NAME);
110 MIMGBaseOpcode BaseOpcode;
111 MIMGEncoding MIMGEncoding = MIMGEncGfx6;
116 def MIMGInfoTable : GenericTable {
117 let FilterClass = "MIMG";
118 let CppTypeName = "MIMGInfo";
119 let Fields = ["Opcode", "BaseOpcode", "MIMGEncoding", "VDataDwords", "VAddrDwords"];
120 GenericEnum TypeOf_BaseOpcode = MIMGBaseOpcode;
121 GenericEnum TypeOf_MIMGEncoding = MIMGEncoding;
123 let PrimaryKey = ["BaseOpcode", "MIMGEncoding", "VDataDwords", "VAddrDwords"];
124 let PrimaryKeyName = "getMIMGOpcodeHelper";
127 def getMIMGInfo : SearchIndex {
128 let Table = MIMGInfoTable;
129 let Key = ["Opcode"];
132 class MIMG_NoSampler_Helper <bits<7> op, string asm,
133 RegisterClass dst_rc,
134 RegisterClass addr_rc,
136 : MIMG <(outs dst_rc:$vdata), dns>,
139 let d16 = !if(BaseOpcode.HasD16, ?, 0);
141 let InOperandList = !con((ins addr_rc:$vaddr, SReg_256:$srsrc,
142 DMask:$dmask, UNorm:$unorm, GLC:$glc, SLC:$slc,
143 R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
144 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
145 let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$glc$slc$r128$tfe$lwe$da"
146 #!if(BaseOpcode.HasD16, "$d16", "");
149 multiclass MIMG_NoSampler_Src_Helper <bits<7> op, string asm,
150 RegisterClass dst_rc,
152 let VAddrDwords = 1 in
153 def NAME # _V1 : MIMG_NoSampler_Helper <op, asm, dst_rc, VGPR_32,
154 !if(enableDisasm, "AMDGPU", "")>;
155 let VAddrDwords = 2 in
156 def NAME # _V2 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_64>;
157 let VAddrDwords = 3 in
158 def NAME # _V3 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_96>;
159 let VAddrDwords = 4 in
160 def NAME # _V4 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_128>;
163 multiclass MIMG_NoSampler <bits<7> op, string asm, bit has_d16, bit mip = 0,
165 def "" : MIMGBaseOpcode {
166 let Coordinates = !if(isResInfo, 0, 1);
167 let LodOrClampOrMip = mip;
168 let HasD16 = has_d16;
171 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME),
172 mayLoad = !if(isResInfo, 0, 1) in {
173 let VDataDwords = 1 in
174 defm _V1 : MIMG_NoSampler_Src_Helper <op, asm, VGPR_32, 1>;
175 let VDataDwords = 2 in
176 defm _V2 : MIMG_NoSampler_Src_Helper <op, asm, VReg_64, 0>;
177 let VDataDwords = 3 in
178 defm _V3 : MIMG_NoSampler_Src_Helper <op, asm, VReg_96, 0>;
179 let VDataDwords = 4 in
180 defm _V4 : MIMG_NoSampler_Src_Helper <op, asm, VReg_128, 0>;
181 let VDataDwords = 8 in
182 defm _V8 : MIMG_NoSampler_Src_Helper <op, asm, VReg_256, 0>;
186 class MIMG_Store_Helper <bits<7> op, string asm,
187 RegisterClass data_rc,
188 RegisterClass addr_rc,
190 : MIMG <(outs), dns>,
193 let d16 = !if(BaseOpcode.HasD16, ?, 0);
197 let hasSideEffects = 0;
198 let hasPostISelHook = 0;
201 let InOperandList = !con((ins data_rc:$vdata, addr_rc:$vaddr, SReg_256:$srsrc,
202 DMask:$dmask, UNorm:$unorm, GLC:$glc, SLC:$slc,
203 R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
204 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
205 let AsmString = asm#" $vdata, $vaddr, $srsrc$dmask$unorm$glc$slc$r128$tfe$lwe$da"
206 #!if(BaseOpcode.HasD16, "$d16", "");
209 multiclass MIMG_Store_Addr_Helper <bits<7> op, string asm,
210 RegisterClass data_rc,
212 let VAddrDwords = 1 in
213 def NAME # _V1 : MIMG_Store_Helper <op, asm, data_rc, VGPR_32,
214 !if(enableDisasm, "AMDGPU", "")>;
215 let VAddrDwords = 2 in
216 def NAME # _V2 : MIMG_Store_Helper <op, asm, data_rc, VReg_64>;
217 let VAddrDwords = 3 in
218 def NAME # _V3 : MIMG_Store_Helper <op, asm, data_rc, VReg_96>;
219 let VAddrDwords = 4 in
220 def NAME # _V4 : MIMG_Store_Helper <op, asm, data_rc, VReg_128>;
223 multiclass MIMG_Store <bits<7> op, string asm, bit has_d16, bit mip = 0> {
224 def "" : MIMGBaseOpcode {
226 let LodOrClampOrMip = mip;
227 let HasD16 = has_d16;
230 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME) in {
231 let VDataDwords = 1 in
232 defm _V1 : MIMG_Store_Addr_Helper <op, asm, VGPR_32, 1>;
233 let VDataDwords = 2 in
234 defm _V2 : MIMG_Store_Addr_Helper <op, asm, VReg_64, 0>;
235 let VDataDwords = 3 in
236 defm _V3 : MIMG_Store_Addr_Helper <op, asm, VReg_96, 0>;
237 let VDataDwords = 4 in
238 defm _V4 : MIMG_Store_Addr_Helper <op, asm, VReg_128, 0>;
242 class MIMG_Atomic_Helper <string asm, RegisterClass data_rc,
243 RegisterClass addr_rc, string dns="",
245 : MIMG <(outs data_rc:$vdst), !if(enableDasm, dns, "")> {
248 let hasSideEffects = 1; // FIXME: Remove this
249 let hasPostISelHook = 0;
251 let Constraints = "$vdst = $vdata";
252 let AsmMatchConverter = "cvtMIMGAtomic";
254 let InOperandList = (ins data_rc:$vdata, addr_rc:$vaddr, SReg_256:$srsrc,
255 DMask:$dmask, UNorm:$unorm, GLC:$glc, SLC:$slc,
256 R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da);
257 let AsmString = asm#" $vdst, $vaddr, $srsrc$dmask$unorm$glc$slc$r128$tfe$lwe$da";
260 multiclass MIMG_Atomic_Helper_m <mimg op, string asm, RegisterClass data_rc,
261 RegisterClass addr_rc, bit enableDasm = 0> {
262 let ssamp = 0, d16 = 0 in {
263 def _si : MIMG_Atomic_Helper<asm, data_rc, addr_rc, "SICI", enableDasm>,
264 SIMCInstr<NAME, SIEncodingFamily.SI>,
266 let AssemblerPredicates = [isSICI];
267 let DisableDecoder = DisableSIDecoder;
270 def _vi : MIMG_Atomic_Helper<asm, data_rc, addr_rc, "VI", enableDasm>,
271 SIMCInstr<NAME, SIEncodingFamily.VI>,
273 let AssemblerPredicates = [isVI];
274 let DisableDecoder = DisableVIDecoder;
275 let MIMGEncoding = MIMGEncGfx8;
280 multiclass MIMG_Atomic_Addr_Helper_m <mimg op, string asm,
281 RegisterClass data_rc,
282 bit enableDasm = 0> {
283 // _V* variants have different address size, but the size is not encoded.
284 // So only one variant can be disassembled. V1 looks the safest to decode.
285 let VAddrDwords = 1 in
286 defm _V1 : MIMG_Atomic_Helper_m <op, asm, data_rc, VGPR_32, enableDasm>;
287 let VAddrDwords = 2 in
288 defm _V2 : MIMG_Atomic_Helper_m <op, asm, data_rc, VReg_64>;
289 let VAddrDwords = 3 in
290 defm _V3 : MIMG_Atomic_Helper_m <op, asm, data_rc, VReg_96>;
291 let VAddrDwords = 4 in
292 defm _V4 : MIMG_Atomic_Helper_m <op, asm, data_rc, VReg_128>;
295 multiclass MIMG_Atomic <mimg op, string asm, bit isCmpSwap = 0> { // 64-bit atomics
296 def "" : MIMGBaseOpcode {
298 let AtomicX2 = isCmpSwap;
301 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME) in {
302 // _V* variants have different dst size, but the size is encoded implicitly,
303 // using dmask and tfe. Only 32-bit variant is registered with disassembler.
304 // Other variants are reconstructed by disassembler using dmask and tfe.
305 let VDataDwords = !if(isCmpSwap, 2, 1) in
306 defm _V1 : MIMG_Atomic_Addr_Helper_m <op, asm, !if(isCmpSwap, VReg_64, VGPR_32), 1>;
307 let VDataDwords = !if(isCmpSwap, 4, 2) in
308 defm _V2 : MIMG_Atomic_Addr_Helper_m <op, asm, !if(isCmpSwap, VReg_128, VReg_64)>;
312 class MIMG_Sampler_Helper <bits<7> op, string asm, RegisterClass dst_rc,
313 RegisterClass src_rc, string dns="">
314 : MIMG <(outs dst_rc:$vdata), dns>,
316 let d16 = !if(BaseOpcode.HasD16, ?, 0);
318 let InOperandList = !con((ins src_rc:$vaddr, SReg_256:$srsrc, SReg_128:$ssamp,
319 DMask:$dmask, UNorm:$unorm, GLC:$glc, SLC:$slc,
320 R128A16:$r128, TFE:$tfe, LWE:$lwe, DA:$da),
321 !if(BaseOpcode.HasD16, (ins D16:$d16), (ins)));
322 let AsmString = asm#" $vdata, $vaddr, $srsrc, $ssamp$dmask$unorm$glc$slc$r128$tfe$lwe$da"
323 #!if(BaseOpcode.HasD16, "$d16", "");
326 class MIMGAddrSize<int dw, bit enable_disasm> {
329 RegisterClass RegClass = !if(!le(NumWords, 0), ?,
330 !if(!eq(NumWords, 1), VGPR_32,
331 !if(!eq(NumWords, 2), VReg_64,
332 !if(!eq(NumWords, 3), VReg_96,
333 !if(!eq(NumWords, 4), VReg_128,
334 !if(!le(NumWords, 8), VReg_256,
335 !if(!le(NumWords, 16), VReg_512, ?)))))));
337 // Whether the instruction variant with this vaddr size should be enabled for
338 // the auto-generated disassembler.
339 bit Disassemble = enable_disasm;
342 // Return whether a value inside the range [min, max] (endpoints inclusive)
343 // is in the given list.
344 class isRangeInList<int min, int max, list<int> lst> {
345 bit ret = !foldl(0, lst, lhs, y, !or(lhs, !and(!le(min, y), !le(y, max))));
348 class MIMGAddrSizes_tmp<list<MIMGAddrSize> lst, int min> {
349 list<MIMGAddrSize> List = lst;
353 class MIMG_Sampler_AddrSizes<AMDGPUSampleVariant sample> {
354 // List of all possible numbers of address words, taking all combinations of
355 // A16 and image dimension into account (note: no MSAA, since this is for
356 // sample/gather ops).
357 list<int> AllNumAddrWords =
358 !foreach(dw, !if(sample.Gradients,
359 !if(!eq(sample.LodOrClamp, ""),
360 [2, 3, 4, 5, 6, 7, 9],
361 [2, 3, 4, 5, 7, 8, 10]),
362 !if(!eq(sample.LodOrClamp, ""),
365 !add(dw, !size(sample.ExtraAddrArgs)));
367 // Generate machine instructions based on possible register classes for the
368 // required numbers of address words. The disassembler defaults to the
369 // smallest register class.
370 list<MIMGAddrSize> MachineInstrs =
371 !foldl(MIMGAddrSizes_tmp<[], 0>, [1, 2, 3, 4, 8, 16], lhs, dw,
372 !if(isRangeInList<lhs.Min, dw, AllNumAddrWords>.ret,
374 !listconcat(lhs.List, [MIMGAddrSize<dw, !empty(lhs.List)>]),
375 !if(!eq(dw, 3), 3, !add(dw, 1))>, // we still need _V4 for codegen w/ 3 dwords
379 multiclass MIMG_Sampler_Src_Helper <bits<7> op, string asm,
380 AMDGPUSampleVariant sample, RegisterClass dst_rc,
381 bit enableDisasm = 0> {
382 foreach addr = MIMG_Sampler_AddrSizes<sample>.MachineInstrs in {
383 let VAddrDwords = addr.NumWords in
384 def _V # addr.NumWords
385 : MIMG_Sampler_Helper <op, asm, dst_rc, addr.RegClass,
386 !if(!and(enableDisasm, addr.Disassemble), "AMDGPU", "")>;
390 class MIMG_Sampler_BaseOpcode<AMDGPUSampleVariant sample>
393 let NumExtraArgs = !size(sample.ExtraAddrArgs);
394 let Gradients = sample.Gradients;
395 let LodOrClampOrMip = !ne(sample.LodOrClamp, "");
398 multiclass MIMG_Sampler <bits<7> op, AMDGPUSampleVariant sample, bit wqm = 0,
400 string asm = "image_sample"#sample.LowerCaseMod> {
401 def "" : MIMG_Sampler_BaseOpcode<sample> {
402 let HasD16 = !if(isGetLod, 0, 1);
405 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME), WQM = wqm,
406 mayLoad = !if(isGetLod, 0, 1) in {
407 let VDataDwords = 1 in
408 defm _V1 : MIMG_Sampler_Src_Helper<op, asm, sample, VGPR_32, 1>;
409 let VDataDwords = 2 in
410 defm _V2 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_64>;
411 let VDataDwords = 3 in
412 defm _V3 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_96>;
413 let VDataDwords = 4 in
414 defm _V4 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_128>;
415 let VDataDwords = 8 in
416 defm _V8 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_256>;
420 multiclass MIMG_Sampler_WQM <bits<7> op, AMDGPUSampleVariant sample>
421 : MIMG_Sampler<op, sample, 1>;
423 multiclass MIMG_Gather <bits<7> op, AMDGPUSampleVariant sample, bit wqm = 0,
424 string asm = "image_gather4"#sample.LowerCaseMod> {
425 def "" : MIMG_Sampler_BaseOpcode<sample> {
430 let BaseOpcode = !cast<MIMGBaseOpcode>(NAME), WQM = wqm,
431 Gather4 = 1, hasPostISelHook = 0 in {
432 let VDataDwords = 2 in
433 defm _V2 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_64>; /* for packed D16 only */
434 let VDataDwords = 4 in
435 defm _V4 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_128, 1>;
436 let VDataDwords = 8 in
437 defm _V8 : MIMG_Sampler_Src_Helper<op, asm, sample, VReg_256>;
441 multiclass MIMG_Gather_WQM <bits<7> op, AMDGPUSampleVariant sample>
442 : MIMG_Gather<op, sample, 1>;
444 //===----------------------------------------------------------------------===//
446 //===----------------------------------------------------------------------===//
447 defm IMAGE_LOAD : MIMG_NoSampler <0x00000000, "image_load", 1>;
448 defm IMAGE_LOAD_MIP : MIMG_NoSampler <0x00000001, "image_load_mip", 1, 1>;
449 defm IMAGE_LOAD_PCK : MIMG_NoSampler <0x00000002, "image_load_pck", 0>;
450 defm IMAGE_LOAD_PCK_SGN : MIMG_NoSampler <0x00000003, "image_load_pck_sgn", 0>;
451 defm IMAGE_LOAD_MIP_PCK : MIMG_NoSampler <0x00000004, "image_load_mip_pck", 0, 1>;
452 defm IMAGE_LOAD_MIP_PCK_SGN : MIMG_NoSampler <0x00000005, "image_load_mip_pck_sgn", 0, 1>;
453 defm IMAGE_STORE : MIMG_Store <0x00000008, "image_store", 1>;
454 defm IMAGE_STORE_MIP : MIMG_Store <0x00000009, "image_store_mip", 1, 1>;
455 defm IMAGE_STORE_PCK : MIMG_Store <0x0000000a, "image_store_pck", 0>;
456 defm IMAGE_STORE_MIP_PCK : MIMG_Store <0x0000000b, "image_store_mip_pck", 0, 1>;
458 defm IMAGE_GET_RESINFO : MIMG_NoSampler <0x0000000e, "image_get_resinfo", 0, 1, 1>;
460 defm IMAGE_ATOMIC_SWAP : MIMG_Atomic <mimg<0x0f, 0x10>, "image_atomic_swap">;
461 defm IMAGE_ATOMIC_CMPSWAP : MIMG_Atomic <mimg<0x10, 0x11>, "image_atomic_cmpswap", 1>;
462 defm IMAGE_ATOMIC_ADD : MIMG_Atomic <mimg<0x11, 0x12>, "image_atomic_add">;
463 defm IMAGE_ATOMIC_SUB : MIMG_Atomic <mimg<0x12, 0x13>, "image_atomic_sub">;
464 //def IMAGE_ATOMIC_RSUB : MIMG_NoPattern_ <"image_atomic_rsub", 0x00000013>; -- not on VI
465 defm IMAGE_ATOMIC_SMIN : MIMG_Atomic <mimg<0x14>, "image_atomic_smin">;
466 defm IMAGE_ATOMIC_UMIN : MIMG_Atomic <mimg<0x15>, "image_atomic_umin">;
467 defm IMAGE_ATOMIC_SMAX : MIMG_Atomic <mimg<0x16>, "image_atomic_smax">;
468 defm IMAGE_ATOMIC_UMAX : MIMG_Atomic <mimg<0x17>, "image_atomic_umax">;
469 defm IMAGE_ATOMIC_AND : MIMG_Atomic <mimg<0x18>, "image_atomic_and">;
470 defm IMAGE_ATOMIC_OR : MIMG_Atomic <mimg<0x19>, "image_atomic_or">;
471 defm IMAGE_ATOMIC_XOR : MIMG_Atomic <mimg<0x1a>, "image_atomic_xor">;
472 defm IMAGE_ATOMIC_INC : MIMG_Atomic <mimg<0x1b>, "image_atomic_inc">;
473 defm IMAGE_ATOMIC_DEC : MIMG_Atomic <mimg<0x1c>, "image_atomic_dec">;
474 //def IMAGE_ATOMIC_FCMPSWAP : MIMG_NoPattern_ <"image_atomic_fcmpswap", 0x0000001d, 1>; -- not on VI
475 //def IMAGE_ATOMIC_FMIN : MIMG_NoPattern_ <"image_atomic_fmin", 0x0000001e>; -- not on VI
476 //def IMAGE_ATOMIC_FMAX : MIMG_NoPattern_ <"image_atomic_fmax", 0x0000001f>; -- not on VI
477 defm IMAGE_SAMPLE : MIMG_Sampler_WQM <0x00000020, AMDGPUSample>;
478 defm IMAGE_SAMPLE_CL : MIMG_Sampler_WQM <0x00000021, AMDGPUSample_cl>;
479 defm IMAGE_SAMPLE_D : MIMG_Sampler <0x00000022, AMDGPUSample_d>;
480 defm IMAGE_SAMPLE_D_CL : MIMG_Sampler <0x00000023, AMDGPUSample_d_cl>;
481 defm IMAGE_SAMPLE_L : MIMG_Sampler <0x00000024, AMDGPUSample_l>;
482 defm IMAGE_SAMPLE_B : MIMG_Sampler_WQM <0x00000025, AMDGPUSample_b>;
483 defm IMAGE_SAMPLE_B_CL : MIMG_Sampler_WQM <0x00000026, AMDGPUSample_b_cl>;
484 defm IMAGE_SAMPLE_LZ : MIMG_Sampler <0x00000027, AMDGPUSample_lz>;
485 defm IMAGE_SAMPLE_C : MIMG_Sampler_WQM <0x00000028, AMDGPUSample_c>;
486 defm IMAGE_SAMPLE_C_CL : MIMG_Sampler_WQM <0x00000029, AMDGPUSample_c_cl>;
487 defm IMAGE_SAMPLE_C_D : MIMG_Sampler <0x0000002a, AMDGPUSample_c_d>;
488 defm IMAGE_SAMPLE_C_D_CL : MIMG_Sampler <0x0000002b, AMDGPUSample_c_d_cl>;
489 defm IMAGE_SAMPLE_C_L : MIMG_Sampler <0x0000002c, AMDGPUSample_c_l>;
490 defm IMAGE_SAMPLE_C_B : MIMG_Sampler_WQM <0x0000002d, AMDGPUSample_c_b>;
491 defm IMAGE_SAMPLE_C_B_CL : MIMG_Sampler_WQM <0x0000002e, AMDGPUSample_c_b_cl>;
492 defm IMAGE_SAMPLE_C_LZ : MIMG_Sampler <0x0000002f, AMDGPUSample_c_lz>;
493 defm IMAGE_SAMPLE_O : MIMG_Sampler_WQM <0x00000030, AMDGPUSample_o>;
494 defm IMAGE_SAMPLE_CL_O : MIMG_Sampler_WQM <0x00000031, AMDGPUSample_cl_o>;
495 defm IMAGE_SAMPLE_D_O : MIMG_Sampler <0x00000032, AMDGPUSample_d_o>;
496 defm IMAGE_SAMPLE_D_CL_O : MIMG_Sampler <0x00000033, AMDGPUSample_d_cl_o>;
497 defm IMAGE_SAMPLE_L_O : MIMG_Sampler <0x00000034, AMDGPUSample_l_o>;
498 defm IMAGE_SAMPLE_B_O : MIMG_Sampler_WQM <0x00000035, AMDGPUSample_b_o>;
499 defm IMAGE_SAMPLE_B_CL_O : MIMG_Sampler_WQM <0x00000036, AMDGPUSample_b_cl_o>;
500 defm IMAGE_SAMPLE_LZ_O : MIMG_Sampler <0x00000037, AMDGPUSample_lz_o>;
501 defm IMAGE_SAMPLE_C_O : MIMG_Sampler_WQM <0x00000038, AMDGPUSample_c_o>;
502 defm IMAGE_SAMPLE_C_CL_O : MIMG_Sampler_WQM <0x00000039, AMDGPUSample_c_cl_o>;
503 defm IMAGE_SAMPLE_C_D_O : MIMG_Sampler <0x0000003a, AMDGPUSample_c_d_o>;
504 defm IMAGE_SAMPLE_C_D_CL_O : MIMG_Sampler <0x0000003b, AMDGPUSample_c_d_cl_o>;
505 defm IMAGE_SAMPLE_C_L_O : MIMG_Sampler <0x0000003c, AMDGPUSample_c_l_o>;
506 defm IMAGE_SAMPLE_C_B_CL_O : MIMG_Sampler_WQM <0x0000003e, AMDGPUSample_c_b_cl_o>;
507 defm IMAGE_SAMPLE_C_B_O : MIMG_Sampler_WQM <0x0000003d, AMDGPUSample_c_b_o>;
508 defm IMAGE_SAMPLE_C_LZ_O : MIMG_Sampler <0x0000003f, AMDGPUSample_c_lz_o>;
509 defm IMAGE_GATHER4 : MIMG_Gather_WQM <0x00000040, AMDGPUSample>;
510 defm IMAGE_GATHER4_CL : MIMG_Gather_WQM <0x00000041, AMDGPUSample_cl>;
511 defm IMAGE_GATHER4_L : MIMG_Gather <0x00000044, AMDGPUSample_l>;
512 defm IMAGE_GATHER4_B : MIMG_Gather_WQM <0x00000045, AMDGPUSample_b>;
513 defm IMAGE_GATHER4_B_CL : MIMG_Gather_WQM <0x00000046, AMDGPUSample_b_cl>;
514 defm IMAGE_GATHER4_LZ : MIMG_Gather <0x00000047, AMDGPUSample_lz>;
515 defm IMAGE_GATHER4_C : MIMG_Gather_WQM <0x00000048, AMDGPUSample_c>;
516 defm IMAGE_GATHER4_C_CL : MIMG_Gather_WQM <0x00000049, AMDGPUSample_c_cl>;
517 defm IMAGE_GATHER4_C_L : MIMG_Gather <0x0000004c, AMDGPUSample_c_l>;
518 defm IMAGE_GATHER4_C_B : MIMG_Gather_WQM <0x0000004d, AMDGPUSample_c_b>;
519 defm IMAGE_GATHER4_C_B_CL : MIMG_Gather_WQM <0x0000004e, AMDGPUSample_c_b_cl>;
520 defm IMAGE_GATHER4_C_LZ : MIMG_Gather <0x0000004f, AMDGPUSample_c_lz>;
521 defm IMAGE_GATHER4_O : MIMG_Gather_WQM <0x00000050, AMDGPUSample_o>;
522 defm IMAGE_GATHER4_CL_O : MIMG_Gather_WQM <0x00000051, AMDGPUSample_cl_o>;
523 defm IMAGE_GATHER4_L_O : MIMG_Gather <0x00000054, AMDGPUSample_l_o>;
524 defm IMAGE_GATHER4_B_O : MIMG_Gather_WQM <0x00000055, AMDGPUSample_b_o>;
525 defm IMAGE_GATHER4_B_CL_O : MIMG_Gather <0x00000056, AMDGPUSample_b_cl_o>;
526 defm IMAGE_GATHER4_LZ_O : MIMG_Gather <0x00000057, AMDGPUSample_lz_o>;
527 defm IMAGE_GATHER4_C_O : MIMG_Gather_WQM <0x00000058, AMDGPUSample_c_o>;
528 defm IMAGE_GATHER4_C_CL_O : MIMG_Gather_WQM <0x00000059, AMDGPUSample_c_cl_o>;
529 defm IMAGE_GATHER4_C_L_O : MIMG_Gather <0x0000005c, AMDGPUSample_c_l_o>;
530 defm IMAGE_GATHER4_C_B_O : MIMG_Gather_WQM <0x0000005d, AMDGPUSample_c_b_o>;
531 defm IMAGE_GATHER4_C_B_CL_O : MIMG_Gather_WQM <0x0000005e, AMDGPUSample_c_b_cl_o>;
532 defm IMAGE_GATHER4_C_LZ_O : MIMG_Gather <0x0000005f, AMDGPUSample_c_lz_o>;
534 defm IMAGE_GET_LOD : MIMG_Sampler <0x00000060, AMDGPUSample, 1, 1, "image_get_lod">;
536 defm IMAGE_SAMPLE_CD : MIMG_Sampler <0x00000068, AMDGPUSample_cd>;
537 defm IMAGE_SAMPLE_CD_CL : MIMG_Sampler <0x00000069, AMDGPUSample_cd_cl>;
538 defm IMAGE_SAMPLE_C_CD : MIMG_Sampler <0x0000006a, AMDGPUSample_c_cd>;
539 defm IMAGE_SAMPLE_C_CD_CL : MIMG_Sampler <0x0000006b, AMDGPUSample_c_cd_cl>;
540 defm IMAGE_SAMPLE_CD_O : MIMG_Sampler <0x0000006c, AMDGPUSample_cd_o>;
541 defm IMAGE_SAMPLE_CD_CL_O : MIMG_Sampler <0x0000006d, AMDGPUSample_cd_cl_o>;
542 defm IMAGE_SAMPLE_C_CD_O : MIMG_Sampler <0x0000006e, AMDGPUSample_c_cd_o>;
543 defm IMAGE_SAMPLE_C_CD_CL_O : MIMG_Sampler <0x0000006f, AMDGPUSample_c_cd_cl_o>;
544 //def IMAGE_RSRC256 : MIMG_NoPattern_RSRC256 <"image_rsrc256", 0x0000007e>;
545 //def IMAGE_SAMPLER : MIMG_NoPattern_ <"image_sampler", 0x0000007f>;
547 /********** ========================================= **********/
548 /********** Table of dimension-aware image intrinsics **********/
549 /********** ========================================= **********/
551 class ImageDimIntrinsicInfo<AMDGPUImageDimIntrinsic I> {
553 MIMGBaseOpcode BaseOpcode = !cast<MIMGBaseOpcode>(!strconcat("IMAGE_", I.P.OpMod));
554 AMDGPUDimProps Dim = I.P.Dim;
557 def ImageDimIntrinsicTable : GenericTable {
558 let FilterClass = "ImageDimIntrinsicInfo";
559 let Fields = ["Intr", "BaseOpcode", "Dim"];
560 GenericEnum TypeOf_BaseOpcode = MIMGBaseOpcode;
561 GenericEnum TypeOf_Dim = MIMGDim;
563 let PrimaryKey = ["Intr"];
564 let PrimaryKeyName = "getImageDimIntrinsicInfo";
565 let PrimaryKeyEarlyOut = 1;
568 foreach intr = !listconcat(AMDGPUImageDimIntrinsics,
569 AMDGPUImageDimAtomicIntrinsics) in {
570 def : ImageDimIntrinsicInfo<intr>;
573 // L to LZ Optimization Mapping
574 def : MIMGLZMapping<IMAGE_SAMPLE_L, IMAGE_SAMPLE_LZ>;
575 def : MIMGLZMapping<IMAGE_SAMPLE_C_L, IMAGE_SAMPLE_C_LZ>;
576 def : MIMGLZMapping<IMAGE_SAMPLE_L_O, IMAGE_SAMPLE_LZ_O>;
577 def : MIMGLZMapping<IMAGE_SAMPLE_C_L_O, IMAGE_SAMPLE_C_LZ_O>;
578 def : MIMGLZMapping<IMAGE_GATHER4_L, IMAGE_GATHER4_LZ>;
579 def : MIMGLZMapping<IMAGE_GATHER4_C_L, IMAGE_GATHER4_C_LZ>;
580 def : MIMGLZMapping<IMAGE_GATHER4_L_O, IMAGE_GATHER4_LZ_O>;
581 def : MIMGLZMapping<IMAGE_GATHER4_C_L_O, IMAGE_GATHER4_C_LZ_O>;