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