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