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// Execpt 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 639foreach I = 1-4 in { 640def shl#I#_add : PatFrag < 641 (ops node:$src0, node:$src1), 642 (add (shl_oneuse $src0, (i32 I)), $src1)> { 643 // FIXME: Poor substitute for disabling pattern in SelectionDAG 644 let PredicateCode = [{return false;}]; 645 let GISelPredicateCode = [{return true;}]; 646} 647} 648 649multiclass SIAtomicM0Glue2 <string op_name, bit is_amdgpu = 0, 650 SDTypeProfile tc = SDTAtomic2, 651 bit IsInt = 1> { 652 653 def _glue : SDNode < 654 !if(is_amdgpu, "AMDGPUISD", "ISD")#"::ATOMIC_"#op_name, tc, 655 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand, SDNPInGlue] 656 >; 657 658 let AddressSpaces = StoreAddress_local.AddrSpaces in { 659 defm _local_m0 : binary_atomic_op <!cast<SDNode>(NAME#"_glue"), IsInt>; 660 } 661 662 let AddressSpaces = StoreAddress_region.AddrSpaces in { 663 defm _region_m0 : binary_atomic_op <!cast<SDNode>(NAME#"_glue"), IsInt>; 664 } 665} 666 667defm atomic_load_add : SIAtomicM0Glue2 <"LOAD_ADD">; 668defm atomic_load_sub : SIAtomicM0Glue2 <"LOAD_SUB">; 669defm atomic_inc : SIAtomicM0Glue2 <"INC", 1>; 670defm atomic_dec : SIAtomicM0Glue2 <"DEC", 1>; 671defm atomic_load_and : SIAtomicM0Glue2 <"LOAD_AND">; 672defm atomic_load_min : SIAtomicM0Glue2 <"LOAD_MIN">; 673defm atomic_load_max : SIAtomicM0Glue2 <"LOAD_MAX">; 674defm atomic_load_or : SIAtomicM0Glue2 <"LOAD_OR">; 675defm atomic_load_xor : SIAtomicM0Glue2 <"LOAD_XOR">; 676defm atomic_load_umin : SIAtomicM0Glue2 <"LOAD_UMIN">; 677defm atomic_load_umax : SIAtomicM0Glue2 <"LOAD_UMAX">; 678defm atomic_swap : SIAtomicM0Glue2 <"SWAP">; 679defm atomic_load_fadd : SIAtomicM0Glue2 <"LOAD_FADD", 0, SDTAtomic2_f32, 0>; 680defm atomic_load_fmin : SIAtomicM0Glue2 <"LOAD_FMIN", 1, SDTAtomic2_f32, 0>; 681defm atomic_load_fmax : SIAtomicM0Glue2 <"LOAD_FMAX", 1, SDTAtomic2_f32, 0>; 682 683def as_i1timm : SDNodeXForm<timm, [{ 684 return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i1); 685}]>; 686 687def as_i8imm : SDNodeXForm<imm, [{ 688 return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i8); 689}]>; 690 691def as_i8timm : SDNodeXForm<timm, [{ 692 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i16); 693}]>; 694 695def as_i16imm : SDNodeXForm<imm, [{ 696 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i16); 697}]>; 698 699def as_i16timm : SDNodeXForm<timm, [{ 700 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i16); 701}]>; 702 703def as_i32imm: SDNodeXForm<imm, [{ 704 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i32); 705}]>; 706 707def as_i32timm: SDNodeXForm<timm, [{ 708 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i32); 709}]>; 710 711def as_i64imm: SDNodeXForm<imm, [{ 712 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i64); 713}]>; 714 715def cond_as_i32imm: SDNodeXForm<cond, [{ 716 return CurDAG->getTargetConstant(N->get(), SDLoc(N), MVT::i32); 717}]>; 718 719// Copied from the AArch64 backend: 720def bitcast_fpimm_to_i32 : SDNodeXForm<fpimm, [{ 721return CurDAG->getTargetConstant( 722 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32); 723}]>; 724 725def frameindex_to_targetframeindex : SDNodeXForm<frameindex, [{ 726 auto FI = cast<FrameIndexSDNode>(N); 727 return CurDAG->getTargetFrameIndex(FI->getIndex(), MVT::i32); 728}]>; 729 730// Copied from the AArch64 backend: 731def bitcast_fpimm_to_i64 : SDNodeXForm<fpimm, [{ 732return CurDAG->getTargetConstant( 733 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i64); 734}]>; 735 736class bitextract_imm<int bitnum> : SDNodeXForm<imm, [{ 737 uint64_t Imm = N->getZExtValue(); 738 unsigned Bit = (Imm >> }] # bitnum # [{ ) & 1; 739 return CurDAG->getTargetConstant(Bit, SDLoc(N), MVT::i1); 740}]>; 741 742def SIMM16bit : ImmLeaf <i32, 743 [{return isInt<16>(Imm);}] 744>; 745 746def UIMM16bit : ImmLeaf <i32, 747 [{return isUInt<16>(Imm);}] 748>; 749 750def i64imm_32bit : ImmLeaf<i64, [{ 751 return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm); 752}]>; 753 754def InlineImm16 : ImmLeaf<i16, [{ 755 return isInlineImmediate16(Imm); 756}]>; 757 758def InlineImm32 : ImmLeaf<i32, [{ 759 return isInlineImmediate32(Imm); 760}]>; 761 762def InlineImm64 : ImmLeaf<i64, [{ 763 return isInlineImmediate64(Imm); 764}]>; 765 766def InlineImmFP32 : FPImmLeaf<f32, [{ 767 return isInlineImmediate(Imm); 768}]>; 769 770def InlineImmFP64 : FPImmLeaf<f64, [{ 771 return isInlineImmediate(Imm); 772}]>; 773 774 775class VGPRImm <dag frag> : PatLeaf<frag, [{ 776 return isVGPRImm(N); 777}]>; 778 779def NegateImm : SDNodeXForm<imm, [{ 780 return CurDAG->getConstant(-N->getSExtValue(), SDLoc(N), MVT::i32); 781}]>; 782 783// TODO: When FP inline imm values work? 784def NegSubInlineConst32 : ImmLeaf<i32, [{ 785 return Imm < -16 && Imm >= -64; 786}], NegateImm>; 787 788def NegSubInlineIntConst16 : ImmLeaf<i16, [{ 789 return Imm < -16 && Imm >= -64; 790}], NegateImm>; 791 792def ShiftAmt32Imm : ImmLeaf <i32, [{ 793 return Imm < 32; 794}]>; 795 796def getNegV2I16Imm : SDNodeXForm<build_vector, [{ 797 return SDValue(packNegConstantV2I16(N, *CurDAG), 0); 798}]>; 799 800def NegSubInlineConstV216 : PatLeaf<(build_vector), [{ 801 assert(N->getNumOperands() == 2); 802 assert(N->getOperand(0).getValueType().getSizeInBits() == 16); 803 SDValue Src0 = N->getOperand(0); 804 SDValue Src1 = N->getOperand(1); 805 if (Src0 == Src1) 806 return isNegInlineImmediate(Src0.getNode()); 807 808 return (isNullConstantOrUndef(Src0) && isNegInlineImmediate(Src1.getNode())) || 809 (isNullConstantOrUndef(Src1) && isNegInlineImmediate(Src0.getNode())); 810}], getNegV2I16Imm>; 811 812//===----------------------------------------------------------------------===// 813// MUBUF/SMEM Patterns 814//===----------------------------------------------------------------------===// 815 816def extract_glc : SDNodeXForm<timm, [{ 817 return CurDAG->getTargetConstant(N->getZExtValue() & 1, SDLoc(N), MVT::i8); 818}]>; 819 820def extract_slc : SDNodeXForm<timm, [{ 821 return CurDAG->getTargetConstant((N->getZExtValue() >> 1) & 1, SDLoc(N), MVT::i8); 822}]>; 823 824def extract_dlc : SDNodeXForm<timm, [{ 825 return CurDAG->getTargetConstant((N->getZExtValue() >> 2) & 1, SDLoc(N), MVT::i8); 826}]>; 827 828def extract_swz : SDNodeXForm<timm, [{ 829 return CurDAG->getTargetConstant((N->getZExtValue() >> 3) & 1, SDLoc(N), MVT::i8); 830}]>; 831 832def extract_sccb : SDNodeXForm<timm, [{ 833 return CurDAG->getTargetConstant((N->getZExtValue() >> 4) & 1, SDLoc(N), MVT::i8); 834}]>; 835 836//===----------------------------------------------------------------------===// 837// Custom Operands 838//===----------------------------------------------------------------------===// 839 840def SoppBrTarget : AsmOperandClass { 841 let Name = "SoppBrTarget"; 842 let ParserMethod = "parseSOppBrTarget"; 843} 844 845def sopp_brtarget : Operand<OtherVT> { 846 let EncoderMethod = "getSOPPBrEncoding"; 847 let DecoderMethod = "decodeSoppBrTarget"; 848 let OperandType = "OPERAND_PCREL"; 849 let ParserMatchClass = SoppBrTarget; 850} 851 852def si_ga : Operand<iPTR>; 853 854def InterpSlotMatchClass : AsmOperandClass { 855 let Name = "InterpSlot"; 856 let PredicateMethod = "isInterpSlot"; 857 let ParserMethod = "parseInterpSlot"; 858 let RenderMethod = "addImmOperands"; 859} 860 861def InterpSlot : Operand<i32> { 862 let PrintMethod = "printInterpSlot"; 863 let ParserMatchClass = InterpSlotMatchClass; 864 let OperandType = "OPERAND_IMMEDIATE"; 865} 866 867def AttrMatchClass : AsmOperandClass { 868 let Name = "Attr"; 869 let PredicateMethod = "isInterpAttr"; 870 let ParserMethod = "parseInterpAttr"; 871 let RenderMethod = "addImmOperands"; 872} 873 874// It appears to be necessary to create a separate operand for this to 875// be able to parse attr<num> with no space. 876def Attr : Operand<i32> { 877 let PrintMethod = "printInterpAttr"; 878 let ParserMatchClass = AttrMatchClass; 879 let OperandType = "OPERAND_IMMEDIATE"; 880} 881 882def AttrChanMatchClass : AsmOperandClass { 883 let Name = "AttrChan"; 884 let PredicateMethod = "isAttrChan"; 885 let RenderMethod = "addImmOperands"; 886} 887 888def AttrChan : Operand<i32> { 889 let PrintMethod = "printInterpAttrChan"; 890 let ParserMatchClass = AttrChanMatchClass; 891 let OperandType = "OPERAND_IMMEDIATE"; 892} 893 894def SendMsgMatchClass : AsmOperandClass { 895 let Name = "SendMsg"; 896 let PredicateMethod = "isSendMsg"; 897 let ParserMethod = "parseSendMsgOp"; 898 let RenderMethod = "addImmOperands"; 899} 900 901def SwizzleMatchClass : AsmOperandClass { 902 let Name = "Swizzle"; 903 let PredicateMethod = "isSwizzle"; 904 let ParserMethod = "parseSwizzleOp"; 905 let RenderMethod = "addImmOperands"; 906 let IsOptional = 1; 907} 908 909def EndpgmMatchClass : AsmOperandClass { 910 let Name = "EndpgmImm"; 911 let PredicateMethod = "isEndpgm"; 912 let ParserMethod = "parseEndpgmOp"; 913 let RenderMethod = "addImmOperands"; 914 let IsOptional = 1; 915} 916 917def ExpTgtMatchClass : AsmOperandClass { 918 let Name = "ExpTgt"; 919 let PredicateMethod = "isExpTgt"; 920 let ParserMethod = "parseExpTgt"; 921 let RenderMethod = "printExpTgt"; 922} 923 924def SWaitMatchClass : AsmOperandClass { 925 let Name = "SWaitCnt"; 926 let RenderMethod = "addImmOperands"; 927 let ParserMethod = "parseSWaitCntOps"; 928} 929 930def VReg32OrOffClass : AsmOperandClass { 931 let Name = "VReg32OrOff"; 932 let ParserMethod = "parseVReg32OrOff"; 933} 934 935let OperandType = "OPERAND_IMMEDIATE" in { 936def SendMsgImm : Operand<i32> { 937 let PrintMethod = "printSendMsg"; 938 let ParserMatchClass = SendMsgMatchClass; 939} 940 941def SwizzleImm : Operand<i16> { 942 let PrintMethod = "printSwizzle"; 943 let ParserMatchClass = SwizzleMatchClass; 944} 945 946def EndpgmImm : Operand<i16> { 947 let PrintMethod = "printEndpgm"; 948 let ParserMatchClass = EndpgmMatchClass; 949} 950 951def WAIT_FLAG : Operand <i32> { 952 let ParserMatchClass = SWaitMatchClass; 953 let PrintMethod = "printWaitFlag"; 954} 955} // End OperandType = "OPERAND_IMMEDIATE" 956 957include "SIInstrFormats.td" 958include "VIInstrFormats.td" 959 960def BoolReg : AsmOperandClass { 961 let Name = "BoolReg"; 962 let ParserMethod = "parseBoolReg"; 963 let RenderMethod = "addRegOperands"; 964} 965 966class BoolRC : RegisterOperand<SReg_1> { 967 let ParserMatchClass = BoolReg; 968 let DecoderMethod = "decodeBoolReg"; 969} 970 971def SSrc_i1 : RegisterOperand<SReg_1_XEXEC> { 972 let ParserMatchClass = BoolReg; 973 let DecoderMethod = "decodeBoolReg"; 974} 975 976def VOPDstS64orS32 : BoolRC { 977 let PrintMethod = "printVOPDst"; 978} 979 980// SCSrc_i1 is the operand for pseudo instructions only. 981// Boolean immediates shall not be exposed to codegen instructions. 982def SCSrc_i1 : RegisterOperand<SReg_1_XEXEC> { 983 let OperandNamespace = "AMDGPU"; 984 let OperandType = "OPERAND_REG_IMM_INT32"; 985 let ParserMatchClass = BoolReg; 986 let DecoderMethod = "decodeBoolReg"; 987} 988 989// ===----------------------------------------------------------------------===// 990// ExpSrc* Special cases for exp src operands which are printed as 991// "off" depending on en operand. 992// ===----------------------------------------------------------------------===// 993 994def ExpSrc0 : RegisterOperand<VGPR_32> { 995 let PrintMethod = "printExpSrc0"; 996 let ParserMatchClass = VReg32OrOffClass; 997} 998 999def ExpSrc1 : RegisterOperand<VGPR_32> { 1000 let PrintMethod = "printExpSrc1"; 1001 let ParserMatchClass = VReg32OrOffClass; 1002} 1003 1004def ExpSrc2 : RegisterOperand<VGPR_32> { 1005 let PrintMethod = "printExpSrc2"; 1006 let ParserMatchClass = VReg32OrOffClass; 1007} 1008 1009def ExpSrc3 : RegisterOperand<VGPR_32> { 1010 let PrintMethod = "printExpSrc3"; 1011 let ParserMatchClass = VReg32OrOffClass; 1012} 1013 1014class SDWASrc<ValueType vt> : RegisterOperand<VS_32> { 1015 let OperandNamespace = "AMDGPU"; 1016 string Type = !if(isFloatType<vt>.ret, "FP", "INT"); 1017 let OperandType = "OPERAND_REG_INLINE_C_"#Type#vt.Size; 1018 let DecoderMethod = "decodeSDWASrc"#vt.Size; 1019 let EncoderMethod = "getSDWASrcEncoding"; 1020} 1021 1022def SDWASrc_i32 : SDWASrc<i32>; 1023def SDWASrc_i16 : SDWASrc<i16>; 1024def SDWASrc_f32 : SDWASrc<f32>; 1025def SDWASrc_f16 : SDWASrc<f16>; 1026 1027def SDWAVopcDst : BoolRC { 1028 let OperandNamespace = "AMDGPU"; 1029 let OperandType = "OPERAND_SDWA_VOPC_DST"; 1030 let EncoderMethod = "getSDWAVopcDstEncoding"; 1031 let DecoderMethod = "decodeSDWAVopcDst"; 1032 let PrintMethod = "printVOPDst"; 1033} 1034 1035class NamedMatchClass<string CName, bit Optional = 1> : AsmOperandClass { 1036 let Name = "Imm"#CName; 1037 let PredicateMethod = "is"#CName; 1038 let ParserMethod = !if(Optional, "parseOptionalOperand", "parse"#CName); 1039 let RenderMethod = "addImmOperands"; 1040 let IsOptional = Optional; 1041 let DefaultMethod = !if(Optional, "default"#CName, ?); 1042} 1043 1044class NamedOperandBit<string Name, AsmOperandClass MatchClass> : Operand<i1> { 1045 let PrintMethod = "print"#Name; 1046 let ParserMatchClass = MatchClass; 1047} 1048 1049class NamedOperandBit_0<string Name, AsmOperandClass MatchClass> : 1050 OperandWithDefaultOps<i1, (ops (i1 0))> { 1051 let PrintMethod = "print"#Name; 1052 let ParserMatchClass = MatchClass; 1053} 1054 1055class NamedOperandBit_1<string Name, AsmOperandClass MatchClass> : 1056 OperandWithDefaultOps<i1, (ops (i1 1))> { 1057 let PrintMethod = "print"#Name; 1058 let ParserMatchClass = MatchClass; 1059} 1060 1061class NamedOperandU8<string Name, AsmOperandClass MatchClass> : Operand<i8> { 1062 let PrintMethod = "print"#Name; 1063 let ParserMatchClass = MatchClass; 1064} 1065 1066class NamedOperandU16<string Name, AsmOperandClass MatchClass> : Operand<i16> { 1067 let PrintMethod = "print"#Name; 1068 let ParserMatchClass = MatchClass; 1069} 1070 1071class NamedOperandU32<string Name, AsmOperandClass MatchClass> : Operand<i32> { 1072 let PrintMethod = "print"#Name; 1073 let ParserMatchClass = MatchClass; 1074} 1075 1076class NamedOperandU32_0<string Name, AsmOperandClass MatchClass> : 1077 OperandWithDefaultOps<i32, (ops (i32 0))> { 1078 let PrintMethod = "print"#Name; 1079 let ParserMatchClass = MatchClass; 1080} 1081 1082class NamedOperandU32Default0<string Name, AsmOperandClass MatchClass> : 1083 OperandWithDefaultOps<i32, (ops (i32 0))> { 1084 let PrintMethod = "print"#Name; 1085 let ParserMatchClass = MatchClass; 1086} 1087 1088let OperandType = "OPERAND_IMMEDIATE" in { 1089 1090def offen : NamedOperandBit<"Offen", NamedMatchClass<"Offen">>; 1091def idxen : NamedOperandBit<"Idxen", NamedMatchClass<"Idxen">>; 1092def addr64 : NamedOperandBit<"Addr64", NamedMatchClass<"Addr64">>; 1093 1094def flat_offset : NamedOperandU16<"FlatOffset", NamedMatchClass<"FlatOffset">>; 1095def offset : NamedOperandU16<"Offset", NamedMatchClass<"Offset">>; 1096def offset0 : NamedOperandU8<"Offset0", NamedMatchClass<"Offset0">>; 1097def offset1 : NamedOperandU8<"Offset1", NamedMatchClass<"Offset1">>; 1098 1099def gds : NamedOperandBit<"GDS", NamedMatchClass<"GDS">>; 1100 1101def omod : NamedOperandU32<"OModSI", NamedMatchClass<"OModSI">>; 1102def omod0 : NamedOperandU32_0<"OModSI", NamedMatchClass<"OModSI">>; 1103 1104// We need to make the cases with a default of 0 distinct from no 1105// default to help deal with some cases where the operand appears 1106// before a mandatory operand. 1107def clampmod : NamedOperandBit<"ClampSI", NamedMatchClass<"ClampSI">>; 1108def clampmod0 : NamedOperandBit_0<"ClampSI", NamedMatchClass<"ClampSI">>; 1109def highmod : NamedOperandBit<"High", NamedMatchClass<"High">>; 1110 1111def SCCB : NamedOperandBit<"SCCB", NamedMatchClass<"SCCB">>; 1112def SCCB_0 : NamedOperandBit_0<"SCCB", NamedMatchClass<"SCCB">>; 1113 1114def DLC : NamedOperandBit<"DLC", NamedMatchClass<"DLC">>; 1115def DLC_0 : NamedOperandBit_0<"DLC", NamedMatchClass<"DLC">>; 1116 1117def GLC : NamedOperandBit<"GLC", NamedMatchClass<"GLC">>; 1118def GLC_0 : NamedOperandBit_0<"GLC", NamedMatchClass<"GLC">>; 1119def GLC_1 : NamedOperandBit_1<"GLC", NamedMatchClass<"GLC_1">>; 1120 1121def SLC : NamedOperandBit<"SLC", NamedMatchClass<"SLC">>; 1122def SLC_0 : NamedOperandBit_0<"SLC", NamedMatchClass<"SLC">>; 1123 1124def TFE : NamedOperandBit<"TFE", NamedMatchClass<"TFE">>; 1125def SWZ : NamedOperandBit<"SWZ", NamedMatchClass<"SWZ">>; 1126def UNorm : NamedOperandBit<"UNorm", NamedMatchClass<"UNorm">>; 1127def DA : NamedOperandBit<"DA", NamedMatchClass<"DA">>; 1128def R128A16 : NamedOperandBit<"R128A16", NamedMatchClass<"R128A16">>; 1129def GFX10A16 : NamedOperandBit<"GFX10A16", NamedMatchClass<"GFX10A16">>; 1130def D16 : NamedOperandBit<"D16", NamedMatchClass<"D16">>; 1131def LWE : NamedOperandBit<"LWE", NamedMatchClass<"LWE">>; 1132def exp_compr : NamedOperandBit<"ExpCompr", NamedMatchClass<"ExpCompr">>; 1133def exp_vm : NamedOperandBit<"ExpVM", NamedMatchClass<"ExpVM">>; 1134 1135def FORMAT : NamedOperandU8<"FORMAT", NamedMatchClass<"FORMAT", 0>>; 1136 1137def DMask : NamedOperandU16<"DMask", NamedMatchClass<"DMask">>; 1138def Dim : NamedOperandU8<"Dim", NamedMatchClass<"Dim", 0>>; 1139 1140def dpp8 : NamedOperandU32<"DPP8", NamedMatchClass<"DPP8", 0>>; 1141 1142def dpp_ctrl : NamedOperandU32<"DPPCtrl", NamedMatchClass<"DPPCtrl", 0>>; 1143def row_mask : NamedOperandU32<"RowMask", NamedMatchClass<"RowMask">>; 1144def bank_mask : NamedOperandU32<"BankMask", NamedMatchClass<"BankMask">>; 1145def bound_ctrl : NamedOperandBit<"BoundCtrl", NamedMatchClass<"BoundCtrl">>; 1146def FI : NamedOperandU32<"FI", NamedMatchClass<"FI">>; 1147 1148def dst_sel : NamedOperandU32<"SDWADstSel", NamedMatchClass<"SDWADstSel">>; 1149def src0_sel : NamedOperandU32<"SDWASrc0Sel", NamedMatchClass<"SDWASrc0Sel">>; 1150def src1_sel : NamedOperandU32<"SDWASrc1Sel", NamedMatchClass<"SDWASrc1Sel">>; 1151def dst_unused : NamedOperandU32<"SDWADstUnused", NamedMatchClass<"SDWADstUnused">>; 1152 1153def op_sel0 : NamedOperandU32Default0<"OpSel", NamedMatchClass<"OpSel">>; 1154def op_sel_hi0 : NamedOperandU32Default0<"OpSelHi", NamedMatchClass<"OpSelHi">>; 1155def neg_lo0 : NamedOperandU32Default0<"NegLo", NamedMatchClass<"NegLo">>; 1156def neg_hi0 : NamedOperandU32Default0<"NegHi", NamedMatchClass<"NegHi">>; 1157 1158def blgp : NamedOperandU32<"BLGP", NamedMatchClass<"BLGP">>; 1159def cbsz : NamedOperandU32<"CBSZ", NamedMatchClass<"CBSZ">>; 1160def abid : NamedOperandU32<"ABID", NamedMatchClass<"ABID">>; 1161 1162def hwreg : NamedOperandU32<"Hwreg", NamedMatchClass<"Hwreg", 0>>; 1163 1164def exp_tgt : NamedOperandU32<"ExpTgt", NamedMatchClass<"ExpTgt", 0>> { 1165 1166} 1167 1168} // End OperandType = "OPERAND_IMMEDIATE" 1169 1170class KImmMatchClass<int size> : AsmOperandClass { 1171 let Name = "KImmFP"#size; 1172 let PredicateMethod = "isKImmFP"#size; 1173 let ParserMethod = "parseImm"; 1174 let RenderMethod = "addKImmFP"#size#"Operands"; 1175} 1176 1177class kimmOperand<ValueType vt> : Operand<vt> { 1178 let OperandNamespace = "AMDGPU"; 1179 let OperandType = "OPERAND_KIMM"#vt.Size; 1180 let PrintMethod = "printU"#vt.Size#"ImmOperand"; 1181 let ParserMatchClass = !cast<AsmOperandClass>("KImmFP"#vt.Size#"MatchClass"); 1182} 1183 1184// 32-bit VALU immediate operand that uses the constant bus. 1185def KImmFP32MatchClass : KImmMatchClass<32>; 1186def f32kimm : kimmOperand<i32>; 1187 1188// 32-bit VALU immediate operand with a 16-bit value that uses the 1189// constant bus. 1190def KImmFP16MatchClass : KImmMatchClass<16>; 1191def f16kimm : kimmOperand<i16>; 1192 1193class FPInputModsMatchClass <int opSize> : AsmOperandClass { 1194 let Name = "RegOrImmWithFP"#opSize#"InputMods"; 1195 let ParserMethod = "parseRegOrImmWithFPInputMods"; 1196 let PredicateMethod = "isRegOrImmWithFP"#opSize#"InputMods"; 1197} 1198 1199def FP16InputModsMatchClass : FPInputModsMatchClass<16>; 1200def FP32InputModsMatchClass : FPInputModsMatchClass<32>; 1201def FP64InputModsMatchClass : FPInputModsMatchClass<64>; 1202 1203class InputMods <AsmOperandClass matchClass> : Operand <i32> { 1204 let OperandNamespace = "AMDGPU"; 1205 let OperandType = "OPERAND_INPUT_MODS"; 1206 let ParserMatchClass = matchClass; 1207} 1208 1209class FPInputMods <FPInputModsMatchClass matchClass> : InputMods <matchClass> { 1210 let PrintMethod = "printOperandAndFPInputMods"; 1211} 1212 1213def FP16InputMods : FPInputMods<FP16InputModsMatchClass>; 1214def FP32InputMods : FPInputMods<FP32InputModsMatchClass>; 1215def FP64InputMods : FPInputMods<FP64InputModsMatchClass>; 1216 1217class IntInputModsMatchClass <int opSize> : AsmOperandClass { 1218 let Name = "RegOrImmWithInt"#opSize#"InputMods"; 1219 let ParserMethod = "parseRegOrImmWithIntInputMods"; 1220 let PredicateMethod = "isRegOrImmWithInt"#opSize#"InputMods"; 1221} 1222def Int32InputModsMatchClass : IntInputModsMatchClass<32>; 1223def Int64InputModsMatchClass : IntInputModsMatchClass<64>; 1224 1225class IntInputMods <IntInputModsMatchClass matchClass> : InputMods <matchClass> { 1226 let PrintMethod = "printOperandAndIntInputMods"; 1227} 1228def Int32InputMods : IntInputMods<Int32InputModsMatchClass>; 1229def Int64InputMods : IntInputMods<Int64InputModsMatchClass>; 1230 1231class OpSelModsMatchClass : AsmOperandClass { 1232 let Name = "OpSelMods"; 1233 let ParserMethod = "parseRegOrImm"; 1234 let PredicateMethod = "isRegOrImm"; 1235} 1236 1237def IntOpSelModsMatchClass : OpSelModsMatchClass; 1238def IntOpSelMods : InputMods<IntOpSelModsMatchClass>; 1239 1240class FPSDWAInputModsMatchClass <int opSize> : AsmOperandClass { 1241 let Name = "SDWAWithFP"#opSize#"InputMods"; 1242 let ParserMethod = "parseRegOrImmWithFPInputMods"; 1243 let PredicateMethod = "isSDWAFP"#opSize#"Operand"; 1244} 1245 1246def FP16SDWAInputModsMatchClass : FPSDWAInputModsMatchClass<16>; 1247def FP32SDWAInputModsMatchClass : FPSDWAInputModsMatchClass<32>; 1248 1249class FPSDWAInputMods <FPSDWAInputModsMatchClass matchClass> : 1250 InputMods <matchClass> { 1251 let PrintMethod = "printOperandAndFPInputMods"; 1252} 1253 1254def FP16SDWAInputMods : FPSDWAInputMods<FP16SDWAInputModsMatchClass>; 1255def FP32SDWAInputMods : FPSDWAInputMods<FP32SDWAInputModsMatchClass>; 1256 1257def FPVRegInputModsMatchClass : AsmOperandClass { 1258 let Name = "VRegWithFPInputMods"; 1259 let ParserMethod = "parseRegWithFPInputMods"; 1260 let PredicateMethod = "isVRegWithInputMods"; 1261} 1262 1263def FPVRegInputMods : InputMods <FPVRegInputModsMatchClass> { 1264 let PrintMethod = "printOperandAndFPInputMods"; 1265} 1266 1267class IntSDWAInputModsMatchClass <int opSize> : AsmOperandClass { 1268 let Name = "SDWAWithInt"#opSize#"InputMods"; 1269 let ParserMethod = "parseRegOrImmWithIntInputMods"; 1270 let PredicateMethod = "isSDWAInt"#opSize#"Operand"; 1271} 1272 1273def Int16SDWAInputModsMatchClass : IntSDWAInputModsMatchClass<16>; 1274def Int32SDWAInputModsMatchClass : IntSDWAInputModsMatchClass<32>; 1275 1276class IntSDWAInputMods <IntSDWAInputModsMatchClass matchClass> : 1277 InputMods <matchClass> { 1278 let PrintMethod = "printOperandAndIntInputMods"; 1279} 1280 1281def Int16SDWAInputMods : IntSDWAInputMods<Int16SDWAInputModsMatchClass>; 1282def Int32SDWAInputMods : IntSDWAInputMods<Int32SDWAInputModsMatchClass>; 1283 1284def IntVRegInputModsMatchClass : AsmOperandClass { 1285 let Name = "VRegWithIntInputMods"; 1286 let ParserMethod = "parseRegWithIntInputMods"; 1287 let PredicateMethod = "isVRegWithInputMods"; 1288} 1289 1290def IntVRegInputMods : InputMods <IntVRegInputModsMatchClass> { 1291 let PrintMethod = "printOperandAndIntInputMods"; 1292} 1293 1294class PackedFPInputModsMatchClass <int opSize> : AsmOperandClass { 1295 let Name = "PackedFP"#opSize#"InputMods"; 1296 let ParserMethod = "parseRegOrImm"; 1297 let PredicateMethod = "isRegOrImm"; 1298// let PredicateMethod = "isPackedFP"#opSize#"InputMods"; 1299} 1300 1301class PackedIntInputModsMatchClass <int opSize> : AsmOperandClass { 1302 let Name = "PackedInt"#opSize#"InputMods"; 1303 let ParserMethod = "parseRegOrImm"; 1304 let PredicateMethod = "isRegOrImm"; 1305// let PredicateMethod = "isPackedInt"#opSize#"InputMods"; 1306} 1307 1308def PackedF16InputModsMatchClass : PackedFPInputModsMatchClass<16>; 1309def PackedI16InputModsMatchClass : PackedIntInputModsMatchClass<16>; 1310 1311class PackedFPInputMods <PackedFPInputModsMatchClass matchClass> : InputMods <matchClass> { 1312// let PrintMethod = "printPackedFPInputMods"; 1313} 1314 1315class PackedIntInputMods <PackedIntInputModsMatchClass matchClass> : InputMods <matchClass> { 1316 //let PrintMethod = "printPackedIntInputMods"; 1317} 1318 1319def PackedF16InputMods : PackedFPInputMods<PackedF16InputModsMatchClass>; 1320def PackedI16InputMods : PackedIntInputMods<PackedI16InputModsMatchClass>; 1321 1322//===----------------------------------------------------------------------===// 1323// Complex patterns 1324//===----------------------------------------------------------------------===// 1325 1326def DS1Addr1Offset : ComplexPattern<i32, 2, "SelectDS1Addr1Offset">; 1327def DS64Bit4ByteAligned : ComplexPattern<i32, 3, "SelectDS64Bit4ByteAligned">; 1328def DS128Bit8ByteAligned : ComplexPattern<i64, 3, "SelectDS128Bit8ByteAligned">; 1329 1330def MOVRELOffset : ComplexPattern<i32, 2, "SelectMOVRELOffset">; 1331 1332def VOP3Mods0 : ComplexPattern<untyped, 4, "SelectVOP3Mods0">; 1333def VOP3Mods : ComplexPattern<untyped, 2, "SelectVOP3Mods">; 1334def VOP3NoMods : ComplexPattern<untyped, 1, "SelectVOP3NoMods">; 1335// VOP3Mods, but the input source is known to never be NaN. 1336def VOP3Mods_nnan : ComplexPattern<fAny, 2, "SelectVOP3Mods_NNaN">; 1337 1338def VOP3OMods : ComplexPattern<untyped, 3, "SelectVOP3OMods">; 1339 1340def VOP3PMods : ComplexPattern<untyped, 2, "SelectVOP3PMods">; 1341 1342def VOP3OpSel : ComplexPattern<untyped, 2, "SelectVOP3OpSel">; 1343 1344def VOP3OpSelMods : ComplexPattern<untyped, 2, "SelectVOP3OpSelMods">; 1345 1346def VOP3PMadMixMods : ComplexPattern<untyped, 2, "SelectVOP3PMadMixMods">; 1347 1348//===----------------------------------------------------------------------===// 1349// SI assembler operands 1350//===----------------------------------------------------------------------===// 1351 1352def SIOperand { 1353 int ZERO = 0x80; 1354 int VCC = 0x6A; 1355 int FLAT_SCR = 0x68; 1356} 1357 1358// This should be kept in sync with SISrcMods enum 1359def SRCMODS { 1360 int NONE = 0; 1361 int NEG = 1; 1362 int ABS = 2; 1363 int NEG_ABS = 3; 1364 1365 int NEG_HI = ABS; 1366 int OP_SEL_0 = 4; 1367 int OP_SEL_1 = 8; 1368 int DST_OP_SEL = 8; 1369} 1370 1371def DSTCLAMP { 1372 int NONE = 0; 1373 int ENABLE = 1; 1374} 1375 1376def DSTOMOD { 1377 int NONE = 0; 1378} 1379 1380def TRAPID{ 1381 int LLVM_TRAP = 2; 1382 int LLVM_DEBUG_TRAP = 3; 1383} 1384 1385def HWREG { 1386 int MODE = 1; 1387 int STATUS = 2; 1388 int TRAPSTS = 3; 1389 int HW_ID = 4; 1390 int GPR_ALLOC = 5; 1391 int LDS_ALLOC = 6; 1392 int IB_STS = 7; 1393 int MEM_BASES = 15; 1394 int TBA_LO = 16; 1395 int TBA_HI = 17; 1396 int TMA_LO = 18; 1397 int TMA_HI = 19; 1398 int FLAT_SCR_LO = 20; 1399 int FLAT_SCR_HI = 21; 1400 int XNACK_MASK = 22; 1401 int POPS_PACKER = 25; 1402 int SHADER_CYCLES = 29; 1403} 1404 1405class getHwRegImm<int Reg, int Offset = 0, int Size = 32> { 1406 int ret = !and(!or(Reg, 1407 !shl(Offset, 6), 1408 !shl(!add(Size, -1), 11)), 65535); 1409} 1410 1411//===----------------------------------------------------------------------===// 1412// 1413// SI Instruction multiclass helpers. 1414// 1415// Instructions with _32 take 32-bit operands. 1416// Instructions with _64 take 64-bit operands. 1417// 1418// VOP_* instructions can use either a 32-bit or 64-bit encoding. The 32-bit 1419// encoding is the standard encoding, but instruction that make use of 1420// any of the instruction modifiers must use the 64-bit encoding. 1421// 1422// Instructions with _e32 use the 32-bit encoding. 1423// Instructions with _e64 use the 64-bit encoding. 1424// 1425//===----------------------------------------------------------------------===// 1426 1427class SIMCInstr <string pseudo, int subtarget> { 1428 string PseudoInstr = pseudo; 1429 int Subtarget = subtarget; 1430} 1431 1432//===----------------------------------------------------------------------===// 1433// Vector ALU classes 1434//===----------------------------------------------------------------------===// 1435 1436class getNumSrcArgs<ValueType Src0, ValueType Src1, ValueType Src2> { 1437 int ret = 1438 !if (!eq(Src0.Value, untyped.Value), 0, 1439 !if (!eq(Src1.Value, untyped.Value), 1, // VOP1 1440 !if (!eq(Src2.Value, untyped.Value), 2, // VOP2 1441 3))); // VOP3 1442} 1443 1444// Returns the register class to use for the destination of VOP[123C] 1445// instructions for the given VT. 1446class getVALUDstForVT<ValueType VT> { 1447 RegisterOperand ret = !if(!eq(VT.Size, 32), VOPDstOperand<VGPR_32>, 1448 !if(!eq(VT.Size, 128), VOPDstOperand<VReg_128>, 1449 !if(!eq(VT.Size, 64), VOPDstOperand<VReg_64>, 1450 !if(!eq(VT.Size, 16), VOPDstOperand<VGPR_32>, 1451 VOPDstS64orS32)))); // else VT == i1 1452} 1453 1454// Returns the register class to use for the destination of VOP[12C] 1455// instructions with SDWA extension 1456class getSDWADstForVT<ValueType VT> { 1457 RegisterOperand ret = !if(!eq(VT.Size, 1), 1458 SDWAVopcDst, // VOPC 1459 VOPDstOperand<VGPR_32>); // VOP1/2 32-bit dst 1460} 1461 1462// Returns the register class to use for source 0 of VOP[12C] 1463// instructions for the given VT. 1464class getVOPSrc0ForVT<ValueType VT> { 1465 bit isFP = isFloatType<VT>.ret; 1466 1467 RegisterOperand ret = 1468 !if(isFP, 1469 !if(!eq(VT.Size, 64), 1470 VSrc_f64, 1471 !if(!eq(VT.Value, f16.Value), 1472 VSrc_f16, 1473 !if(!eq(VT.Value, v2f16.Value), 1474 VSrc_v2f16, 1475 !if(!eq(VT.Value, v4f16.Value), 1476 AVSrc_64, 1477 VSrc_f32 1478 ) 1479 ) 1480 ) 1481 ), 1482 !if(!eq(VT.Size, 64), 1483 VSrc_b64, 1484 !if(!eq(VT.Value, i16.Value), 1485 VSrc_b16, 1486 !if(!eq(VT.Value, v2i16.Value), 1487 VSrc_v2b16, 1488 VSrc_b32 1489 ) 1490 ) 1491 ) 1492 ); 1493} 1494 1495class getSOPSrcForVT<ValueType VT> { 1496 RegisterOperand ret = !if(!eq(VT.Size, 64), SSrc_b64, SSrc_b32); 1497} 1498 1499// Returns the vreg register class to use for source operand given VT 1500class getVregSrcForVT<ValueType VT> { 1501 RegisterClass ret = !if(!eq(VT.Size, 128), VReg_128, 1502 !if(!eq(VT.Size, 96), VReg_96, 1503 !if(!eq(VT.Size, 64), VReg_64, 1504 !if(!eq(VT.Size, 48), VReg_64, 1505 VGPR_32)))); 1506} 1507 1508class getSDWASrcForVT <ValueType VT> { 1509 bit isFP = isFloatType<VT>.ret; 1510 RegisterOperand retFlt = !if(!eq(VT.Size, 16), SDWASrc_f16, SDWASrc_f32); 1511 RegisterOperand retInt = !if(!eq(VT.Size, 16), SDWASrc_i16, SDWASrc_i32); 1512 RegisterOperand ret = !if(isFP, retFlt, retInt); 1513} 1514 1515// Returns the register class to use for sources of VOP3 instructions for the 1516// given VT. 1517class getVOP3SrcForVT<ValueType VT> { 1518 bit isFP = isFloatType<VT>.ret; 1519 RegisterOperand ret = 1520 !if(!eq(VT.Size, 128), 1521 VSrc_128, 1522 !if(!eq(VT.Size, 64), 1523 !if(isFP, 1524 !if(!eq(VT.Value, v2f32.Value), 1525 VSrc_v2f32, 1526 VSrc_f64), 1527 !if(!eq(VT.Value, v2i32.Value), 1528 VSrc_v2b32, 1529 VSrc_b64)), 1530 !if(!eq(VT.Value, i1.Value), 1531 SSrc_i1, 1532 !if(isFP, 1533 !if(!eq(VT.Value, f16.Value), 1534 VSrc_f16, 1535 !if(!eq(VT.Value, v2f16.Value), 1536 VSrc_v2f16, 1537 !if(!eq(VT.Value, v4f16.Value), 1538 AVSrc_64, 1539 VSrc_f32 1540 ) 1541 ) 1542 ), 1543 !if(!eq(VT.Value, i16.Value), 1544 VSrc_b16, 1545 !if(!eq(VT.Value, v2i16.Value), 1546 VSrc_v2b16, 1547 VSrc_b32 1548 ) 1549 ) 1550 ) 1551 ) 1552 ) 1553 ); 1554} 1555 1556// Float or packed int 1557class isModifierType<ValueType SrcVT> { 1558 bit ret = !or(!eq(SrcVT.Value, f16.Value), 1559 !eq(SrcVT.Value, f32.Value), 1560 !eq(SrcVT.Value, f64.Value), 1561 !eq(SrcVT.Value, v2f16.Value), 1562 !eq(SrcVT.Value, v2i16.Value), 1563 !eq(SrcVT.Value, v2f32.Value), 1564 !eq(SrcVT.Value, v2i32.Value)); 1565} 1566 1567// Return type of input modifiers operand for specified input operand 1568class getSrcMod <ValueType VT, bit EnableF32SrcMods> { 1569 bit isFP = isFloatType<VT>.ret; 1570 bit isPacked = isPackedType<VT>.ret; 1571 Operand ret = !if(!eq(VT.Size, 64), 1572 !if(isFP, FP64InputMods, Int64InputMods), 1573 !if(isFP, 1574 !if(!eq(VT.Value, f16.Value), 1575 FP16InputMods, 1576 FP32InputMods 1577 ), 1578 !if(EnableF32SrcMods, FP32InputMods, Int32InputMods)) 1579 ); 1580} 1581 1582class getOpSelMod <ValueType VT> { 1583 Operand ret = !if(!eq(VT.Value, f16.Value), FP16InputMods, IntOpSelMods); 1584} 1585 1586// Return type of input modifiers operand specified input operand for DPP 1587class getSrcModDPP <ValueType VT> { 1588 bit isFP = isFloatType<VT>.ret; 1589 Operand ret = !if(isFP, FPVRegInputMods, IntVRegInputMods); 1590} 1591 1592// Return type of input modifiers operand specified input operand for SDWA 1593class getSrcModSDWA <ValueType VT> { 1594 Operand ret = !if(!eq(VT.Value, f16.Value), FP16SDWAInputMods, 1595 !if(!eq(VT.Value, f32.Value), FP32SDWAInputMods, 1596 !if(!eq(VT.Value, i16.Value), Int16SDWAInputMods, 1597 Int32SDWAInputMods))); 1598} 1599 1600// Returns the input arguments for VOP[12C] instructions for the given SrcVT. 1601class getIns32 <RegisterOperand Src0RC, RegisterClass Src1RC, int NumSrcArgs> { 1602 dag ret = !if(!eq(NumSrcArgs, 1), (ins Src0RC:$src0), // VOP1 1603 !if(!eq(NumSrcArgs, 2), (ins Src0RC:$src0, Src1RC:$src1), // VOP2 1604 (ins))); 1605} 1606 1607// Returns the input arguments for VOP3 instructions for the given SrcVT. 1608class getIns64 <RegisterOperand Src0RC, RegisterOperand Src1RC, 1609 RegisterOperand Src2RC, int NumSrcArgs, 1610 bit HasClamp, bit HasModifiers, bit HasSrc2Mods, bit HasOMod, 1611 Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> { 1612 1613 dag ret = 1614 !if (!eq(NumSrcArgs, 0), 1615 // VOP1 without input operands (V_NOP, V_CLREXCP) 1616 (ins), 1617 /* else */ 1618 !if (!eq(NumSrcArgs, 1), 1619 !if (HasModifiers, 1620 // VOP1 with modifiers 1621 (ins Src0Mod:$src0_modifiers, Src0RC:$src0, 1622 clampmod0:$clamp, omod0:$omod) 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 DstRC, 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 DstRC:$old, Src0Mod:$src0_modifiers, 1729 Src0RC:$src0) 1730 /* else */, 1731 // VOP1_DPP without modifiers 1732 (ins DstRC:$old, Src0RC:$src0) 1733 /* endif */), 1734 !if (HasModifiers, 1735 // VOP2_DPP with modifiers 1736 (ins DstRC:$old, 1737 Src0Mod:$src0_modifiers, Src0RC:$src0, 1738 Src1Mod:$src1_modifiers, Src1RC:$src1) 1739 /* else */, 1740 // VOP2_DPP without modifiers 1741 (ins DstRC:$old, 1742 Src0RC:$src0, Src1RC:$src1) 1743 ))); 1744} 1745 1746class getInsDPP <RegisterOperand DstRC, RegisterClass Src0RC, RegisterClass Src1RC, 1747 int NumSrcArgs, bit HasModifiers, 1748 Operand Src0Mod, Operand Src1Mod> { 1749 dag ret = !con(getInsDPPBase<DstRC, 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 DstRC, RegisterClass Src0RC, RegisterClass Src1RC, 1756 int NumSrcArgs, bit HasModifiers, 1757 Operand Src0Mod, Operand Src1Mod> { 1758 dag ret = !con(getInsDPP<DstRC, Src0RC, Src1RC, NumSrcArgs, 1759 HasModifiers, Src0Mod, Src1Mod>.ret, 1760 (ins FI:$fi)); 1761} 1762 1763class getInsDPP8 <RegisterOperand DstRC, RegisterClass Src0RC, RegisterClass Src1RC, 1764 int NumSrcArgs, bit HasModifiers, 1765 Operand Src0Mod, Operand Src1Mod> { 1766 dag ret = !con(getInsDPPBase<DstRC, 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 int NumSrcArgs = getNumSrcArgs<Src0VT, Src1VT, Src2VT>.ret; 2110 field bit HasSrc0 = !ne(Src0VT.Value, untyped.Value); 2111 field bit HasSrc1 = !ne(Src1VT.Value, untyped.Value); 2112 field bit HasSrc2 = !ne(Src2VT.Value, untyped.Value); 2113 2114 // HasSrc*FloatMods affects the SDWA encoding. We ignore EnableF32SrcMods. 2115 field bit HasSrc0FloatMods = isFloatType<Src0VT>.ret; 2116 field bit HasSrc1FloatMods = isFloatType<Src1VT>.ret; 2117 field bit HasSrc2FloatMods = isFloatType<Src2VT>.ret; 2118 2119 // HasSrc*IntMods affects the SDWA encoding. We ignore EnableF32SrcMods. 2120 field bit HasSrc0IntMods = isIntType<Src0VT>.ret; 2121 field bit HasSrc1IntMods = isIntType<Src1VT>.ret; 2122 field bit HasSrc2IntMods = isIntType<Src2VT>.ret; 2123 2124 field bit HasClamp = !or(isModifierType<Src0VT>.ret, EnableClamp); 2125 field bit HasSDWAClamp = EmitDst; 2126 field bit HasFPClamp = !and(isFloatType<DstVT>.ret, HasClamp); 2127 field bit HasIntClamp = !if(isFloatType<DstVT>.ret, 0, HasClamp); 2128 field bit HasClampLo = HasClamp; 2129 field bit HasClampHi = !and(isPackedType<DstVT>.ret, HasClamp); 2130 field bit HasHigh = 0; 2131 2132 field bit IsPacked = isPackedType<Src0VT>.ret; 2133 field bit HasOpSel = IsPacked; 2134 field bit HasOMod = !if(HasOpSel, 0, isFloatType<DstVT>.ret); 2135 field bit HasSDWAOMod = isFloatType<DstVT>.ret; 2136 2137 field bit HasModifiers = !or(isModifierType<Src0VT>.ret, 2138 isModifierType<Src1VT>.ret, 2139 isModifierType<Src2VT>.ret, 2140 HasOMod, 2141 EnableF32SrcMods); 2142 2143 field bit HasSrc0Mods = HasModifiers; 2144 field bit HasSrc1Mods = !if(HasModifiers, !or(HasSrc1FloatMods, HasSrc1IntMods), 0); 2145 field bit HasSrc2Mods = !if(HasModifiers, !or(HasSrc2FloatMods, HasSrc2IntMods), 0); 2146 2147 field bit HasExt = getHasExt<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret; 2148 field bit HasExtDPP = getHasDPP<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret; 2149 field bit HasExt64BitDPP = getHasExt64BitDPP<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret; 2150 field bit HasExtSDWA = getHasSDWA<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret; 2151 field bit HasExtSDWA9 = HasExtSDWA; 2152 field int NeedPatGen = PatGenMode.NoPattern; 2153 2154 field bit IsMAI = 0; 2155 field bit IsDOT = 0; 2156 2157 field Operand Src0PackedMod = !if(HasSrc0FloatMods, PackedF16InputMods, PackedI16InputMods); 2158 field Operand Src1PackedMod = !if(HasSrc1FloatMods, PackedF16InputMods, PackedI16InputMods); 2159 field Operand Src2PackedMod = !if(HasSrc2FloatMods, PackedF16InputMods, PackedI16InputMods); 2160 2161 field dag Outs = !if(HasDst,(outs DstRC:$vdst),(outs)); 2162 2163 // VOP3b instructions are a special case with a second explicit 2164 // output. This is manually overridden for them. 2165 field dag Outs32 = Outs; 2166 field dag Outs64 = Outs; 2167 field dag OutsDPP = getOutsDPP<HasDst, DstVT, DstRCDPP>.ret; 2168 field dag OutsDPP8 = getOutsDPP<HasDst, DstVT, DstRCDPP>.ret; 2169 field dag OutsSDWA = getOutsSDWA<HasDst, DstVT, DstRCSDWA>.ret; 2170 2171 field dag Ins32 = getIns32<Src0RC32, Src1RC32, NumSrcArgs>.ret; 2172 field dag Ins64 = getIns64<Src0RC64, Src1RC64, Src2RC64, NumSrcArgs, 2173 HasIntClamp, HasModifiers, HasSrc2Mods, 2174 HasOMod, Src0Mod, Src1Mod, Src2Mod>.ret; 2175 field dag InsVOP3P = getInsVOP3P<Src0RC64, Src1RC64, Src2RC64, 2176 NumSrcArgs, HasClamp, 2177 Src0PackedMod, Src1PackedMod, Src2PackedMod>.ret; 2178 field dag InsVOP3OpSel = getInsVOP3OpSel<Src0RC64, Src1RC64, Src2RC64, 2179 NumSrcArgs, HasClamp, HasOMod, 2180 getOpSelMod<Src0VT>.ret, 2181 getOpSelMod<Src1VT>.ret, 2182 getOpSelMod<Src2VT>.ret>.ret; 2183 field dag InsDPP = !if(HasExtDPP, 2184 getInsDPP<DstRCDPP, Src0DPP, Src1DPP, NumSrcArgs, 2185 HasModifiers, Src0ModDPP, Src1ModDPP>.ret, 2186 (ins)); 2187 field dag InsDPP16 = getInsDPP16<DstRCDPP, Src0DPP, Src1DPP, NumSrcArgs, 2188 HasModifiers, Src0ModDPP, Src1ModDPP>.ret; 2189 field dag InsDPP8 = getInsDPP8<DstRCDPP, Src0DPP, Src1DPP, NumSrcArgs, 0, 2190 Src0ModDPP, Src1ModDPP>.ret; 2191 field dag InsSDWA = getInsSDWA<Src0SDWA, Src1SDWA, NumSrcArgs, 2192 HasSDWAOMod, Src0ModSDWA, Src1ModSDWA, 2193 DstVT>.ret; 2194 2195 2196 field string Asm32 = getAsm32<HasDst, NumSrcArgs, DstVT>.ret; 2197 field string Asm64 = getAsm64<HasDst, NumSrcArgs, HasIntClamp, HasModifiers, HasOMod, DstVT>.ret; 2198 field string AsmVOP3P = getAsmVOP3P<HasDst, NumSrcArgs, HasModifiers, HasClamp, DstVT>.ret; 2199 field string AsmVOP3OpSel = getAsmVOP3OpSel<NumSrcArgs, 2200 HasClamp, HasOMod, 2201 HasSrc0FloatMods, 2202 HasSrc1FloatMods, 2203 HasSrc2FloatMods>.ret; 2204 field string AsmDPP = !if(HasExtDPP, 2205 getAsmDPP<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret, ""); 2206 field string AsmDPP16 = getAsmDPP16<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret; 2207 field string AsmDPP8 = getAsmDPP8<HasDst, NumSrcArgs, 0, DstVT>.ret; 2208 field string AsmSDWA = getAsmSDWA<HasDst, NumSrcArgs, DstVT>.ret; 2209 field string AsmSDWA9 = getAsmSDWA9<HasDst, HasSDWAOMod, NumSrcArgs, DstVT>.ret; 2210 2211 field string TieRegDPP = "$old"; 2212} 2213 2214class VOP_NO_EXT <VOPProfile p> : VOPProfile <p.ArgVT> { 2215 let HasExt = 0; 2216 let HasExtDPP = 0; 2217 let HasExt64BitDPP = 0; 2218 let HasExtSDWA = 0; 2219 let HasExtSDWA9 = 0; 2220} 2221 2222class VOP_PAT_GEN <VOPProfile p, int mode=PatGenMode.Pattern> : VOPProfile <p.ArgVT> { 2223 let NeedPatGen = mode; 2224} 2225 2226def VOP_F16_F16 : VOPProfile <[f16, f16, untyped, untyped]>; 2227def VOP_F16_I16 : VOPProfile <[f16, i16, untyped, untyped]>; 2228def VOP_I16_F16 : VOPProfile <[i16, f16, untyped, untyped]>; 2229 2230def VOP_F16_F16_F16 : VOPProfile <[f16, f16, f16, untyped]>; 2231def VOP_F16_F16_I16 : VOPProfile <[f16, f16, i16, untyped]>; 2232def VOP_F16_F16_I32 : VOPProfile <[f16, f16, i32, untyped]>; 2233def VOP_I16_I16_I16 : VOPProfile <[i16, i16, i16, untyped]>; 2234def VOP_I16_I16_I16_ARITH : VOPProfile <[i16, i16, i16, untyped], 0, /*EnableClamp=*/1>; 2235 2236def VOP_I16_I16_I16_I16 : VOPProfile <[i16, i16, i16, i16, untyped]>; 2237def VOP_F16_F16_F16_F16 : VOPProfile <[f16, f16, f16, f16, untyped]>; 2238 2239def VOP_I32_I16_I16_I32 : VOPProfile <[i32, i16, i16, i32, untyped]>; 2240 2241def VOP_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, untyped]>; 2242def VOP_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, untyped]>; 2243def VOP_B32_F16_F16 : VOPProfile <[i32, f16, f16, untyped]>; 2244 2245def VOP_V2F16_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, v2f16]>; 2246def VOP_V2I16_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, v2i16]>; 2247def VOP_V2I16_F32_F32 : VOPProfile <[v2i16, f32, f32, untyped]>; 2248def VOP_V2I16_I32_I32 : VOPProfile <[v2i16, i32, i32, untyped]>; 2249 2250def VOP_F32_V2F16_V2F16_V2F16 : VOPProfile <[f32, v2f16, v2f16, v2f16]>; 2251 2252def VOP_NONE : VOPProfile <[untyped, untyped, untyped, untyped]>; 2253 2254def VOP_F32_F32 : VOPProfile <[f32, f32, untyped, untyped]>; 2255def VOP_F32_F64 : VOPProfile <[f32, f64, untyped, untyped]>; 2256def VOP_F32_I32 : VOPProfile <[f32, i32, untyped, untyped]>; 2257def VOP_F64_F32 : VOPProfile <[f64, f32, untyped, untyped]>; 2258def VOP_F64_F64 : VOPProfile <[f64, f64, untyped, untyped]>; 2259def VOP_F64_I32 : VOPProfile <[f64, i32, untyped, untyped]>; 2260def VOP_I32_F32 : VOPProfile <[i32, f32, untyped, untyped]>; 2261def VOP_I32_F64 : VOPProfile <[i32, f64, untyped, untyped]>; 2262def VOP_I32_I32 : VOPProfile <[i32, i32, untyped, untyped]>; 2263def VOP_F16_F32 : VOPProfile <[f16, f32, untyped, untyped]>; 2264def VOP_F32_F16 : VOPProfile <[f32, f16, untyped, untyped]>; 2265def VOP_I64_I64 : VOPProfile <[i64, i64, untyped, untyped]>; 2266 2267def VOP_F32_F32_F16 : VOPProfile <[f32, f32, f16, untyped]>; 2268def VOP_F32_F32_F32 : VOPProfile <[f32, f32, f32, untyped]>; 2269def VOP_F32_F32_I32 : VOPProfile <[f32, f32, i32, untyped]>; 2270def VOP_F64_F64_F64 : VOPProfile <[f64, f64, f64, untyped]>; 2271def VOP_F64_F64_I32 : VOPProfile <[f64, f64, i32, untyped]>; 2272def VOP_I32_F32_F32 : VOPProfile <[i32, f32, f32, untyped]>; 2273def VOP_I32_F32_I32 : VOPProfile <[i32, f32, i32, untyped]>; 2274def VOP_I32_I32_I32 : VOPProfile <[i32, i32, i32, untyped]>; 2275def VOP_I32_I32_I32_ARITH : VOPProfile <[i32, i32, i32, untyped], 0, /*EnableClamp=*/1>; 2276def VOP_V2F16_F32_F32 : VOPProfile <[v2f16, f32, f32, untyped]>; 2277def VOP_F32_F16_F16_F16 : VOPProfile <[f32, f16, f16, f16]>; 2278 2279def VOP_I64_I64_I32 : VOPProfile <[i64, i64, i32, untyped]>; 2280def VOP_I64_I32_I64 : VOPProfile <[i64, i32, i64, untyped]>; 2281def VOP_I64_I64_I64 : VOPProfile <[i64, i64, i64, untyped]>; 2282 2283def VOP_F16_F32_F16_F32 : VOPProfile <[f16, f32, f16, f32]>; 2284def VOP_F32_F32_F16_F16 : VOPProfile <[f32, f32, f16, f16]>; 2285def VOP_F32_F32_F32_F32 : VOPProfile <[f32, f32, f32, f32]>; 2286def VOP_F64_F64_F64_F64 : VOPProfile <[f64, f64, f64, f64]>; 2287def VOP_I32_I32_I32_I32 : VOPProfile <[i32, i32, i32, i32]>; 2288def VOP_I64_I32_I32_I64 : VOPProfile <[i64, i32, i32, i64]>; 2289def VOP_I32_F32_I32_I32 : VOPProfile <[i32, f32, i32, i32]>; 2290def VOP_I64_I64_I32_I64 : VOPProfile <[i64, i64, i32, i64]>; 2291def VOP_V4I32_I64_I32_V4I32 : VOPProfile <[v4i32, i64, i32, v4i32]>; 2292 2293def VOP_F32_V2F16_V2F16_F32 : VOPProfile <[f32, v2f16, v2f16, f32]>; 2294def VOP_I32_V2I16_V2I16_I32 : VOPProfile <[i32, v2i16, v2i16, i32]>; 2295 2296def VOP_V4F32_F32_F32_V4F32 : VOPProfile <[v4f32, f32, f32, v4f32]>; 2297def VOP_V16F32_F32_F32_V16F32 : VOPProfile <[v16f32, f32, f32, v16f32]>; 2298def VOP_V32F32_F32_F32_V32F32 : VOPProfile <[v32f32, f32, f32, v32f32]>; 2299def VOP_V4F32_V4F16_V4F16_V4F32 : VOPProfile <[v4f32, v4f16, v4f16, v4f32]>; 2300def VOP_V16F32_V4F16_V4F16_V16F32 : VOPProfile <[v16f32, v4f16, v4f16, v16f32]>; 2301def VOP_V32F32_V4F16_V4F16_V32F32 : VOPProfile <[v32f32, v4f16, v4f16, v32f32]>; 2302def VOP_V4F32_V2I16_V2I16_V4F32 : VOPProfile <[v4f32, v2i16, v2i16, v4f32]>; 2303def VOP_V16F32_V2I16_V2I16_V16F32 : VOPProfile <[v16f32, v2i16, v2i16, v16f32]>; 2304def VOP_V32F32_V2I16_V2I16_V32F32 : VOPProfile <[v32f32, v2i16, v2i16, v32f32]>; 2305def VOP_V4I32_I32_I32_V4I32 : VOPProfile <[v4i32, i32, i32, v4i32]>; 2306def VOP_V16I32_I32_I32_V16I32 : VOPProfile <[v16i32, i32, i32, v16i32]>; 2307def VOP_V32I32_I32_I32_V32I32 : VOPProfile <[v32i32, i32, i32, v32i32]>; 2308 2309def VOP_V4F64_F64_F64_V4F64 : VOPProfile <[v4f64, f64, f64, v4f64]>; 2310def VOP_V1F64_F64_F64_V1F64 : VOPProfile <[v1f64, f64, f64, v1f64]>; 2311 2312def VOP_V2F32_V2F32_V2F32_V2F32 : VOPProfile <[v2f32, v2f32, v2f32, v2f32]>; 2313def VOP_V2F32_V2F32_V2F32 : VOPProfile <[v2f32, v2f32, v2f32, untyped]>; 2314def VOP_V2I32_V2I32_V2I32 : VOPProfile <[v2i32, v2i32, v2i32, untyped]>; 2315def VOP_V4F32_V4I16_V4I16_V4F32 : VOPProfile <[v4f32, v4i16, v4i16, v4f32]>; 2316def VOP_V16F32_V4I16_V4I16_V16F32 : VOPProfile <[v16f32, v4i16, v4i16, v16f32]>; 2317def VOP_V32F32_V4I16_V4I16_V32F32 : VOPProfile <[v32f32, v4i16, v4i16, v32f32]>; 2318 2319class Commutable_REV <string revOp, bit isOrig> { 2320 string RevOp = revOp; 2321 bit IsOrig = isOrig; 2322} 2323 2324class AtomicNoRet <string noRetOp, bit isRet> { 2325 string NoRetOp = noRetOp; 2326 bit IsRet = isRet; 2327} 2328 2329//===----------------------------------------------------------------------===// 2330// Interpolation opcodes 2331//===----------------------------------------------------------------------===// 2332 2333class VINTRPDstOperand <RegisterClass rc> : RegisterOperand <rc, "printVINTRPDst">; 2334 2335class VINTRP_Pseudo <string opName, dag outs, dag ins, list<dag> pattern> : 2336 VINTRPCommon <outs, ins, "", pattern>, 2337 SIMCInstr<opName, SIEncodingFamily.NONE> { 2338 let isPseudo = 1; 2339 let isCodeGenOnly = 1; 2340} 2341 2342// FIXME-GFX10: WIP. 2343class VINTRP_Real_si <bits <2> op, string opName, dag outs, dag ins, 2344 string asm, int encodingFamily> : 2345 VINTRPCommon <outs, ins, asm, []>, 2346 VINTRPe <op>, 2347 SIMCInstr<opName, encodingFamily> { 2348} 2349 2350class VINTRP_Real_vi <bits <2> op, string opName, dag outs, dag ins, 2351 string asm> : 2352 VINTRPCommon <outs, ins, asm, []>, 2353 VINTRPe_vi <op>, 2354 SIMCInstr<opName, SIEncodingFamily.VI> { 2355 let AssemblerPredicate = VIAssemblerPredicate; 2356 let DecoderNamespace = "GFX8"; 2357} 2358 2359// FIXME-GFX10: WIP. 2360multiclass VINTRP_m <bits <2> op, dag outs, dag ins, string asm, 2361 list<dag> pattern = []> { 2362 def "" : VINTRP_Pseudo <NAME, outs, ins, pattern>; 2363 2364 let AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in { 2365 def _si : VINTRP_Real_si <op, NAME, outs, ins, asm, SIEncodingFamily.SI>; 2366 } // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" 2367 2368 def _vi : VINTRP_Real_vi <op, NAME, outs, ins, asm>; 2369 2370 let AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in { 2371 def _gfx10 : VINTRP_Real_si<op, NAME, outs, ins, asm, SIEncodingFamily.GFX10>; 2372 } // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" 2373} 2374//===----------------------------------------------------------------------===// 2375// Vector instruction mappings 2376//===----------------------------------------------------------------------===// 2377 2378// Maps an opcode in e32 form to its e64 equivalent 2379def getVOPe64 : InstrMapping { 2380 let FilterClass = "VOP"; 2381 let RowFields = ["OpName"]; 2382 let ColFields = ["Size", "VOP3"]; 2383 let KeyCol = ["4", "0"]; 2384 let ValueCols = [["8", "1"]]; 2385} 2386 2387// Maps an opcode in e64 form to its e32 equivalent 2388def getVOPe32 : InstrMapping { 2389 let FilterClass = "VOP"; 2390 let RowFields = ["OpName"]; 2391 let ColFields = ["Size", "VOP3"]; 2392 let KeyCol = ["8", "1"]; 2393 let ValueCols = [["4", "0"]]; 2394} 2395 2396// Maps ordinary instructions to their SDWA counterparts 2397def getSDWAOp : InstrMapping { 2398 let FilterClass = "VOP"; 2399 let RowFields = ["OpName"]; 2400 let ColFields = ["AsmVariantName"]; 2401 let KeyCol = ["Default"]; 2402 let ValueCols = [["SDWA"]]; 2403} 2404 2405// Maps SDWA instructions to their ordinary counterparts 2406def getBasicFromSDWAOp : InstrMapping { 2407 let FilterClass = "VOP"; 2408 let RowFields = ["OpName"]; 2409 let ColFields = ["AsmVariantName"]; 2410 let KeyCol = ["SDWA"]; 2411 let ValueCols = [["Default"]]; 2412} 2413 2414// Maps ordinary instructions to their DPP counterparts 2415def getDPPOp32 : InstrMapping { 2416 let FilterClass = "VOP"; 2417 let RowFields = ["OpName"]; 2418 let ColFields = ["AsmVariantName"]; 2419 let KeyCol = ["Default"]; 2420 let ValueCols = [["DPP"]]; 2421} 2422 2423// Maps an commuted opcode to its original version 2424def getCommuteOrig : InstrMapping { 2425 let FilterClass = "Commutable_REV"; 2426 let RowFields = ["RevOp"]; 2427 let ColFields = ["IsOrig"]; 2428 let KeyCol = ["0"]; 2429 let ValueCols = [["1"]]; 2430} 2431 2432// Maps an original opcode to its commuted version 2433def getCommuteRev : InstrMapping { 2434 let FilterClass = "Commutable_REV"; 2435 let RowFields = ["RevOp"]; 2436 let ColFields = ["IsOrig"]; 2437 let KeyCol = ["1"]; 2438 let ValueCols = [["0"]]; 2439} 2440 2441def getMCOpcodeGen : InstrMapping { 2442 let FilterClass = "SIMCInstr"; 2443 let RowFields = ["PseudoInstr"]; 2444 let ColFields = ["Subtarget"]; 2445 let KeyCol = [!cast<string>(SIEncodingFamily.NONE)]; 2446 let ValueCols = [[!cast<string>(SIEncodingFamily.SI)], 2447 [!cast<string>(SIEncodingFamily.VI)], 2448 [!cast<string>(SIEncodingFamily.SDWA)], 2449 [!cast<string>(SIEncodingFamily.SDWA9)], 2450 // GFX80 encoding is added to work around a multiple matching 2451 // issue for buffer instructions with unpacked d16 data. This 2452 // does not actually change the encoding, and thus may be 2453 // removed later. 2454 [!cast<string>(SIEncodingFamily.GFX80)], 2455 [!cast<string>(SIEncodingFamily.GFX9)], 2456 [!cast<string>(SIEncodingFamily.GFX10)], 2457 [!cast<string>(SIEncodingFamily.SDWA10)], 2458 [!cast<string>(SIEncodingFamily.GFX90A)]]; 2459} 2460 2461// Get equivalent SOPK instruction. 2462def getSOPKOp : InstrMapping { 2463 let FilterClass = "SOPKInstTable"; 2464 let RowFields = ["BaseCmpOp"]; 2465 let ColFields = ["IsSOPK"]; 2466 let KeyCol = ["0"]; 2467 let ValueCols = [["1"]]; 2468} 2469 2470def getAddr64Inst : InstrMapping { 2471 let FilterClass = "MUBUFAddr64Table"; 2472 let RowFields = ["OpName"]; 2473 let ColFields = ["IsAddr64"]; 2474 let KeyCol = ["0"]; 2475 let ValueCols = [["1"]]; 2476} 2477 2478def getIfAddr64Inst : InstrMapping { 2479 let FilterClass = "MUBUFAddr64Table"; 2480 let RowFields = ["OpName"]; 2481 let ColFields = ["IsAddr64"]; 2482 let KeyCol = ["1"]; 2483 let ValueCols = [["1"]]; 2484} 2485 2486def getMUBUFNoLdsInst : InstrMapping { 2487 let FilterClass = "MUBUFLdsTable"; 2488 let RowFields = ["OpName"]; 2489 let ColFields = ["IsLds"]; 2490 let KeyCol = ["1"]; 2491 let ValueCols = [["0"]]; 2492} 2493 2494// Maps an atomic opcode to its returnless version. 2495def getAtomicNoRetOp : InstrMapping { 2496 let FilterClass = "AtomicNoRet"; 2497 let RowFields = ["NoRetOp"]; 2498 let ColFields = ["IsRet"]; 2499 let KeyCol = ["1"]; 2500 let ValueCols = [["0"]]; 2501} 2502 2503// Maps a GLOBAL to its SADDR form. 2504def getGlobalSaddrOp : InstrMapping { 2505 let FilterClass = "GlobalSaddrTable"; 2506 let RowFields = ["SaddrOp"]; 2507 let ColFields = ["IsSaddr"]; 2508 let KeyCol = ["0"]; 2509 let ValueCols = [["1"]]; 2510} 2511 2512// Maps a v_cmpx opcode with sdst to opcode without sdst. 2513def getVCMPXNoSDstOp : InstrMapping { 2514 let FilterClass = "VCMPXNoSDstTable"; 2515 let RowFields = ["NoSDstOp"]; 2516 let ColFields = ["HasSDst"]; 2517 let KeyCol = ["1"]; 2518 let ValueCols = [["0"]]; 2519} 2520 2521// Maps a SOPP to a SOPP with S_NOP 2522def getSOPPWithRelaxation : InstrMapping { 2523 let FilterClass = "SOPPRelaxTable"; 2524 let RowFields = ["KeyName"]; 2525 let ColFields = ["IsRelaxed"]; 2526 let KeyCol = ["0"]; 2527 let ValueCols = [["1"]]; 2528} 2529 2530// Maps flat scratch opcodes by addressing modes 2531def getFlatScratchInstSTfromSS : InstrMapping { 2532 let FilterClass = "FlatScratchInst"; 2533 let RowFields = ["SVOp"]; 2534 let ColFields = ["Mode"]; 2535 let KeyCol = ["SS"]; 2536 let ValueCols = [["ST"]]; 2537} 2538 2539def getFlatScratchInstSSfromSV : InstrMapping { 2540 let FilterClass = "FlatScratchInst"; 2541 let RowFields = ["SVOp"]; 2542 let ColFields = ["Mode"]; 2543 let KeyCol = ["SV"]; 2544 let ValueCols = [["SS"]]; 2545} 2546 2547include "SIInstructions.td" 2548 2549include "DSInstructions.td" 2550include "MIMGInstructions.td" 2551