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