1//===-- DSInstructions.td - DS Instruction Definitions --------------------===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9class DS_Pseudo <string opName, dag outs, dag ins, string asmOps, list<dag> pattern=[]> : 10 InstSI <outs, ins, "", pattern>, 11 SIMCInstr <opName, SIEncodingFamily.NONE> { 12 13 let LGKM_CNT = 1; 14 let DS = 1; 15 let Size = 8; 16 let UseNamedOperandTable = 1; 17 18 // Most instruction load and store data, so set this as the default. 19 let mayLoad = 1; 20 let mayStore = 1; 21 let maybeAtomic = 1; 22 23 let hasSideEffects = 0; 24 let SchedRW = [WriteLDS]; 25 26 let isPseudo = 1; 27 let isCodeGenOnly = 1; 28 29 let AsmMatchConverter = "cvtDS"; 30 31 string Mnemonic = opName; 32 string AsmOperands = asmOps; 33 34 // Well these bits a kind of hack because it would be more natural 35 // to test "outs" and "ins" dags for the presence of particular operands 36 bits<1> has_vdst = 1; 37 bits<1> has_addr = 1; 38 bits<1> has_data0 = 1; 39 bits<1> has_data1 = 1; 40 41 bits<1> has_gws_data0 = 0; // data0 is encoded as addr 42 43 bits<1> has_offset = 1; // has "offset" that should be split to offset0,1 44 bits<1> has_offset0 = 1; 45 bits<1> has_offset1 = 1; 46 47 bits<1> has_gds = 1; 48 bits<1> gdsValue = 0; // if has_gds == 0 set gds to this value 49 50 bits<1> has_m0_read = 1; 51 52 let Uses = !if(has_m0_read, [M0, EXEC], [EXEC]); 53} 54 55class DS_Real <DS_Pseudo ps> : 56 InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []>, 57 Enc64 { 58 59 let isPseudo = 0; 60 let isCodeGenOnly = 0; 61 let LGKM_CNT = 1; 62 let DS = 1; 63 let UseNamedOperandTable = 1; 64 65 // copy relevant pseudo op flags 66 let SubtargetPredicate = ps.SubtargetPredicate; 67 let OtherPredicates = ps.OtherPredicates; 68 let AsmMatchConverter = ps.AsmMatchConverter; 69 let SchedRW = ps.SchedRW; 70 let mayLoad = ps.mayLoad; 71 let mayStore = ps.mayStore; 72 let IsAtomicRet = ps.IsAtomicRet; 73 let IsAtomicNoRet = ps.IsAtomicNoRet; 74 75 // encoding fields 76 bits<10> vdst; 77 bits<1> gds; 78 bits<8> addr; 79 bits<10> data0; 80 bits<10> data1; 81 bits<8> offset0; 82 bits<8> offset1; 83 84 bits<16> offset; 85 let offset0 = !if(ps.has_offset, offset{7-0}, ?); 86 let offset1 = !if(ps.has_offset, offset{15-8}, ?); 87 88 bits<1> acc = !if(ps.has_vdst, vdst{9}, 89 !if(!or(ps.has_data0, ps.has_gws_data0), data0{9}, 0)); 90} 91 92 93// DS Pseudo instructions 94 95class DS_0A1D_NORET<string opName, RegisterClass rc = VGPR_32> 96: DS_Pseudo<opName, 97 (outs), 98 (ins getLdStRegisterOperand<rc>.ret:$data0, offset:$offset, gds:$gds), 99 " $data0$offset$gds"> { 100 101 let has_addr = 0; 102 let has_data1 = 0; 103 let has_vdst = 0; 104} 105 106class DS_1A1D_NORET<string opName, RegisterClass rc = VGPR_32> 107: DS_Pseudo<opName, 108 (outs), 109 (ins VGPR_32:$addr, getLdStRegisterOperand<rc>.ret:$data0, offset:$offset, gds:$gds), 110 " $addr, $data0$offset$gds"> { 111 112 let has_data1 = 0; 113 let has_vdst = 0; 114 let IsAtomicNoRet = 1; 115} 116 117multiclass DS_1A1D_NORET_mc<string opName, RegisterClass rc = VGPR_32> { 118 def "" : DS_1A1D_NORET<opName, rc>, 119 AtomicNoRet<opName, 0>; 120 121 let has_m0_read = 0 in { 122 def _gfx9 : DS_1A1D_NORET<opName, rc>, 123 AtomicNoRet<opName#"_gfx9", 0>; 124 } 125} 126 127multiclass DS_1A1D_NORET_mc_gfx9<string opName, RegisterClass rc = VGPR_32> { 128 let has_m0_read = 0 in { 129 def "" : DS_1A1D_NORET<opName, rc>, 130 AtomicNoRet<opName, 0>; 131 } 132} 133 134class DS_1A2D_NORET<string opName, RegisterClass rc = VGPR_32, 135 RegisterOperand data_op = getLdStRegisterOperand<rc>.ret> 136: DS_Pseudo<opName, 137 (outs), 138 (ins VGPR_32:$addr, data_op:$data0, data_op:$data1, offset:$offset, gds:$gds), 139 " $addr, $data0, $data1$offset$gds"> { 140 141 let has_vdst = 0; 142 let IsAtomicNoRet = 1; 143} 144 145multiclass DS_1A2D_NORET_mc<string opName, RegisterClass rc = VGPR_32> { 146 def "" : DS_1A2D_NORET<opName, rc>, 147 AtomicNoRet<opName, 0>; 148 149 let has_m0_read = 0 in { 150 def _gfx9 : DS_1A2D_NORET<opName, rc>, 151 AtomicNoRet<opName#"_gfx9", 0>; 152 } 153} 154 155class DS_1A2D_Off8_NORET <string opName, RegisterClass rc = VGPR_32, 156 RegisterOperand data_op = getLdStRegisterOperand<rc>.ret> 157: DS_Pseudo<opName, 158 (outs), 159 (ins VGPR_32:$addr, data_op:$data0, data_op:$data1, 160 offset0:$offset0, offset1:$offset1, gds:$gds), 161 " $addr, $data0, $data1$offset0$offset1$gds"> { 162 163 let has_vdst = 0; 164 let has_offset = 0; 165 let AsmMatchConverter = "cvtDSOffset01"; 166} 167 168multiclass DS_1A2D_Off8_NORET_mc <string opName, RegisterClass rc = VGPR_32> { 169 def "" : DS_1A2D_Off8_NORET<opName, rc>; 170 171 let has_m0_read = 0 in { 172 def _gfx9 : DS_1A2D_Off8_NORET<opName, rc>; 173 } 174} 175 176class DS_1A1D_RET <string opName, RegisterClass rc = VGPR_32, 177 RegisterOperand data_op = getLdStRegisterOperand<rc>.ret> 178: DS_Pseudo<opName, 179 (outs data_op:$vdst), 180 (ins VGPR_32:$addr, data_op:$data0, offset:$offset, gds:$gds), 181 " $vdst, $addr, $data0$offset$gds"> { 182 183 let hasPostISelHook = 1; 184 let has_data1 = 0; 185 let IsAtomicRet = 1; 186} 187 188multiclass DS_1A1D_RET_mc <string opName, RegisterClass rc = VGPR_32, 189 string NoRetOp = ""> { 190 def "" : DS_1A1D_RET<opName, rc>, 191 AtomicNoRet<NoRetOp, !ne(NoRetOp, "")>; 192 193 let has_m0_read = 0 in { 194 def _gfx9 : DS_1A1D_RET<opName, rc>, 195 AtomicNoRet<!if(!eq(NoRetOp, ""), "", NoRetOp#"_gfx9"), 196 !ne(NoRetOp, "")>; 197 } 198} 199 200multiclass DS_1A1D_RET_mc_gfx9 <string opName, RegisterClass rc = VGPR_32, 201 string NoRetOp = ""> { 202 let has_m0_read = 0 in { 203 def "" : DS_1A1D_RET<opName, rc>, 204 AtomicNoRet<!if(!eq(NoRetOp, ""), "", NoRetOp), 205 !if(!eq(NoRetOp, ""), 0, 1)>; 206 } 207} 208 209class DS_1A2D_RET<string opName, 210 RegisterClass rc = VGPR_32, 211 RegisterClass src = rc, 212 RegisterOperand dst_op = getLdStRegisterOperand<rc>.ret, 213 RegisterOperand src_op = getLdStRegisterOperand<src>.ret> 214: DS_Pseudo<opName, 215 (outs dst_op:$vdst), 216 (ins VGPR_32:$addr, src_op:$data0, src_op:$data1, offset:$offset, gds:$gds), 217 " $vdst, $addr, $data0, $data1$offset$gds"> { 218 219 let hasPostISelHook = 1; 220 let IsAtomicRet = 1; 221} 222 223multiclass DS_1A2D_RET_mc<string opName, 224 RegisterClass rc = VGPR_32, 225 string NoRetOp = "", 226 RegisterClass src = rc> { 227 def "" : DS_1A2D_RET<opName, rc, src>, 228 AtomicNoRet<NoRetOp, !ne(NoRetOp, "")>; 229 230 let has_m0_read = 0 in { 231 def _gfx9 : DS_1A2D_RET<opName, rc, src>, 232 AtomicNoRet<NoRetOp#"_gfx9", !ne(NoRetOp, "")>; 233 } 234} 235 236class DS_1A2D_Off8_RET<string opName, 237 RegisterClass rc = VGPR_32, 238 RegisterClass src = rc, 239 RegisterOperand dst_op = getLdStRegisterOperand<rc>.ret, 240 RegisterOperand src_op = getLdStRegisterOperand<src>.ret> 241: DS_Pseudo<opName, 242 (outs dst_op:$vdst), 243 (ins VGPR_32:$addr, src_op:$data0, src_op:$data1, offset0:$offset0, offset1:$offset1, gds:$gds), 244 " $vdst, $addr, $data0, $data1$offset0$offset1$gds"> { 245 246 let has_offset = 0; 247 let AsmMatchConverter = "cvtDSOffset01"; 248 249 let hasPostISelHook = 1; 250} 251 252multiclass DS_1A2D_Off8_RET_mc<string opName, 253 RegisterClass rc = VGPR_32, 254 RegisterClass src = rc> { 255 def "" : DS_1A2D_Off8_RET<opName, rc, src>; 256 257 let has_m0_read = 0 in { 258 def _gfx9 : DS_1A2D_Off8_RET<opName, rc, src>; 259 } 260} 261 262 263class DS_1A_RET<string opName, RegisterClass rc = VGPR_32, bit HasTiedOutput = 0, Operand ofs = offset, 264 RegisterOperand data_op = getLdStRegisterOperand<rc>.ret> 265: DS_Pseudo<opName, 266 (outs data_op:$vdst), 267 !if(HasTiedOutput, 268 (ins VGPR_32:$addr, ofs:$offset, gds:$gds, data_op:$vdst_in), 269 (ins VGPR_32:$addr, ofs:$offset, gds:$gds)), 270 " $vdst, $addr$offset$gds"> { 271 let Constraints = !if(HasTiedOutput, "$vdst = $vdst_in", ""); 272 let DisableEncoding = !if(HasTiedOutput, "$vdst_in", ""); 273 let has_data0 = 0; 274 let has_data1 = 0; 275} 276 277multiclass DS_1A_RET_mc<string opName, RegisterClass rc = VGPR_32, bit HasTiedOutput = 0, Operand ofs = offset> { 278 def "" : DS_1A_RET<opName, rc, HasTiedOutput, ofs>; 279 280 let has_m0_read = 0 in { 281 def _gfx9 : DS_1A_RET<opName, rc, HasTiedOutput, ofs>; 282 } 283} 284 285class DS_1A_RET_Tied<string opName, RegisterClass rc = VGPR_32> : 286 DS_1A_RET<opName, rc, 1>; 287 288class DS_1A_Off8_RET <string opName, RegisterClass rc = VGPR_32> 289: DS_Pseudo<opName, 290 (outs getLdStRegisterOperand<rc>.ret:$vdst), 291 (ins VGPR_32:$addr, offset0:$offset0, offset1:$offset1, gds:$gds), 292 " $vdst, $addr$offset0$offset1$gds"> { 293 294 let has_offset = 0; 295 let has_data0 = 0; 296 let has_data1 = 0; 297 let AsmMatchConverter = "cvtDSOffset01"; 298} 299 300multiclass DS_1A_Off8_RET_mc <string opName, RegisterClass rc = VGPR_32> { 301 def "" : DS_1A_Off8_RET<opName, rc>; 302 303 let has_m0_read = 0 in { 304 def _gfx9 : DS_1A_Off8_RET<opName, rc>; 305 } 306} 307 308class DS_1A_RET_GDS <string opName> : DS_Pseudo<opName, 309 (outs getLdStRegisterOperand<VGPR_32>.ret:$vdst), 310 (ins VGPR_32:$addr, offset:$offset), 311 " $vdst, $addr$offset gds"> { 312 313 let has_data0 = 0; 314 let has_data1 = 0; 315 let has_gds = 0; 316 let gdsValue = 1; 317 let AsmMatchConverter = "cvtDSGds"; 318} 319 320class DS_0A_RET <string opName> : DS_Pseudo<opName, 321 (outs getLdStRegisterOperand<VGPR_32>.ret:$vdst), 322 (ins offset:$offset, gds:$gds), 323 " $vdst$offset$gds"> { 324 325 let mayLoad = 1; 326 let mayStore = 1; 327 328 let has_addr = 0; 329 let has_data0 = 0; 330 let has_data1 = 0; 331} 332 333class DS_1A <string opName> : DS_Pseudo<opName, 334 (outs), 335 (ins VGPR_32:$addr, offset:$offset, gds:$gds), 336 " $addr$offset$gds"> { 337 338 let mayLoad = 1; 339 let mayStore = 1; 340 341 let has_vdst = 0; 342 let has_data0 = 0; 343 let has_data1 = 0; 344} 345 346multiclass DS_1A_mc <string opName> { 347 def "" : DS_1A<opName>; 348 349 let has_m0_read = 0 in { 350 def _gfx9 : DS_1A<opName>; 351 } 352} 353 354 355class DS_GWS <string opName, dag ins, string asmOps> 356: DS_Pseudo<opName, (outs), ins, asmOps> { 357 358 let has_vdst = 0; 359 let has_addr = 0; 360 let has_data0 = 0; 361 let has_data1 = 0; 362 363 let has_gds = 0; 364 let gdsValue = 1; 365 let AsmMatchConverter = "cvtDSGds"; 366} 367 368class DS_GWS_0D <string opName> 369: DS_GWS<opName, 370 (ins offset:$offset), "$offset gds"> { 371 let hasSideEffects = 1; 372} 373 374class DS_GWS_1D <string opName> 375: DS_GWS<opName, 376 (ins getLdStRegisterOperand<VGPR_32>.ret:$data0, offset:$offset), 377 " $data0$offset gds"> { 378 379 let has_gws_data0 = 1; 380 let hasSideEffects = 1; 381} 382 383class DS_VOID <string opName> : DS_Pseudo<opName, 384 (outs), (ins), ""> { 385 let mayLoad = 0; 386 let mayStore = 0; 387 let hasSideEffects = 1; 388 let UseNamedOperandTable = 0; 389 let AsmMatchConverter = ""; 390 391 let has_vdst = 0; 392 let has_addr = 0; 393 let has_data0 = 0; 394 let has_data1 = 0; 395 let has_offset = 0; 396 let has_offset0 = 0; 397 let has_offset1 = 0; 398 let has_gds = 0; 399} 400 401class DS_1A1D_PERMUTE <string opName, SDPatternOperator node = null_frag, 402 RegisterOperand data_op = getLdStRegisterOperand<VGPR_32>.ret> 403: DS_Pseudo<opName, 404 (outs data_op:$vdst), 405 (ins VGPR_32:$addr, data_op:$data0, offset:$offset), 406 " $vdst, $addr, $data0$offset", 407 [(set i32:$vdst, 408 (node (DS1Addr1Offset i32:$addr, i16:$offset), i32:$data0))] > { 409 410 let mayLoad = 0; 411 let mayStore = 0; 412 let isConvergent = 1; 413 414 let has_data1 = 0; 415 let has_gds = 0; 416} 417 418defm DS_ADD_U32 : DS_1A1D_NORET_mc<"ds_add_u32">; 419defm DS_SUB_U32 : DS_1A1D_NORET_mc<"ds_sub_u32">; 420defm DS_RSUB_U32 : DS_1A1D_NORET_mc<"ds_rsub_u32">; 421defm DS_INC_U32 : DS_1A1D_NORET_mc<"ds_inc_u32">; 422defm DS_DEC_U32 : DS_1A1D_NORET_mc<"ds_dec_u32">; 423defm DS_MIN_I32 : DS_1A1D_NORET_mc<"ds_min_i32">; 424defm DS_MAX_I32 : DS_1A1D_NORET_mc<"ds_max_i32">; 425defm DS_MIN_U32 : DS_1A1D_NORET_mc<"ds_min_u32">; 426defm DS_MAX_U32 : DS_1A1D_NORET_mc<"ds_max_u32">; 427defm DS_AND_B32 : DS_1A1D_NORET_mc<"ds_and_b32">; 428defm DS_OR_B32 : DS_1A1D_NORET_mc<"ds_or_b32">; 429defm DS_XOR_B32 : DS_1A1D_NORET_mc<"ds_xor_b32">; 430 431let SubtargetPredicate = HasLDSFPAtomicAdd in { 432defm DS_ADD_F32 : DS_1A1D_NORET_mc<"ds_add_f32">; 433} 434 435defm DS_MIN_F32 : DS_1A1D_NORET_mc<"ds_min_f32">; 436defm DS_MAX_F32 : DS_1A1D_NORET_mc<"ds_max_f32">; 437 438let mayLoad = 0 in { 439defm DS_WRITE_B8 : DS_1A1D_NORET_mc<"ds_write_b8">; 440defm DS_WRITE_B16 : DS_1A1D_NORET_mc<"ds_write_b16">; 441defm DS_WRITE_B32 : DS_1A1D_NORET_mc<"ds_write_b32">; 442defm DS_WRITE2_B32 : DS_1A2D_Off8_NORET_mc<"ds_write2_b32">; 443defm DS_WRITE2ST64_B32: DS_1A2D_Off8_NORET_mc<"ds_write2st64_b32">; 444 445 446let has_m0_read = 0 in { 447 448let SubtargetPredicate = HasD16LoadStore in { 449def DS_WRITE_B8_D16_HI : DS_1A1D_NORET<"ds_write_b8_d16_hi">; 450def DS_WRITE_B16_D16_HI : DS_1A1D_NORET<"ds_write_b16_d16_hi">; 451} 452 453} // End has_m0_read = 0 454 455let SubtargetPredicate = HasDSAddTid in { 456def DS_WRITE_ADDTID_B32 : DS_0A1D_NORET<"ds_write_addtid_b32">; 457} 458 459} // End mayLoad = 0 460 461let SubtargetPredicate = isGFX90APlus in { 462 defm DS_ADD_F64 : DS_1A1D_NORET_mc_gfx9<"ds_add_f64", VReg_64>; 463 defm DS_ADD_RTN_F64 : DS_1A1D_RET_mc_gfx9<"ds_add_rtn_f64", VReg_64, "ds_add_f64">; 464} // End SubtargetPredicate = isGFX90APlus 465 466defm DS_MSKOR_B32 : DS_1A2D_NORET_mc<"ds_mskor_b32">; 467defm DS_CMPST_B32 : DS_1A2D_NORET_mc<"ds_cmpst_b32">; 468defm DS_CMPST_F32 : DS_1A2D_NORET_mc<"ds_cmpst_f32">; 469 470defm DS_ADD_U64 : DS_1A1D_NORET_mc<"ds_add_u64", VReg_64>; 471defm DS_SUB_U64 : DS_1A1D_NORET_mc<"ds_sub_u64", VReg_64>; 472defm DS_RSUB_U64 : DS_1A1D_NORET_mc<"ds_rsub_u64", VReg_64>; 473defm DS_INC_U64 : DS_1A1D_NORET_mc<"ds_inc_u64", VReg_64>; 474defm DS_DEC_U64 : DS_1A1D_NORET_mc<"ds_dec_u64", VReg_64>; 475defm DS_MIN_I64 : DS_1A1D_NORET_mc<"ds_min_i64", VReg_64>; 476defm DS_MAX_I64 : DS_1A1D_NORET_mc<"ds_max_i64", VReg_64>; 477defm DS_MIN_U64 : DS_1A1D_NORET_mc<"ds_min_u64", VReg_64>; 478defm DS_MAX_U64 : DS_1A1D_NORET_mc<"ds_max_u64", VReg_64>; 479defm DS_AND_B64 : DS_1A1D_NORET_mc<"ds_and_b64", VReg_64>; 480defm DS_OR_B64 : DS_1A1D_NORET_mc<"ds_or_b64", VReg_64>; 481defm DS_XOR_B64 : DS_1A1D_NORET_mc<"ds_xor_b64", VReg_64>; 482defm DS_MSKOR_B64 : DS_1A2D_NORET_mc<"ds_mskor_b64", VReg_64>; 483let mayLoad = 0 in { 484defm DS_WRITE_B64 : DS_1A1D_NORET_mc<"ds_write_b64", VReg_64>; 485defm DS_WRITE2_B64 : DS_1A2D_Off8_NORET_mc<"ds_write2_b64", VReg_64>; 486defm DS_WRITE2ST64_B64: DS_1A2D_Off8_NORET_mc<"ds_write2st64_b64", VReg_64>; 487} 488defm DS_CMPST_B64 : DS_1A2D_NORET_mc<"ds_cmpst_b64", VReg_64>; 489defm DS_CMPST_F64 : DS_1A2D_NORET_mc<"ds_cmpst_f64", VReg_64>; 490defm DS_MIN_F64 : DS_1A1D_NORET_mc<"ds_min_f64", VReg_64>; 491defm DS_MAX_F64 : DS_1A1D_NORET_mc<"ds_max_f64", VReg_64>; 492 493defm DS_ADD_RTN_U32 : DS_1A1D_RET_mc<"ds_add_rtn_u32", VGPR_32, "ds_add_u32">; 494 495let SubtargetPredicate = HasLDSFPAtomicAdd in { 496defm DS_ADD_RTN_F32 : DS_1A1D_RET_mc<"ds_add_rtn_f32", VGPR_32, "ds_add_f32">; 497} 498defm DS_SUB_RTN_U32 : DS_1A1D_RET_mc<"ds_sub_rtn_u32", VGPR_32, "ds_sub_u32">; 499defm DS_RSUB_RTN_U32 : DS_1A1D_RET_mc<"ds_rsub_rtn_u32", VGPR_32, "ds_rsub_u32">; 500defm DS_INC_RTN_U32 : DS_1A1D_RET_mc<"ds_inc_rtn_u32", VGPR_32, "ds_inc_u32">; 501defm DS_DEC_RTN_U32 : DS_1A1D_RET_mc<"ds_dec_rtn_u32", VGPR_32, "ds_dec_u32">; 502defm DS_MIN_RTN_I32 : DS_1A1D_RET_mc<"ds_min_rtn_i32", VGPR_32, "ds_min_i32">; 503defm DS_MAX_RTN_I32 : DS_1A1D_RET_mc<"ds_max_rtn_i32", VGPR_32, "ds_max_i32">; 504defm DS_MIN_RTN_U32 : DS_1A1D_RET_mc<"ds_min_rtn_u32", VGPR_32, "ds_min_u32">; 505defm DS_MAX_RTN_U32 : DS_1A1D_RET_mc<"ds_max_rtn_u32", VGPR_32, "ds_max_u32">; 506defm DS_AND_RTN_B32 : DS_1A1D_RET_mc<"ds_and_rtn_b32", VGPR_32, "ds_and_b32">; 507defm DS_OR_RTN_B32 : DS_1A1D_RET_mc<"ds_or_rtn_b32", VGPR_32, "ds_or_b32">; 508defm DS_XOR_RTN_B32 : DS_1A1D_RET_mc<"ds_xor_rtn_b32", VGPR_32, "ds_xor_b32">; 509defm DS_MSKOR_RTN_B32 : DS_1A2D_RET_mc<"ds_mskor_rtn_b32", VGPR_32, "ds_mskor_b32">; 510defm DS_CMPST_RTN_B32 : DS_1A2D_RET_mc<"ds_cmpst_rtn_b32", VGPR_32, "ds_cmpst_b32">; 511defm DS_CMPST_RTN_F32 : DS_1A2D_RET_mc<"ds_cmpst_rtn_f32", VGPR_32, "ds_cmpst_f32">; 512defm DS_MIN_RTN_F32 : DS_1A1D_RET_mc<"ds_min_rtn_f32", VGPR_32, "ds_min_f32">; 513defm DS_MAX_RTN_F32 : DS_1A1D_RET_mc<"ds_max_rtn_f32", VGPR_32, "ds_max_f32">; 514 515defm DS_WRXCHG_RTN_B32 : DS_1A1D_RET_mc<"ds_wrxchg_rtn_b32">; 516defm DS_WRXCHG2_RTN_B32 : DS_1A2D_Off8_RET_mc<"ds_wrxchg2_rtn_b32", VReg_64, VGPR_32>; 517defm DS_WRXCHG2ST64_RTN_B32 : DS_1A2D_Off8_RET_mc<"ds_wrxchg2st64_rtn_b32", VReg_64, VGPR_32>; 518 519defm DS_ADD_RTN_U64 : DS_1A1D_RET_mc<"ds_add_rtn_u64", VReg_64, "ds_add_u64">; 520defm DS_SUB_RTN_U64 : DS_1A1D_RET_mc<"ds_sub_rtn_u64", VReg_64, "ds_sub_u64">; 521defm DS_RSUB_RTN_U64 : DS_1A1D_RET_mc<"ds_rsub_rtn_u64", VReg_64, "ds_rsub_u64">; 522defm DS_INC_RTN_U64 : DS_1A1D_RET_mc<"ds_inc_rtn_u64", VReg_64, "ds_inc_u64">; 523defm DS_DEC_RTN_U64 : DS_1A1D_RET_mc<"ds_dec_rtn_u64", VReg_64, "ds_dec_u64">; 524defm DS_MIN_RTN_I64 : DS_1A1D_RET_mc<"ds_min_rtn_i64", VReg_64, "ds_min_i64">; 525defm DS_MAX_RTN_I64 : DS_1A1D_RET_mc<"ds_max_rtn_i64", VReg_64, "ds_max_i64">; 526defm DS_MIN_RTN_U64 : DS_1A1D_RET_mc<"ds_min_rtn_u64", VReg_64, "ds_min_u64">; 527defm DS_MAX_RTN_U64 : DS_1A1D_RET_mc<"ds_max_rtn_u64", VReg_64, "ds_max_u64">; 528defm DS_AND_RTN_B64 : DS_1A1D_RET_mc<"ds_and_rtn_b64", VReg_64, "ds_and_b64">; 529defm DS_OR_RTN_B64 : DS_1A1D_RET_mc<"ds_or_rtn_b64", VReg_64, "ds_or_b64">; 530defm DS_XOR_RTN_B64 : DS_1A1D_RET_mc<"ds_xor_rtn_b64", VReg_64, "ds_xor_b64">; 531defm DS_MSKOR_RTN_B64 : DS_1A2D_RET_mc<"ds_mskor_rtn_b64", VReg_64, "ds_mskor_b64">; 532defm DS_CMPST_RTN_B64 : DS_1A2D_RET_mc<"ds_cmpst_rtn_b64", VReg_64, "ds_cmpst_b64">; 533defm DS_CMPST_RTN_F64 : DS_1A2D_RET_mc<"ds_cmpst_rtn_f64", VReg_64, "ds_cmpst_f64">; 534defm DS_MIN_RTN_F64 : DS_1A1D_RET_mc<"ds_min_rtn_f64", VReg_64, "ds_min_f64">; 535defm DS_MAX_RTN_F64 : DS_1A1D_RET_mc<"ds_max_rtn_f64", VReg_64, "ds_max_f64">; 536 537defm DS_WRXCHG_RTN_B64 : DS_1A1D_RET_mc<"ds_wrxchg_rtn_b64", VReg_64>; 538defm DS_WRXCHG2_RTN_B64 : DS_1A2D_Off8_RET_mc<"ds_wrxchg2_rtn_b64", VReg_128, VReg_64>; 539defm DS_WRXCHG2ST64_RTN_B64 : DS_1A2D_Off8_RET_mc<"ds_wrxchg2st64_rtn_b64", VReg_128, VReg_64>; 540 541let isConvergent = 1, usesCustomInserter = 1 in { 542def DS_GWS_INIT : DS_GWS_1D<"ds_gws_init"> { 543 let mayLoad = 0; 544} 545def DS_GWS_SEMA_V : DS_GWS_0D<"ds_gws_sema_v">; 546def DS_GWS_SEMA_BR : DS_GWS_1D<"ds_gws_sema_br">; 547def DS_GWS_SEMA_P : DS_GWS_0D<"ds_gws_sema_p">; 548def DS_GWS_BARRIER : DS_GWS_1D<"ds_gws_barrier">; 549} 550 551let SubtargetPredicate = HasDsSrc2Insts in { 552def DS_ADD_SRC2_U32 : DS_1A<"ds_add_src2_u32">; 553def DS_SUB_SRC2_U32 : DS_1A<"ds_sub_src2_u32">; 554def DS_RSUB_SRC2_U32 : DS_1A<"ds_rsub_src2_u32">; 555def DS_INC_SRC2_U32 : DS_1A<"ds_inc_src2_u32">; 556def DS_DEC_SRC2_U32 : DS_1A<"ds_dec_src2_u32">; 557def DS_MIN_SRC2_I32 : DS_1A<"ds_min_src2_i32">; 558def DS_MAX_SRC2_I32 : DS_1A<"ds_max_src2_i32">; 559def DS_MIN_SRC2_U32 : DS_1A<"ds_min_src2_u32">; 560def DS_MAX_SRC2_U32 : DS_1A<"ds_max_src2_u32">; 561def DS_AND_SRC2_B32 : DS_1A<"ds_and_src2_b32">; 562def DS_OR_SRC2_B32 : DS_1A<"ds_or_src2_b32">; 563def DS_XOR_SRC2_B32 : DS_1A<"ds_xor_src2_b32">; 564def DS_MIN_SRC2_F32 : DS_1A<"ds_min_src2_f32">; 565def DS_MAX_SRC2_F32 : DS_1A<"ds_max_src2_f32">; 566 567def DS_ADD_SRC2_U64 : DS_1A<"ds_add_src2_u64">; 568def DS_SUB_SRC2_U64 : DS_1A<"ds_sub_src2_u64">; 569def DS_RSUB_SRC2_U64 : DS_1A<"ds_rsub_src2_u64">; 570def DS_INC_SRC2_U64 : DS_1A<"ds_inc_src2_u64">; 571def DS_DEC_SRC2_U64 : DS_1A<"ds_dec_src2_u64">; 572def DS_MIN_SRC2_I64 : DS_1A<"ds_min_src2_i64">; 573def DS_MAX_SRC2_I64 : DS_1A<"ds_max_src2_i64">; 574def DS_MIN_SRC2_U64 : DS_1A<"ds_min_src2_u64">; 575def DS_MAX_SRC2_U64 : DS_1A<"ds_max_src2_u64">; 576def DS_AND_SRC2_B64 : DS_1A<"ds_and_src2_b64">; 577def DS_OR_SRC2_B64 : DS_1A<"ds_or_src2_b64">; 578def DS_XOR_SRC2_B64 : DS_1A<"ds_xor_src2_b64">; 579def DS_MIN_SRC2_F64 : DS_1A<"ds_min_src2_f64">; 580def DS_MAX_SRC2_F64 : DS_1A<"ds_max_src2_f64">; 581 582def DS_WRITE_SRC2_B32 : DS_1A<"ds_write_src2_b32">; 583def DS_WRITE_SRC2_B64 : DS_1A<"ds_write_src2_b64">; 584} // End SubtargetPredicate = HasDsSrc2Insts 585 586let Uses = [EXEC], mayLoad = 0, mayStore = 0, isConvergent = 1 in { 587def DS_SWIZZLE_B32 : DS_1A_RET <"ds_swizzle_b32", VGPR_32, 0, SwizzleImm>; 588} 589 590let mayStore = 0 in { 591defm DS_READ_I8 : DS_1A_RET_mc<"ds_read_i8">; 592defm DS_READ_U8 : DS_1A_RET_mc<"ds_read_u8">; 593defm DS_READ_I16 : DS_1A_RET_mc<"ds_read_i16">; 594defm DS_READ_U16 : DS_1A_RET_mc<"ds_read_u16">; 595defm DS_READ_B32 : DS_1A_RET_mc<"ds_read_b32">; 596defm DS_READ_B64 : DS_1A_RET_mc<"ds_read_b64", VReg_64>; 597 598defm DS_READ2_B32 : DS_1A_Off8_RET_mc<"ds_read2_b32", VReg_64>; 599defm DS_READ2ST64_B32: DS_1A_Off8_RET_mc<"ds_read2st64_b32", VReg_64>; 600 601defm DS_READ2_B64 : DS_1A_Off8_RET_mc<"ds_read2_b64", VReg_128>; 602defm DS_READ2ST64_B64: DS_1A_Off8_RET_mc<"ds_read2st64_b64", VReg_128>; 603 604let has_m0_read = 0 in { 605let SubtargetPredicate = HasD16LoadStore in { 606def DS_READ_U8_D16 : DS_1A_RET_Tied<"ds_read_u8_d16">; 607def DS_READ_U8_D16_HI : DS_1A_RET_Tied<"ds_read_u8_d16_hi">; 608def DS_READ_I8_D16 : DS_1A_RET_Tied<"ds_read_i8_d16">; 609def DS_READ_I8_D16_HI : DS_1A_RET_Tied<"ds_read_i8_d16_hi">; 610def DS_READ_U16_D16 : DS_1A_RET_Tied<"ds_read_u16_d16">; 611def DS_READ_U16_D16_HI : DS_1A_RET_Tied<"ds_read_u16_d16_hi">; 612} 613} // End has_m0_read = 0 614 615let SubtargetPredicate = HasDSAddTid in { 616def DS_READ_ADDTID_B32 : DS_0A_RET<"ds_read_addtid_b32">; 617} 618 619} // End mayStore = 0 620 621def DS_CONSUME : DS_0A_RET<"ds_consume">; 622def DS_APPEND : DS_0A_RET<"ds_append">; 623def DS_ORDERED_COUNT : DS_1A_RET_GDS<"ds_ordered_count">; 624 625//===----------------------------------------------------------------------===// 626// Instruction definitions for CI and newer. 627//===----------------------------------------------------------------------===// 628 629let SubtargetPredicate = isGFX7Plus in { 630 631defm DS_WRAP_RTN_B32 : DS_1A2D_RET_mc<"ds_wrap_rtn_b32", VGPR_32>; 632defm DS_CONDXCHG32_RTN_B64 : DS_1A1D_RET_mc<"ds_condxchg32_rtn_b64", VReg_64>; 633 634let isConvergent = 1, usesCustomInserter = 1 in { 635def DS_GWS_SEMA_RELEASE_ALL : DS_GWS_0D<"ds_gws_sema_release_all">; 636} 637 638let mayStore = 0 in { 639defm DS_READ_B96 : DS_1A_RET_mc<"ds_read_b96", VReg_96>; 640defm DS_READ_B128: DS_1A_RET_mc<"ds_read_b128", VReg_128>; 641} // End mayStore = 0 642 643let mayLoad = 0 in { 644defm DS_WRITE_B96 : DS_1A1D_NORET_mc<"ds_write_b96", VReg_96>; 645defm DS_WRITE_B128 : DS_1A1D_NORET_mc<"ds_write_b128", VReg_128>; 646} // End mayLoad = 0 647 648def DS_NOP : DS_VOID<"ds_nop">; 649 650} // let SubtargetPredicate = isGFX7Plus 651 652//===----------------------------------------------------------------------===// 653// Instruction definitions for VI and newer. 654//===----------------------------------------------------------------------===// 655 656let SubtargetPredicate = isGFX8Plus in { 657 658let Uses = [EXEC] in { 659def DS_PERMUTE_B32 : DS_1A1D_PERMUTE <"ds_permute_b32", 660 int_amdgcn_ds_permute>; 661def DS_BPERMUTE_B32 : DS_1A1D_PERMUTE <"ds_bpermute_b32", 662 int_amdgcn_ds_bpermute>; 663} 664 665} // let SubtargetPredicate = isGFX8Plus 666 667let SubtargetPredicate = HasLDSFPAtomicAdd, OtherPredicates = [HasDsSrc2Insts] in { 668def DS_ADD_SRC2_F32 : DS_1A<"ds_add_src2_f32">; 669} 670 671//===----------------------------------------------------------------------===// 672// DS Patterns 673//===----------------------------------------------------------------------===// 674 675def : GCNPat < 676 (int_amdgcn_ds_swizzle i32:$src, timm:$offset16), 677 (DS_SWIZZLE_B32 VGPR_32:$src, (as_i16timm $offset16), (i1 0)) 678>; 679 680class DSReadPat <DS_Pseudo inst, ValueType vt, PatFrag frag, int gds=0> : GCNPat < 681 (vt (frag (DS1Addr1Offset i32:$ptr, i16:$offset))), 682 (inst $ptr, offset:$offset, (i1 gds)) 683>; 684 685multiclass DSReadPat_mc<DS_Pseudo inst, ValueType vt, string frag> { 686 687 let OtherPredicates = [LDSRequiresM0Init] in { 688 def : DSReadPat<inst, vt, !cast<PatFrag>(frag#"_m0")>; 689 } 690 691 let OtherPredicates = [NotLDSRequiresM0Init] in { 692 def : DSReadPat<!cast<DS_Pseudo>(!cast<string>(inst)#"_gfx9"), vt, !cast<PatFrag>(frag)>; 693 } 694} 695 696class DSReadPat_D16 <DS_Pseudo inst, PatFrag frag, ValueType vt> : GCNPat < 697 (frag (DS1Addr1Offset i32:$ptr, i16:$offset), vt:$in), 698 (inst $ptr, offset:$offset, (i1 0), $in) 699>; 700 701defm : DSReadPat_mc <DS_READ_I8, i32, "sextloadi8_local">; 702defm : DSReadPat_mc <DS_READ_I8, i16, "sextloadi8_local">; 703defm : DSReadPat_mc <DS_READ_U8, i32, "extloadi8_local">; 704defm : DSReadPat_mc <DS_READ_U8, i32, "zextloadi8_local">; 705defm : DSReadPat_mc <DS_READ_U8, i16, "extloadi8_local">; 706defm : DSReadPat_mc <DS_READ_U8, i16, "zextloadi8_local">; 707defm : DSReadPat_mc <DS_READ_I16, i32, "sextloadi16_local">; 708defm : DSReadPat_mc <DS_READ_I16, i32, "sextloadi16_local">; 709defm : DSReadPat_mc <DS_READ_U16, i32, "extloadi16_local">; 710defm : DSReadPat_mc <DS_READ_U16, i32, "zextloadi16_local">; 711defm : DSReadPat_mc <DS_READ_U16, i16, "load_local">; 712 713foreach vt = Reg32Types.types in { 714defm : DSReadPat_mc <DS_READ_B32, vt, "load_local">; 715} 716 717defm : DSReadPat_mc <DS_READ_U8, i16, "atomic_load_8_local">; 718defm : DSReadPat_mc <DS_READ_U8, i32, "atomic_load_8_local">; 719defm : DSReadPat_mc <DS_READ_U16, i16, "atomic_load_16_local">; 720defm : DSReadPat_mc <DS_READ_U16, i32, "atomic_load_16_local">; 721defm : DSReadPat_mc <DS_READ_B32, i32, "atomic_load_32_local">; 722defm : DSReadPat_mc <DS_READ_B64, i64, "atomic_load_64_local">; 723 724let OtherPredicates = [D16PreservesUnusedBits] in { 725def : DSReadPat_D16<DS_READ_U16_D16_HI, load_d16_hi_local, v2i16>; 726def : DSReadPat_D16<DS_READ_U16_D16_HI, load_d16_hi_local, v2f16>; 727def : DSReadPat_D16<DS_READ_U8_D16_HI, az_extloadi8_d16_hi_local, v2i16>; 728def : DSReadPat_D16<DS_READ_U8_D16_HI, az_extloadi8_d16_hi_local, v2f16>; 729def : DSReadPat_D16<DS_READ_I8_D16_HI, sextloadi8_d16_hi_local, v2i16>; 730def : DSReadPat_D16<DS_READ_I8_D16_HI, sextloadi8_d16_hi_local, v2f16>; 731 732def : DSReadPat_D16<DS_READ_U16_D16, load_d16_lo_local, v2i16>; 733def : DSReadPat_D16<DS_READ_U16_D16, load_d16_lo_local, v2f16>; 734def : DSReadPat_D16<DS_READ_U8_D16, az_extloadi8_d16_lo_local, v2i16>; 735def : DSReadPat_D16<DS_READ_U8_D16, az_extloadi8_d16_lo_local, v2f16>; 736def : DSReadPat_D16<DS_READ_I8_D16, sextloadi8_d16_lo_local, v2i16>; 737def : DSReadPat_D16<DS_READ_I8_D16, sextloadi8_d16_lo_local, v2f16>; 738} 739 740class DSWritePat <DS_Pseudo inst, ValueType vt, PatFrag frag, int gds=0> : GCNPat < 741 (frag vt:$value, (DS1Addr1Offset i32:$ptr, i16:$offset)), 742 (inst $ptr, getVregSrcForVT<vt>.ret:$value, offset:$offset, (i1 gds)) 743>; 744 745multiclass DSWritePat_mc <DS_Pseudo inst, ValueType vt, string frag> { 746 let OtherPredicates = [LDSRequiresM0Init] in { 747 def : DSWritePat<inst, vt, !cast<PatFrag>(frag#"_m0")>; 748 } 749 750 let OtherPredicates = [NotLDSRequiresM0Init] in { 751 def : DSWritePat<!cast<DS_Pseudo>(!cast<string>(inst)#"_gfx9"), vt, !cast<PatFrag>(frag)>; 752 } 753} 754 755// Irritatingly, atomic_store reverses the order of operands from a 756// normal store. 757class DSAtomicWritePat <DS_Pseudo inst, ValueType vt, PatFrag frag> : GCNPat < 758 (frag (DS1Addr1Offset i32:$ptr, i16:$offset), vt:$value), 759 (inst $ptr, getVregSrcForVT<vt>.ret:$value, offset:$offset, (i1 0)) 760>; 761 762multiclass DSAtomicWritePat_mc <DS_Pseudo inst, ValueType vt, string frag> { 763 let OtherPredicates = [LDSRequiresM0Init] in { 764 def : DSAtomicWritePat<inst, vt, !cast<PatFrag>(frag#"_m0")>; 765 } 766 767 let OtherPredicates = [NotLDSRequiresM0Init] in { 768 def : DSAtomicWritePat<!cast<DS_Pseudo>(!cast<string>(inst)#"_gfx9"), vt, !cast<PatFrag>(frag)>; 769 } 770} 771 772defm : DSWritePat_mc <DS_WRITE_B8, i32, "truncstorei8_local">; 773defm : DSWritePat_mc <DS_WRITE_B16, i32, "truncstorei16_local">; 774defm : DSWritePat_mc <DS_WRITE_B8, i16, "truncstorei8_local">; 775defm : DSWritePat_mc <DS_WRITE_B16, i16, "store_local">; 776 777foreach vt = Reg32Types.types in { 778defm : DSWritePat_mc <DS_WRITE_B32, vt, "store_local">; 779} 780 781defm : DSAtomicWritePat_mc <DS_WRITE_B8, i16, "atomic_store_local_8">; 782defm : DSAtomicWritePat_mc <DS_WRITE_B8, i32, "atomic_store_local_8">; 783defm : DSAtomicWritePat_mc <DS_WRITE_B16, i16, "atomic_store_local_16">; 784defm : DSAtomicWritePat_mc <DS_WRITE_B16, i32, "atomic_store_local_16">; 785defm : DSAtomicWritePat_mc <DS_WRITE_B32, i32, "atomic_store_local_32">; 786defm : DSAtomicWritePat_mc <DS_WRITE_B64, i64, "atomic_store_local_64">; 787 788let OtherPredicates = [D16PreservesUnusedBits] in { 789def : DSWritePat <DS_WRITE_B16_D16_HI, i32, store_hi16_local>; 790def : DSWritePat <DS_WRITE_B8_D16_HI, i32, truncstorei8_hi16_local>; 791} 792 793class DS64Bit4ByteAlignedReadPat<DS_Pseudo inst, ValueType vt, PatFrag frag> : GCNPat < 794 (vt:$value (frag (DS64Bit4ByteAligned i32:$ptr, i8:$offset0, i8:$offset1))), 795 (inst $ptr, $offset0, $offset1, (i1 0)) 796>; 797 798class DS64Bit4ByteAlignedWritePat<DS_Pseudo inst, ValueType vt, PatFrag frag> : GCNPat< 799 (frag vt:$value, (DS64Bit4ByteAligned i32:$ptr, i8:$offset0, i8:$offset1)), 800 (inst $ptr, (i32 (EXTRACT_SUBREG VReg_64:$value, sub0)), 801 (i32 (EXTRACT_SUBREG VReg_64:$value, sub1)), $offset0, $offset1, 802 (i1 0)) 803>; 804 805class DS128Bit8ByteAlignedReadPat<DS_Pseudo inst, ValueType vt, PatFrag frag> : GCNPat < 806 (vt:$value (frag (DS128Bit8ByteAligned i32:$ptr, i8:$offset0, i8:$offset1))), 807 (inst $ptr, $offset0, $offset1, (i1 0)) 808>; 809 810class DS128Bit8ByteAlignedWritePat<DS_Pseudo inst, ValueType vt, PatFrag frag> : GCNPat< 811 (frag vt:$value, (DS128Bit8ByteAligned i32:$ptr, i8:$offset0, i8:$offset1)), 812 (inst $ptr, (i64 (EXTRACT_SUBREG VReg_128:$value, sub0_sub1)), 813 (i64 (EXTRACT_SUBREG VReg_128:$value, sub2_sub3)), $offset0, $offset1, 814 (i1 0)) 815>; 816 817multiclass DS64Bit4ByteAlignedPat_mc<ValueType vt> { 818 let OtherPredicates = [LDSRequiresM0Init, isGFX7Plus] in { 819 def : DS64Bit4ByteAlignedReadPat<DS_READ2_B32, vt, load_local_m0>; 820 def : DS64Bit4ByteAlignedWritePat<DS_WRITE2_B32, vt, store_local_m0>; 821 } 822 823 let OtherPredicates = [NotLDSRequiresM0Init] in { 824 def : DS64Bit4ByteAlignedReadPat<DS_READ2_B32_gfx9, vt, load_local>; 825 def : DS64Bit4ByteAlignedWritePat<DS_WRITE2_B32_gfx9, vt, store_local>; 826 } 827} 828 829multiclass DS128Bit8ByteAlignedPat_mc<ValueType vt> { 830 let OtherPredicates = [LDSRequiresM0Init, isGFX7Plus] in { 831 def : DS128Bit8ByteAlignedReadPat<DS_READ2_B64, vt, load_local_m0>; 832 def : DS128Bit8ByteAlignedWritePat<DS_WRITE2_B64, vt, store_local_m0>; 833 } 834 835 let OtherPredicates = [NotLDSRequiresM0Init] in { 836 def : DS128Bit8ByteAlignedReadPat<DS_READ2_B64_gfx9, vt, load_local>; 837 def : DS128Bit8ByteAlignedWritePat<DS_WRITE2_B64_gfx9, vt, store_local>; 838 } 839} 840 841// v2i32 loads are split into i32 loads on SI during lowering, due to a bug 842// related to bounds checking. 843foreach vt = VReg_64.RegTypes in { 844defm : DS64Bit4ByteAlignedPat_mc<vt>; 845} 846 847foreach vt = VReg_128.RegTypes in { 848defm : DS128Bit8ByteAlignedPat_mc<vt>; 849} 850 851// Prefer ds_read over ds_read2 and ds_write over ds_write2, all other things 852// being equal, because it has a larger immediate offset range. 853let AddedComplexity = 100 in { 854 855foreach vt = VReg_64.RegTypes in { 856defm : DSReadPat_mc <DS_READ_B64, vt, "load_align8_local">; 857defm : DSWritePat_mc <DS_WRITE_B64, vt, "store_align8_local">; 858} 859 860let SubtargetPredicate = isGFX7Plus in { 861 862foreach vt = VReg_96.RegTypes in { 863defm : DSReadPat_mc <DS_READ_B96, vt, "load_align16_local">; 864defm : DSWritePat_mc <DS_WRITE_B96, vt, "store_align16_local">; 865} 866 867foreach vt = VReg_128.RegTypes in { 868defm : DSReadPat_mc <DS_READ_B128, vt, "load_align16_local">; 869defm : DSWritePat_mc <DS_WRITE_B128, vt, "store_align16_local">; 870} 871 872let SubtargetPredicate = HasUnalignedAccessMode in { 873 874// FIXME: From performance point of view, is ds_read_b96/ds_write_b96 better choice 875// for unaligned accesses? 876foreach vt = VReg_96.RegTypes in { 877defm : DSReadPat_mc <DS_READ_B96, vt, "load_local">; 878defm : DSWritePat_mc <DS_WRITE_B96, vt, "store_local">; 879} 880 881// For performance reasons, *do not* select ds_read_b128/ds_write_b128 for unaligned 882// accesses. 883 884} // End SubtargetPredicate = HasUnalignedAccessMode 885 886} // End SubtargetPredicate = isGFX7Plus 887 888} // End AddedComplexity = 100 889 890class DSAtomicRetPat<DS_Pseudo inst, ValueType vt, PatFrag frag, bit gds=0> : GCNPat < 891 (frag (DS1Addr1Offset i32:$ptr, i16:$offset), vt:$value), 892 (inst $ptr, getVregSrcForVT<vt>.ret:$value, offset:$offset, (i1 gds)) 893>; 894 895multiclass DSAtomicRetPat_mc<DS_Pseudo inst, ValueType vt, string frag> { 896 let OtherPredicates = [LDSRequiresM0Init] in { 897 def : DSAtomicRetPat<inst, vt, !cast<PatFrag>(frag#"_local_m0_"#vt.Size)>; 898 } 899 900 let OtherPredicates = [NotLDSRequiresM0Init] in { 901 def : DSAtomicRetPat<!cast<DS_Pseudo>(!cast<string>(inst)#"_gfx9"), vt, 902 !cast<PatFrag>(frag#"_local_"#vt.Size)>; 903 } 904 905 def : DSAtomicRetPat<inst, vt, !cast<PatFrag>(frag#"_region_m0_"#vt.Size), 1>; 906} 907 908 909 910class DSAtomicCmpXChg<DS_Pseudo inst, ValueType vt, PatFrag frag, bit gds=0> : GCNPat < 911 (frag (DS1Addr1Offset i32:$ptr, i16:$offset), vt:$cmp, vt:$swap), 912 (inst $ptr, getVregSrcForVT<vt>.ret:$cmp, getVregSrcForVT<vt>.ret:$swap, offset:$offset, (i1 gds)) 913>; 914 915multiclass DSAtomicCmpXChg_mc<DS_Pseudo inst, ValueType vt, string frag> { 916 let OtherPredicates = [LDSRequiresM0Init] in { 917 def : DSAtomicCmpXChg<inst, vt, !cast<PatFrag>(frag#"_local_m0_"#vt.Size)>; 918 } 919 920 let OtherPredicates = [NotLDSRequiresM0Init] in { 921 def : DSAtomicCmpXChg<!cast<DS_Pseudo>(!cast<string>(inst)#"_gfx9"), vt, 922 !cast<PatFrag>(frag#"_local_"#vt.Size)>; 923 } 924 925 def : DSAtomicCmpXChg<inst, vt, !cast<PatFrag>(frag#"_region_m0_"#vt.Size), 1>; 926} 927 928 929 930// 32-bit atomics. 931defm : DSAtomicRetPat_mc<DS_WRXCHG_RTN_B32, i32, "atomic_swap">; 932defm : DSAtomicRetPat_mc<DS_ADD_RTN_U32, i32, "atomic_load_add">; 933defm : DSAtomicRetPat_mc<DS_SUB_RTN_U32, i32, "atomic_load_sub">; 934defm : DSAtomicRetPat_mc<DS_INC_RTN_U32, i32, "atomic_inc">; 935defm : DSAtomicRetPat_mc<DS_DEC_RTN_U32, i32, "atomic_dec">; 936defm : DSAtomicRetPat_mc<DS_AND_RTN_B32, i32, "atomic_load_and">; 937defm : DSAtomicRetPat_mc<DS_OR_RTN_B32, i32, "atomic_load_or">; 938defm : DSAtomicRetPat_mc<DS_XOR_RTN_B32, i32, "atomic_load_xor">; 939defm : DSAtomicRetPat_mc<DS_MIN_RTN_I32, i32, "atomic_load_min">; 940defm : DSAtomicRetPat_mc<DS_MAX_RTN_I32, i32, "atomic_load_max">; 941defm : DSAtomicRetPat_mc<DS_MIN_RTN_U32, i32, "atomic_load_umin">; 942defm : DSAtomicRetPat_mc<DS_MAX_RTN_U32, i32, "atomic_load_umax">; 943defm : DSAtomicRetPat_mc<DS_MIN_RTN_F32, f32, "atomic_load_fmin">; 944defm : DSAtomicRetPat_mc<DS_MAX_RTN_F32, f32, "atomic_load_fmax">; 945defm : DSAtomicCmpXChg_mc<DS_CMPST_RTN_B32, i32, "atomic_cmp_swap">; 946 947let SubtargetPredicate = HasLDSFPAtomicAdd in { 948defm : DSAtomicRetPat_mc<DS_ADD_RTN_F32, f32, "atomic_load_fadd">; 949} 950 951// 64-bit atomics. 952defm : DSAtomicRetPat_mc<DS_WRXCHG_RTN_B64, i64, "atomic_swap">; 953defm : DSAtomicRetPat_mc<DS_ADD_RTN_U64, i64, "atomic_load_add">; 954defm : DSAtomicRetPat_mc<DS_SUB_RTN_U64, i64, "atomic_load_sub">; 955defm : DSAtomicRetPat_mc<DS_INC_RTN_U64, i64, "atomic_inc">; 956defm : DSAtomicRetPat_mc<DS_DEC_RTN_U64, i64, "atomic_dec">; 957defm : DSAtomicRetPat_mc<DS_AND_RTN_B64, i64, "atomic_load_and">; 958defm : DSAtomicRetPat_mc<DS_OR_RTN_B64, i64, "atomic_load_or">; 959defm : DSAtomicRetPat_mc<DS_XOR_RTN_B64, i64, "atomic_load_xor">; 960defm : DSAtomicRetPat_mc<DS_MIN_RTN_I64, i64, "atomic_load_min">; 961defm : DSAtomicRetPat_mc<DS_MAX_RTN_I64, i64, "atomic_load_max">; 962defm : DSAtomicRetPat_mc<DS_MIN_RTN_U64, i64, "atomic_load_umin">; 963defm : DSAtomicRetPat_mc<DS_MAX_RTN_U64, i64, "atomic_load_umax">; 964defm : DSAtomicRetPat_mc<DS_MIN_RTN_F64, f64, "atomic_load_fmin">; 965defm : DSAtomicRetPat_mc<DS_MAX_RTN_F64, f64, "atomic_load_fmax">; 966 967defm : DSAtomicCmpXChg_mc<DS_CMPST_RTN_B64, i64, "atomic_cmp_swap">; 968 969let SubtargetPredicate = isGFX90APlus in { 970def : DSAtomicRetPat<DS_ADD_RTN_F64, f64, atomic_load_fadd_local_64>; 971} 972 973def : Pat < 974 (SIds_ordered_count i32:$value, i16:$offset), 975 (DS_ORDERED_COUNT $value, (as_i16imm $offset)) 976>; 977 978//===----------------------------------------------------------------------===// 979// Target-specific instruction encodings. 980//===----------------------------------------------------------------------===// 981 982//===----------------------------------------------------------------------===// 983// Base ENC_DS for GFX6, GFX7, GFX10. 984//===----------------------------------------------------------------------===// 985 986class Base_DS_Real_gfx6_gfx7_gfx10<bits<8> op, DS_Pseudo ps, int ef> : 987 DS_Real<ps>, SIMCInstr <ps.Mnemonic, ef> { 988 989 let Inst{7-0} = !if(ps.has_offset0, offset0, 0); 990 let Inst{15-8} = !if(ps.has_offset1, offset1, 0); 991 let Inst{17} = !if(ps.has_gds, gds, ps.gdsValue); 992 let Inst{25-18} = op; 993 let Inst{31-26} = 0x36; 994 let Inst{39-32} = !if(ps.has_addr, addr, !if(ps.has_gws_data0, data0{7-0}, 0)); 995 let Inst{47-40} = !if(ps.has_data0, data0{7-0}, 0); 996 let Inst{55-48} = !if(ps.has_data1, data1{7-0}, 0); 997 let Inst{63-56} = !if(ps.has_vdst, vdst{7-0}, 0); 998} 999 1000//===----------------------------------------------------------------------===// 1001// GFX10. 1002//===----------------------------------------------------------------------===// 1003 1004let AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in { 1005 multiclass DS_Real_gfx10<bits<8> op> { 1006 def _gfx10 : Base_DS_Real_gfx6_gfx7_gfx10<op, !cast<DS_Pseudo>(NAME), 1007 SIEncodingFamily.GFX10>; 1008 } 1009} // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" 1010 1011defm DS_ADD_F32 : DS_Real_gfx10<0x015>; 1012defm DS_ADD_RTN_F32 : DS_Real_gfx10<0x055>; 1013defm DS_ADD_SRC2_F32 : DS_Real_gfx10<0x095>; 1014defm DS_WRITE_B8_D16_HI : DS_Real_gfx10<0x0a0>; 1015defm DS_WRITE_B16_D16_HI : DS_Real_gfx10<0x0a1>; 1016defm DS_READ_U8_D16 : DS_Real_gfx10<0x0a2>; 1017defm DS_READ_U8_D16_HI : DS_Real_gfx10<0x0a3>; 1018defm DS_READ_I8_D16 : DS_Real_gfx10<0x0a4>; 1019defm DS_READ_I8_D16_HI : DS_Real_gfx10<0x0a5>; 1020defm DS_READ_U16_D16 : DS_Real_gfx10<0x0a6>; 1021defm DS_READ_U16_D16_HI : DS_Real_gfx10<0x0a7>; 1022defm DS_WRITE_ADDTID_B32 : DS_Real_gfx10<0x0b0>; 1023defm DS_READ_ADDTID_B32 : DS_Real_gfx10<0x0b1>; 1024defm DS_PERMUTE_B32 : DS_Real_gfx10<0x0b2>; 1025defm DS_BPERMUTE_B32 : DS_Real_gfx10<0x0b3>; 1026 1027//===----------------------------------------------------------------------===// 1028// GFX7, GFX10. 1029//===----------------------------------------------------------------------===// 1030 1031let AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7" in { 1032 multiclass DS_Real_gfx7<bits<8> op> { 1033 def _gfx7 : Base_DS_Real_gfx6_gfx7_gfx10<op, !cast<DS_Pseudo>(NAME), 1034 SIEncodingFamily.SI>; 1035 } 1036} // End AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7" 1037 1038multiclass DS_Real_gfx7_gfx10<bits<8> op> : 1039 DS_Real_gfx7<op>, DS_Real_gfx10<op>; 1040 1041// FIXME-GFX7: Add tests when upstreaming this part. 1042defm DS_GWS_SEMA_RELEASE_ALL : DS_Real_gfx7_gfx10<0x018>; 1043defm DS_WRAP_RTN_B32 : DS_Real_gfx7_gfx10<0x034>; 1044defm DS_CONDXCHG32_RTN_B64 : DS_Real_gfx7_gfx10<0x07e>; 1045defm DS_WRITE_B96 : DS_Real_gfx7_gfx10<0x0de>; 1046defm DS_WRITE_B128 : DS_Real_gfx7_gfx10<0x0df>; 1047defm DS_READ_B96 : DS_Real_gfx7_gfx10<0x0fe>; 1048defm DS_READ_B128 : DS_Real_gfx7_gfx10<0x0ff>; 1049 1050//===----------------------------------------------------------------------===// 1051// GFX6, GFX7, GFX10. 1052//===----------------------------------------------------------------------===// 1053 1054let AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in { 1055 multiclass DS_Real_gfx6_gfx7<bits<8> op> { 1056 def _gfx6_gfx7 : Base_DS_Real_gfx6_gfx7_gfx10<op, !cast<DS_Pseudo>(NAME), 1057 SIEncodingFamily.SI>; 1058 } 1059} // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" 1060 1061multiclass DS_Real_gfx6_gfx7_gfx10<bits<8> op> : 1062 DS_Real_gfx6_gfx7<op>, DS_Real_gfx10<op>; 1063 1064defm DS_ADD_U32 : DS_Real_gfx6_gfx7_gfx10<0x000>; 1065defm DS_SUB_U32 : DS_Real_gfx6_gfx7_gfx10<0x001>; 1066defm DS_RSUB_U32 : DS_Real_gfx6_gfx7_gfx10<0x002>; 1067defm DS_INC_U32 : DS_Real_gfx6_gfx7_gfx10<0x003>; 1068defm DS_DEC_U32 : DS_Real_gfx6_gfx7_gfx10<0x004>; 1069defm DS_MIN_I32 : DS_Real_gfx6_gfx7_gfx10<0x005>; 1070defm DS_MAX_I32 : DS_Real_gfx6_gfx7_gfx10<0x006>; 1071defm DS_MIN_U32 : DS_Real_gfx6_gfx7_gfx10<0x007>; 1072defm DS_MAX_U32 : DS_Real_gfx6_gfx7_gfx10<0x008>; 1073defm DS_AND_B32 : DS_Real_gfx6_gfx7_gfx10<0x009>; 1074defm DS_OR_B32 : DS_Real_gfx6_gfx7_gfx10<0x00a>; 1075defm DS_XOR_B32 : DS_Real_gfx6_gfx7_gfx10<0x00b>; 1076defm DS_MSKOR_B32 : DS_Real_gfx6_gfx7_gfx10<0x00c>; 1077defm DS_WRITE_B32 : DS_Real_gfx6_gfx7_gfx10<0x00d>; 1078defm DS_WRITE2_B32 : DS_Real_gfx6_gfx7_gfx10<0x00e>; 1079defm DS_WRITE2ST64_B32 : DS_Real_gfx6_gfx7_gfx10<0x00f>; 1080defm DS_CMPST_B32 : DS_Real_gfx6_gfx7_gfx10<0x010>; 1081defm DS_CMPST_F32 : DS_Real_gfx6_gfx7_gfx10<0x011>; 1082defm DS_MIN_F32 : DS_Real_gfx6_gfx7_gfx10<0x012>; 1083defm DS_MAX_F32 : DS_Real_gfx6_gfx7_gfx10<0x013>; 1084defm DS_NOP : DS_Real_gfx6_gfx7_gfx10<0x014>; 1085defm DS_GWS_INIT : DS_Real_gfx6_gfx7_gfx10<0x019>; 1086defm DS_GWS_SEMA_V : DS_Real_gfx6_gfx7_gfx10<0x01a>; 1087defm DS_GWS_SEMA_BR : DS_Real_gfx6_gfx7_gfx10<0x01b>; 1088defm DS_GWS_SEMA_P : DS_Real_gfx6_gfx7_gfx10<0x01c>; 1089defm DS_GWS_BARRIER : DS_Real_gfx6_gfx7_gfx10<0x01d>; 1090defm DS_WRITE_B8 : DS_Real_gfx6_gfx7_gfx10<0x01e>; 1091defm DS_WRITE_B16 : DS_Real_gfx6_gfx7_gfx10<0x01f>; 1092defm DS_ADD_RTN_U32 : DS_Real_gfx6_gfx7_gfx10<0x020>; 1093defm DS_SUB_RTN_U32 : DS_Real_gfx6_gfx7_gfx10<0x021>; 1094defm DS_RSUB_RTN_U32 : DS_Real_gfx6_gfx7_gfx10<0x022>; 1095defm DS_INC_RTN_U32 : DS_Real_gfx6_gfx7_gfx10<0x023>; 1096defm DS_DEC_RTN_U32 : DS_Real_gfx6_gfx7_gfx10<0x024>; 1097defm DS_MIN_RTN_I32 : DS_Real_gfx6_gfx7_gfx10<0x025>; 1098defm DS_MAX_RTN_I32 : DS_Real_gfx6_gfx7_gfx10<0x026>; 1099defm DS_MIN_RTN_U32 : DS_Real_gfx6_gfx7_gfx10<0x027>; 1100defm DS_MAX_RTN_U32 : DS_Real_gfx6_gfx7_gfx10<0x028>; 1101defm DS_AND_RTN_B32 : DS_Real_gfx6_gfx7_gfx10<0x029>; 1102defm DS_OR_RTN_B32 : DS_Real_gfx6_gfx7_gfx10<0x02a>; 1103defm DS_XOR_RTN_B32 : DS_Real_gfx6_gfx7_gfx10<0x02b>; 1104defm DS_MSKOR_RTN_B32 : DS_Real_gfx6_gfx7_gfx10<0x02c>; 1105defm DS_WRXCHG_RTN_B32 : DS_Real_gfx6_gfx7_gfx10<0x02d>; 1106defm DS_WRXCHG2_RTN_B32 : DS_Real_gfx6_gfx7_gfx10<0x02e>; 1107defm DS_WRXCHG2ST64_RTN_B32 : DS_Real_gfx6_gfx7_gfx10<0x02f>; 1108defm DS_CMPST_RTN_B32 : DS_Real_gfx6_gfx7_gfx10<0x030>; 1109defm DS_CMPST_RTN_F32 : DS_Real_gfx6_gfx7_gfx10<0x031>; 1110defm DS_MIN_RTN_F32 : DS_Real_gfx6_gfx7_gfx10<0x032>; 1111defm DS_MAX_RTN_F32 : DS_Real_gfx6_gfx7_gfx10<0x033>; 1112defm DS_SWIZZLE_B32 : DS_Real_gfx6_gfx7_gfx10<0x035>; 1113defm DS_READ_B32 : DS_Real_gfx6_gfx7_gfx10<0x036>; 1114defm DS_READ2_B32 : DS_Real_gfx6_gfx7_gfx10<0x037>; 1115defm DS_READ2ST64_B32 : DS_Real_gfx6_gfx7_gfx10<0x038>; 1116defm DS_READ_I8 : DS_Real_gfx6_gfx7_gfx10<0x039>; 1117defm DS_READ_U8 : DS_Real_gfx6_gfx7_gfx10<0x03a>; 1118defm DS_READ_I16 : DS_Real_gfx6_gfx7_gfx10<0x03b>; 1119defm DS_READ_U16 : DS_Real_gfx6_gfx7_gfx10<0x03c>; 1120defm DS_CONSUME : DS_Real_gfx6_gfx7_gfx10<0x03d>; 1121defm DS_APPEND : DS_Real_gfx6_gfx7_gfx10<0x03e>; 1122defm DS_ORDERED_COUNT : DS_Real_gfx6_gfx7_gfx10<0x03f>; 1123defm DS_ADD_U64 : DS_Real_gfx6_gfx7_gfx10<0x040>; 1124defm DS_SUB_U64 : DS_Real_gfx6_gfx7_gfx10<0x041>; 1125defm DS_RSUB_U64 : DS_Real_gfx6_gfx7_gfx10<0x042>; 1126defm DS_INC_U64 : DS_Real_gfx6_gfx7_gfx10<0x043>; 1127defm DS_DEC_U64 : DS_Real_gfx6_gfx7_gfx10<0x044>; 1128defm DS_MIN_I64 : DS_Real_gfx6_gfx7_gfx10<0x045>; 1129defm DS_MAX_I64 : DS_Real_gfx6_gfx7_gfx10<0x046>; 1130defm DS_MIN_U64 : DS_Real_gfx6_gfx7_gfx10<0x047>; 1131defm DS_MAX_U64 : DS_Real_gfx6_gfx7_gfx10<0x048>; 1132defm DS_AND_B64 : DS_Real_gfx6_gfx7_gfx10<0x049>; 1133defm DS_OR_B64 : DS_Real_gfx6_gfx7_gfx10<0x04a>; 1134defm DS_XOR_B64 : DS_Real_gfx6_gfx7_gfx10<0x04b>; 1135defm DS_MSKOR_B64 : DS_Real_gfx6_gfx7_gfx10<0x04c>; 1136defm DS_WRITE_B64 : DS_Real_gfx6_gfx7_gfx10<0x04d>; 1137defm DS_WRITE2_B64 : DS_Real_gfx6_gfx7_gfx10<0x04e>; 1138defm DS_WRITE2ST64_B64 : DS_Real_gfx6_gfx7_gfx10<0x04f>; 1139defm DS_CMPST_B64 : DS_Real_gfx6_gfx7_gfx10<0x050>; 1140defm DS_CMPST_F64 : DS_Real_gfx6_gfx7_gfx10<0x051>; 1141defm DS_MIN_F64 : DS_Real_gfx6_gfx7_gfx10<0x052>; 1142defm DS_MAX_F64 : DS_Real_gfx6_gfx7_gfx10<0x053>; 1143defm DS_ADD_RTN_U64 : DS_Real_gfx6_gfx7_gfx10<0x060>; 1144defm DS_SUB_RTN_U64 : DS_Real_gfx6_gfx7_gfx10<0x061>; 1145defm DS_RSUB_RTN_U64 : DS_Real_gfx6_gfx7_gfx10<0x062>; 1146defm DS_INC_RTN_U64 : DS_Real_gfx6_gfx7_gfx10<0x063>; 1147defm DS_DEC_RTN_U64 : DS_Real_gfx6_gfx7_gfx10<0x064>; 1148defm DS_MIN_RTN_I64 : DS_Real_gfx6_gfx7_gfx10<0x065>; 1149defm DS_MAX_RTN_I64 : DS_Real_gfx6_gfx7_gfx10<0x066>; 1150defm DS_MIN_RTN_U64 : DS_Real_gfx6_gfx7_gfx10<0x067>; 1151defm DS_MAX_RTN_U64 : DS_Real_gfx6_gfx7_gfx10<0x068>; 1152defm DS_AND_RTN_B64 : DS_Real_gfx6_gfx7_gfx10<0x069>; 1153defm DS_OR_RTN_B64 : DS_Real_gfx6_gfx7_gfx10<0x06a>; 1154defm DS_XOR_RTN_B64 : DS_Real_gfx6_gfx7_gfx10<0x06b>; 1155defm DS_MSKOR_RTN_B64 : DS_Real_gfx6_gfx7_gfx10<0x06c>; 1156defm DS_WRXCHG_RTN_B64 : DS_Real_gfx6_gfx7_gfx10<0x06d>; 1157defm DS_WRXCHG2_RTN_B64 : DS_Real_gfx6_gfx7_gfx10<0x06e>; 1158defm DS_WRXCHG2ST64_RTN_B64 : DS_Real_gfx6_gfx7_gfx10<0x06f>; 1159defm DS_CMPST_RTN_B64 : DS_Real_gfx6_gfx7_gfx10<0x070>; 1160defm DS_CMPST_RTN_F64 : DS_Real_gfx6_gfx7_gfx10<0x071>; 1161defm DS_MIN_RTN_F64 : DS_Real_gfx6_gfx7_gfx10<0x072>; 1162defm DS_MAX_RTN_F64 : DS_Real_gfx6_gfx7_gfx10<0x073>; 1163defm DS_READ_B64 : DS_Real_gfx6_gfx7_gfx10<0x076>; 1164defm DS_READ2_B64 : DS_Real_gfx6_gfx7_gfx10<0x077>; 1165defm DS_READ2ST64_B64 : DS_Real_gfx6_gfx7_gfx10<0x078>; 1166defm DS_ADD_SRC2_U32 : DS_Real_gfx6_gfx7_gfx10<0x080>; 1167defm DS_SUB_SRC2_U32 : DS_Real_gfx6_gfx7_gfx10<0x081>; 1168defm DS_RSUB_SRC2_U32 : DS_Real_gfx6_gfx7_gfx10<0x082>; 1169defm DS_INC_SRC2_U32 : DS_Real_gfx6_gfx7_gfx10<0x083>; 1170defm DS_DEC_SRC2_U32 : DS_Real_gfx6_gfx7_gfx10<0x084>; 1171defm DS_MIN_SRC2_I32 : DS_Real_gfx6_gfx7_gfx10<0x085>; 1172defm DS_MAX_SRC2_I32 : DS_Real_gfx6_gfx7_gfx10<0x086>; 1173defm DS_MIN_SRC2_U32 : DS_Real_gfx6_gfx7_gfx10<0x087>; 1174defm DS_MAX_SRC2_U32 : DS_Real_gfx6_gfx7_gfx10<0x088>; 1175defm DS_AND_SRC2_B32 : DS_Real_gfx6_gfx7_gfx10<0x089>; 1176defm DS_OR_SRC2_B32 : DS_Real_gfx6_gfx7_gfx10<0x08a>; 1177defm DS_XOR_SRC2_B32 : DS_Real_gfx6_gfx7_gfx10<0x08b>; 1178defm DS_WRITE_SRC2_B32 : DS_Real_gfx6_gfx7_gfx10<0x08d>; 1179defm DS_MIN_SRC2_F32 : DS_Real_gfx6_gfx7_gfx10<0x092>; 1180defm DS_MAX_SRC2_F32 : DS_Real_gfx6_gfx7_gfx10<0x093>; 1181defm DS_ADD_SRC2_U64 : DS_Real_gfx6_gfx7_gfx10<0x0c0>; 1182defm DS_SUB_SRC2_U64 : DS_Real_gfx6_gfx7_gfx10<0x0c1>; 1183defm DS_RSUB_SRC2_U64 : DS_Real_gfx6_gfx7_gfx10<0x0c2>; 1184defm DS_INC_SRC2_U64 : DS_Real_gfx6_gfx7_gfx10<0x0c3>; 1185defm DS_DEC_SRC2_U64 : DS_Real_gfx6_gfx7_gfx10<0x0c4>; 1186defm DS_MIN_SRC2_I64 : DS_Real_gfx6_gfx7_gfx10<0x0c5>; 1187defm DS_MAX_SRC2_I64 : DS_Real_gfx6_gfx7_gfx10<0x0c6>; 1188defm DS_MIN_SRC2_U64 : DS_Real_gfx6_gfx7_gfx10<0x0c7>; 1189defm DS_MAX_SRC2_U64 : DS_Real_gfx6_gfx7_gfx10<0x0c8>; 1190defm DS_AND_SRC2_B64 : DS_Real_gfx6_gfx7_gfx10<0x0c9>; 1191defm DS_OR_SRC2_B64 : DS_Real_gfx6_gfx7_gfx10<0x0ca>; 1192defm DS_XOR_SRC2_B64 : DS_Real_gfx6_gfx7_gfx10<0x0cb>; 1193defm DS_WRITE_SRC2_B64 : DS_Real_gfx6_gfx7_gfx10<0x0cd>; 1194defm DS_MIN_SRC2_F64 : DS_Real_gfx6_gfx7_gfx10<0x0d2>; 1195defm DS_MAX_SRC2_F64 : DS_Real_gfx6_gfx7_gfx10<0x0d3>; 1196 1197//===----------------------------------------------------------------------===// 1198// GFX8, GFX9 (VI). 1199//===----------------------------------------------------------------------===// 1200 1201class DS_Real_vi <bits<8> op, DS_Pseudo ps> : 1202 DS_Real <ps>, 1203 SIMCInstr <ps.Mnemonic, SIEncodingFamily.VI> { 1204 let AssemblerPredicate = isGFX8GFX9; 1205 let DecoderNamespace = "GFX8"; 1206 1207 // encoding 1208 let Inst{7-0} = !if(ps.has_offset0, offset0, 0); 1209 let Inst{15-8} = !if(ps.has_offset1, offset1, 0); 1210 let Inst{16} = !if(ps.has_gds, gds, ps.gdsValue); 1211 let Inst{24-17} = op; 1212 let Inst{25} = acc; 1213 let Inst{31-26} = 0x36; // ds prefix 1214 let Inst{39-32} = !if(ps.has_addr, addr, !if(ps.has_gws_data0, data0{7-0}, 0)); 1215 let Inst{47-40} = !if(ps.has_data0, data0{7-0}, 0); 1216 let Inst{55-48} = !if(ps.has_data1, data1{7-0}, 0); 1217 let Inst{63-56} = !if(ps.has_vdst, vdst{7-0}, 0); 1218} 1219 1220def DS_ADD_U32_vi : DS_Real_vi<0x0, DS_ADD_U32>; 1221def DS_SUB_U32_vi : DS_Real_vi<0x1, DS_SUB_U32>; 1222def DS_RSUB_U32_vi : DS_Real_vi<0x2, DS_RSUB_U32>; 1223def DS_INC_U32_vi : DS_Real_vi<0x3, DS_INC_U32>; 1224def DS_DEC_U32_vi : DS_Real_vi<0x4, DS_DEC_U32>; 1225def DS_MIN_I32_vi : DS_Real_vi<0x5, DS_MIN_I32>; 1226def DS_MAX_I32_vi : DS_Real_vi<0x6, DS_MAX_I32>; 1227def DS_MIN_U32_vi : DS_Real_vi<0x7, DS_MIN_U32>; 1228def DS_MAX_U32_vi : DS_Real_vi<0x8, DS_MAX_U32>; 1229def DS_AND_B32_vi : DS_Real_vi<0x9, DS_AND_B32>; 1230def DS_OR_B32_vi : DS_Real_vi<0xa, DS_OR_B32>; 1231def DS_XOR_B32_vi : DS_Real_vi<0xb, DS_XOR_B32>; 1232def DS_MSKOR_B32_vi : DS_Real_vi<0xc, DS_MSKOR_B32>; 1233def DS_WRITE_B32_vi : DS_Real_vi<0xd, DS_WRITE_B32>; 1234def DS_WRITE2_B32_vi : DS_Real_vi<0xe, DS_WRITE2_B32>; 1235def DS_WRITE2ST64_B32_vi : DS_Real_vi<0xf, DS_WRITE2ST64_B32>; 1236def DS_CMPST_B32_vi : DS_Real_vi<0x10, DS_CMPST_B32>; 1237def DS_CMPST_F32_vi : DS_Real_vi<0x11, DS_CMPST_F32>; 1238def DS_MIN_F32_vi : DS_Real_vi<0x12, DS_MIN_F32>; 1239def DS_MAX_F32_vi : DS_Real_vi<0x13, DS_MAX_F32>; 1240def DS_NOP_vi : DS_Real_vi<0x14, DS_NOP>; 1241def DS_ADD_F32_vi : DS_Real_vi<0x15, DS_ADD_F32>; 1242def DS_GWS_INIT_vi : DS_Real_vi<0x99, DS_GWS_INIT>; 1243def DS_GWS_SEMA_V_vi : DS_Real_vi<0x9a, DS_GWS_SEMA_V>; 1244def DS_GWS_SEMA_BR_vi : DS_Real_vi<0x9b, DS_GWS_SEMA_BR>; 1245def DS_GWS_SEMA_P_vi : DS_Real_vi<0x9c, DS_GWS_SEMA_P>; 1246def DS_GWS_BARRIER_vi : DS_Real_vi<0x9d, DS_GWS_BARRIER>; 1247def DS_WRITE_ADDTID_B32_vi : DS_Real_vi<0x1d, DS_WRITE_ADDTID_B32>; 1248def DS_WRITE_B8_vi : DS_Real_vi<0x1e, DS_WRITE_B8>; 1249def DS_WRITE_B16_vi : DS_Real_vi<0x1f, DS_WRITE_B16>; 1250def DS_ADD_RTN_U32_vi : DS_Real_vi<0x20, DS_ADD_RTN_U32>; 1251def DS_SUB_RTN_U32_vi : DS_Real_vi<0x21, DS_SUB_RTN_U32>; 1252def DS_RSUB_RTN_U32_vi : DS_Real_vi<0x22, DS_RSUB_RTN_U32>; 1253def DS_INC_RTN_U32_vi : DS_Real_vi<0x23, DS_INC_RTN_U32>; 1254def DS_DEC_RTN_U32_vi : DS_Real_vi<0x24, DS_DEC_RTN_U32>; 1255def DS_MIN_RTN_I32_vi : DS_Real_vi<0x25, DS_MIN_RTN_I32>; 1256def DS_MAX_RTN_I32_vi : DS_Real_vi<0x26, DS_MAX_RTN_I32>; 1257def DS_MIN_RTN_U32_vi : DS_Real_vi<0x27, DS_MIN_RTN_U32>; 1258def DS_MAX_RTN_U32_vi : DS_Real_vi<0x28, DS_MAX_RTN_U32>; 1259def DS_AND_RTN_B32_vi : DS_Real_vi<0x29, DS_AND_RTN_B32>; 1260def DS_OR_RTN_B32_vi : DS_Real_vi<0x2a, DS_OR_RTN_B32>; 1261def DS_XOR_RTN_B32_vi : DS_Real_vi<0x2b, DS_XOR_RTN_B32>; 1262def DS_MSKOR_RTN_B32_vi : DS_Real_vi<0x2c, DS_MSKOR_RTN_B32>; 1263def DS_WRXCHG_RTN_B32_vi : DS_Real_vi<0x2d, DS_WRXCHG_RTN_B32>; 1264def DS_WRXCHG2_RTN_B32_vi : DS_Real_vi<0x2e, DS_WRXCHG2_RTN_B32>; 1265def DS_WRXCHG2ST64_RTN_B32_vi : DS_Real_vi<0x2f, DS_WRXCHG2ST64_RTN_B32>; 1266def DS_CMPST_RTN_B32_vi : DS_Real_vi<0x30, DS_CMPST_RTN_B32>; 1267def DS_CMPST_RTN_F32_vi : DS_Real_vi<0x31, DS_CMPST_RTN_F32>; 1268def DS_MIN_RTN_F32_vi : DS_Real_vi<0x32, DS_MIN_RTN_F32>; 1269def DS_MAX_RTN_F32_vi : DS_Real_vi<0x33, DS_MAX_RTN_F32>; 1270def DS_WRAP_RTN_B32_vi : DS_Real_vi<0x34, DS_WRAP_RTN_B32>; 1271def DS_ADD_RTN_F32_vi : DS_Real_vi<0x35, DS_ADD_RTN_F32>; 1272def DS_READ_B32_vi : DS_Real_vi<0x36, DS_READ_B32>; 1273def DS_READ2_B32_vi : DS_Real_vi<0x37, DS_READ2_B32>; 1274def DS_READ2ST64_B32_vi : DS_Real_vi<0x38, DS_READ2ST64_B32>; 1275def DS_READ_I8_vi : DS_Real_vi<0x39, DS_READ_I8>; 1276def DS_READ_U8_vi : DS_Real_vi<0x3a, DS_READ_U8>; 1277def DS_READ_I16_vi : DS_Real_vi<0x3b, DS_READ_I16>; 1278def DS_READ_U16_vi : DS_Real_vi<0x3c, DS_READ_U16>; 1279def DS_READ_ADDTID_B32_vi : DS_Real_vi<0xb6, DS_READ_ADDTID_B32>; 1280def DS_CONSUME_vi : DS_Real_vi<0xbd, DS_CONSUME>; 1281def DS_APPEND_vi : DS_Real_vi<0xbe, DS_APPEND>; 1282def DS_ORDERED_COUNT_vi : DS_Real_vi<0xbf, DS_ORDERED_COUNT>; 1283def DS_SWIZZLE_B32_vi : DS_Real_vi<0x3d, DS_SWIZZLE_B32>; 1284def DS_PERMUTE_B32_vi : DS_Real_vi<0x3e, DS_PERMUTE_B32>; 1285def DS_BPERMUTE_B32_vi : DS_Real_vi<0x3f, DS_BPERMUTE_B32>; 1286 1287def DS_ADD_U64_vi : DS_Real_vi<0x40, DS_ADD_U64>; 1288def DS_SUB_U64_vi : DS_Real_vi<0x41, DS_SUB_U64>; 1289def DS_RSUB_U64_vi : DS_Real_vi<0x42, DS_RSUB_U64>; 1290def DS_INC_U64_vi : DS_Real_vi<0x43, DS_INC_U64>; 1291def DS_DEC_U64_vi : DS_Real_vi<0x44, DS_DEC_U64>; 1292def DS_MIN_I64_vi : DS_Real_vi<0x45, DS_MIN_I64>; 1293def DS_MAX_I64_vi : DS_Real_vi<0x46, DS_MAX_I64>; 1294def DS_MIN_U64_vi : DS_Real_vi<0x47, DS_MIN_U64>; 1295def DS_MAX_U64_vi : DS_Real_vi<0x48, DS_MAX_U64>; 1296def DS_AND_B64_vi : DS_Real_vi<0x49, DS_AND_B64>; 1297def DS_OR_B64_vi : DS_Real_vi<0x4a, DS_OR_B64>; 1298def DS_XOR_B64_vi : DS_Real_vi<0x4b, DS_XOR_B64>; 1299def DS_MSKOR_B64_vi : DS_Real_vi<0x4c, DS_MSKOR_B64>; 1300def DS_WRITE_B64_vi : DS_Real_vi<0x4d, DS_WRITE_B64>; 1301def DS_WRITE2_B64_vi : DS_Real_vi<0x4E, DS_WRITE2_B64>; 1302def DS_WRITE2ST64_B64_vi : DS_Real_vi<0x4f, DS_WRITE2ST64_B64>; 1303def DS_CMPST_B64_vi : DS_Real_vi<0x50, DS_CMPST_B64>; 1304def DS_CMPST_F64_vi : DS_Real_vi<0x51, DS_CMPST_F64>; 1305def DS_MIN_F64_vi : DS_Real_vi<0x52, DS_MIN_F64>; 1306def DS_MAX_F64_vi : DS_Real_vi<0x53, DS_MAX_F64>; 1307 1308def DS_WRITE_B8_D16_HI_vi : DS_Real_vi<0x54, DS_WRITE_B8_D16_HI>; 1309def DS_WRITE_B16_D16_HI_vi : DS_Real_vi<0x55, DS_WRITE_B16_D16_HI>; 1310 1311def DS_READ_U8_D16_vi : DS_Real_vi<0x56, DS_READ_U8_D16>; 1312def DS_READ_U8_D16_HI_vi : DS_Real_vi<0x57, DS_READ_U8_D16_HI>; 1313def DS_READ_I8_D16_vi : DS_Real_vi<0x58, DS_READ_I8_D16>; 1314def DS_READ_I8_D16_HI_vi : DS_Real_vi<0x59, DS_READ_I8_D16_HI>; 1315def DS_READ_U16_D16_vi : DS_Real_vi<0x5a, DS_READ_U16_D16>; 1316def DS_READ_U16_D16_HI_vi : DS_Real_vi<0x5b, DS_READ_U16_D16_HI>; 1317 1318def DS_ADD_RTN_U64_vi : DS_Real_vi<0x60, DS_ADD_RTN_U64>; 1319def DS_SUB_RTN_U64_vi : DS_Real_vi<0x61, DS_SUB_RTN_U64>; 1320def DS_RSUB_RTN_U64_vi : DS_Real_vi<0x62, DS_RSUB_RTN_U64>; 1321def DS_INC_RTN_U64_vi : DS_Real_vi<0x63, DS_INC_RTN_U64>; 1322def DS_DEC_RTN_U64_vi : DS_Real_vi<0x64, DS_DEC_RTN_U64>; 1323def DS_MIN_RTN_I64_vi : DS_Real_vi<0x65, DS_MIN_RTN_I64>; 1324def DS_MAX_RTN_I64_vi : DS_Real_vi<0x66, DS_MAX_RTN_I64>; 1325def DS_MIN_RTN_U64_vi : DS_Real_vi<0x67, DS_MIN_RTN_U64>; 1326def DS_MAX_RTN_U64_vi : DS_Real_vi<0x68, DS_MAX_RTN_U64>; 1327def DS_AND_RTN_B64_vi : DS_Real_vi<0x69, DS_AND_RTN_B64>; 1328def DS_OR_RTN_B64_vi : DS_Real_vi<0x6a, DS_OR_RTN_B64>; 1329def DS_XOR_RTN_B64_vi : DS_Real_vi<0x6b, DS_XOR_RTN_B64>; 1330def DS_MSKOR_RTN_B64_vi : DS_Real_vi<0x6c, DS_MSKOR_RTN_B64>; 1331def DS_WRXCHG_RTN_B64_vi : DS_Real_vi<0x6d, DS_WRXCHG_RTN_B64>; 1332def DS_WRXCHG2_RTN_B64_vi : DS_Real_vi<0x6e, DS_WRXCHG2_RTN_B64>; 1333def DS_WRXCHG2ST64_RTN_B64_vi : DS_Real_vi<0x6f, DS_WRXCHG2ST64_RTN_B64>; 1334def DS_CONDXCHG32_RTN_B64_vi : DS_Real_vi<0x7e, DS_CONDXCHG32_RTN_B64>; 1335def DS_GWS_SEMA_RELEASE_ALL_vi : DS_Real_vi<0x98, DS_GWS_SEMA_RELEASE_ALL>; 1336def DS_CMPST_RTN_B64_vi : DS_Real_vi<0x70, DS_CMPST_RTN_B64>; 1337def DS_CMPST_RTN_F64_vi : DS_Real_vi<0x71, DS_CMPST_RTN_F64>; 1338def DS_MIN_RTN_F64_vi : DS_Real_vi<0x72, DS_MIN_RTN_F64>; 1339def DS_MAX_RTN_F64_vi : DS_Real_vi<0x73, DS_MAX_RTN_F64>; 1340 1341def DS_READ_B64_vi : DS_Real_vi<0x76, DS_READ_B64>; 1342def DS_READ2_B64_vi : DS_Real_vi<0x77, DS_READ2_B64>; 1343def DS_READ2ST64_B64_vi : DS_Real_vi<0x78, DS_READ2ST64_B64>; 1344 1345def DS_ADD_SRC2_U32_vi : DS_Real_vi<0x80, DS_ADD_SRC2_U32>; 1346def DS_SUB_SRC2_U32_vi : DS_Real_vi<0x81, DS_SUB_SRC2_U32>; 1347def DS_RSUB_SRC2_U32_vi : DS_Real_vi<0x82, DS_RSUB_SRC2_U32>; 1348def DS_INC_SRC2_U32_vi : DS_Real_vi<0x83, DS_INC_SRC2_U32>; 1349def DS_DEC_SRC2_U32_vi : DS_Real_vi<0x84, DS_DEC_SRC2_U32>; 1350def DS_MIN_SRC2_I32_vi : DS_Real_vi<0x85, DS_MIN_SRC2_I32>; 1351def DS_MAX_SRC2_I32_vi : DS_Real_vi<0x86, DS_MAX_SRC2_I32>; 1352def DS_MIN_SRC2_U32_vi : DS_Real_vi<0x87, DS_MIN_SRC2_U32>; 1353def DS_MAX_SRC2_U32_vi : DS_Real_vi<0x88, DS_MAX_SRC2_U32>; 1354def DS_AND_SRC2_B32_vi : DS_Real_vi<0x89, DS_AND_SRC2_B32>; 1355def DS_OR_SRC2_B32_vi : DS_Real_vi<0x8a, DS_OR_SRC2_B32>; 1356def DS_XOR_SRC2_B32_vi : DS_Real_vi<0x8b, DS_XOR_SRC2_B32>; 1357def DS_WRITE_SRC2_B32_vi : DS_Real_vi<0x8d, DS_WRITE_SRC2_B32>; 1358def DS_MIN_SRC2_F32_vi : DS_Real_vi<0x92, DS_MIN_SRC2_F32>; 1359def DS_MAX_SRC2_F32_vi : DS_Real_vi<0x93, DS_MAX_SRC2_F32>; 1360def DS_ADD_SRC2_F32_vi : DS_Real_vi<0x95, DS_ADD_SRC2_F32>; 1361def DS_ADD_SRC2_U64_vi : DS_Real_vi<0xc0, DS_ADD_SRC2_U64>; 1362def DS_SUB_SRC2_U64_vi : DS_Real_vi<0xc1, DS_SUB_SRC2_U64>; 1363def DS_RSUB_SRC2_U64_vi : DS_Real_vi<0xc2, DS_RSUB_SRC2_U64>; 1364def DS_INC_SRC2_U64_vi : DS_Real_vi<0xc3, DS_INC_SRC2_U64>; 1365def DS_DEC_SRC2_U64_vi : DS_Real_vi<0xc4, DS_DEC_SRC2_U64>; 1366def DS_MIN_SRC2_I64_vi : DS_Real_vi<0xc5, DS_MIN_SRC2_I64>; 1367def DS_MAX_SRC2_I64_vi : DS_Real_vi<0xc6, DS_MAX_SRC2_I64>; 1368def DS_MIN_SRC2_U64_vi : DS_Real_vi<0xc7, DS_MIN_SRC2_U64>; 1369def DS_MAX_SRC2_U64_vi : DS_Real_vi<0xc8, DS_MAX_SRC2_U64>; 1370def DS_AND_SRC2_B64_vi : DS_Real_vi<0xc9, DS_AND_SRC2_B64>; 1371def DS_OR_SRC2_B64_vi : DS_Real_vi<0xca, DS_OR_SRC2_B64>; 1372def DS_XOR_SRC2_B64_vi : DS_Real_vi<0xcb, DS_XOR_SRC2_B64>; 1373def DS_WRITE_SRC2_B64_vi : DS_Real_vi<0xcd, DS_WRITE_SRC2_B64>; 1374def DS_MIN_SRC2_F64_vi : DS_Real_vi<0xd2, DS_MIN_SRC2_F64>; 1375def DS_MAX_SRC2_F64_vi : DS_Real_vi<0xd3, DS_MAX_SRC2_F64>; 1376def DS_WRITE_B96_vi : DS_Real_vi<0xde, DS_WRITE_B96>; 1377def DS_WRITE_B128_vi : DS_Real_vi<0xdf, DS_WRITE_B128>; 1378def DS_READ_B96_vi : DS_Real_vi<0xfe, DS_READ_B96>; 1379def DS_READ_B128_vi : DS_Real_vi<0xff, DS_READ_B128>; 1380 1381let SubtargetPredicate = isGFX90APlus in { 1382 def DS_ADD_F64_vi : DS_Real_vi<0x5c, DS_ADD_F64>; 1383 def DS_ADD_RTN_F64_vi : DS_Real_vi<0x7c, DS_ADD_RTN_F64>; 1384} // End SubtargetPredicate = isGFX90APlus 1385