1//===-- SIInstrInfo.td - SI Instruction Infos -------------*- tablegen -*--===// 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 9def isWave32 : Predicate<"Subtarget->getWavefrontSize() == 32">, 10 AssemblerPredicate <(all_of FeatureWavefrontSize32)>; 11def isWave64 : Predicate<"Subtarget->getWavefrontSize() == 64">, 12 AssemblerPredicate <(all_of FeatureWavefrontSize64)>; 13 14class GCNPredicateControl : PredicateControl { 15 Predicate SIAssemblerPredicate = isGFX6GFX7; 16 Predicate VIAssemblerPredicate = isGFX8GFX9; 17} 18 19// Except for the NONE field, this must be kept in sync with the 20// SIEncodingFamily enum in AMDGPUInstrInfo.cpp 21def SIEncodingFamily { 22 int NONE = -1; 23 int SI = 0; 24 int VI = 1; 25 int SDWA = 2; 26 int SDWA9 = 3; 27 int GFX80 = 4; 28 int GFX9 = 5; 29 int GFX10 = 6; 30 int SDWA10 = 7; 31 int GFX90A = 8; 32} 33 34//===----------------------------------------------------------------------===// 35// SI DAG Nodes 36//===----------------------------------------------------------------------===// 37 38def AMDGPUclamp : SDNode<"AMDGPUISD::CLAMP", SDTFPUnaryOp>; 39 40def SIsbuffer_load : SDNode<"AMDGPUISD::SBUFFER_LOAD", 41 SDTypeProfile<1, 3, [SDTCisVT<1, v4i32>, SDTCisVT<2, i32>, SDTCisVT<3, i32>]>, 42 [SDNPMayLoad, SDNPMemOperand] 43>; 44 45def SIds_ordered_count : SDNode<"AMDGPUISD::DS_ORDERED_COUNT", 46 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisVT<1, i32>, SDTCisVT<2, i16>]>, 47 [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain, SDNPInGlue] 48>; 49 50def SIatomic_inc : SDNode<"AMDGPUISD::ATOMIC_INC", SDTAtomic2, 51 [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain] 52>; 53 54def SIatomic_dec : SDNode<"AMDGPUISD::ATOMIC_DEC", SDTAtomic2, 55 [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain] 56>; 57 58def SDTAtomic2_f32 : SDTypeProfile<1, 2, [ 59 SDTCisSameAs<0,2>, SDTCisFP<0>, SDTCisPtrTy<1> 60]>; 61 62def SIatomic_fmin : SDNode<"AMDGPUISD::ATOMIC_LOAD_FMIN", SDTAtomic2_f32, 63 [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain] 64>; 65 66def SIatomic_fmax : SDNode<"AMDGPUISD::ATOMIC_LOAD_FMAX", SDTAtomic2_f32, 67 [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain] 68>; 69 70// load_d16_{lo|hi} ptr, tied_input 71def SIload_d16 : SDTypeProfile<1, 2, [ 72 SDTCisPtrTy<1>, 73 SDTCisSameAs<0, 2> 74]>; 75 76 77def SDTtbuffer_load : SDTypeProfile<1, 8, 78 [ // vdata 79 SDTCisVT<1, v4i32>, // rsrc 80 SDTCisVT<2, i32>, // vindex(VGPR) 81 SDTCisVT<3, i32>, // voffset(VGPR) 82 SDTCisVT<4, i32>, // soffset(SGPR) 83 SDTCisVT<5, i32>, // offset(imm) 84 SDTCisVT<6, i32>, // format(imm) 85 SDTCisVT<7, i32>, // cachepolicy, swizzled buffer(imm) 86 SDTCisVT<8, i1> // idxen(imm) 87 ]>; 88 89def SItbuffer_load : SDNode<"AMDGPUISD::TBUFFER_LOAD_FORMAT", SDTtbuffer_load, 90 [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]>; 91def SItbuffer_load_d16 : SDNode<"AMDGPUISD::TBUFFER_LOAD_FORMAT_D16", 92 SDTtbuffer_load, 93 [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]>; 94 95def SDTtbuffer_store : SDTypeProfile<0, 9, 96 [ // vdata 97 SDTCisVT<1, v4i32>, // rsrc 98 SDTCisVT<2, i32>, // vindex(VGPR) 99 SDTCisVT<3, i32>, // voffset(VGPR) 100 SDTCisVT<4, i32>, // soffset(SGPR) 101 SDTCisVT<5, i32>, // offset(imm) 102 SDTCisVT<6, i32>, // format(imm) 103 SDTCisVT<7, i32>, // cachepolicy, swizzled buffer(imm) 104 SDTCisVT<8, i1> // idxen(imm) 105 ]>; 106 107def SItbuffer_store : SDNode<"AMDGPUISD::TBUFFER_STORE_FORMAT", SDTtbuffer_store, 108 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>; 109def SItbuffer_store_d16 : SDNode<"AMDGPUISD::TBUFFER_STORE_FORMAT_D16", 110 SDTtbuffer_store, 111 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>; 112 113def SDTBufferLoad : SDTypeProfile<1, 7, 114 [ // vdata 115 SDTCisVT<1, v4i32>, // rsrc 116 SDTCisVT<2, i32>, // vindex(VGPR) 117 SDTCisVT<3, i32>, // voffset(VGPR) 118 SDTCisVT<4, i32>, // soffset(SGPR) 119 SDTCisVT<5, i32>, // offset(imm) 120 SDTCisVT<6, i32>, // cachepolicy, swizzled buffer(imm) 121 SDTCisVT<7, i1>]>; // idxen(imm) 122 123def SIbuffer_load : SDNode <"AMDGPUISD::BUFFER_LOAD", SDTBufferLoad, 124 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>; 125def SIbuffer_load_ubyte : SDNode <"AMDGPUISD::BUFFER_LOAD_UBYTE", SDTBufferLoad, 126 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>; 127def SIbuffer_load_ushort : SDNode <"AMDGPUISD::BUFFER_LOAD_USHORT", SDTBufferLoad, 128 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>; 129def SIbuffer_load_byte : SDNode <"AMDGPUISD::BUFFER_LOAD_BYTE", SDTBufferLoad, 130 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>; 131def SIbuffer_load_short: SDNode <"AMDGPUISD::BUFFER_LOAD_SHORT", SDTBufferLoad, 132 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>; 133def SIbuffer_load_format : SDNode <"AMDGPUISD::BUFFER_LOAD_FORMAT", SDTBufferLoad, 134 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>; 135def SIbuffer_load_format_d16 : SDNode <"AMDGPUISD::BUFFER_LOAD_FORMAT_D16", 136 SDTBufferLoad, 137 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>; 138 139def SDTBufferStore : SDTypeProfile<0, 8, 140 [ // vdata 141 SDTCisVT<1, v4i32>, // rsrc 142 SDTCisVT<2, i32>, // vindex(VGPR) 143 SDTCisVT<3, i32>, // voffset(VGPR) 144 SDTCisVT<4, i32>, // soffset(SGPR) 145 SDTCisVT<5, i32>, // offset(imm) 146 SDTCisVT<6, i32>, // cachepolicy, swizzled buffer(imm) 147 SDTCisVT<7, i1>]>; // idxen(imm) 148 149def SIbuffer_store : SDNode <"AMDGPUISD::BUFFER_STORE", SDTBufferStore, 150 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>; 151def SIbuffer_store_byte: SDNode <"AMDGPUISD::BUFFER_STORE_BYTE", 152 SDTBufferStore, 153 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>; 154def SIbuffer_store_short : SDNode <"AMDGPUISD::BUFFER_STORE_SHORT", 155 SDTBufferStore, 156 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>; 157def SIbuffer_store_format : SDNode <"AMDGPUISD::BUFFER_STORE_FORMAT", 158 SDTBufferStore, 159 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>; 160def SIbuffer_store_format_d16 : SDNode <"AMDGPUISD::BUFFER_STORE_FORMAT_D16", 161 SDTBufferStore, 162 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>; 163 164class SDBufferAtomic<string opcode> : SDNode <opcode, 165 SDTypeProfile<1, 8, 166 [SDTCisVT<2, v4i32>, // rsrc 167 SDTCisVT<3, i32>, // vindex(VGPR) 168 SDTCisVT<4, i32>, // voffset(VGPR) 169 SDTCisVT<5, i32>, // soffset(SGPR) 170 SDTCisVT<6, i32>, // offset(imm) 171 SDTCisVT<7, i32>, // cachepolicy(imm) 172 SDTCisVT<8, i1>]>, // idxen(imm) 173 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad, SDNPMayStore] 174>; 175 176def SIbuffer_atomic_swap : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SWAP">; 177def SIbuffer_atomic_add : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_ADD">; 178def SIbuffer_atomic_sub : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SUB">; 179def SIbuffer_atomic_smin : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SMIN">; 180def SIbuffer_atomic_umin : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_UMIN">; 181def SIbuffer_atomic_smax : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SMAX">; 182def SIbuffer_atomic_umax : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_UMAX">; 183def SIbuffer_atomic_and : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_AND">; 184def SIbuffer_atomic_or : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_OR">; 185def SIbuffer_atomic_xor : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_XOR">; 186def SIbuffer_atomic_inc : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_INC">; 187def SIbuffer_atomic_dec : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_DEC">; 188def SIbuffer_atomic_csub : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_CSUB">; 189def SIbuffer_atomic_fadd : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_FADD">; 190def SIbuffer_atomic_fmin : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_FMIN">; 191def SIbuffer_atomic_fmax : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_FMAX">; 192 193def SIbuffer_atomic_cmpswap : SDNode <"AMDGPUISD::BUFFER_ATOMIC_CMPSWAP", 194 SDTypeProfile<1, 9, 195 [SDTCisVT<0, i32>, // dst 196 SDTCisVT<1, i32>, // src 197 SDTCisVT<2, i32>, // cmp 198 SDTCisVT<3, v4i32>, // rsrc 199 SDTCisVT<4, i32>, // vindex(VGPR) 200 SDTCisVT<5, i32>, // voffset(VGPR) 201 SDTCisVT<6, i32>, // soffset(SGPR) 202 SDTCisVT<7, i32>, // offset(imm) 203 SDTCisVT<8, i32>, // cachepolicy(imm) 204 SDTCisVT<9, i1>]>, // idxen(imm) 205 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad, SDNPMayStore] 206>; 207 208class SDGlobalAtomicNoRtn<string opcode, ValueType ty> : SDNode <opcode, 209 SDTypeProfile<0, 2, 210 [SDTCisPtrTy<0>, // vaddr 211 SDTCisVT<1, ty>]>, // vdata 212 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad, SDNPMayStore] 213>; 214 215def SIpc_add_rel_offset : SDNode<"AMDGPUISD::PC_ADD_REL_OFFSET", 216 SDTypeProfile<1, 2, [SDTCisVT<0, iPTR>, SDTCisSameAs<0,1>, SDTCisSameAs<0,2>]> 217>; 218 219def SIlds : SDNode<"AMDGPUISD::LDS", 220 SDTypeProfile<1, 1, [SDTCisVT<0, iPTR>, SDTCisSameAs<0,1>]> 221>; 222 223def SIload_d16_lo : SDNode<"AMDGPUISD::LOAD_D16_LO", 224 SIload_d16, 225 [SDNPMayLoad, SDNPMemOperand, SDNPHasChain] 226>; 227 228def SIload_d16_lo_u8 : SDNode<"AMDGPUISD::LOAD_D16_LO_U8", 229 SIload_d16, 230 [SDNPMayLoad, SDNPMemOperand, SDNPHasChain] 231>; 232 233def SIload_d16_lo_i8 : SDNode<"AMDGPUISD::LOAD_D16_LO_I8", 234 SIload_d16, 235 [SDNPMayLoad, SDNPMemOperand, SDNPHasChain] 236>; 237 238def SIload_d16_hi : SDNode<"AMDGPUISD::LOAD_D16_HI", 239 SIload_d16, 240 [SDNPMayLoad, SDNPMemOperand, SDNPHasChain] 241>; 242 243def SIload_d16_hi_u8 : SDNode<"AMDGPUISD::LOAD_D16_HI_U8", 244 SIload_d16, 245 [SDNPMayLoad, SDNPMemOperand, SDNPHasChain] 246>; 247 248def SIload_d16_hi_i8 : SDNode<"AMDGPUISD::LOAD_D16_HI_I8", 249 SIload_d16, 250 [SDNPMayLoad, SDNPMemOperand, SDNPHasChain] 251>; 252 253def SIdenorm_mode : SDNode<"AMDGPUISD::DENORM_MODE", 254 SDTypeProfile<0 ,1, [SDTCisInt<0>]>, 255 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue] 256>; 257 258//===----------------------------------------------------------------------===// 259// ValueType helpers 260//===----------------------------------------------------------------------===// 261 262// Returns 1 if the source arguments have modifiers, 0 if they do not. 263// XXX - do f16 instructions? 264class isFloatType<ValueType SrcVT> { 265 bit ret = !or(!eq(SrcVT.Value, f16.Value), 266 !eq(SrcVT.Value, f32.Value), 267 !eq(SrcVT.Value, f64.Value), 268 !eq(SrcVT.Value, v2f16.Value), 269 !eq(SrcVT.Value, v4f16.Value), 270 !eq(SrcVT.Value, v2f32.Value), 271 !eq(SrcVT.Value, v2f64.Value), 272 !eq(SrcVT.Value, v4f64.Value)); 273} 274 275class isIntType<ValueType SrcVT> { 276 bit ret = !or(!eq(SrcVT.Value, i16.Value), 277 !eq(SrcVT.Value, i32.Value), 278 !eq(SrcVT.Value, i64.Value), 279 !eq(SrcVT.Value, v2i32.Value)); 280} 281 282class isPackedType<ValueType SrcVT> { 283 bit ret = !or(!eq(SrcVT.Value, v2i16.Value), 284 !eq(SrcVT.Value, v2f16.Value), 285 !eq(SrcVT.Value, v4f16.Value), 286 !eq(SrcVT.Value, v2f32.Value)); 287} 288 289 290//===----------------------------------------------------------------------===// 291// PatFrags for global memory operations 292//===----------------------------------------------------------------------===// 293 294foreach as = [ "global", "flat", "constant", "local", "private", "region" ] in { 295let AddressSpaces = !cast<AddressSpaceList>("LoadAddress_"#as).AddrSpaces in { 296 297 298defm atomic_inc_#as : binary_atomic_op<SIatomic_inc>; 299defm atomic_dec_#as : binary_atomic_op<SIatomic_dec>; 300defm atomic_load_fmin_#as : binary_atomic_op<SIatomic_fmin, 0>; 301defm atomic_load_fmax_#as : binary_atomic_op<SIatomic_fmax, 0>; 302 303 304} // End let AddressSpaces = ... 305} // End foreach AddrSpace 306 307 308//===----------------------------------------------------------------------===// 309// SDNodes PatFrags for loads/stores with a glue input. 310// This is for SDNodes and PatFrag for local loads and stores to 311// enable s_mov_b32 m0, -1 to be glued to the memory instructions. 312// 313// These mirror the regular load/store PatFrags and rely on special 314// processing during Select() to add the glued copy. 315// 316//===----------------------------------------------------------------------===// 317 318def AMDGPUld_glue : SDNode <"ISD::LOAD", SDTLoad, 319 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand, SDNPInGlue] 320>; 321 322def AMDGPUatomic_ld_glue : SDNode <"ISD::ATOMIC_LOAD", SDTAtomicLoad, 323 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand, SDNPInGlue] 324>; 325 326def unindexedload_glue : PatFrag <(ops node:$ptr), (AMDGPUld_glue node:$ptr)> { 327 let IsLoad = 1; 328 let IsUnindexed = 1; 329} 330 331def load_glue : PatFrag <(ops node:$ptr), (unindexedload_glue node:$ptr)> { 332 let IsLoad = 1; 333 let IsNonExtLoad = 1; 334} 335 336def atomic_load_32_glue : PatFrag<(ops node:$ptr), 337 (AMDGPUatomic_ld_glue node:$ptr)> { 338 let IsAtomic = 1; 339 let MemoryVT = i32; 340} 341 342def atomic_load_64_glue : PatFrag<(ops node:$ptr), 343 (AMDGPUatomic_ld_glue node:$ptr)> { 344 let IsAtomic = 1; 345 let MemoryVT = i64; 346} 347 348def extload_glue : PatFrag<(ops node:$ptr), (unindexedload_glue node:$ptr)> { 349 let IsLoad = 1; 350 let IsAnyExtLoad = 1; 351} 352 353def sextload_glue : PatFrag<(ops node:$ptr), (unindexedload_glue node:$ptr)> { 354 let IsLoad = 1; 355 let IsSignExtLoad = 1; 356} 357 358def zextload_glue : PatFrag<(ops node:$ptr), (unindexedload_glue node:$ptr)> { 359 let IsLoad = 1; 360 let IsZeroExtLoad = 1; 361} 362 363def extloadi8_glue : PatFrag<(ops node:$ptr), (extload_glue node:$ptr)> { 364 let IsLoad = 1; 365 let MemoryVT = i8; 366} 367 368def zextloadi8_glue : PatFrag<(ops node:$ptr), (zextload_glue node:$ptr)> { 369 let IsLoad = 1; 370 let MemoryVT = i8; 371} 372 373def extloadi16_glue : PatFrag<(ops node:$ptr), (extload_glue node:$ptr)> { 374 let IsLoad = 1; 375 let MemoryVT = i16; 376} 377 378def zextloadi16_glue : PatFrag<(ops node:$ptr), (zextload_glue node:$ptr)> { 379 let IsLoad = 1; 380 let MemoryVT = i16; 381} 382 383def sextloadi8_glue : PatFrag<(ops node:$ptr), (sextload_glue node:$ptr)> { 384 let IsLoad = 1; 385 let MemoryVT = i8; 386} 387 388def sextloadi16_glue : PatFrag<(ops node:$ptr), (sextload_glue node:$ptr)> { 389 let IsLoad = 1; 390 let MemoryVT = i16; 391} 392 393 394let IsLoad = 1, AddressSpaces = LoadAddress_local.AddrSpaces in { 395def load_local_m0 : PatFrag<(ops node:$ptr), (load_glue node:$ptr)> { 396 let IsNonExtLoad = 1; 397} 398 399let MemoryVT = i8 in { 400def extloadi8_local_m0 : PatFrag<(ops node:$ptr), (extloadi8_glue node:$ptr)>; 401def sextloadi8_local_m0 : PatFrag<(ops node:$ptr), (sextloadi8_glue node:$ptr)>; 402def zextloadi8_local_m0 : PatFrag<(ops node:$ptr), (zextloadi8_glue node:$ptr)>; 403} 404 405let MemoryVT = i16 in { 406def extloadi16_local_m0 : PatFrag<(ops node:$ptr), (extloadi16_glue node:$ptr)>; 407def sextloadi16_local_m0 : PatFrag<(ops node:$ptr), (sextloadi16_glue node:$ptr)>; 408def zextloadi16_local_m0 : PatFrag<(ops node:$ptr), (zextloadi16_glue node:$ptr)>; 409} 410 411def load_align8_local_m0 : PatFrag<(ops node:$ptr), 412 (load_local_m0 node:$ptr)>, Aligned<8> { 413 let IsLoad = 1; 414 let IsNonExtLoad = 1; 415} 416 417def load_align16_local_m0 : PatFrag<(ops node:$ptr), 418 (load_local_m0 node:$ptr)>, Aligned<16> { 419 let IsLoad = 1; 420 let IsNonExtLoad = 1; 421} 422 423} // End IsLoad = 1 424 425let IsAtomic = 1, AddressSpaces = LoadAddress_local.AddrSpaces in { 426def atomic_load_32_local_m0 : PatFrag<(ops node:$ptr), 427 (atomic_load_32_glue node:$ptr)> { 428 let MemoryVT = i32; 429} 430def atomic_load_64_local_m0 : PatFrag<(ops node:$ptr), 431 (atomic_load_64_glue node:$ptr)> { 432 let MemoryVT = i64; 433} 434 435} // End let AddressSpaces = LoadAddress_local.AddrSpaces 436 437 438def AMDGPUst_glue : SDNode <"ISD::STORE", SDTStore, 439 [SDNPHasChain, SDNPMayStore, SDNPMemOperand, SDNPInGlue] 440>; 441 442def AMDGPUatomic_st_glue : SDNode <"ISD::ATOMIC_STORE", SDTAtomicStore, 443 [SDNPHasChain, SDNPMayStore, SDNPMemOperand, SDNPInGlue] 444>; 445 446def unindexedstore_glue : PatFrag<(ops node:$val, node:$ptr), 447 (AMDGPUst_glue node:$val, node:$ptr)> { 448 let IsStore = 1; 449 let IsUnindexed = 1; 450} 451 452def store_glue : PatFrag<(ops node:$val, node:$ptr), 453 (unindexedstore_glue node:$val, node:$ptr)> { 454 let IsStore = 1; 455 let IsTruncStore = 0; 456} 457 458def truncstore_glue : PatFrag<(ops node:$val, node:$ptr), 459 (unindexedstore_glue node:$val, node:$ptr)> { 460 let IsStore = 1; 461 let IsTruncStore = 1; 462} 463 464def truncstorei8_glue : PatFrag<(ops node:$val, node:$ptr), 465 (truncstore_glue node:$val, node:$ptr)> { 466 let IsStore = 1; 467 let MemoryVT = i8; 468} 469 470def truncstorei16_glue : PatFrag<(ops node:$val, node:$ptr), 471 (truncstore_glue node:$val, node:$ptr)> { 472 let IsStore = 1; 473 let MemoryVT = i16; 474} 475 476let IsStore = 1, AddressSpaces = StoreAddress_local.AddrSpaces in { 477def store_local_m0 : PatFrag<(ops node:$val, node:$ptr), 478 (store_glue node:$val, node:$ptr)> { 479 let IsStore = 1; 480 let IsTruncStore = 0; 481} 482 483def truncstorei8_local_m0 : PatFrag<(ops node:$val, node:$ptr), 484 (unindexedstore_glue node:$val, node:$ptr)> { 485 let IsStore = 1; 486 let MemoryVT = i8; 487} 488 489def truncstorei16_local_m0 : PatFrag<(ops node:$val, node:$ptr), 490 (unindexedstore_glue node:$val, node:$ptr)> { 491 let IsStore = 1; 492 let MemoryVT = i16; 493} 494} 495 496def store_align8_local_m0 : PatFrag <(ops node:$value, node:$ptr), 497 (store_local_m0 node:$value, node:$ptr)>, 498 Aligned<8> { 499 let IsStore = 1; 500 let IsTruncStore = 0; 501} 502 503def store_align16_local_m0 : PatFrag <(ops node:$value, node:$ptr), 504 (store_local_m0 node:$value, node:$ptr)>, 505 Aligned<16> { 506 let IsStore = 1; 507 let IsTruncStore = 0; 508} 509 510let AddressSpaces = StoreAddress_local.AddrSpaces in { 511 512def atomic_store_local_32_m0 : PatFrag < 513 (ops node:$value, node:$ptr), 514 (AMDGPUatomic_st_glue node:$value, node:$ptr)> { 515 let IsAtomic = 1; 516 let MemoryVT = i32; 517} 518def atomic_store_local_64_m0 : PatFrag < 519 (ops node:$value, node:$ptr), 520 (AMDGPUatomic_st_glue node:$value, node:$ptr)> { 521 let IsAtomic = 1; 522 let MemoryVT = i64; 523} 524} // End let AddressSpaces = StoreAddress_local.AddrSpaces 525 526 527def si_setcc_uniform : PatFrag < 528 (ops node:$lhs, node:$rhs, node:$cond), 529 (setcc node:$lhs, node:$rhs, node:$cond), [{ 530 return !N->isDivergent(); 531}]>; 532 533//===----------------------------------------------------------------------===// 534// SDNodes PatFrags for a16 loads and stores with 3 components. 535// v3f16/v3i16 is widened to v4f16/v4i16, so we need to match on the memory 536// load/store size. 537//===----------------------------------------------------------------------===// 538 539class mubuf_intrinsic_load<SDPatternOperator name, ValueType vt> : PatFrag < 540 (ops node:$rsrc, node:$vindex, node:$voffset, node:$soffset, node:$offset, 541 node:$auxiliary, node:$idxen), 542 (name node:$rsrc, node:$vindex, node:$voffset, node:$soffset, node:$offset, 543 node:$auxiliary, node:$idxen)> { 544 let IsLoad = 1; 545 let MemoryVT = vt; 546} 547 548class mubuf_intrinsic_store<SDPatternOperator name, ValueType vt> : PatFrag < 549 (ops node:$vdata, node:$rsrc, node:$vindex, node:$voffset, node:$soffset, node:$offset, 550 node:$auxiliary, node:$idxen), 551 (name node:$vdata, node:$rsrc, node:$vindex, node:$voffset, node:$soffset, node:$offset, 552 node:$auxiliary, node:$idxen)> { 553 let IsStore = 1; 554 let MemoryVT = vt; 555} 556 557class mtbuf_intrinsic_load<SDPatternOperator name, ValueType vt> : PatFrag < 558 (ops node:$rsrc, node:$vindex, node:$voffset, node:$soffset, node:$offset, 559 node:$format, node:$auxiliary, node:$idxen), 560 (name node:$rsrc, node:$vindex, node:$voffset, node:$soffset, node:$offset, 561 node:$format, node:$auxiliary, node:$idxen)> { 562 let IsLoad = 1; 563 let MemoryVT = vt; 564} 565 566class mtbuf_intrinsic_store<SDPatternOperator name, ValueType vt> : PatFrag < 567 (ops node:$vdata, node:$rsrc, node:$vindex, node:$voffset, node:$soffset, node:$offset, 568 node:$format, node:$auxiliary, node:$idxen), 569 (name node:$vdata, node:$rsrc, node:$vindex, node:$voffset, node:$soffset, node:$offset, 570 node:$format, node:$auxiliary, node:$idxen)> { 571 let IsStore = 1; 572 let MemoryVT = vt; 573} 574 575//===----------------------------------------------------------------------===// 576// SDNodes PatFrags for d16 loads 577//===----------------------------------------------------------------------===// 578 579class LoadD16Frag <SDPatternOperator op> : PatFrag< 580 (ops node:$ptr, node:$tied_in), 581 (op node:$ptr, node:$tied_in)> { 582 let IsLoad = 1; 583} 584 585foreach as = [ "global", "flat", "constant", "local", "private", "region" ] in { 586let AddressSpaces = !cast<AddressSpaceList>("LoadAddress_"#as).AddrSpaces in { 587 588def load_d16_hi_#as : LoadD16Frag <SIload_d16_hi>; 589 590def az_extloadi8_d16_hi_#as : LoadD16Frag <SIload_d16_hi_u8> { 591 let MemoryVT = i8; 592} 593 594def sextloadi8_d16_hi_#as : LoadD16Frag <SIload_d16_hi_i8> { 595 let MemoryVT = i8; 596} 597 598def load_d16_lo_#as : LoadD16Frag <SIload_d16_lo>; 599 600def az_extloadi8_d16_lo_#as : LoadD16Frag <SIload_d16_lo_u8> { 601 let MemoryVT = i8; 602} 603 604def sextloadi8_d16_lo_#as : LoadD16Frag <SIload_d16_lo_i8> { 605 let MemoryVT = i8; 606} 607 608} // End let AddressSpaces = ... 609} // End foreach AddrSpace 610 611def lshr_rev : PatFrag < 612 (ops node:$src1, node:$src0), 613 (srl $src0, $src1) 614>; 615 616def ashr_rev : PatFrag < 617 (ops node:$src1, node:$src0), 618 (sra $src0, $src1) 619>; 620 621def lshl_rev : PatFrag < 622 (ops node:$src1, node:$src0), 623 (shl $src0, $src1) 624>; 625 626def add_ctpop : PatFrag < 627 (ops node:$src0, node:$src1), 628 (add (ctpop $src0), $src1) 629>; 630 631def xnor : PatFrag < 632 (ops node:$src0, node:$src1), 633 (not (xor $src0, $src1)) 634>; 635 636foreach I = 1-4 in { 637def shl#I#_add : PatFrag < 638 (ops node:$src0, node:$src1), 639 (add (shl_oneuse $src0, (i32 I)), $src1)> { 640 // FIXME: Poor substitute for disabling pattern in SelectionDAG 641 let PredicateCode = [{return false;}]; 642 let GISelPredicateCode = [{return true;}]; 643} 644} 645 646multiclass SIAtomicM0Glue2 <string op_name, bit is_amdgpu = 0, 647 SDTypeProfile tc = SDTAtomic2, 648 bit IsInt = 1> { 649 650 def _glue : SDNode < 651 !if(is_amdgpu, "AMDGPUISD", "ISD")#"::ATOMIC_"#op_name, tc, 652 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand, SDNPInGlue] 653 >; 654 655 let AddressSpaces = StoreAddress_local.AddrSpaces in { 656 defm _local_m0 : binary_atomic_op <!cast<SDNode>(NAME#"_glue"), IsInt>; 657 } 658 659 let AddressSpaces = StoreAddress_region.AddrSpaces in { 660 defm _region_m0 : binary_atomic_op <!cast<SDNode>(NAME#"_glue"), IsInt>; 661 } 662} 663 664defm atomic_load_add : SIAtomicM0Glue2 <"LOAD_ADD">; 665defm atomic_load_sub : SIAtomicM0Glue2 <"LOAD_SUB">; 666defm atomic_inc : SIAtomicM0Glue2 <"INC", 1>; 667defm atomic_dec : SIAtomicM0Glue2 <"DEC", 1>; 668defm atomic_load_and : SIAtomicM0Glue2 <"LOAD_AND">; 669defm atomic_load_min : SIAtomicM0Glue2 <"LOAD_MIN">; 670defm atomic_load_max : SIAtomicM0Glue2 <"LOAD_MAX">; 671defm atomic_load_or : SIAtomicM0Glue2 <"LOAD_OR">; 672defm atomic_load_xor : SIAtomicM0Glue2 <"LOAD_XOR">; 673defm atomic_load_umin : SIAtomicM0Glue2 <"LOAD_UMIN">; 674defm atomic_load_umax : SIAtomicM0Glue2 <"LOAD_UMAX">; 675defm atomic_swap : SIAtomicM0Glue2 <"SWAP">; 676defm atomic_load_fadd : SIAtomicM0Glue2 <"LOAD_FADD", 0, SDTAtomic2_f32, 0>; 677defm atomic_load_fmin : SIAtomicM0Glue2 <"LOAD_FMIN", 1, SDTAtomic2_f32, 0>; 678defm atomic_load_fmax : SIAtomicM0Glue2 <"LOAD_FMAX", 1, SDTAtomic2_f32, 0>; 679 680def as_i1timm : SDNodeXForm<timm, [{ 681 return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i1); 682}]>; 683 684def as_i8imm : SDNodeXForm<imm, [{ 685 return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i8); 686}]>; 687 688def as_i8timm : SDNodeXForm<timm, [{ 689 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i16); 690}]>; 691 692def as_i16imm : SDNodeXForm<imm, [{ 693 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i16); 694}]>; 695 696def as_i16timm : SDNodeXForm<timm, [{ 697 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i16); 698}]>; 699 700def as_i32imm: SDNodeXForm<imm, [{ 701 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i32); 702}]>; 703 704def as_i32timm: SDNodeXForm<timm, [{ 705 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i32); 706}]>; 707 708def as_i64imm: SDNodeXForm<imm, [{ 709 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i64); 710}]>; 711 712def cond_as_i32imm: SDNodeXForm<cond, [{ 713 return CurDAG->getTargetConstant(N->get(), SDLoc(N), MVT::i32); 714}]>; 715 716// Copied from the AArch64 backend: 717def bitcast_fpimm_to_i32 : SDNodeXForm<fpimm, [{ 718return CurDAG->getTargetConstant( 719 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32); 720}]>; 721 722def frameindex_to_targetframeindex : SDNodeXForm<frameindex, [{ 723 auto FI = cast<FrameIndexSDNode>(N); 724 return CurDAG->getTargetFrameIndex(FI->getIndex(), MVT::i32); 725}]>; 726 727// Copied from the AArch64 backend: 728def bitcast_fpimm_to_i64 : SDNodeXForm<fpimm, [{ 729return CurDAG->getTargetConstant( 730 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i64); 731}]>; 732 733class bitextract_imm<int bitnum> : SDNodeXForm<imm, [{ 734 uint64_t Imm = N->getZExtValue(); 735 unsigned Bit = (Imm >> }] # bitnum # [{ ) & 1; 736 return CurDAG->getTargetConstant(Bit, SDLoc(N), MVT::i1); 737}]>; 738 739def SIMM16bit : ImmLeaf <i32, 740 [{return isInt<16>(Imm);}] 741>; 742 743def UIMM16bit : ImmLeaf <i32, 744 [{return isUInt<16>(Imm);}] 745>; 746 747def i64imm_32bit : ImmLeaf<i64, [{ 748 return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm); 749}]>; 750 751def InlineImm16 : ImmLeaf<i16, [{ 752 return isInlineImmediate16(Imm); 753}]>; 754 755def InlineImm32 : ImmLeaf<i32, [{ 756 return isInlineImmediate32(Imm); 757}]>; 758 759def InlineImm64 : ImmLeaf<i64, [{ 760 return isInlineImmediate64(Imm); 761}]>; 762 763def InlineImmFP32 : FPImmLeaf<f32, [{ 764 return isInlineImmediate(Imm); 765}]>; 766 767def InlineImmFP64 : FPImmLeaf<f64, [{ 768 return isInlineImmediate(Imm); 769}]>; 770 771 772class VGPRImm <dag frag> : PatLeaf<frag, [{ 773 return isVGPRImm(N); 774}]>; 775 776def NegateImm : SDNodeXForm<imm, [{ 777 return CurDAG->getConstant(-N->getSExtValue(), SDLoc(N), MVT::i32); 778}]>; 779 780// TODO: When FP inline imm values work? 781def NegSubInlineConst32 : ImmLeaf<i32, [{ 782 return Imm < -16 && Imm >= -64; 783}], NegateImm>; 784 785def NegSubInlineIntConst16 : ImmLeaf<i16, [{ 786 return Imm < -16 && Imm >= -64; 787}], NegateImm>; 788 789def ShiftAmt32Imm : ImmLeaf <i32, [{ 790 return Imm < 32; 791}]>; 792 793def getNegV2I16Imm : SDNodeXForm<build_vector, [{ 794 return SDValue(packNegConstantV2I16(N, *CurDAG), 0); 795}]>; 796 797def NegSubInlineConstV216 : PatLeaf<(build_vector), [{ 798 assert(N->getNumOperands() == 2); 799 assert(N->getOperand(0).getValueType().getSizeInBits() == 16); 800 SDValue Src0 = N->getOperand(0); 801 SDValue Src1 = N->getOperand(1); 802 if (Src0 == Src1) 803 return isNegInlineImmediate(Src0.getNode()); 804 805 return (isNullConstantOrUndef(Src0) && isNegInlineImmediate(Src1.getNode())) || 806 (isNullConstantOrUndef(Src1) && isNegInlineImmediate(Src0.getNode())); 807}], getNegV2I16Imm>; 808 809 810def fp16_zeros_high_16bits : PatLeaf<(f16 VGPR_32:$src), [{ 811 return fp16SrcZerosHighBits(N->getOpcode()); 812}]>; 813 814 815//===----------------------------------------------------------------------===// 816// MUBUF/SMEM Patterns 817//===----------------------------------------------------------------------===// 818 819def extract_cpol : SDNodeXForm<timm, [{ 820 return CurDAG->getTargetConstant(N->getZExtValue() & AMDGPU::CPol::ALL, SDLoc(N), MVT::i8); 821}]>; 822 823def extract_swz : SDNodeXForm<timm, [{ 824 return CurDAG->getTargetConstant((N->getZExtValue() >> 3) & 1, SDLoc(N), MVT::i8); 825}]>; 826 827def set_glc : SDNodeXForm<timm, [{ 828 return CurDAG->getTargetConstant(N->getZExtValue() | AMDGPU::CPol::GLC, SDLoc(N), MVT::i8); 829}]>; 830 831//===----------------------------------------------------------------------===// 832// Custom Operands 833//===----------------------------------------------------------------------===// 834 835def SoppBrTarget : AsmOperandClass { 836 let Name = "SoppBrTarget"; 837 let ParserMethod = "parseSOppBrTarget"; 838} 839 840def sopp_brtarget : Operand<OtherVT> { 841 let EncoderMethod = "getSOPPBrEncoding"; 842 let DecoderMethod = "decodeSoppBrTarget"; 843 let OperandType = "OPERAND_PCREL"; 844 let ParserMatchClass = SoppBrTarget; 845} 846 847def si_ga : Operand<iPTR>; 848 849def InterpSlotMatchClass : AsmOperandClass { 850 let Name = "InterpSlot"; 851 let PredicateMethod = "isInterpSlot"; 852 let ParserMethod = "parseInterpSlot"; 853 let RenderMethod = "addImmOperands"; 854} 855 856def InterpSlot : Operand<i32> { 857 let PrintMethod = "printInterpSlot"; 858 let ParserMatchClass = InterpSlotMatchClass; 859 let OperandType = "OPERAND_IMMEDIATE"; 860} 861 862def AttrMatchClass : AsmOperandClass { 863 let Name = "Attr"; 864 let PredicateMethod = "isInterpAttr"; 865 let ParserMethod = "parseInterpAttr"; 866 let RenderMethod = "addImmOperands"; 867} 868 869// It appears to be necessary to create a separate operand for this to 870// be able to parse attr<num> with no space. 871def Attr : Operand<i32> { 872 let PrintMethod = "printInterpAttr"; 873 let ParserMatchClass = AttrMatchClass; 874 let OperandType = "OPERAND_IMMEDIATE"; 875} 876 877def AttrChanMatchClass : AsmOperandClass { 878 let Name = "AttrChan"; 879 let PredicateMethod = "isAttrChan"; 880 let RenderMethod = "addImmOperands"; 881} 882 883def AttrChan : Operand<i32> { 884 let PrintMethod = "printInterpAttrChan"; 885 let ParserMatchClass = AttrChanMatchClass; 886 let OperandType = "OPERAND_IMMEDIATE"; 887} 888 889def SendMsgMatchClass : AsmOperandClass { 890 let Name = "SendMsg"; 891 let PredicateMethod = "isSendMsg"; 892 let ParserMethod = "parseSendMsgOp"; 893 let RenderMethod = "addImmOperands"; 894} 895 896def SwizzleMatchClass : AsmOperandClass { 897 let Name = "Swizzle"; 898 let PredicateMethod = "isSwizzle"; 899 let ParserMethod = "parseSwizzleOp"; 900 let RenderMethod = "addImmOperands"; 901 let IsOptional = 1; 902} 903 904def EndpgmMatchClass : AsmOperandClass { 905 let Name = "EndpgmImm"; 906 let PredicateMethod = "isEndpgm"; 907 let ParserMethod = "parseEndpgmOp"; 908 let RenderMethod = "addImmOperands"; 909 let IsOptional = 1; 910} 911 912def ExpTgtMatchClass : AsmOperandClass { 913 let Name = "ExpTgt"; 914 let PredicateMethod = "isExpTgt"; 915 let ParserMethod = "parseExpTgt"; 916 let RenderMethod = "printExpTgt"; 917} 918 919def SWaitMatchClass : AsmOperandClass { 920 let Name = "SWaitCnt"; 921 let RenderMethod = "addImmOperands"; 922 let ParserMethod = "parseSWaitCntOps"; 923} 924 925def VReg32OrOffClass : AsmOperandClass { 926 let Name = "VReg32OrOff"; 927 let ParserMethod = "parseVReg32OrOff"; 928} 929 930let OperandType = "OPERAND_IMMEDIATE" in { 931def SendMsgImm : Operand<i32> { 932 let PrintMethod = "printSendMsg"; 933 let ParserMatchClass = SendMsgMatchClass; 934} 935 936def SwizzleImm : Operand<i16> { 937 let PrintMethod = "printSwizzle"; 938 let ParserMatchClass = SwizzleMatchClass; 939} 940 941def EndpgmImm : Operand<i16> { 942 let PrintMethod = "printEndpgm"; 943 let ParserMatchClass = EndpgmMatchClass; 944} 945 946def WAIT_FLAG : Operand <i32> { 947 let ParserMatchClass = SWaitMatchClass; 948 let PrintMethod = "printWaitFlag"; 949} 950} // End OperandType = "OPERAND_IMMEDIATE" 951 952include "SIInstrFormats.td" 953include "VIInstrFormats.td" 954 955def BoolReg : AsmOperandClass { 956 let Name = "BoolReg"; 957 let ParserMethod = "parseBoolReg"; 958 let RenderMethod = "addRegOperands"; 959} 960 961class BoolRC : RegisterOperand<SReg_1> { 962 let ParserMatchClass = BoolReg; 963 let DecoderMethod = "decodeBoolReg"; 964} 965 966def SSrc_i1 : RegisterOperand<SReg_1_XEXEC> { 967 let ParserMatchClass = BoolReg; 968 let DecoderMethod = "decodeBoolReg"; 969} 970 971def VOPDstS64orS32 : BoolRC { 972 let PrintMethod = "printVOPDst"; 973} 974 975// SCSrc_i1 is the operand for pseudo instructions only. 976// Boolean immediates shall not be exposed to codegen instructions. 977def SCSrc_i1 : RegisterOperand<SReg_1_XEXEC> { 978 let OperandNamespace = "AMDGPU"; 979 let OperandType = "OPERAND_REG_IMM_INT32"; 980 let ParserMatchClass = BoolReg; 981 let DecoderMethod = "decodeBoolReg"; 982} 983 984// ===----------------------------------------------------------------------===// 985// ExpSrc* Special cases for exp src operands which are printed as 986// "off" depending on en operand. 987// ===----------------------------------------------------------------------===// 988 989def ExpSrc0 : RegisterOperand<VGPR_32> { 990 let PrintMethod = "printExpSrc0"; 991 let ParserMatchClass = VReg32OrOffClass; 992} 993 994def ExpSrc1 : RegisterOperand<VGPR_32> { 995 let PrintMethod = "printExpSrc1"; 996 let ParserMatchClass = VReg32OrOffClass; 997} 998 999def ExpSrc2 : RegisterOperand<VGPR_32> { 1000 let PrintMethod = "printExpSrc2"; 1001 let ParserMatchClass = VReg32OrOffClass; 1002} 1003 1004def ExpSrc3 : RegisterOperand<VGPR_32> { 1005 let PrintMethod = "printExpSrc3"; 1006 let ParserMatchClass = VReg32OrOffClass; 1007} 1008 1009class SDWASrc<ValueType vt> : RegisterOperand<VS_32> { 1010 let OperandNamespace = "AMDGPU"; 1011 string Type = !if(isFloatType<vt>.ret, "FP", "INT"); 1012 let OperandType = "OPERAND_REG_INLINE_C_"#Type#vt.Size; 1013 let DecoderMethod = "decodeSDWASrc"#vt.Size; 1014 let EncoderMethod = "getSDWASrcEncoding"; 1015} 1016 1017def SDWASrc_i32 : SDWASrc<i32>; 1018def SDWASrc_i16 : SDWASrc<i16>; 1019def SDWASrc_f32 : SDWASrc<f32>; 1020def SDWASrc_f16 : SDWASrc<f16>; 1021 1022def SDWAVopcDst : BoolRC { 1023 let OperandNamespace = "AMDGPU"; 1024 let OperandType = "OPERAND_SDWA_VOPC_DST"; 1025 let EncoderMethod = "getSDWAVopcDstEncoding"; 1026 let DecoderMethod = "decodeSDWAVopcDst"; 1027 let PrintMethod = "printVOPDst"; 1028} 1029 1030class NamedMatchClass<string CName, bit Optional = 1> : AsmOperandClass { 1031 let Name = "Imm"#CName; 1032 let PredicateMethod = "is"#CName; 1033 let ParserMethod = !if(Optional, "parseOptionalOperand", "parse"#CName); 1034 let RenderMethod = "addImmOperands"; 1035 let IsOptional = Optional; 1036 let DefaultMethod = !if(Optional, "default"#CName, ?); 1037} 1038 1039class NamedOperandBit<string Name, AsmOperandClass MatchClass> : Operand<i1> { 1040 let PrintMethod = "print"#Name; 1041 let ParserMatchClass = MatchClass; 1042} 1043 1044class NamedOperandBit_0<string Name, AsmOperandClass MatchClass> : 1045 OperandWithDefaultOps<i1, (ops (i1 0))> { 1046 let PrintMethod = "print"#Name; 1047 let ParserMatchClass = MatchClass; 1048} 1049 1050class NamedOperandBit_1<string Name, AsmOperandClass MatchClass> : 1051 OperandWithDefaultOps<i1, (ops (i1 1))> { 1052 let PrintMethod = "print"#Name; 1053 let ParserMatchClass = MatchClass; 1054} 1055 1056class NamedOperandU8<string Name, AsmOperandClass MatchClass> : Operand<i8> { 1057 let PrintMethod = "print"#Name; 1058 let ParserMatchClass = MatchClass; 1059} 1060 1061class NamedOperandU16<string Name, AsmOperandClass MatchClass> : Operand<i16> { 1062 let PrintMethod = "print"#Name; 1063 let ParserMatchClass = MatchClass; 1064} 1065 1066class NamedOperandU32<string Name, AsmOperandClass MatchClass> : Operand<i32> { 1067 let PrintMethod = "print"#Name; 1068 let ParserMatchClass = MatchClass; 1069} 1070 1071class NamedOperandU32_0<string Name, AsmOperandClass MatchClass> : 1072 OperandWithDefaultOps<i32, (ops (i32 0))> { 1073 let PrintMethod = "print"#Name; 1074 let ParserMatchClass = MatchClass; 1075} 1076 1077class NamedOperandU32Default0<string Name, AsmOperandClass MatchClass> : 1078 OperandWithDefaultOps<i32, (ops (i32 0))> { 1079 let PrintMethod = "print"#Name; 1080 let ParserMatchClass = MatchClass; 1081} 1082 1083class NamedOperandU32Default1<string Name, AsmOperandClass MatchClass> : 1084 OperandWithDefaultOps<i32, (ops (i32 1))> { 1085 let PrintMethod = "print"#Name; 1086 let ParserMatchClass = MatchClass; 1087} 1088 1089let OperandType = "OPERAND_IMMEDIATE" in { 1090 1091def offen : NamedOperandBit<"Offen", NamedMatchClass<"Offen">>; 1092def idxen : NamedOperandBit<"Idxen", NamedMatchClass<"Idxen">>; 1093def addr64 : NamedOperandBit<"Addr64", NamedMatchClass<"Addr64">>; 1094 1095def flat_offset : NamedOperandU16<"FlatOffset", NamedMatchClass<"FlatOffset">>; 1096def offset : NamedOperandU16<"Offset", NamedMatchClass<"Offset">>; 1097def offset0 : NamedOperandU8<"Offset0", NamedMatchClass<"Offset0">>; 1098def offset1 : NamedOperandU8<"Offset1", NamedMatchClass<"Offset1">>; 1099 1100def gds : NamedOperandBit<"GDS", NamedMatchClass<"GDS">>; 1101 1102def omod : NamedOperandU32<"OModSI", NamedMatchClass<"OModSI">>; 1103def omod0 : NamedOperandU32_0<"OModSI", NamedMatchClass<"OModSI">>; 1104 1105// We need to make the cases with a default of 0 distinct from no 1106// default to help deal with some cases where the operand appears 1107// before a mandatory operand. 1108def clampmod : NamedOperandBit<"ClampSI", NamedMatchClass<"ClampSI">>; 1109def clampmod0 : NamedOperandBit_0<"ClampSI", NamedMatchClass<"ClampSI">>; 1110def highmod : NamedOperandBit<"High", NamedMatchClass<"High">>; 1111 1112def CPol : NamedOperandU32<"CPol", NamedMatchClass<"CPol">>; 1113def CPol_0 : NamedOperandU32Default0<"CPol", NamedMatchClass<"CPol">>; 1114def CPol_GLC1 : NamedOperandU32Default1<"CPol", NamedMatchClass<"CPol">>; 1115 1116def TFE : NamedOperandBit<"TFE", NamedMatchClass<"TFE">>; 1117def TFE_0 : NamedOperandBit_0<"TFE", NamedMatchClass<"TFE">>; 1118def SWZ : NamedOperandBit<"SWZ", NamedMatchClass<"SWZ">>; 1119def SWZ_0 : NamedOperandBit_0<"SWZ", NamedMatchClass<"SWZ">>; 1120def UNorm : NamedOperandBit<"UNorm", NamedMatchClass<"UNorm">>; 1121def DA : NamedOperandBit<"DA", NamedMatchClass<"DA">>; 1122def R128A16 : NamedOperandBit<"R128A16", NamedMatchClass<"R128A16">>; 1123def GFX10A16 : NamedOperandBit<"GFX10A16", NamedMatchClass<"GFX10A16">>; 1124def D16 : NamedOperandBit<"D16", NamedMatchClass<"D16">>; 1125def LWE : NamedOperandBit<"LWE", NamedMatchClass<"LWE">>; 1126def exp_compr : NamedOperandBit<"ExpCompr", NamedMatchClass<"ExpCompr">>; 1127def exp_vm : NamedOperandBit<"ExpVM", NamedMatchClass<"ExpVM">>; 1128 1129def FORMAT : NamedOperandU8<"FORMAT", NamedMatchClass<"FORMAT", 0>>; 1130 1131def DMask : NamedOperandU16<"DMask", NamedMatchClass<"DMask">>; 1132def Dim : NamedOperandU8<"Dim", NamedMatchClass<"Dim", 0>>; 1133 1134def dpp8 : NamedOperandU32<"DPP8", NamedMatchClass<"DPP8", 0>>; 1135 1136def dpp_ctrl : NamedOperandU32<"DPPCtrl", NamedMatchClass<"DPPCtrl", 0>>; 1137def row_mask : NamedOperandU32<"RowMask", NamedMatchClass<"RowMask">>; 1138def bank_mask : NamedOperandU32<"BankMask", NamedMatchClass<"BankMask">>; 1139def bound_ctrl : NamedOperandBit<"BoundCtrl", NamedMatchClass<"BoundCtrl">>; 1140def FI : NamedOperandU32<"FI", NamedMatchClass<"FI">>; 1141 1142def dst_sel : NamedOperandU32<"SDWADstSel", NamedMatchClass<"SDWADstSel">>; 1143def src0_sel : NamedOperandU32<"SDWASrc0Sel", NamedMatchClass<"SDWASrc0Sel">>; 1144def src1_sel : NamedOperandU32<"SDWASrc1Sel", NamedMatchClass<"SDWASrc1Sel">>; 1145def dst_unused : NamedOperandU32<"SDWADstUnused", NamedMatchClass<"SDWADstUnused">>; 1146 1147def op_sel0 : NamedOperandU32Default0<"OpSel", NamedMatchClass<"OpSel">>; 1148def op_sel_hi0 : NamedOperandU32Default0<"OpSelHi", NamedMatchClass<"OpSelHi">>; 1149def neg_lo0 : NamedOperandU32Default0<"NegLo", NamedMatchClass<"NegLo">>; 1150def neg_hi0 : NamedOperandU32Default0<"NegHi", NamedMatchClass<"NegHi">>; 1151 1152def blgp : NamedOperandU32<"BLGP", NamedMatchClass<"BLGP">>; 1153def cbsz : NamedOperandU32<"CBSZ", NamedMatchClass<"CBSZ">>; 1154def abid : NamedOperandU32<"ABID", NamedMatchClass<"ABID">>; 1155 1156def hwreg : NamedOperandU32<"Hwreg", NamedMatchClass<"Hwreg", 0>>; 1157 1158def exp_tgt : NamedOperandU32<"ExpTgt", NamedMatchClass<"ExpTgt", 0>> { 1159 1160} 1161 1162} // End OperandType = "OPERAND_IMMEDIATE" 1163 1164class KImmMatchClass<int size> : AsmOperandClass { 1165 let Name = "KImmFP"#size; 1166 let PredicateMethod = "isKImmFP"#size; 1167 let ParserMethod = "parseImm"; 1168 let RenderMethod = "addKImmFP"#size#"Operands"; 1169} 1170 1171class kimmOperand<ValueType vt> : Operand<vt> { 1172 let OperandNamespace = "AMDGPU"; 1173 let OperandType = "OPERAND_KIMM"#vt.Size; 1174 let PrintMethod = "printU"#vt.Size#"ImmOperand"; 1175 let ParserMatchClass = !cast<AsmOperandClass>("KImmFP"#vt.Size#"MatchClass"); 1176} 1177 1178// 32-bit VALU immediate operand that uses the constant bus. 1179def KImmFP32MatchClass : KImmMatchClass<32>; 1180def f32kimm : kimmOperand<i32>; 1181 1182// 32-bit VALU immediate operand with a 16-bit value that uses the 1183// constant bus. 1184def KImmFP16MatchClass : KImmMatchClass<16>; 1185def f16kimm : kimmOperand<i16>; 1186 1187class FPInputModsMatchClass <int opSize> : AsmOperandClass { 1188 let Name = "RegOrImmWithFP"#opSize#"InputMods"; 1189 let ParserMethod = "parseRegOrImmWithFPInputMods"; 1190 let PredicateMethod = "isRegOrImmWithFP"#opSize#"InputMods"; 1191} 1192 1193def FP16InputModsMatchClass : FPInputModsMatchClass<16>; 1194def FP32InputModsMatchClass : FPInputModsMatchClass<32>; 1195def FP64InputModsMatchClass : FPInputModsMatchClass<64>; 1196 1197class InputMods <AsmOperandClass matchClass> : Operand <i32> { 1198 let OperandNamespace = "AMDGPU"; 1199 let OperandType = "OPERAND_INPUT_MODS"; 1200 let ParserMatchClass = matchClass; 1201} 1202 1203class FPInputMods <FPInputModsMatchClass matchClass> : InputMods <matchClass> { 1204 let PrintMethod = "printOperandAndFPInputMods"; 1205} 1206 1207def FP16InputMods : FPInputMods<FP16InputModsMatchClass>; 1208def FP32InputMods : FPInputMods<FP32InputModsMatchClass>; 1209def FP64InputMods : FPInputMods<FP64InputModsMatchClass>; 1210 1211class IntInputModsMatchClass <int opSize> : AsmOperandClass { 1212 let Name = "RegOrImmWithInt"#opSize#"InputMods"; 1213 let ParserMethod = "parseRegOrImmWithIntInputMods"; 1214 let PredicateMethod = "isRegOrImmWithInt"#opSize#"InputMods"; 1215} 1216def Int32InputModsMatchClass : IntInputModsMatchClass<32>; 1217def Int64InputModsMatchClass : IntInputModsMatchClass<64>; 1218 1219class IntInputMods <IntInputModsMatchClass matchClass> : InputMods <matchClass> { 1220 let PrintMethod = "printOperandAndIntInputMods"; 1221} 1222def Int32InputMods : IntInputMods<Int32InputModsMatchClass>; 1223def Int64InputMods : IntInputMods<Int64InputModsMatchClass>; 1224 1225class OpSelModsMatchClass : AsmOperandClass { 1226 let Name = "OpSelMods"; 1227 let ParserMethod = "parseRegOrImm"; 1228 let PredicateMethod = "isRegOrImm"; 1229} 1230 1231def IntOpSelModsMatchClass : OpSelModsMatchClass; 1232def IntOpSelMods : InputMods<IntOpSelModsMatchClass>; 1233 1234class FPSDWAInputModsMatchClass <int opSize> : AsmOperandClass { 1235 let Name = "SDWAWithFP"#opSize#"InputMods"; 1236 let ParserMethod = "parseRegOrImmWithFPInputMods"; 1237 let PredicateMethod = "isSDWAFP"#opSize#"Operand"; 1238} 1239 1240def FP16SDWAInputModsMatchClass : FPSDWAInputModsMatchClass<16>; 1241def FP32SDWAInputModsMatchClass : FPSDWAInputModsMatchClass<32>; 1242 1243class FPSDWAInputMods <FPSDWAInputModsMatchClass matchClass> : 1244 InputMods <matchClass> { 1245 let PrintMethod = "printOperandAndFPInputMods"; 1246} 1247 1248def FP16SDWAInputMods : FPSDWAInputMods<FP16SDWAInputModsMatchClass>; 1249def FP32SDWAInputMods : FPSDWAInputMods<FP32SDWAInputModsMatchClass>; 1250 1251def FPVRegInputModsMatchClass : AsmOperandClass { 1252 let Name = "VRegWithFPInputMods"; 1253 let ParserMethod = "parseRegWithFPInputMods"; 1254 let PredicateMethod = "isVRegWithInputMods"; 1255} 1256 1257def FPVRegInputMods : InputMods <FPVRegInputModsMatchClass> { 1258 let PrintMethod = "printOperandAndFPInputMods"; 1259} 1260 1261class IntSDWAInputModsMatchClass <int opSize> : AsmOperandClass { 1262 let Name = "SDWAWithInt"#opSize#"InputMods"; 1263 let ParserMethod = "parseRegOrImmWithIntInputMods"; 1264 let PredicateMethod = "isSDWAInt"#opSize#"Operand"; 1265} 1266 1267def Int16SDWAInputModsMatchClass : IntSDWAInputModsMatchClass<16>; 1268def Int32SDWAInputModsMatchClass : IntSDWAInputModsMatchClass<32>; 1269 1270class IntSDWAInputMods <IntSDWAInputModsMatchClass matchClass> : 1271 InputMods <matchClass> { 1272 let PrintMethod = "printOperandAndIntInputMods"; 1273} 1274 1275def Int16SDWAInputMods : IntSDWAInputMods<Int16SDWAInputModsMatchClass>; 1276def Int32SDWAInputMods : IntSDWAInputMods<Int32SDWAInputModsMatchClass>; 1277 1278def IntVRegInputModsMatchClass : AsmOperandClass { 1279 let Name = "VRegWithIntInputMods"; 1280 let ParserMethod = "parseRegWithIntInputMods"; 1281 let PredicateMethod = "isVRegWithInputMods"; 1282} 1283 1284def IntVRegInputMods : InputMods <IntVRegInputModsMatchClass> { 1285 let PrintMethod = "printOperandAndIntInputMods"; 1286} 1287 1288class PackedFPInputModsMatchClass <int opSize> : AsmOperandClass { 1289 let Name = "PackedFP"#opSize#"InputMods"; 1290 let ParserMethod = "parseRegOrImm"; 1291 let PredicateMethod = "isRegOrImm"; 1292// let PredicateMethod = "isPackedFP"#opSize#"InputMods"; 1293} 1294 1295class PackedIntInputModsMatchClass <int opSize> : AsmOperandClass { 1296 let Name = "PackedInt"#opSize#"InputMods"; 1297 let ParserMethod = "parseRegOrImm"; 1298 let PredicateMethod = "isRegOrImm"; 1299// let PredicateMethod = "isPackedInt"#opSize#"InputMods"; 1300} 1301 1302def PackedF16InputModsMatchClass : PackedFPInputModsMatchClass<16>; 1303def PackedI16InputModsMatchClass : PackedIntInputModsMatchClass<16>; 1304 1305class PackedFPInputMods <PackedFPInputModsMatchClass matchClass> : InputMods <matchClass> { 1306// let PrintMethod = "printPackedFPInputMods"; 1307} 1308 1309class PackedIntInputMods <PackedIntInputModsMatchClass matchClass> : InputMods <matchClass> { 1310 //let PrintMethod = "printPackedIntInputMods"; 1311} 1312 1313def PackedF16InputMods : PackedFPInputMods<PackedF16InputModsMatchClass>; 1314def PackedI16InputMods : PackedIntInputMods<PackedI16InputModsMatchClass>; 1315 1316//===----------------------------------------------------------------------===// 1317// Complex patterns 1318//===----------------------------------------------------------------------===// 1319 1320def DS1Addr1Offset : ComplexPattern<i32, 2, "SelectDS1Addr1Offset">; 1321def DS64Bit4ByteAligned : ComplexPattern<i32, 3, "SelectDS64Bit4ByteAligned">; 1322def DS128Bit8ByteAligned : ComplexPattern<i64, 3, "SelectDS128Bit8ByteAligned">; 1323 1324def MOVRELOffset : ComplexPattern<i32, 2, "SelectMOVRELOffset">; 1325 1326def VOP3Mods0 : ComplexPattern<untyped, 4, "SelectVOP3Mods0">; 1327def VOP3Mods : ComplexPattern<untyped, 2, "SelectVOP3Mods">; 1328def VOP3NoMods : ComplexPattern<untyped, 1, "SelectVOP3NoMods">; 1329// VOP3Mods, but the input source is known to never be NaN. 1330def VOP3Mods_nnan : ComplexPattern<fAny, 2, "SelectVOP3Mods_NNaN">; 1331 1332def VOP3OMods : ComplexPattern<untyped, 3, "SelectVOP3OMods">; 1333 1334def VOP3PMods : ComplexPattern<untyped, 2, "SelectVOP3PMods">; 1335 1336def VOP3OpSel : ComplexPattern<untyped, 2, "SelectVOP3OpSel">; 1337 1338def VOP3OpSelMods : ComplexPattern<untyped, 2, "SelectVOP3OpSelMods">; 1339 1340def VOP3PMadMixMods : ComplexPattern<untyped, 2, "SelectVOP3PMadMixMods">; 1341 1342//===----------------------------------------------------------------------===// 1343// SI assembler operands 1344//===----------------------------------------------------------------------===// 1345 1346def SIOperand { 1347 int ZERO = 0x80; 1348 int VCC = 0x6A; 1349 int FLAT_SCR = 0x68; 1350} 1351 1352// This should be kept in sync with SISrcMods enum 1353def SRCMODS { 1354 int NONE = 0; 1355 int NEG = 1; 1356 int ABS = 2; 1357 int NEG_ABS = 3; 1358 1359 int NEG_HI = ABS; 1360 int OP_SEL_0 = 4; 1361 int OP_SEL_1 = 8; 1362 int DST_OP_SEL = 8; 1363} 1364 1365def DSTCLAMP { 1366 int NONE = 0; 1367 int ENABLE = 1; 1368} 1369 1370def DSTOMOD { 1371 int NONE = 0; 1372} 1373 1374def HWREG { 1375 int MODE = 1; 1376 int STATUS = 2; 1377 int TRAPSTS = 3; 1378 int HW_ID = 4; 1379 int GPR_ALLOC = 5; 1380 int LDS_ALLOC = 6; 1381 int IB_STS = 7; 1382 int MEM_BASES = 15; 1383 int TBA_LO = 16; 1384 int TBA_HI = 17; 1385 int TMA_LO = 18; 1386 int TMA_HI = 19; 1387 int FLAT_SCR_LO = 20; 1388 int FLAT_SCR_HI = 21; 1389 int XNACK_MASK = 22; 1390 int POPS_PACKER = 25; 1391 int SHADER_CYCLES = 29; 1392} 1393 1394class getHwRegImm<int Reg, int Offset = 0, int Size = 32> { 1395 int ret = !and(!or(Reg, 1396 !shl(Offset, 6), 1397 !shl(!add(Size, -1), 11)), 65535); 1398} 1399 1400//===----------------------------------------------------------------------===// 1401// 1402// SI Instruction multiclass helpers. 1403// 1404// Instructions with _32 take 32-bit operands. 1405// Instructions with _64 take 64-bit operands. 1406// 1407// VOP_* instructions can use either a 32-bit or 64-bit encoding. The 32-bit 1408// encoding is the standard encoding, but instruction that make use of 1409// any of the instruction modifiers must use the 64-bit encoding. 1410// 1411// Instructions with _e32 use the 32-bit encoding. 1412// Instructions with _e64 use the 64-bit encoding. 1413// 1414//===----------------------------------------------------------------------===// 1415 1416class SIMCInstr <string pseudo, int subtarget> { 1417 string PseudoInstr = pseudo; 1418 int Subtarget = subtarget; 1419} 1420 1421//===----------------------------------------------------------------------===// 1422// Vector ALU classes 1423//===----------------------------------------------------------------------===// 1424 1425class getNumSrcArgs<ValueType Src0, ValueType Src1, ValueType Src2> { 1426 int ret = 1427 !if (!eq(Src0.Value, untyped.Value), 0, 1428 !if (!eq(Src1.Value, untyped.Value), 1, // VOP1 1429 !if (!eq(Src2.Value, untyped.Value), 2, // VOP2 1430 3))); // VOP3 1431} 1432 1433// Returns the register class to use for the destination of VOP[123C] 1434// instructions for the given VT. 1435class getVALUDstForVT<ValueType VT> { 1436 RegisterOperand ret = !if(!eq(VT.Size, 32), VOPDstOperand<VGPR_32>, 1437 !if(!eq(VT.Size, 128), VOPDstOperand<VReg_128>, 1438 !if(!eq(VT.Size, 64), VOPDstOperand<VReg_64>, 1439 !if(!eq(VT.Size, 16), VOPDstOperand<VGPR_32>, 1440 VOPDstS64orS32)))); // else VT == i1 1441} 1442 1443// Returns the register class to use for the destination of VOP[12C] 1444// instructions with SDWA extension 1445class getSDWADstForVT<ValueType VT> { 1446 RegisterOperand ret = !if(!eq(VT.Size, 1), 1447 SDWAVopcDst, // VOPC 1448 VOPDstOperand<VGPR_32>); // VOP1/2 32-bit dst 1449} 1450 1451// Returns the register class to use for source 0 of VOP[12C] 1452// instructions for the given VT. 1453class getVOPSrc0ForVT<ValueType VT> { 1454 bit isFP = isFloatType<VT>.ret; 1455 1456 RegisterOperand ret = 1457 !if(isFP, 1458 !if(!eq(VT.Size, 64), 1459 VSrc_f64, 1460 !if(!eq(VT.Value, f16.Value), 1461 VSrc_f16, 1462 !if(!eq(VT.Value, v2f16.Value), 1463 VSrc_v2f16, 1464 !if(!eq(VT.Value, v4f16.Value), 1465 AVSrc_64, 1466 VSrc_f32 1467 ) 1468 ) 1469 ) 1470 ), 1471 !if(!eq(VT.Size, 64), 1472 VSrc_b64, 1473 !if(!eq(VT.Value, i16.Value), 1474 VSrc_b16, 1475 !if(!eq(VT.Value, v2i16.Value), 1476 VSrc_v2b16, 1477 VSrc_b32 1478 ) 1479 ) 1480 ) 1481 ); 1482} 1483 1484class getSOPSrcForVT<ValueType VT> { 1485 RegisterOperand ret = !if(!eq(VT.Size, 64), SSrc_b64, SSrc_b32); 1486} 1487 1488// Returns the vreg register class to use for source operand given VT 1489class getVregSrcForVT<ValueType VT> { 1490 RegisterClass ret = !if(!eq(VT.Size, 128), VReg_128, 1491 !if(!eq(VT.Size, 96), VReg_96, 1492 !if(!eq(VT.Size, 64), VReg_64, 1493 !if(!eq(VT.Size, 48), VReg_64, 1494 VGPR_32)))); 1495} 1496 1497class getSDWASrcForVT <ValueType VT> { 1498 bit isFP = isFloatType<VT>.ret; 1499 RegisterOperand retFlt = !if(!eq(VT.Size, 16), SDWASrc_f16, SDWASrc_f32); 1500 RegisterOperand retInt = !if(!eq(VT.Size, 16), SDWASrc_i16, SDWASrc_i32); 1501 RegisterOperand ret = !if(isFP, retFlt, retInt); 1502} 1503 1504// Returns the register class to use for sources of VOP3 instructions for the 1505// given VT. 1506class getVOP3SrcForVT<ValueType VT> { 1507 bit isFP = isFloatType<VT>.ret; 1508 RegisterOperand ret = 1509 !if(!eq(VT.Size, 128), 1510 VSrc_128, 1511 !if(!eq(VT.Size, 64), 1512 !if(isFP, 1513 !if(!eq(VT.Value, v2f32.Value), 1514 VSrc_v2f32, 1515 VSrc_f64), 1516 !if(!eq(VT.Value, v2i32.Value), 1517 VSrc_v2b32, 1518 VSrc_b64)), 1519 !if(!eq(VT.Value, i1.Value), 1520 SSrc_i1, 1521 !if(isFP, 1522 !if(!eq(VT.Value, f16.Value), 1523 VSrc_f16, 1524 !if(!eq(VT.Value, v2f16.Value), 1525 VSrc_v2f16, 1526 !if(!eq(VT.Value, v4f16.Value), 1527 AVSrc_64, 1528 VSrc_f32 1529 ) 1530 ) 1531 ), 1532 !if(!eq(VT.Value, i16.Value), 1533 VSrc_b16, 1534 !if(!eq(VT.Value, v2i16.Value), 1535 VSrc_v2b16, 1536 VSrc_b32 1537 ) 1538 ) 1539 ) 1540 ) 1541 ) 1542 ); 1543} 1544 1545// Float or packed int 1546class isModifierType<ValueType SrcVT> { 1547 bit ret = !or(!eq(SrcVT.Value, f16.Value), 1548 !eq(SrcVT.Value, f32.Value), 1549 !eq(SrcVT.Value, f64.Value), 1550 !eq(SrcVT.Value, v2f16.Value), 1551 !eq(SrcVT.Value, v2i16.Value), 1552 !eq(SrcVT.Value, v2f32.Value), 1553 !eq(SrcVT.Value, v2i32.Value)); 1554} 1555 1556// Return type of input modifiers operand for specified input operand 1557class getSrcMod <ValueType VT, bit EnableF32SrcMods> { 1558 bit isFP = isFloatType<VT>.ret; 1559 bit isPacked = isPackedType<VT>.ret; 1560 Operand ret = !if(!eq(VT.Size, 64), 1561 !if(isFP, FP64InputMods, Int64InputMods), 1562 !if(isFP, 1563 !if(!eq(VT.Value, f16.Value), 1564 FP16InputMods, 1565 FP32InputMods 1566 ), 1567 !if(EnableF32SrcMods, FP32InputMods, Int32InputMods)) 1568 ); 1569} 1570 1571class getOpSelMod <ValueType VT> { 1572 Operand ret = !if(!eq(VT.Value, f16.Value), FP16InputMods, IntOpSelMods); 1573} 1574 1575// Return type of input modifiers operand specified input operand for DPP 1576class getSrcModDPP <ValueType VT> { 1577 bit isFP = isFloatType<VT>.ret; 1578 Operand ret = !if(isFP, FPVRegInputMods, IntVRegInputMods); 1579} 1580 1581// Return type of input modifiers operand specified input operand for SDWA 1582class getSrcModSDWA <ValueType VT> { 1583 Operand ret = !if(!eq(VT.Value, f16.Value), FP16SDWAInputMods, 1584 !if(!eq(VT.Value, f32.Value), FP32SDWAInputMods, 1585 !if(!eq(VT.Value, i16.Value), Int16SDWAInputMods, 1586 Int32SDWAInputMods))); 1587} 1588 1589// Returns the input arguments for VOP[12C] instructions for the given SrcVT. 1590class getIns32 <RegisterOperand Src0RC, RegisterClass Src1RC, int NumSrcArgs> { 1591 dag ret = !if(!eq(NumSrcArgs, 1), (ins Src0RC:$src0), // VOP1 1592 !if(!eq(NumSrcArgs, 2), (ins Src0RC:$src0, Src1RC:$src1), // VOP2 1593 (ins))); 1594} 1595 1596// Returns the input arguments for VOP3 instructions for the given SrcVT. 1597class getIns64 <RegisterOperand Src0RC, RegisterOperand Src1RC, 1598 RegisterOperand Src2RC, int NumSrcArgs, 1599 bit HasClamp, bit HasModifiers, bit HasSrc2Mods, bit HasOMod, 1600 Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> { 1601 1602 dag ret = 1603 !if (!eq(NumSrcArgs, 0), 1604 // VOP1 without input operands (V_NOP, V_CLREXCP) 1605 (ins), 1606 /* else */ 1607 !if (!eq(NumSrcArgs, 1), 1608 !if (HasModifiers, 1609 // VOP1 with modifiers 1610 !if(HasOMod, 1611 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1612 clampmod0:$clamp, omod0:$omod), 1613 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1614 clampmod0:$clamp)) 1615 /* else */, 1616 // VOP1 without modifiers 1617 !if (HasClamp, 1618 (ins Src0RC:$src0, clampmod0:$clamp), 1619 (ins Src0RC:$src0)) 1620 /* endif */ ), 1621 !if (!eq(NumSrcArgs, 2), 1622 !if (HasModifiers, 1623 // VOP 2 with modifiers 1624 !if(HasOMod, 1625 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1626 Src1Mod:$src1_modifiers, Src1RC:$src1, 1627 clampmod0:$clamp, omod0:$omod), 1628 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1629 Src1Mod:$src1_modifiers, Src1RC:$src1, 1630 clampmod0:$clamp)) 1631 /* else */, 1632 // VOP2 without modifiers 1633 !if (HasClamp, 1634 (ins Src0RC:$src0, Src1RC:$src1, clampmod0:$clamp), 1635 (ins Src0RC:$src0, Src1RC:$src1)) 1636 1637 /* endif */ ) 1638 /* NumSrcArgs == 3 */, 1639 !if (HasModifiers, 1640 !if (HasSrc2Mods, 1641 // VOP3 with modifiers 1642 !if (HasOMod, 1643 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1644 Src1Mod:$src1_modifiers, Src1RC:$src1, 1645 Src2Mod:$src2_modifiers, Src2RC:$src2, 1646 clampmod0:$clamp, omod0:$omod), 1647 !if (HasClamp, 1648 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1649 Src1Mod:$src1_modifiers, Src1RC:$src1, 1650 Src2Mod:$src2_modifiers, Src2RC:$src2, 1651 clampmod0:$clamp), 1652 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1653 Src1Mod:$src1_modifiers, Src1RC:$src1, 1654 Src2Mod:$src2_modifiers, Src2RC:$src2))), 1655 // VOP3 with modifiers except src2 1656 !if (HasOMod, 1657 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1658 Src1Mod:$src1_modifiers, Src1RC:$src1, 1659 Src2RC:$src2, clampmod0:$clamp, omod0:$omod), 1660 !if (HasClamp, 1661 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1662 Src1Mod:$src1_modifiers, Src1RC:$src1, 1663 Src2RC:$src2, clampmod0:$clamp), 1664 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1665 Src1Mod:$src1_modifiers, Src1RC:$src1, 1666 Src2RC:$src2)))) 1667 /* else */, 1668 // VOP3 without modifiers 1669 !if (HasClamp, 1670 (ins Src0RC:$src0, Src1RC:$src1, Src2RC:$src2, clampmod0:$clamp), 1671 (ins Src0RC:$src0, Src1RC:$src1, Src2RC:$src2)) 1672 /* endif */ )))); 1673} 1674 1675class getInsVOP3Base<RegisterOperand Src0RC, RegisterOperand Src1RC, 1676 RegisterOperand Src2RC, int NumSrcArgs, 1677 bit HasClamp, bit HasModifiers, bit HasSrc2Mods, bit HasOMod, 1678 Operand Src0Mod, Operand Src1Mod, Operand Src2Mod, bit HasOpSel, 1679 bit IsVOP3P> { 1680 // getInst64 handles clamp and omod. implicit mutex between vop3p and omod 1681 dag base = getIns64 <Src0RC, Src1RC, Src2RC, NumSrcArgs, 1682 HasClamp, HasModifiers, HasSrc2Mods, HasOMod, 1683 Src0Mod, Src1Mod, Src2Mod>.ret; 1684 dag opsel = (ins op_sel0:$op_sel); 1685 dag vop3pFields = (ins op_sel_hi0:$op_sel_hi, neg_lo0:$neg_lo, neg_hi0:$neg_hi); 1686 dag ret = !con(base, 1687 !if(HasOpSel, opsel,(ins)), 1688 !if(IsVOP3P, vop3pFields,(ins))); 1689} 1690 1691class getInsVOP3P <RegisterOperand Src0RC, RegisterOperand Src1RC, 1692 RegisterOperand Src2RC, int NumSrcArgs, bit HasClamp, 1693 Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> { 1694 dag ret = getInsVOP3Base<Src0RC, Src1RC, Src2RC, NumSrcArgs, 1695 HasClamp, 1/*HasModifiers*/, 1/*HasSrc2Mods*/, 1696 0/*HasOMod*/, Src0Mod, Src1Mod, Src2Mod, 1697 1/*HasOpSel*/, 1/*IsVOP3P*/>.ret; 1698} 1699 1700class getInsVOP3OpSel <RegisterOperand Src0RC, RegisterOperand Src1RC, 1701 RegisterOperand Src2RC, int NumSrcArgs, 1702 bit HasClamp, bit HasOMod, 1703 Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> { 1704 dag ret = getInsVOP3Base<Src0RC, Src1RC, 1705 Src2RC, NumSrcArgs, 1706 HasClamp, 1/*HasModifiers*/, 1/*HasSrc2Mods*/, HasOMod, 1707 Src0Mod, Src1Mod, Src2Mod, 1/*HasOpSel*/, 0>.ret; 1708} 1709 1710class getInsDPPBase <RegisterOperand OldRC, RegisterClass Src0RC, RegisterClass Src1RC, 1711 int NumSrcArgs, bit HasModifiers, 1712 Operand Src0Mod, Operand Src1Mod> { 1713 1714 dag ret = !if (!eq(NumSrcArgs, 0), 1715 // VOP1 without input operands (V_NOP) 1716 (ins ), 1717 !if (!eq(NumSrcArgs, 1), 1718 !if (HasModifiers, 1719 // VOP1_DPP with modifiers 1720 (ins OldRC:$old, Src0Mod:$src0_modifiers, 1721 Src0RC:$src0) 1722 /* else */, 1723 // VOP1_DPP without modifiers 1724 (ins OldRC:$old, Src0RC:$src0) 1725 /* endif */), 1726 !if (HasModifiers, 1727 // VOP2_DPP with modifiers 1728 (ins OldRC:$old, 1729 Src0Mod:$src0_modifiers, Src0RC:$src0, 1730 Src1Mod:$src1_modifiers, Src1RC:$src1) 1731 /* else */, 1732 // VOP2_DPP without modifiers 1733 (ins OldRC:$old, 1734 Src0RC:$src0, Src1RC:$src1) 1735 ))); 1736} 1737 1738class getInsDPP <RegisterOperand OldRC, RegisterClass Src0RC, RegisterClass Src1RC, 1739 int NumSrcArgs, bit HasModifiers, 1740 Operand Src0Mod, Operand Src1Mod> { 1741 dag ret = !con(getInsDPPBase<OldRC, Src0RC, Src1RC, NumSrcArgs, 1742 HasModifiers, Src0Mod, Src1Mod>.ret, 1743 (ins dpp_ctrl:$dpp_ctrl, row_mask:$row_mask, 1744 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)); 1745} 1746 1747class getInsDPP16 <RegisterOperand OldRC, RegisterClass Src0RC, RegisterClass Src1RC, 1748 int NumSrcArgs, bit HasModifiers, 1749 Operand Src0Mod, Operand Src1Mod> { 1750 dag ret = !con(getInsDPP<OldRC, Src0RC, Src1RC, NumSrcArgs, 1751 HasModifiers, Src0Mod, Src1Mod>.ret, 1752 (ins FI:$fi)); 1753} 1754 1755class getInsDPP8 <RegisterOperand OldRC, RegisterClass Src0RC, RegisterClass Src1RC, 1756 int NumSrcArgs, bit HasModifiers, 1757 Operand Src0Mod, Operand Src1Mod> { 1758 dag ret = !con(getInsDPPBase<OldRC, Src0RC, Src1RC, NumSrcArgs, 1759 HasModifiers, Src0Mod, Src1Mod>.ret, 1760 (ins dpp8:$dpp8, FI:$fi)); 1761} 1762 1763 1764// Ins for SDWA 1765class getInsSDWA <RegisterOperand Src0RC, RegisterOperand Src1RC, int NumSrcArgs, 1766 bit HasSDWAOMod, Operand Src0Mod, Operand Src1Mod, 1767 ValueType DstVT> { 1768 1769 dag ret = !if(!eq(NumSrcArgs, 0), 1770 // VOP1 without input operands (V_NOP) 1771 (ins), 1772 !if(!eq(NumSrcArgs, 1), 1773 // VOP1 1774 !if(!not(HasSDWAOMod), 1775 // VOP1_SDWA without omod 1776 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1777 clampmod:$clamp, 1778 dst_sel:$dst_sel, dst_unused:$dst_unused, 1779 src0_sel:$src0_sel), 1780 // VOP1_SDWA with omod 1781 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1782 clampmod:$clamp, omod:$omod, 1783 dst_sel:$dst_sel, dst_unused:$dst_unused, 1784 src0_sel:$src0_sel)), 1785 !if(!eq(NumSrcArgs, 2), 1786 !if(!eq(DstVT.Size, 1), 1787 // VOPC_SDWA 1788 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1789 Src1Mod:$src1_modifiers, Src1RC:$src1, 1790 clampmod:$clamp, src0_sel:$src0_sel, src1_sel:$src1_sel), 1791 // VOP2_SDWA 1792 !if(!not(HasSDWAOMod), 1793 // VOP2_SDWA without omod 1794 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1795 Src1Mod:$src1_modifiers, Src1RC:$src1, 1796 clampmod:$clamp, 1797 dst_sel:$dst_sel, dst_unused:$dst_unused, 1798 src0_sel:$src0_sel, src1_sel:$src1_sel), 1799 // VOP2_SDWA with omod 1800 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1801 Src1Mod:$src1_modifiers, Src1RC:$src1, 1802 clampmod:$clamp, omod:$omod, 1803 dst_sel:$dst_sel, dst_unused:$dst_unused, 1804 src0_sel:$src0_sel, src1_sel:$src1_sel))), 1805 (ins)/* endif */))); 1806} 1807 1808// Outs for DPP 1809class getOutsDPP <bit HasDst, ValueType DstVT, RegisterOperand DstRCDPP> { 1810 dag ret = !if(HasDst, 1811 !if(!eq(DstVT.Size, 1), 1812 (outs), // no dst for VOPC, we use "vcc"-token as dst in SDWA VOPC instructions 1813 (outs DstRCDPP:$vdst)), 1814 (outs)); // V_NOP 1815} 1816 1817// Outs for SDWA 1818class getOutsSDWA <bit HasDst, ValueType DstVT, RegisterOperand DstRCSDWA> { 1819 dag ret = !if(HasDst, 1820 !if(!eq(DstVT.Size, 1), 1821 (outs DstRCSDWA:$sdst), 1822 (outs DstRCSDWA:$vdst)), 1823 (outs)); // V_NOP 1824} 1825 1826// Returns the assembly string for the inputs and outputs of a VOP[12C] 1827// instruction. This does not add the _e32 suffix, so it can be reused 1828// by getAsm64. 1829class getAsm32 <bit HasDst, int NumSrcArgs, ValueType DstVT = i32> { 1830 string dst = !if(!eq(DstVT.Size, 1), "$sdst", "$vdst"); // use $sdst for VOPC 1831 string src0 = ", $src0"; 1832 string src1 = ", $src1"; 1833 string src2 = ", $src2"; 1834 string ret = !if(HasDst, dst, "") # 1835 !if(!eq(NumSrcArgs, 1), src0, "") # 1836 !if(!eq(NumSrcArgs, 2), src0#src1, "") # 1837 !if(!eq(NumSrcArgs, 3), src0#src1#src2, ""); 1838} 1839 1840// Returns the assembly string for the inputs and outputs of a VOP3 1841// instruction. 1842class getAsm64 <bit HasDst, int NumSrcArgs, bit HasIntClamp, bit HasModifiers, 1843 bit HasOMod, ValueType DstVT = i32> { 1844 string dst = !if(!eq(DstVT.Size, 1), "$sdst", "$vdst"); // use $sdst for VOPC 1845 string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,"); 1846 string src1 = !if(!eq(NumSrcArgs, 1), "", 1847 !if(!eq(NumSrcArgs, 2), " $src1_modifiers", 1848 " $src1_modifiers,")); 1849 string src2 = !if(!eq(NumSrcArgs, 3), " $src2_modifiers", ""); 1850 string iclamp = !if(HasIntClamp, "$clamp", ""); 1851 string ret = 1852 !if(!not(HasModifiers), 1853 getAsm32<HasDst, NumSrcArgs, DstVT>.ret # iclamp, 1854 dst#", "#src0#src1#src2#"$clamp"#!if(HasOMod, "$omod", "")); 1855} 1856 1857// Returns the assembly string for the inputs and outputs of a VOP3P 1858// instruction. 1859class getAsmVOP3P <int NumSrcArgs, bit HasModifiers, 1860 bit HasClamp> { 1861 string dst = "$vdst"; 1862 string src0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,"); 1863 string src1 = !if(!eq(NumSrcArgs, 1), "", 1864 !if(!eq(NumSrcArgs, 2), " $src1", 1865 " $src1,")); 1866 string src2 = !if(!eq(NumSrcArgs, 3), " $src2", ""); 1867 1868 string mods = !if(HasModifiers, "$neg_lo$neg_hi", ""); 1869 string clamp = !if(HasClamp, "$clamp", ""); 1870 1871 // Each modifier is printed as an array of bits for each operand, so 1872 // all operands are printed as part of src0_modifiers. 1873 string ret = dst#", "#src0#src1#src2#"$op_sel$op_sel_hi"#mods#clamp; 1874} 1875 1876class getAsmVOP3OpSel <int NumSrcArgs, 1877 bit HasClamp, 1878 bit Src0HasMods, 1879 bit Src1HasMods, 1880 bit Src2HasMods> { 1881 string dst = "$vdst"; 1882 1883 string isrc0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,"); 1884 string isrc1 = !if(!eq(NumSrcArgs, 1), "", 1885 !if(!eq(NumSrcArgs, 2), " $src1", 1886 " $src1,")); 1887 string isrc2 = !if(!eq(NumSrcArgs, 3), " $src2", ""); 1888 1889 string fsrc0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,"); 1890 string fsrc1 = !if(!eq(NumSrcArgs, 1), "", 1891 !if(!eq(NumSrcArgs, 2), " $src1_modifiers", 1892 " $src1_modifiers,")); 1893 string fsrc2 = !if(!eq(NumSrcArgs, 3), " $src2_modifiers", ""); 1894 1895 string src0 = !if(Src0HasMods, fsrc0, isrc0); 1896 string src1 = !if(Src1HasMods, fsrc1, isrc1); 1897 string src2 = !if(Src2HasMods, fsrc2, isrc2); 1898 1899 string clamp = !if(HasClamp, "$clamp", ""); 1900 1901 string ret = dst#", "#src0#src1#src2#"$op_sel"#clamp; 1902} 1903 1904class getAsmDPP <bit HasDst, int NumSrcArgs, bit HasModifiers, ValueType DstVT = i32> { 1905 string dst = !if(HasDst, 1906 !if(!eq(DstVT.Size, 1), 1907 "$sdst", 1908 "$vdst"), 1909 ""); // use $sdst for VOPC 1910 string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,"); 1911 string src1 = !if(!eq(NumSrcArgs, 1), "", 1912 !if(!eq(NumSrcArgs, 2), " $src1_modifiers", 1913 " $src1_modifiers,")); 1914 string args = !if(!not(HasModifiers), 1915 getAsm32<0, NumSrcArgs, DstVT>.ret, 1916 ", "#src0#src1); 1917 string ret = dst#args#" $dpp_ctrl$row_mask$bank_mask$bound_ctrl"; 1918} 1919 1920class getAsmDPP16 <bit HasDst, int NumSrcArgs, bit HasModifiers, ValueType DstVT = i32> { 1921 string ret = getAsmDPP<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret#"$fi"; 1922} 1923 1924class getAsmDPP8 <bit HasDst, int NumSrcArgs, bit HasModifiers, ValueType DstVT = i32> 1925 : getAsmDPP<HasDst, NumSrcArgs, HasModifiers, DstVT> { 1926 let ret = dst#args#" $dpp8$fi"; 1927} 1928 1929 1930class getAsmSDWA <bit HasDst, int NumSrcArgs, ValueType DstVT = i32> { 1931 string dst = !if(HasDst, 1932 !if(!eq(DstVT.Size, 1), 1933 " vcc", // use vcc token as dst for VOPC instructioins 1934 "$vdst"), 1935 ""); 1936 string src0 = "$src0_modifiers"; 1937 string src1 = "$src1_modifiers"; 1938 string args = !if(!eq(NumSrcArgs, 0), 1939 "", 1940 !if(!eq(NumSrcArgs, 1), 1941 ", "#src0#"$clamp", 1942 ", "#src0#", "#src1#"$clamp" 1943 ) 1944 ); 1945 string sdwa = !if(!eq(NumSrcArgs, 0), 1946 "", 1947 !if(!eq(NumSrcArgs, 1), 1948 " $dst_sel $dst_unused $src0_sel", 1949 !if(!eq(DstVT.Size, 1), 1950 " $src0_sel $src1_sel", // No dst_sel and dst_unused for VOPC 1951 " $dst_sel $dst_unused $src0_sel $src1_sel" 1952 ) 1953 ) 1954 ); 1955 string ret = dst#args#sdwa; 1956} 1957 1958class getAsmSDWA9 <bit HasDst, bit HasOMod, int NumSrcArgs, 1959 ValueType DstVT = i32> { 1960 string dst = !if(HasDst, 1961 !if(!eq(DstVT.Size, 1), 1962 "$sdst", // VOPC 1963 "$vdst"), // VOP1/2 1964 ""); 1965 string src0 = "$src0_modifiers"; 1966 string src1 = "$src1_modifiers"; 1967 string out_mods = !if(!not(HasOMod), "$clamp", "$clamp$omod"); 1968 string args = !if(!eq(NumSrcArgs, 0), "", 1969 !if(!eq(NumSrcArgs, 1), 1970 ", "#src0, 1971 ", "#src0#", "#src1 1972 ) 1973 ); 1974 string sdwa = !if(!eq(NumSrcArgs, 0), "", 1975 !if(!eq(NumSrcArgs, 1), 1976 out_mods#" $dst_sel $dst_unused $src0_sel", 1977 !if(!eq(DstVT.Size, 1), 1978 " $src0_sel $src1_sel", // No dst_sel, dst_unused and output modifiers for VOPC 1979 out_mods#" $dst_sel $dst_unused $src0_sel $src1_sel" 1980 ) 1981 ) 1982 ); 1983 string ret = dst#args#sdwa; 1984} 1985 1986class getHas64BitOps <int NumSrcArgs, ValueType DstVT, ValueType Src0VT, 1987 ValueType Src1VT> { 1988 bit ret = !if(!eq(NumSrcArgs, 3), 1989 0, 1990 !if(!eq(DstVT.Size, 64), 1991 1, 1992 !if(!eq(Src0VT.Size, 64), 1993 1, 1994 !if(!eq(Src1VT.Size, 64), 1995 1, 1996 0 1997 ) 1998 ) 1999 ) 2000 ); 2001} 2002 2003class getHasSDWA <int NumSrcArgs, ValueType DstVT = i32, ValueType Src0VT = i32, 2004 ValueType Src1VT = i32> { 2005 bit ret = !if(!eq(NumSrcArgs, 3), 2006 0, // NumSrcArgs == 3 - No SDWA for VOP3 2007 !if(!eq(DstVT.Size, 64), 2008 0, // 64-bit dst - No SDWA for 64-bit operands 2009 !if(!eq(Src0VT.Size, 64), 2010 0, // 64-bit src0 2011 !if(!eq(Src1VT.Size, 64), 2012 0, // 64-bit src2 2013 1 2014 ) 2015 ) 2016 ) 2017 ); 2018} 2019 2020class getHasDPP <int NumSrcArgs> { 2021 bit ret = !if(!eq(NumSrcArgs, 3), 2022 0, // NumSrcArgs == 3 - No DPP for VOP3 2023 1); 2024} 2025 2026class getHasExt64BitDPP <int NumSrcArgs, ValueType DstVT = i32, ValueType Src0VT = i32, 2027 ValueType Src1VT = i32> { 2028 bit ret = !and(getHasDPP<NumSrcArgs>.ret, 2029 getHas64BitOps<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret); 2030} 2031 2032// Function that checks if instruction supports DPP and SDWA 2033class getHasExt <int NumSrcArgs, ValueType DstVT = i32, ValueType Src0VT = i32, 2034 ValueType Src1VT = i32> { 2035 bit ret = !or(getHasDPP<NumSrcArgs>.ret, 2036 getHasSDWA<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret); 2037} 2038 2039// Return an AGPR+VGPR operand class for the given VGPR register class. 2040class getLdStRegisterOperand<RegisterClass RC> { 2041 RegisterOperand ret = 2042 !if(!eq(RC.Size, 32), AVLdSt_32, 2043 !if(!eq(RC.Size, 64), AVLdSt_64, 2044 !if(!eq(RC.Size, 96), AVLdSt_96, 2045 !if(!eq(RC.Size, 128), AVLdSt_128, 2046 !if(!eq(RC.Size, 160), AVLdSt_160, 2047 RegisterOperand<VReg_1> // invalid register 2048 ))))); 2049} 2050 2051class BitOr<bit a, bit b> { 2052 bit ret = !if(a, 1, !if(b, 1, 0)); 2053} 2054 2055class BitAnd<bit a, bit b> { 2056 bit ret = !if(a, !if(b, 1, 0), 0); 2057} 2058 2059def PatGenMode { 2060 int NoPattern = 0; 2061 int Pattern = 1; 2062} 2063 2064class VOPProfile <list<ValueType> _ArgVT, bit _EnableF32SrcMods = 0, 2065 bit _EnableClamp = 0> { 2066 2067 field list<ValueType> ArgVT = _ArgVT; 2068 field bit EnableF32SrcMods = _EnableF32SrcMods; 2069 field bit EnableClamp = _EnableClamp; 2070 2071 field ValueType DstVT = ArgVT[0]; 2072 field ValueType Src0VT = ArgVT[1]; 2073 field ValueType Src1VT = ArgVT[2]; 2074 field ValueType Src2VT = ArgVT[3]; 2075 field RegisterOperand DstRC = getVALUDstForVT<DstVT>.ret; 2076 field RegisterOperand DstRCDPP = getVALUDstForVT<DstVT>.ret; 2077 field RegisterOperand DstRCSDWA = getSDWADstForVT<DstVT>.ret; 2078 field RegisterOperand Src0RC32 = getVOPSrc0ForVT<Src0VT>.ret; 2079 field RegisterClass Src1RC32 = getVregSrcForVT<Src1VT>.ret; 2080 field RegisterOperand Src0RC64 = getVOP3SrcForVT<Src0VT>.ret; 2081 field RegisterOperand Src1RC64 = getVOP3SrcForVT<Src1VT>.ret; 2082 field RegisterOperand Src2RC64 = getVOP3SrcForVT<Src2VT>.ret; 2083 field RegisterClass Src0DPP = getVregSrcForVT<Src0VT>.ret; 2084 field RegisterClass Src1DPP = getVregSrcForVT<Src1VT>.ret; 2085 field RegisterOperand Src0SDWA = getSDWASrcForVT<Src0VT>.ret; 2086 field RegisterOperand Src1SDWA = getSDWASrcForVT<Src0VT>.ret; 2087 field Operand Src0Mod = getSrcMod<Src0VT, EnableF32SrcMods>.ret; 2088 field Operand Src1Mod = getSrcMod<Src1VT, EnableF32SrcMods>.ret; 2089 field Operand Src2Mod = getSrcMod<Src2VT, EnableF32SrcMods>.ret; 2090 field Operand Src0ModDPP = getSrcModDPP<Src0VT>.ret; 2091 field Operand Src1ModDPP = getSrcModDPP<Src1VT>.ret; 2092 field Operand Src0ModSDWA = getSrcModSDWA<Src0VT>.ret; 2093 field Operand Src1ModSDWA = getSrcModSDWA<Src1VT>.ret; 2094 2095 2096 field bit HasDst = !ne(DstVT.Value, untyped.Value); 2097 field bit HasDst32 = HasDst; 2098 field bit EmitDst = HasDst; // force dst encoding, see v_movreld_b32 special case 2099 field bit EmitDstSel = EmitDst; 2100 field int NumSrcArgs = getNumSrcArgs<Src0VT, Src1VT, Src2VT>.ret; 2101 field bit HasSrc0 = !ne(Src0VT.Value, untyped.Value); 2102 field bit HasSrc1 = !ne(Src1VT.Value, untyped.Value); 2103 field bit HasSrc2 = !ne(Src2VT.Value, untyped.Value); 2104 2105 // HasSrc*FloatMods affects the SDWA encoding. We ignore EnableF32SrcMods. 2106 field bit HasSrc0FloatMods = isFloatType<Src0VT>.ret; 2107 field bit HasSrc1FloatMods = isFloatType<Src1VT>.ret; 2108 field bit HasSrc2FloatMods = isFloatType<Src2VT>.ret; 2109 2110 // HasSrc*IntMods affects the SDWA encoding. We ignore EnableF32SrcMods. 2111 field bit HasSrc0IntMods = isIntType<Src0VT>.ret; 2112 field bit HasSrc1IntMods = isIntType<Src1VT>.ret; 2113 field bit HasSrc2IntMods = isIntType<Src2VT>.ret; 2114 2115 field bit HasClamp = !or(isModifierType<Src0VT>.ret, EnableClamp); 2116 field bit HasSDWAClamp = EmitDst; 2117 field bit HasFPClamp = !and(isFloatType<DstVT>.ret, HasClamp); 2118 field bit HasIntClamp = !if(isFloatType<DstVT>.ret, 0, HasClamp); 2119 field bit HasClampLo = HasClamp; 2120 field bit HasClampHi = !and(isPackedType<DstVT>.ret, HasClamp); 2121 field bit HasHigh = 0; 2122 2123 field bit IsPacked = isPackedType<Src0VT>.ret; 2124 field bit HasOpSel = IsPacked; 2125 field bit HasOMod = !if(HasOpSel, 0, isFloatType<DstVT>.ret); 2126 field bit HasSDWAOMod = isFloatType<DstVT>.ret; 2127 2128 field bit HasModifiers = !or(isModifierType<Src0VT>.ret, 2129 isModifierType<Src1VT>.ret, 2130 isModifierType<Src2VT>.ret, 2131 HasOMod, 2132 EnableF32SrcMods); 2133 2134 field bit HasSrc0Mods = HasModifiers; 2135 field bit HasSrc1Mods = !if(HasModifiers, !or(HasSrc1FloatMods, HasSrc1IntMods), 0); 2136 field bit HasSrc2Mods = !if(HasModifiers, !or(HasSrc2FloatMods, HasSrc2IntMods), 0); 2137 2138 field bit HasExt = getHasExt<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret; 2139 field bit HasExtDPP = getHasDPP<NumSrcArgs>.ret; 2140 field bit HasExt64BitDPP = getHasExt64BitDPP<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret; 2141 field bit HasExtSDWA = getHasSDWA<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret; 2142 field bit HasExtSDWA9 = HasExtSDWA; 2143 field int NeedPatGen = PatGenMode.NoPattern; 2144 2145 field bit IsMAI = 0; 2146 field bit IsDOT = 0; 2147 field bit IsSingle = 0; 2148 2149 field Operand Src0PackedMod = !if(HasSrc0FloatMods, PackedF16InputMods, PackedI16InputMods); 2150 field Operand Src1PackedMod = !if(HasSrc1FloatMods, PackedF16InputMods, PackedI16InputMods); 2151 field Operand Src2PackedMod = !if(HasSrc2FloatMods, PackedF16InputMods, PackedI16InputMods); 2152 2153 field dag Outs = !if(HasDst,(outs DstRC:$vdst),(outs)); 2154 2155 // VOP3b instructions are a special case with a second explicit 2156 // output. This is manually overridden for them. 2157 field dag Outs32 = Outs; 2158 field dag Outs64 = Outs; 2159 field dag OutsDPP = getOutsDPP<HasDst, DstVT, DstRCDPP>.ret; 2160 field dag OutsDPP8 = getOutsDPP<HasDst, DstVT, DstRCDPP>.ret; 2161 field dag OutsSDWA = getOutsSDWA<HasDst, DstVT, DstRCSDWA>.ret; 2162 2163 field dag Ins32 = getIns32<Src0RC32, Src1RC32, NumSrcArgs>.ret; 2164 field dag Ins64 = getIns64<Src0RC64, Src1RC64, Src2RC64, NumSrcArgs, 2165 HasIntClamp, HasModifiers, HasSrc2Mods, 2166 HasOMod, Src0Mod, Src1Mod, Src2Mod>.ret; 2167 field dag InsVOP3P = getInsVOP3P<Src0RC64, Src1RC64, Src2RC64, 2168 NumSrcArgs, HasClamp, 2169 Src0PackedMod, Src1PackedMod, Src2PackedMod>.ret; 2170 field dag InsVOP3OpSel = getInsVOP3OpSel<Src0RC64, Src1RC64, Src2RC64, 2171 NumSrcArgs, HasClamp, HasOMod, 2172 getOpSelMod<Src0VT>.ret, 2173 getOpSelMod<Src1VT>.ret, 2174 getOpSelMod<Src2VT>.ret>.ret; 2175 field dag InsDPP = !if(HasExtDPP, 2176 getInsDPP<DstRCDPP, Src0DPP, Src1DPP, NumSrcArgs, 2177 HasModifiers, Src0ModDPP, Src1ModDPP>.ret, 2178 (ins)); 2179 field dag InsDPP16 = getInsDPP16<DstRCDPP, Src0DPP, Src1DPP, NumSrcArgs, 2180 HasModifiers, Src0ModDPP, Src1ModDPP>.ret; 2181 field dag InsDPP8 = getInsDPP8<DstRCDPP, Src0DPP, Src1DPP, NumSrcArgs, 0, 2182 Src0ModDPP, Src1ModDPP>.ret; 2183 field dag InsSDWA = getInsSDWA<Src0SDWA, Src1SDWA, NumSrcArgs, 2184 HasSDWAOMod, Src0ModSDWA, Src1ModSDWA, 2185 DstVT>.ret; 2186 2187 2188 field string Asm32 = getAsm32<HasDst, NumSrcArgs, DstVT>.ret; 2189 field string Asm64 = getAsm64<HasDst, NumSrcArgs, HasIntClamp, HasModifiers, HasOMod, DstVT>.ret; 2190 field string AsmVOP3P = getAsmVOP3P<NumSrcArgs, HasModifiers, HasClamp>.ret; 2191 field string AsmVOP3OpSel = getAsmVOP3OpSel<NumSrcArgs, 2192 HasClamp, 2193 HasSrc0FloatMods, 2194 HasSrc1FloatMods, 2195 HasSrc2FloatMods>.ret; 2196 field string AsmDPP = !if(HasExtDPP, 2197 getAsmDPP<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret, ""); 2198 field string AsmDPP16 = getAsmDPP16<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret; 2199 // DPP8 encoding has no fields for modifiers, and it is enforced by setting 2200 // the asm operand name via this HasModifiers flag 2201 field string AsmDPP8 = getAsmDPP8<HasDst, NumSrcArgs, 0 /*HasModifiers*/, DstVT>.ret; 2202 field string AsmSDWA = getAsmSDWA<HasDst, NumSrcArgs, DstVT>.ret; 2203 field string AsmSDWA9 = getAsmSDWA9<HasDst, HasSDWAOMod, NumSrcArgs, DstVT>.ret; 2204 2205 field string TieRegDPP = "$old"; 2206} 2207 2208class VOP_NO_EXT <VOPProfile p> : VOPProfile <p.ArgVT> { 2209 let HasExt = 0; 2210 let HasExtDPP = 0; 2211 let HasExt64BitDPP = 0; 2212 let HasExtSDWA = 0; 2213 let HasExtSDWA9 = 0; 2214} 2215 2216class VOP_PAT_GEN <VOPProfile p, int mode=PatGenMode.Pattern> : VOPProfile <p.ArgVT> { 2217 let NeedPatGen = mode; 2218} 2219 2220def VOP_F16_F16 : VOPProfile <[f16, f16, untyped, untyped]>; 2221def VOP_F16_I16 : VOPProfile <[f16, i16, untyped, untyped]>; 2222def VOP_I16_F16 : VOPProfile <[i16, f16, untyped, untyped]>; 2223 2224def VOP_F16_F16_F16 : VOPProfile <[f16, f16, f16, untyped]>; 2225def VOP_F16_F16_I16 : VOPProfile <[f16, f16, i16, untyped]>; 2226def VOP_F16_F16_I32 : VOPProfile <[f16, f16, i32, untyped]>; 2227def VOP_I16_I16_I16 : VOPProfile <[i16, i16, i16, untyped]>; 2228def VOP_I16_I16_I16_ARITH : VOPProfile <[i16, i16, i16, untyped], 0, /*EnableClamp=*/1>; 2229 2230def VOP_I16_I16_I16_I16 : VOPProfile <[i16, i16, i16, i16, untyped]>; 2231def VOP_F16_F16_F16_F16 : VOPProfile <[f16, f16, f16, f16, untyped]>; 2232 2233def VOP_I32_I16_I16_I32 : VOPProfile <[i32, i16, i16, i32, untyped]>; 2234 2235def VOP_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, untyped]>; 2236def VOP_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, untyped]>; 2237def VOP_B32_F16_F16 : VOPProfile <[i32, f16, f16, untyped]>; 2238 2239def VOP_V2F16_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, v2f16]>; 2240def VOP_V2I16_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, v2i16]>; 2241def VOP_V2I16_F32_F32 : VOPProfile <[v2i16, f32, f32, untyped]>; 2242def VOP_V2I16_I32_I32 : VOPProfile <[v2i16, i32, i32, untyped]>; 2243 2244def VOP_F32_V2F16_V2F16_V2F16 : VOPProfile <[f32, v2f16, v2f16, v2f16]>; 2245 2246def VOP_NONE : VOPProfile <[untyped, untyped, untyped, untyped]>; 2247 2248def VOP_F32_F32 : VOPProfile <[f32, f32, untyped, untyped]>; 2249def VOP_F32_F64 : VOPProfile <[f32, f64, untyped, untyped]>; 2250def VOP_F32_I32 : VOPProfile <[f32, i32, untyped, untyped]>; 2251def VOP_F64_F32 : VOPProfile <[f64, f32, untyped, untyped]>; 2252def VOP_F64_F64 : VOPProfile <[f64, f64, untyped, untyped]>; 2253def VOP_F64_I32 : VOPProfile <[f64, i32, untyped, untyped]>; 2254def VOP_I32_F32 : VOPProfile <[i32, f32, untyped, untyped]>; 2255def VOP_I32_F64 : VOPProfile <[i32, f64, untyped, untyped]>; 2256def VOP_I32_I32 : VOPProfile <[i32, i32, untyped, untyped]>; 2257def VOP_F16_F32 : VOPProfile <[f16, f32, untyped, untyped]>; 2258def VOP_F32_F16 : VOPProfile <[f32, f16, untyped, untyped]>; 2259def VOP_I64_I64 : VOPProfile <[i64, i64, untyped, untyped]>; 2260 2261def VOP_F32_F32_F16 : VOPProfile <[f32, f32, f16, untyped]>; 2262def VOP_F32_F32_F32 : VOPProfile <[f32, f32, f32, untyped]>; 2263def VOP_F32_F32_I32 : VOPProfile <[f32, f32, i32, untyped]>; 2264def VOP_F64_F64_F64 : VOPProfile <[f64, f64, f64, untyped]>; 2265def VOP_F64_F64_I32 : VOPProfile <[f64, f64, i32, untyped]>; 2266def VOP_I32_F32_F32 : VOPProfile <[i32, f32, f32, untyped]>; 2267def VOP_I32_F32_I32 : VOPProfile <[i32, f32, i32, untyped]>; 2268def VOP_I32_I32_I32 : VOPProfile <[i32, i32, i32, untyped]>; 2269def VOP_I32_I32_I32_ARITH : VOPProfile <[i32, i32, i32, untyped], 0, /*EnableClamp=*/1>; 2270def VOP_V2F16_F32_F32 : VOPProfile <[v2f16, f32, f32, untyped]>; 2271def VOP_F32_F16_F16_F16 : VOPProfile <[f32, f16, f16, f16]>; 2272 2273def VOP_I64_I64_I32 : VOPProfile <[i64, i64, i32, untyped]>; 2274def VOP_I64_I32_I64 : VOPProfile <[i64, i32, i64, untyped]>; 2275def VOP_I64_I64_I64 : VOPProfile <[i64, i64, i64, untyped]>; 2276 2277def VOP_F16_F32_F16_F32 : VOPProfile <[f16, f32, f16, f32]>; 2278def VOP_F32_F32_F16_F16 : VOPProfile <[f32, f32, f16, f16]>; 2279def VOP_F32_F32_F32_F32 : VOPProfile <[f32, f32, f32, f32]>; 2280def VOP_F64_F64_F64_F64 : VOPProfile <[f64, f64, f64, f64]>; 2281def VOP_I32_I32_I32_I32 : VOPProfile <[i32, i32, i32, i32]>; 2282def VOP_I64_I32_I32_I64 : VOPProfile <[i64, i32, i32, i64]>; 2283def VOP_I32_F32_I32_I32 : VOPProfile <[i32, f32, i32, i32]>; 2284def VOP_I64_I64_I32_I64 : VOPProfile <[i64, i64, i32, i64]>; 2285def VOP_V4I32_I64_I32_V4I32 : VOPProfile <[v4i32, i64, i32, v4i32]>; 2286 2287def VOP_F32_V2F16_V2F16_F32 : VOPProfile <[f32, v2f16, v2f16, f32]>; 2288def VOP_I32_V2I16_V2I16_I32 : VOPProfile <[i32, v2i16, v2i16, i32]>; 2289 2290def VOP_V4F32_F32_F32_V4F32 : VOPProfile <[v4f32, f32, f32, v4f32]>; 2291def VOP_V16F32_F32_F32_V16F32 : VOPProfile <[v16f32, f32, f32, v16f32]>; 2292def VOP_V32F32_F32_F32_V32F32 : VOPProfile <[v32f32, f32, f32, v32f32]>; 2293def VOP_V4F32_V4F16_V4F16_V4F32 : VOPProfile <[v4f32, v4f16, v4f16, v4f32]>; 2294def VOP_V16F32_V4F16_V4F16_V16F32 : VOPProfile <[v16f32, v4f16, v4f16, v16f32]>; 2295def VOP_V32F32_V4F16_V4F16_V32F32 : VOPProfile <[v32f32, v4f16, v4f16, v32f32]>; 2296def VOP_V4F32_V2I16_V2I16_V4F32 : VOPProfile <[v4f32, v2i16, v2i16, v4f32]>; 2297def VOP_V16F32_V2I16_V2I16_V16F32 : VOPProfile <[v16f32, v2i16, v2i16, v16f32]>; 2298def VOP_V32F32_V2I16_V2I16_V32F32 : VOPProfile <[v32f32, v2i16, v2i16, v32f32]>; 2299def VOP_V4I32_I32_I32_V4I32 : VOPProfile <[v4i32, i32, i32, v4i32]>; 2300def VOP_V16I32_I32_I32_V16I32 : VOPProfile <[v16i32, i32, i32, v16i32]>; 2301def VOP_V32I32_I32_I32_V32I32 : VOPProfile <[v32i32, i32, i32, v32i32]>; 2302 2303def VOP_V4F64_F64_F64_V4F64 : VOPProfile <[v4f64, f64, f64, v4f64]>; 2304def VOP_V1F64_F64_F64_V1F64 : VOPProfile <[v1f64, f64, f64, v1f64]>; 2305 2306def VOP_V2F32_V2F32_V2F32_V2F32 : VOPProfile <[v2f32, v2f32, v2f32, v2f32]>; 2307def VOP_V2F32_V2F32_V2F32 : VOPProfile <[v2f32, v2f32, v2f32, untyped]>; 2308def VOP_V2I32_V2I32_V2I32 : VOPProfile <[v2i32, v2i32, v2i32, untyped]>; 2309def VOP_V4F32_V4I16_V4I16_V4F32 : VOPProfile <[v4f32, v4i16, v4i16, v4f32]>; 2310def VOP_V16F32_V4I16_V4I16_V16F32 : VOPProfile <[v16f32, v4i16, v4i16, v16f32]>; 2311def VOP_V32F32_V4I16_V4I16_V32F32 : VOPProfile <[v32f32, v4i16, v4i16, v32f32]>; 2312 2313class Commutable_REV <string revOp, bit isOrig> { 2314 string RevOp = revOp; 2315 bit IsOrig = isOrig; 2316} 2317 2318class AtomicNoRet <string noRetOp, bit isRet> { 2319 string NoRetOp = noRetOp; 2320 bit IsRet = isRet; 2321} 2322 2323//===----------------------------------------------------------------------===// 2324// Interpolation opcodes 2325//===----------------------------------------------------------------------===// 2326 2327class VINTRPDstOperand <RegisterClass rc> : RegisterOperand <rc, "printVINTRPDst">; 2328 2329class VINTRP_Pseudo <string opName, dag outs, dag ins, list<dag> pattern> : 2330 VINTRPCommon <outs, ins, "", pattern>, 2331 SIMCInstr<opName, SIEncodingFamily.NONE> { 2332 let isPseudo = 1; 2333 let isCodeGenOnly = 1; 2334} 2335 2336// FIXME-GFX10: WIP. 2337class VINTRP_Real_si <bits <2> op, string opName, dag outs, dag ins, 2338 string asm, int encodingFamily> : 2339 VINTRPCommon <outs, ins, asm, []>, 2340 VINTRPe <op>, 2341 SIMCInstr<opName, encodingFamily> { 2342} 2343 2344class VINTRP_Real_vi <bits <2> op, string opName, dag outs, dag ins, 2345 string asm> : 2346 VINTRPCommon <outs, ins, asm, []>, 2347 VINTRPe_vi <op>, 2348 SIMCInstr<opName, SIEncodingFamily.VI> { 2349 let AssemblerPredicate = VIAssemblerPredicate; 2350 let DecoderNamespace = "GFX8"; 2351} 2352 2353// FIXME-GFX10: WIP. 2354multiclass VINTRP_m <bits <2> op, dag outs, dag ins, string asm, 2355 list<dag> pattern = []> { 2356 def "" : VINTRP_Pseudo <NAME, outs, ins, pattern>; 2357 2358 let AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in { 2359 def _si : VINTRP_Real_si <op, NAME, outs, ins, asm, SIEncodingFamily.SI>; 2360 } // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" 2361 2362 def _vi : VINTRP_Real_vi <op, NAME, outs, ins, asm>; 2363 2364 let AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in { 2365 def _gfx10 : VINTRP_Real_si<op, NAME, outs, ins, asm, SIEncodingFamily.GFX10>; 2366 } // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" 2367} 2368//===----------------------------------------------------------------------===// 2369// Vector instruction mappings 2370//===----------------------------------------------------------------------===// 2371 2372// Maps an opcode in e32 form to its e64 equivalent 2373def getVOPe64 : InstrMapping { 2374 let FilterClass = "VOP"; 2375 let RowFields = ["OpName"]; 2376 let ColFields = ["Size", "VOP3"]; 2377 let KeyCol = ["4", "0"]; 2378 let ValueCols = [["8", "1"]]; 2379} 2380 2381// Maps an opcode in e64 form to its e32 equivalent 2382def getVOPe32 : InstrMapping { 2383 let FilterClass = "VOP"; 2384 let RowFields = ["OpName"]; 2385 let ColFields = ["Size", "VOP3"]; 2386 let KeyCol = ["8", "1"]; 2387 let ValueCols = [["4", "0"]]; 2388} 2389 2390// Maps ordinary instructions to their SDWA counterparts 2391def getSDWAOp : InstrMapping { 2392 let FilterClass = "VOP"; 2393 let RowFields = ["OpName"]; 2394 let ColFields = ["AsmVariantName"]; 2395 let KeyCol = ["Default"]; 2396 let ValueCols = [["SDWA"]]; 2397} 2398 2399// Maps SDWA instructions to their ordinary counterparts 2400def getBasicFromSDWAOp : InstrMapping { 2401 let FilterClass = "VOP"; 2402 let RowFields = ["OpName"]; 2403 let ColFields = ["AsmVariantName"]; 2404 let KeyCol = ["SDWA"]; 2405 let ValueCols = [["Default"]]; 2406} 2407 2408// Maps ordinary instructions to their DPP counterparts 2409def getDPPOp32 : InstrMapping { 2410 let FilterClass = "VOP"; 2411 let RowFields = ["OpName"]; 2412 let ColFields = ["AsmVariantName"]; 2413 let KeyCol = ["Default"]; 2414 let ValueCols = [["DPP"]]; 2415} 2416 2417// Maps an commuted opcode to its original version 2418def getCommuteOrig : InstrMapping { 2419 let FilterClass = "Commutable_REV"; 2420 let RowFields = ["RevOp"]; 2421 let ColFields = ["IsOrig"]; 2422 let KeyCol = ["0"]; 2423 let ValueCols = [["1"]]; 2424} 2425 2426// Maps an original opcode to its commuted version 2427def getCommuteRev : InstrMapping { 2428 let FilterClass = "Commutable_REV"; 2429 let RowFields = ["RevOp"]; 2430 let ColFields = ["IsOrig"]; 2431 let KeyCol = ["1"]; 2432 let ValueCols = [["0"]]; 2433} 2434 2435def getMCOpcodeGen : InstrMapping { 2436 let FilterClass = "SIMCInstr"; 2437 let RowFields = ["PseudoInstr"]; 2438 let ColFields = ["Subtarget"]; 2439 let KeyCol = [!cast<string>(SIEncodingFamily.NONE)]; 2440 let ValueCols = [[!cast<string>(SIEncodingFamily.SI)], 2441 [!cast<string>(SIEncodingFamily.VI)], 2442 [!cast<string>(SIEncodingFamily.SDWA)], 2443 [!cast<string>(SIEncodingFamily.SDWA9)], 2444 // GFX80 encoding is added to work around a multiple matching 2445 // issue for buffer instructions with unpacked d16 data. This 2446 // does not actually change the encoding, and thus may be 2447 // removed later. 2448 [!cast<string>(SIEncodingFamily.GFX80)], 2449 [!cast<string>(SIEncodingFamily.GFX9)], 2450 [!cast<string>(SIEncodingFamily.GFX10)], 2451 [!cast<string>(SIEncodingFamily.SDWA10)], 2452 [!cast<string>(SIEncodingFamily.GFX90A)]]; 2453} 2454 2455// Get equivalent SOPK instruction. 2456def getSOPKOp : InstrMapping { 2457 let FilterClass = "SOPKInstTable"; 2458 let RowFields = ["BaseCmpOp"]; 2459 let ColFields = ["IsSOPK"]; 2460 let KeyCol = ["0"]; 2461 let ValueCols = [["1"]]; 2462} 2463 2464def getAddr64Inst : InstrMapping { 2465 let FilterClass = "MUBUFAddr64Table"; 2466 let RowFields = ["OpName"]; 2467 let ColFields = ["IsAddr64"]; 2468 let KeyCol = ["0"]; 2469 let ValueCols = [["1"]]; 2470} 2471 2472def getIfAddr64Inst : InstrMapping { 2473 let FilterClass = "MUBUFAddr64Table"; 2474 let RowFields = ["OpName"]; 2475 let ColFields = ["IsAddr64"]; 2476 let KeyCol = ["1"]; 2477 let ValueCols = [["1"]]; 2478} 2479 2480def getMUBUFNoLdsInst : InstrMapping { 2481 let FilterClass = "MUBUFLdsTable"; 2482 let RowFields = ["OpName"]; 2483 let ColFields = ["IsLds"]; 2484 let KeyCol = ["1"]; 2485 let ValueCols = [["0"]]; 2486} 2487 2488// Maps an atomic opcode to its returnless version. 2489def getAtomicNoRetOp : InstrMapping { 2490 let FilterClass = "AtomicNoRet"; 2491 let RowFields = ["NoRetOp"]; 2492 let ColFields = ["IsRet"]; 2493 let KeyCol = ["1"]; 2494 let ValueCols = [["0"]]; 2495} 2496 2497// Maps a GLOBAL to its SADDR form. 2498def getGlobalSaddrOp : InstrMapping { 2499 let FilterClass = "GlobalSaddrTable"; 2500 let RowFields = ["SaddrOp"]; 2501 let ColFields = ["IsSaddr"]; 2502 let KeyCol = ["0"]; 2503 let ValueCols = [["1"]]; 2504} 2505 2506// Maps a GLOBAL SADDR to its VADDR form. 2507def getGlobalVaddrOp : InstrMapping { 2508 let FilterClass = "GlobalSaddrTable"; 2509 let RowFields = ["SaddrOp"]; 2510 let ColFields = ["IsSaddr"]; 2511 let KeyCol = ["1"]; 2512 let ValueCols = [["0"]]; 2513} 2514 2515// Maps a v_cmpx opcode with sdst to opcode without sdst. 2516def getVCMPXNoSDstOp : InstrMapping { 2517 let FilterClass = "VCMPXNoSDstTable"; 2518 let RowFields = ["NoSDstOp"]; 2519 let ColFields = ["HasSDst"]; 2520 let KeyCol = ["1"]; 2521 let ValueCols = [["0"]]; 2522} 2523 2524// Maps a SOPP to a SOPP with S_NOP 2525def getSOPPWithRelaxation : InstrMapping { 2526 let FilterClass = "SOPPRelaxTable"; 2527 let RowFields = ["KeyName"]; 2528 let ColFields = ["IsRelaxed"]; 2529 let KeyCol = ["0"]; 2530 let ValueCols = [["1"]]; 2531} 2532 2533// Maps flat scratch opcodes by addressing modes 2534def getFlatScratchInstSTfromSS : InstrMapping { 2535 let FilterClass = "FlatScratchInst"; 2536 let RowFields = ["SVOp"]; 2537 let ColFields = ["Mode"]; 2538 let KeyCol = ["SS"]; 2539 let ValueCols = [["ST"]]; 2540} 2541 2542def getFlatScratchInstSSfromSV : InstrMapping { 2543 let FilterClass = "FlatScratchInst"; 2544 let RowFields = ["SVOp"]; 2545 let ColFields = ["Mode"]; 2546 let KeyCol = ["SV"]; 2547 let ValueCols = [["SS"]]; 2548} 2549 2550def getFlatScratchInstSVfromSS : InstrMapping { 2551 let FilterClass = "FlatScratchInst"; 2552 let RowFields = ["SVOp"]; 2553 let ColFields = ["Mode"]; 2554 let KeyCol = ["SS"]; 2555 let ValueCols = [["SV"]]; 2556} 2557 2558include "SIInstructions.td" 2559 2560include "DSInstructions.td" 2561include "MIMGInstructions.td" 2562