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