1//===-- SOPInstructions.td - SOP 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 9def GPRIdxModeMatchClass : AsmOperandClass { 10 let Name = "GPRIdxMode"; 11 let PredicateMethod = "isGPRIdxMode"; 12 let ParserMethod = "parseGPRIdxMode"; 13 let RenderMethod = "addImmOperands"; 14} 15 16def GPRIdxMode : Operand<i32> { 17 let PrintMethod = "printVGPRIndexMode"; 18 let ParserMatchClass = GPRIdxModeMatchClass; 19 let OperandType = "OPERAND_IMMEDIATE"; 20} 21 22class SOP_Pseudo<string opName, dag outs, dag ins, string asmOps, 23 list<dag> pattern=[]> : 24 InstSI<outs, ins, "", pattern>, 25 SIMCInstr<opName, SIEncodingFamily.NONE> { 26 27 let isPseudo = 1; 28 let isCodeGenOnly = 1; 29 30 string Mnemonic = opName; 31 string AsmOperands = asmOps; 32 33 bits<1> has_sdst = 0; 34} 35 36//===----------------------------------------------------------------------===// 37// SOP1 Instructions 38//===----------------------------------------------------------------------===// 39 40class SOP1_Pseudo <string opName, dag outs, dag ins, 41 string asmOps, list<dag> pattern=[]> : 42 SOP_Pseudo<opName, outs, ins, asmOps, pattern> { 43 44 let mayLoad = 0; 45 let mayStore = 0; 46 let hasSideEffects = 0; 47 let SALU = 1; 48 let SOP1 = 1; 49 let SchedRW = [WriteSALU]; 50 let Size = 4; 51 let UseNamedOperandTable = 1; 52 53 bits<1> has_src0 = 1; 54 bits<1> has_sdst = 1; 55} 56 57class SOP1_Real<bits<8> op, SOP1_Pseudo ps, string real_name = ps.Mnemonic> : 58 InstSI <ps.OutOperandList, ps.InOperandList, 59 real_name # " " # ps.AsmOperands, []>, 60 Enc32 { 61 62 let SALU = 1; 63 let SOP1 = 1; 64 let isPseudo = 0; 65 let isCodeGenOnly = 0; 66 let Size = 4; 67 68 // copy relevant pseudo op flags 69 let SubtargetPredicate = ps.SubtargetPredicate; 70 let AsmMatchConverter = ps.AsmMatchConverter; 71 let SchedRW = ps.SchedRW; 72 let mayLoad = ps.mayLoad; 73 let mayStore = ps.mayStore; 74 75 // encoding 76 bits<7> sdst; 77 bits<8> src0; 78 79 let Inst{7-0} = !if(ps.has_src0, src0, ?); 80 let Inst{15-8} = op; 81 let Inst{22-16} = !if(ps.has_sdst, sdst, ?); 82 let Inst{31-23} = 0x17d; //encoding; 83} 84 85class SOP1_32 <string opName, list<dag> pattern=[], bit tied_in = 0> : SOP1_Pseudo < 86 opName, (outs SReg_32:$sdst), 87 !if(tied_in, (ins SSrc_b32:$src0, SReg_32:$sdst_in), 88 (ins SSrc_b32:$src0)), 89 "$sdst, $src0", pattern> { 90 let Constraints = !if(tied_in, "$sdst = $sdst_in", ""); 91} 92 93// Only register input allowed. 94class SOP1_32R <string opName, list<dag> pattern=[]> : SOP1_Pseudo < 95 opName, (outs SReg_32:$sdst), (ins SReg_32:$src0), 96 "$sdst, $src0", pattern>; 97 98// 32-bit input, no output. 99class SOP1_0_32 <string opName, list<dag> pattern = []> : SOP1_Pseudo < 100 opName, (outs), (ins SSrc_b32:$src0), 101 "$src0", pattern> { 102 let has_sdst = 0; 103} 104 105// Special case for movreld where sdst is treated as a use operand. 106class SOP1_32_movreld <string opName, list<dag> pattern=[]> : SOP1_Pseudo < 107 opName, (outs), (ins SReg_32:$sdst, SSrc_b32:$src0), 108 "$sdst, $src0", pattern>; 109 110// Special case for movreld where sdst is treated as a use operand. 111class SOP1_64_movreld <string opName, list<dag> pattern=[]> : SOP1_Pseudo < 112 opName, (outs), (ins SReg_64:$sdst, SSrc_b64:$src0), 113 "$sdst, $src0", pattern 114>; 115 116class SOP1_0_32R <string opName, list<dag> pattern = []> : SOP1_Pseudo < 117 opName, (outs), (ins SReg_32:$src0), 118 "$src0", pattern> { 119 let has_sdst = 0; 120} 121 122class SOP1_64 <string opName, list<dag> pattern=[]> : SOP1_Pseudo < 123 opName, (outs SReg_64:$sdst), (ins SSrc_b64:$src0), 124 "$sdst, $src0", pattern 125>; 126 127// Only register input allowed. 128class SOP1_64R <string opName, list<dag> pattern=[]> : SOP1_Pseudo < 129 opName, (outs SReg_64:$sdst), (ins SReg_64:$src0), 130 "$sdst, $src0", pattern 131>; 132 133// 64-bit input, 32-bit output. 134class SOP1_32_64 <string opName, list<dag> pattern=[]> : SOP1_Pseudo < 135 opName, (outs SReg_32:$sdst), (ins SSrc_b64:$src0), 136 "$sdst, $src0", pattern 137>; 138 139// 32-bit input, 64-bit output. 140class SOP1_64_32 <string opName, list<dag> pattern=[], bit tied_in = 0> : SOP1_Pseudo < 141 opName, (outs SReg_64:$sdst), 142 !if(tied_in, (ins SSrc_b32:$src0, SReg_64:$sdst_in), 143 (ins SSrc_b32:$src0)), 144 "$sdst, $src0", pattern> { 145 let Constraints = !if(tied_in, "$sdst = $sdst_in", ""); 146} 147 148// no input, 64-bit output. 149class SOP1_64_0 <string opName, list<dag> pattern=[]> : SOP1_Pseudo < 150 opName, (outs SReg_64:$sdst), (ins), "$sdst", pattern> { 151 let has_src0 = 0; 152} 153 154// 64-bit input, no output 155class SOP1_1 <string opName, RegisterClass rc = SReg_64, list<dag> pattern=[]> : SOP1_Pseudo < 156 opName, (outs), (ins rc:$src0), "$src0", pattern> { 157 let has_sdst = 0; 158} 159 160 161let isMoveImm = 1 in { 162 let isReMaterializable = 1, isAsCheapAsAMove = 1 in { 163 def S_MOV_B32 : SOP1_32 <"s_mov_b32">; 164 def S_MOV_B64 : SOP1_64 <"s_mov_b64">; 165 } // End isReMaterializable = 1 166 167 let Uses = [SCC] in { 168 def S_CMOV_B32 : SOP1_32 <"s_cmov_b32">; 169 def S_CMOV_B64 : SOP1_64 <"s_cmov_b64">; 170 } // End Uses = [SCC] 171} // End isMoveImm = 1 172 173let Defs = [SCC] in { 174 def S_NOT_B32 : SOP1_32 <"s_not_b32", 175 [(set i32:$sdst, (not i32:$src0))] 176 >; 177 178 def S_NOT_B64 : SOP1_64 <"s_not_b64", 179 [(set i64:$sdst, (not i64:$src0))] 180 >; 181 def S_WQM_B32 : SOP1_32 <"s_wqm_b32">; 182 def S_WQM_B64 : SOP1_64 <"s_wqm_b64">; 183} // End Defs = [SCC] 184 185 186let WaveSizePredicate = isWave32 in { 187def : GCNPat < 188 (int_amdgcn_wqm_vote i1:$src0), 189 (S_WQM_B32 SSrc_b32:$src0) 190>; 191} 192 193let WaveSizePredicate = isWave64 in { 194def : GCNPat < 195 (int_amdgcn_wqm_vote i1:$src0), 196 (S_WQM_B64 SSrc_b64:$src0) 197>; 198} 199 200let isReMaterializable = 1, isAsCheapAsAMove = 1 in { 201def S_BREV_B32 : SOP1_32 <"s_brev_b32", 202 [(set i32:$sdst, (bitreverse i32:$src0))] 203>; 204def S_BREV_B64 : SOP1_64 <"s_brev_b64", 205 [(set i64:$sdst, (bitreverse i64:$src0))] 206>; 207} // End isReMaterializable = 1, isAsCheapAsAMove = 1 208 209let Defs = [SCC] in { 210def S_BCNT0_I32_B32 : SOP1_32 <"s_bcnt0_i32_b32">; 211def S_BCNT0_I32_B64 : SOP1_32_64 <"s_bcnt0_i32_b64">; 212def S_BCNT1_I32_B32 : SOP1_32 <"s_bcnt1_i32_b32", 213 [(set i32:$sdst, (ctpop i32:$src0))] 214>; 215def S_BCNT1_I32_B64 : SOP1_32_64 <"s_bcnt1_i32_b64", 216 [(set i32:$sdst, (ctpop i64:$src0))] 217>; 218} // End Defs = [SCC] 219 220let isReMaterializable = 1 in { 221def S_FF0_I32_B32 : SOP1_32 <"s_ff0_i32_b32">; 222def S_FF0_I32_B64 : SOP1_32_64 <"s_ff0_i32_b64">; 223def S_FF1_I32_B64 : SOP1_32_64 <"s_ff1_i32_b64", 224 [(set i32:$sdst, (AMDGPUffbl_b32 i64:$src0))] 225>; 226 227def S_FF1_I32_B32 : SOP1_32 <"s_ff1_i32_b32", 228 [(set i32:$sdst, (AMDGPUffbl_b32 i32:$src0))] 229>; 230 231def S_FLBIT_I32_B32 : SOP1_32 <"s_flbit_i32_b32", 232 [(set i32:$sdst, (AMDGPUffbh_u32 i32:$src0))] 233>; 234 235def S_FLBIT_I32_B64 : SOP1_32_64 <"s_flbit_i32_b64", 236 [(set i32:$sdst, (AMDGPUffbh_u32 i64:$src0))] 237>; 238def S_FLBIT_I32 : SOP1_32 <"s_flbit_i32", 239 [(set i32:$sdst, (AMDGPUffbh_i32 i32:$src0))] 240>; 241def S_FLBIT_I32_I64 : SOP1_32_64 <"s_flbit_i32_i64">; 242def S_SEXT_I32_I8 : SOP1_32 <"s_sext_i32_i8", 243 [(set i32:$sdst, (sext_inreg i32:$src0, i8))] 244>; 245def S_SEXT_I32_I16 : SOP1_32 <"s_sext_i32_i16", 246 [(set i32:$sdst, (sext_inreg i32:$src0, i16))] 247>; 248} // End isReMaterializable = 1 249 250def S_BITSET0_B32 : SOP1_32 <"s_bitset0_b32", [], 1>; 251def S_BITSET0_B64 : SOP1_64_32 <"s_bitset0_b64", [], 1>; 252def S_BITSET1_B32 : SOP1_32 <"s_bitset1_b32", [], 1>; 253def S_BITSET1_B64 : SOP1_64_32 <"s_bitset1_b64", [], 1>; 254 255def S_GETPC_B64 : SOP1_64_0 <"s_getpc_b64", 256 [(set i64:$sdst, (int_amdgcn_s_getpc))] 257>; 258 259let isTerminator = 1, isBarrier = 1, SchedRW = [WriteBranch] in { 260 261let isBranch = 1, isIndirectBranch = 1 in { 262def S_SETPC_B64 : SOP1_1 <"s_setpc_b64">; 263} // End isBranch = 1, isIndirectBranch = 1 264 265let isReturn = 1 in { 266// Define variant marked as return rather than branch. 267def S_SETPC_B64_return : SOP1_1<"", CCR_SGPR_64, [(AMDGPUret_flag i64:$src0)]>; 268} 269} // End isTerminator = 1, isBarrier = 1 270 271let isCall = 1 in { 272def S_SWAPPC_B64 : SOP1_64 <"s_swappc_b64" 273>; 274} 275 276def S_RFE_B64 : SOP1_1 <"s_rfe_b64">; 277 278let hasSideEffects = 1, Uses = [EXEC], Defs = [EXEC, SCC] in { 279 280def S_AND_SAVEEXEC_B64 : SOP1_64 <"s_and_saveexec_b64">; 281def S_OR_SAVEEXEC_B64 : SOP1_64 <"s_or_saveexec_b64">; 282def S_XOR_SAVEEXEC_B64 : SOP1_64 <"s_xor_saveexec_b64">; 283def S_ANDN2_SAVEEXEC_B64 : SOP1_64 <"s_andn2_saveexec_b64">; 284def S_ORN2_SAVEEXEC_B64 : SOP1_64 <"s_orn2_saveexec_b64">; 285def S_NAND_SAVEEXEC_B64 : SOP1_64 <"s_nand_saveexec_b64">; 286def S_NOR_SAVEEXEC_B64 : SOP1_64 <"s_nor_saveexec_b64">; 287def S_XNOR_SAVEEXEC_B64 : SOP1_64 <"s_xnor_saveexec_b64">; 288 289} // End hasSideEffects = 1, Uses = [EXEC], Defs = [EXEC, SCC] 290 291def S_QUADMASK_B32 : SOP1_32 <"s_quadmask_b32">; 292def S_QUADMASK_B64 : SOP1_64 <"s_quadmask_b64">; 293 294let Uses = [M0] in { 295def S_MOVRELS_B32 : SOP1_32R <"s_movrels_b32">; 296def S_MOVRELS_B64 : SOP1_64R <"s_movrels_b64">; 297def S_MOVRELD_B32 : SOP1_32_movreld <"s_movreld_b32">; 298def S_MOVRELD_B64 : SOP1_64_movreld <"s_movreld_b64">; 299} // End Uses = [M0] 300 301let SubtargetPredicate = isGFX6GFX7GFX8GFX9 in { 302def S_CBRANCH_JOIN : SOP1_0_32R <"s_cbranch_join">; 303} // End SubtargetPredicate = isGFX6GFX7GFX8GFX9 304 305let Defs = [SCC] in { 306def S_ABS_I32 : SOP1_32 <"s_abs_i32", 307 [(set i32:$sdst, (abs i32:$src0))] 308 >; 309} // End Defs = [SCC] 310 311let SubtargetPredicate = HasVGPRIndexMode in { 312def S_SET_GPR_IDX_IDX : SOP1_0_32<"s_set_gpr_idx_idx"> { 313 let Uses = [M0, MODE]; 314 let Defs = [M0, MODE]; 315} 316} 317 318let SubtargetPredicate = isGFX9Plus in { 319 let hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] in { 320 def S_ANDN1_SAVEEXEC_B64 : SOP1_64<"s_andn1_saveexec_b64">; 321 def S_ORN1_SAVEEXEC_B64 : SOP1_64<"s_orn1_saveexec_b64">; 322 def S_ANDN1_WREXEC_B64 : SOP1_64<"s_andn1_wrexec_b64">; 323 def S_ANDN2_WREXEC_B64 : SOP1_64<"s_andn2_wrexec_b64">; 324 } // End hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] 325 326 let isReMaterializable = 1 in 327 def S_BITREPLICATE_B64_B32 : SOP1_64_32<"s_bitreplicate_b64_b32">; 328} // End SubtargetPredicate = isGFX9Plus 329 330let SubtargetPredicate = isGFX10Plus in { 331 let hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] in { 332 def S_AND_SAVEEXEC_B32 : SOP1_32<"s_and_saveexec_b32">; 333 def S_OR_SAVEEXEC_B32 : SOP1_32<"s_or_saveexec_b32">; 334 def S_XOR_SAVEEXEC_B32 : SOP1_32<"s_xor_saveexec_b32">; 335 def S_ANDN2_SAVEEXEC_B32 : SOP1_32<"s_andn2_saveexec_b32">; 336 def S_ORN2_SAVEEXEC_B32 : SOP1_32<"s_orn2_saveexec_b32">; 337 def S_NAND_SAVEEXEC_B32 : SOP1_32<"s_nand_saveexec_b32">; 338 def S_NOR_SAVEEXEC_B32 : SOP1_32<"s_nor_saveexec_b32">; 339 def S_XNOR_SAVEEXEC_B32 : SOP1_32<"s_xnor_saveexec_b32">; 340 def S_ANDN1_SAVEEXEC_B32 : SOP1_32<"s_andn1_saveexec_b32">; 341 def S_ORN1_SAVEEXEC_B32 : SOP1_32<"s_orn1_saveexec_b32">; 342 def S_ANDN1_WREXEC_B32 : SOP1_32<"s_andn1_wrexec_b32">; 343 def S_ANDN2_WREXEC_B32 : SOP1_32<"s_andn2_wrexec_b32">; 344 } // End hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] 345 346 let Uses = [M0] in { 347 def S_MOVRELSD_2_B32 : SOP1_32<"s_movrelsd_2_b32">; 348 } // End Uses = [M0] 349} // End SubtargetPredicate = isGFX10Plus 350 351//===----------------------------------------------------------------------===// 352// SOP2 Instructions 353//===----------------------------------------------------------------------===// 354 355class SOP2_Pseudo<string opName, dag outs, dag ins, 356 string asmOps, list<dag> pattern=[]> : 357 SOP_Pseudo<opName, outs, ins, asmOps, pattern> { 358 359 let mayLoad = 0; 360 let mayStore = 0; 361 let hasSideEffects = 0; 362 let SALU = 1; 363 let SOP2 = 1; 364 let SchedRW = [WriteSALU]; 365 let UseNamedOperandTable = 1; 366 367 let has_sdst = 1; 368 369 // Pseudo instructions have no encodings, but adding this field here allows 370 // us to do: 371 // let sdst = xxx in { 372 // for multiclasses that include both real and pseudo instructions. 373 // field bits<7> sdst = 0; 374 // let Size = 4; // Do we need size here? 375} 376 377class SOP2_Real<bits<7> op, SOP_Pseudo ps, string real_name = ps.Mnemonic> : 378 InstSI <ps.OutOperandList, ps.InOperandList, 379 real_name # " " # ps.AsmOperands, []>, 380 Enc32 { 381 let SALU = 1; 382 let SOP2 = 1; 383 let isPseudo = 0; 384 let isCodeGenOnly = 0; 385 386 // copy relevant pseudo op flags 387 let SubtargetPredicate = ps.SubtargetPredicate; 388 let AsmMatchConverter = ps.AsmMatchConverter; 389 let UseNamedOperandTable = ps.UseNamedOperandTable; 390 let TSFlags = ps.TSFlags; 391 let SchedRW = ps.SchedRW; 392 let mayLoad = ps.mayLoad; 393 let mayStore = ps.mayStore; 394 395 // encoding 396 bits<7> sdst; 397 bits<8> src0; 398 bits<8> src1; 399 400 let Inst{7-0} = src0; 401 let Inst{15-8} = src1; 402 let Inst{22-16} = !if(ps.has_sdst, sdst, ?); 403 let Inst{29-23} = op; 404 let Inst{31-30} = 0x2; // encoding 405} 406 407 408class SOP2_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo < 409 opName, (outs SReg_32:$sdst), (ins SSrc_b32:$src0, SSrc_b32:$src1), 410 "$sdst, $src0, $src1", pattern 411>; 412 413class SOP2_64 <string opName, list<dag> pattern=[]> : SOP2_Pseudo < 414 opName, (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1), 415 "$sdst, $src0, $src1", pattern 416>; 417 418class SOP2_64_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo < 419 opName, (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b32:$src1), 420 "$sdst, $src0, $src1", pattern 421>; 422 423class SOP2_64_32_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo < 424 opName, (outs SReg_64:$sdst), (ins SSrc_b32:$src0, SSrc_b32:$src1), 425 "$sdst, $src0, $src1", pattern 426>; 427 428class UniformUnaryFrag<SDPatternOperator Op> : PatFrag < 429 (ops node:$src0), 430 (Op $src0), 431 [{ return !N->isDivergent(); }]> { 432 // This check is unnecessary as it's captured by the result register 433 // bank constraint. 434 // 435 // FIXME: Should add a way for the emitter to recognize this is a 436 // trivially true predicate to eliminate the check. 437 let GISelPredicateCode = [{return true;}]; 438} 439 440class UniformBinFrag<SDPatternOperator Op> : PatFrag < 441 (ops node:$src0, node:$src1), 442 (Op $src0, $src1), 443 [{ return !N->isDivergent(); }]> { 444 // This check is unnecessary as it's captured by the result register 445 // bank constraint. 446 // 447 // FIXME: Should add a way for the emitter to recognize this is a 448 // trivially true predicate to eliminate the check. 449 let GISelPredicateCode = [{return true;}]; 450} 451 452class DivergentBinFrag<SDPatternOperator Op> : PatFrag < 453 (ops node:$src0, node:$src1), 454 (Op $src0, $src1), 455 [{ return N->isDivergent(); }]> { 456 // This check is unnecessary as it's captured by the result register 457 // bank constraint. 458 // 459 // FIXME: Should add a way for the emitter to recognize this is a 460 // trivially true predicate to eliminate the check. 461 let GISelPredicateCode = [{return true;}]; 462} 463 464let Defs = [SCC] in { // Carry out goes to SCC 465let isCommutable = 1 in { 466def S_ADD_U32 : SOP2_32 <"s_add_u32">; 467def S_ADD_I32 : SOP2_32 <"s_add_i32", 468 [(set i32:$sdst, (UniformBinFrag<add> SSrc_b32:$src0, SSrc_b32:$src1))] 469>; 470} // End isCommutable = 1 471 472def S_SUB_U32 : SOP2_32 <"s_sub_u32">; 473def S_SUB_I32 : SOP2_32 <"s_sub_i32", 474 [(set i32:$sdst, (UniformBinFrag<sub> SSrc_b32:$src0, SSrc_b32:$src1))] 475>; 476 477let Uses = [SCC] in { // Carry in comes from SCC 478let isCommutable = 1 in { 479def S_ADDC_U32 : SOP2_32 <"s_addc_u32", 480 [(set i32:$sdst, (UniformBinFrag<adde> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]>; 481} // End isCommutable = 1 482 483def S_SUBB_U32 : SOP2_32 <"s_subb_u32", 484 [(set i32:$sdst, (UniformBinFrag<sube> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]>; 485} // End Uses = [SCC] 486 487 488let isCommutable = 1 in { 489def S_MIN_I32 : SOP2_32 <"s_min_i32", 490 [(set i32:$sdst, (smin i32:$src0, i32:$src1))] 491>; 492def S_MIN_U32 : SOP2_32 <"s_min_u32", 493 [(set i32:$sdst, (umin i32:$src0, i32:$src1))] 494>; 495def S_MAX_I32 : SOP2_32 <"s_max_i32", 496 [(set i32:$sdst, (smax i32:$src0, i32:$src1))] 497>; 498def S_MAX_U32 : SOP2_32 <"s_max_u32", 499 [(set i32:$sdst, (umax i32:$src0, i32:$src1))] 500>; 501} // End isCommutable = 1 502} // End Defs = [SCC] 503 504// This pattern is restricted to certain subtargets (practically GFX8Plus) 505// because isel sometimes produces an sreg_64 copy to SCC as a by-product 506// of this pattern, and only for subtargets with hasScalarCompareEq64 507// is it possible to map such copy to a single instruction (S_CMP_LG_U64). 508class SelectPat<SDPatternOperator select> : PatFrag < 509 (ops node:$src1, node:$src2), 510 (select SCC, $src1, $src2), 511 [{ return Subtarget->hasScalarCompareEq64() && 512 N->getOperand(0)->hasOneUse() && !N->isDivergent(); }] 513>; 514 515let Uses = [SCC] in { 516 let AddedComplexity = 20 in { 517 def S_CSELECT_B32 : SOP2_32 <"s_cselect_b32", 518 [(set i32:$sdst, (SelectPat<select> i32:$src0, i32:$src1))] 519 >; 520 } 521 522 def S_CSELECT_B64 : SOP2_64 <"s_cselect_b64">; 523} // End Uses = [SCC] 524 525let Defs = [SCC] in { 526let isCommutable = 1 in { 527def S_AND_B32 : SOP2_32 <"s_and_b32", 528 [(set i32:$sdst, (UniformBinFrag<and> i32:$src0, i32:$src1))] 529>; 530 531def S_AND_B64 : SOP2_64 <"s_and_b64", 532 [(set i64:$sdst, (UniformBinFrag<and> i64:$src0, i64:$src1))] 533>; 534 535def S_OR_B32 : SOP2_32 <"s_or_b32", 536 [(set i32:$sdst, (UniformBinFrag<or> i32:$src0, i32:$src1))] 537>; 538 539def S_OR_B64 : SOP2_64 <"s_or_b64", 540 [(set i64:$sdst, (UniformBinFrag<or> i64:$src0, i64:$src1))] 541>; 542 543def S_XOR_B32 : SOP2_32 <"s_xor_b32", 544 [(set i32:$sdst, (UniformBinFrag<xor> i32:$src0, i32:$src1))] 545>; 546 547def S_XOR_B64 : SOP2_64 <"s_xor_b64", 548 [(set i64:$sdst, (UniformBinFrag<xor> i64:$src0, i64:$src1))] 549>; 550 551def S_XNOR_B32 : SOP2_32 <"s_xnor_b32", 552 [(set i32:$sdst, (not (xor_oneuse i32:$src0, i32:$src1)))] 553>; 554 555def S_XNOR_B64 : SOP2_64 <"s_xnor_b64", 556 [(set i64:$sdst, (not (xor_oneuse i64:$src0, i64:$src1)))] 557>; 558 559def S_NAND_B32 : SOP2_32 <"s_nand_b32", 560 [(set i32:$sdst, (not (and_oneuse i32:$src0, i32:$src1)))] 561>; 562 563def S_NAND_B64 : SOP2_64 <"s_nand_b64", 564 [(set i64:$sdst, (not (and_oneuse i64:$src0, i64:$src1)))] 565>; 566 567def S_NOR_B32 : SOP2_32 <"s_nor_b32", 568 [(set i32:$sdst, (not (or_oneuse i32:$src0, i32:$src1)))] 569>; 570 571def S_NOR_B64 : SOP2_64 <"s_nor_b64", 572 [(set i64:$sdst, (not (or_oneuse i64:$src0, i64:$src1)))] 573>; 574} // End isCommutable = 1 575 576// There are also separate patterns for types other than i32 577def S_ANDN2_B32 : SOP2_32 <"s_andn2_b32", 578 [(set i32:$sdst, (UniformBinFrag<and> i32:$src0, (UniformUnaryFrag<not> i32:$src1)))] 579>; 580 581def S_ANDN2_B64 : SOP2_64 <"s_andn2_b64", 582 [(set i64:$sdst, (UniformBinFrag<and> i64:$src0, (UniformUnaryFrag<not> i64:$src1)))] 583>; 584 585def S_ORN2_B32 : SOP2_32 <"s_orn2_b32", 586 [(set i32:$sdst, (UniformBinFrag<or> i32:$src0, (UniformUnaryFrag<not> i32:$src1)))] 587>; 588 589def S_ORN2_B64 : SOP2_64 <"s_orn2_b64", 590 [(set i64:$sdst, (UniformBinFrag<or> i64:$src0, (UniformUnaryFrag<not> i64:$src1)))] 591>; 592} // End Defs = [SCC] 593 594// Use added complexity so these patterns are preferred to the VALU patterns. 595let AddedComplexity = 1 in { 596 597let Defs = [SCC] in { 598// TODO: b64 versions require VOP3 change since v_lshlrev_b64 is VOP3 599def S_LSHL_B32 : SOP2_32 <"s_lshl_b32", 600 [(set SReg_32:$sdst, (UniformBinFrag<shl> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))] 601>; 602def S_LSHL_B64 : SOP2_64_32 <"s_lshl_b64", 603 [(set SReg_64:$sdst, (UniformBinFrag<shl> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))] 604>; 605def S_LSHR_B32 : SOP2_32 <"s_lshr_b32", 606 [(set SReg_32:$sdst, (UniformBinFrag<srl> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))] 607>; 608def S_LSHR_B64 : SOP2_64_32 <"s_lshr_b64", 609 [(set SReg_64:$sdst, (UniformBinFrag<srl> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))] 610>; 611def S_ASHR_I32 : SOP2_32 <"s_ashr_i32", 612 [(set SReg_32:$sdst, (UniformBinFrag<sra> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))] 613>; 614def S_ASHR_I64 : SOP2_64_32 <"s_ashr_i64", 615 [(set SReg_64:$sdst, (UniformBinFrag<sra> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))] 616>; 617} // End Defs = [SCC] 618 619let isReMaterializable = 1 in { 620def S_BFM_B32 : SOP2_32 <"s_bfm_b32", 621 [(set i32:$sdst, (UniformBinFrag<AMDGPUbfm> i32:$src0, i32:$src1))]>; 622def S_BFM_B64 : SOP2_64_32_32 <"s_bfm_b64">; 623 624// TODO: S_MUL_I32 require V_MUL_LO_I32 from VOP3 change 625def S_MUL_I32 : SOP2_32 <"s_mul_i32", 626 [(set i32:$sdst, (mul i32:$src0, i32:$src1))]> { 627 let isCommutable = 1; 628} 629} // End isReMaterializable = 1 630} // End AddedComplexity = 1 631 632let Defs = [SCC] in { 633def S_BFE_U32 : SOP2_32 <"s_bfe_u32">; 634def S_BFE_I32 : SOP2_32 <"s_bfe_i32">; 635def S_BFE_U64 : SOP2_64_32 <"s_bfe_u64">; 636def S_BFE_I64 : SOP2_64_32 <"s_bfe_i64">; 637} // End Defs = [SCC] 638 639def S_CBRANCH_G_FORK : SOP2_Pseudo < 640 "s_cbranch_g_fork", (outs), 641 (ins SCSrc_b64:$src0, SCSrc_b64:$src1), 642 "$src0, $src1" 643> { 644 let has_sdst = 0; 645 let SubtargetPredicate = isGFX6GFX7GFX8GFX9; 646} 647 648let Defs = [SCC] in { 649def S_ABSDIFF_I32 : SOP2_32 <"s_absdiff_i32">; 650} // End Defs = [SCC] 651 652let SubtargetPredicate = isGFX8GFX9 in { 653 def S_RFE_RESTORE_B64 : SOP2_Pseudo < 654 "s_rfe_restore_b64", (outs), 655 (ins SSrc_b64:$src0, SSrc_b32:$src1), 656 "$src0, $src1" 657 > { 658 let hasSideEffects = 1; 659 let has_sdst = 0; 660 } 661} 662 663let SubtargetPredicate = isGFX9Plus in { 664 let isReMaterializable = 1 in { 665 def S_PACK_LL_B32_B16 : SOP2_32<"s_pack_ll_b32_b16">; 666 def S_PACK_LH_B32_B16 : SOP2_32<"s_pack_lh_b32_b16">; 667 def S_PACK_HH_B32_B16 : SOP2_32<"s_pack_hh_b32_b16">; 668 } // End isReMaterializable = 1 669 670 let Defs = [SCC] in { 671 def S_LSHL1_ADD_U32 : SOP2_32<"s_lshl1_add_u32", 672 [(set i32:$sdst, (shl1_add SSrc_b32:$src0, SSrc_b32:$src1))] 673 >; 674 def S_LSHL2_ADD_U32 : SOP2_32<"s_lshl2_add_u32", 675 [(set i32:$sdst, (shl2_add SSrc_b32:$src0, SSrc_b32:$src1))] 676 >; 677 def S_LSHL3_ADD_U32 : SOP2_32<"s_lshl3_add_u32", 678 [(set i32:$sdst, (shl3_add SSrc_b32:$src0, SSrc_b32:$src1))] 679 >; 680 def S_LSHL4_ADD_U32 : SOP2_32<"s_lshl4_add_u32", 681 [(set i32:$sdst, (shl4_add SSrc_b32:$src0, SSrc_b32:$src1))] 682 >; 683 } // End Defs = [SCC] 684 685 let isCommutable = 1, isReMaterializable = 1 in { 686 def S_MUL_HI_U32 : SOP2_32<"s_mul_hi_u32", 687 [(set i32:$sdst, (UniformBinFrag<mulhu> SSrc_b32:$src0, SSrc_b32:$src1))]>; 688 def S_MUL_HI_I32 : SOP2_32<"s_mul_hi_i32", 689 [(set i32:$sdst, (UniformBinFrag<mulhs> SSrc_b32:$src0, SSrc_b32:$src1))]>; 690 } // End isCommutable = 1, isReMaterializable = 1 691} // End SubtargetPredicate = isGFX9Plus 692 693//===----------------------------------------------------------------------===// 694// SOPK Instructions 695//===----------------------------------------------------------------------===// 696 697class SOPK_Pseudo <string opName, dag outs, dag ins, 698 string asmOps, list<dag> pattern=[]> : 699 InstSI <outs, ins, "", pattern>, 700 SIMCInstr<opName, SIEncodingFamily.NONE> { 701 let isPseudo = 1; 702 let isCodeGenOnly = 1; 703 let mayLoad = 0; 704 let mayStore = 0; 705 let hasSideEffects = 0; 706 let SALU = 1; 707 let SOPK = 1; 708 let SchedRW = [WriteSALU]; 709 let UseNamedOperandTable = 1; 710 string Mnemonic = opName; 711 string AsmOperands = asmOps; 712 713 bits<1> has_sdst = 1; 714} 715 716class SOPK_Real<bits<5> op, SOPK_Pseudo ps> : 717 InstSI <ps.OutOperandList, ps.InOperandList, 718 ps.Mnemonic # " " # ps.AsmOperands, []> { 719 let SALU = 1; 720 let SOPK = 1; 721 let isPseudo = 0; 722 let isCodeGenOnly = 0; 723 724 // copy relevant pseudo op flags 725 let SubtargetPredicate = ps.SubtargetPredicate; 726 let AsmMatchConverter = ps.AsmMatchConverter; 727 let DisableEncoding = ps.DisableEncoding; 728 let Constraints = ps.Constraints; 729 let SchedRW = ps.SchedRW; 730 let mayLoad = ps.mayLoad; 731 let mayStore = ps.mayStore; 732 let isBranch = ps.isBranch; 733 let isCall = ps.isCall; 734 735 // encoding 736 bits<7> sdst; 737 bits<16> simm16; 738 bits<32> imm; 739} 740 741class SOPK_Real32<bits<5> op, SOPK_Pseudo ps> : 742 SOPK_Real <op, ps>, 743 Enc32 { 744 let Inst{15-0} = simm16; 745 let Inst{22-16} = !if(ps.has_sdst, sdst, ?); 746 let Inst{27-23} = op; 747 let Inst{31-28} = 0xb; //encoding 748} 749 750class SOPK_Real64<bits<5> op, SOPK_Pseudo ps> : 751 SOPK_Real<op, ps>, 752 Enc64 { 753 let Inst{15-0} = simm16; 754 let Inst{22-16} = !if(ps.has_sdst, sdst, ?); 755 let Inst{27-23} = op; 756 let Inst{31-28} = 0xb; //encoding 757 let Inst{63-32} = imm; 758} 759 760class SOPKInstTable <bit is_sopk, string cmpOp = ""> { 761 bit IsSOPK = is_sopk; 762 string BaseCmpOp = cmpOp; 763} 764 765class SOPK_32 <string opName, list<dag> pattern=[]> : SOPK_Pseudo < 766 opName, 767 (outs SReg_32:$sdst), 768 (ins s16imm:$simm16), 769 "$sdst, $simm16", 770 pattern>; 771 772class SOPK_32_BR <string opName, list<dag> pattern=[]> : SOPK_Pseudo < 773 opName, 774 (outs), 775 (ins sopp_brtarget:$simm16, SReg_32:$sdst), 776 "$sdst, $simm16", 777 pattern> { 778 let Defs = [EXEC]; 779 let Uses = [EXEC]; 780 let isBranch = 1; 781 let isTerminator = 1; 782 let SchedRW = [WriteBranch]; 783} 784 785class SOPK_SCC <string opName, string base_op, bit isSignExt> : SOPK_Pseudo < 786 opName, 787 (outs), 788 !if(isSignExt, 789 (ins SReg_32:$sdst, s16imm:$simm16), 790 (ins SReg_32:$sdst, u16imm:$simm16)), 791 "$sdst, $simm16", []>, 792 SOPKInstTable<1, base_op>{ 793 let Defs = [SCC]; 794} 795 796class SOPK_32TIE <string opName, list<dag> pattern=[]> : SOPK_Pseudo < 797 opName, 798 (outs SReg_32:$sdst), 799 (ins SReg_32:$src0, s16imm:$simm16), 800 "$sdst, $simm16", 801 pattern 802>; 803 804let isReMaterializable = 1, isMoveImm = 1 in { 805def S_MOVK_I32 : SOPK_32 <"s_movk_i32">; 806} // End isReMaterializable = 1 807let Uses = [SCC] in { 808def S_CMOVK_I32 : SOPK_32 <"s_cmovk_i32">; 809} 810 811let isCompare = 1 in { 812 813// This instruction is disabled for now until we can figure out how to teach 814// the instruction selector to correctly use the S_CMP* vs V_CMP* 815// instructions. 816// 817// When this instruction is enabled the code generator sometimes produces this 818// invalid sequence: 819// 820// SCC = S_CMPK_EQ_I32 SGPR0, imm 821// VCC = COPY SCC 822// VGPR0 = V_CNDMASK VCC, VGPR0, VGPR1 823// 824// def S_CMPK_EQ_I32 : SOPK_SCC <"s_cmpk_eq_i32", 825// [(set i1:$dst, (setcc i32:$src0, imm:$src1, SETEQ))] 826// >; 827 828def S_CMPK_EQ_I32 : SOPK_SCC <"s_cmpk_eq_i32", "s_cmp_eq_i32", 1>; 829def S_CMPK_LG_I32 : SOPK_SCC <"s_cmpk_lg_i32", "s_cmp_lg_i32", 1>; 830def S_CMPK_GT_I32 : SOPK_SCC <"s_cmpk_gt_i32", "s_cmp_gt_i32", 1>; 831def S_CMPK_GE_I32 : SOPK_SCC <"s_cmpk_ge_i32", "s_cmp_ge_i32", 1>; 832def S_CMPK_LT_I32 : SOPK_SCC <"s_cmpk_lt_i32", "s_cmp_lt_i32", 1>; 833def S_CMPK_LE_I32 : SOPK_SCC <"s_cmpk_le_i32", "s_cmp_le_i32", 1>; 834 835let SOPKZext = 1 in { 836def S_CMPK_EQ_U32 : SOPK_SCC <"s_cmpk_eq_u32", "s_cmp_eq_u32", 0>; 837def S_CMPK_LG_U32 : SOPK_SCC <"s_cmpk_lg_u32", "s_cmp_lg_u32", 0>; 838def S_CMPK_GT_U32 : SOPK_SCC <"s_cmpk_gt_u32", "s_cmp_gt_u32", 0>; 839def S_CMPK_GE_U32 : SOPK_SCC <"s_cmpk_ge_u32", "s_cmp_ge_u32", 0>; 840def S_CMPK_LT_U32 : SOPK_SCC <"s_cmpk_lt_u32", "s_cmp_lt_u32", 0>; 841def S_CMPK_LE_U32 : SOPK_SCC <"s_cmpk_le_u32", "s_cmp_le_u32", 0>; 842} // End SOPKZext = 1 843} // End isCompare = 1 844 845let Defs = [SCC], isCommutable = 1, DisableEncoding = "$src0", 846 Constraints = "$sdst = $src0" in { 847 def S_ADDK_I32 : SOPK_32TIE <"s_addk_i32">; 848 def S_MULK_I32 : SOPK_32TIE <"s_mulk_i32">; 849} 850 851let SubtargetPredicate = isGFX6GFX7GFX8GFX9 in 852def S_CBRANCH_I_FORK : SOPK_Pseudo < 853 "s_cbranch_i_fork", 854 (outs), (ins SReg_64:$sdst, sopp_brtarget:$simm16), 855 "$sdst, $simm16" 856>; 857 858let mayLoad = 1 in { 859// s_getreg_b32 should use hasSideEffects = 1 for tablegen to allow 860// its use in the readcyclecounter selection. 861// FIXME: Need to truncate immediate to 16-bits. 862def S_GETREG_B32 : SOPK_Pseudo < 863 "s_getreg_b32", 864 (outs SReg_32:$sdst), (ins hwreg:$simm16), 865 "$sdst, $simm16", 866 [(set i32:$sdst, (int_amdgcn_s_getreg (i32 timm:$simm16)))]> { 867 let SOPKZext = 1; 868 let hasSideEffects = 1; 869} 870} // End mayLoad = 1 871 872let mayLoad = 0, mayStore = 0, Defs = [MODE], Uses = [MODE] in { 873 874// FIXME: Need to truncate immediate to 16-bits. 875class S_SETREG_B32_Pseudo <list<dag> pattern=[]> : SOPK_Pseudo < 876 "s_setreg_b32", 877 (outs), (ins SReg_32:$sdst, hwreg:$simm16), 878 "$simm16, $sdst", 879 pattern>; 880 881def S_SETREG_B32 : S_SETREG_B32_Pseudo < 882 [(int_amdgcn_s_setreg (i32 timm:$simm16), i32:$sdst)]> { 883 // Use custom inserter to optimize some cases to 884 // S_DENORM_MODE/S_ROUND_MODE/S_SETREG_B32_mode. 885 let usesCustomInserter = 1; 886 let hasSideEffects = 1; 887} 888 889// Variant of SETREG that is guaranteed to only touch FP bits in the MODE 890// register, so doesn't have unmodeled side effects. 891def S_SETREG_B32_mode : S_SETREG_B32_Pseudo { 892 let hasSideEffects = 0; 893} 894 895// FIXME: Not on SI? 896//def S_GETREG_REGRD_B32 : SOPK_32 <sopk<0x14, 0x13>, "s_getreg_regrd_b32">; 897 898class S_SETREG_IMM32_B32_Pseudo : SOPK_Pseudo < 899 "s_setreg_imm32_b32", 900 (outs), (ins i32imm:$imm, hwreg:$simm16), 901 "$simm16, $imm"> { 902 let Size = 8; // Unlike every other SOPK instruction. 903 let has_sdst = 0; 904} 905 906def S_SETREG_IMM32_B32 : S_SETREG_IMM32_B32_Pseudo { 907 let hasSideEffects = 1; 908} 909 910// Variant of SETREG_IMM32 that is guaranteed to only touch FP bits in the MODE 911// register, so doesn't have unmodeled side effects. 912def S_SETREG_IMM32_B32_mode : S_SETREG_IMM32_B32_Pseudo { 913 let hasSideEffects = 0; 914} 915 916} // End mayLoad = 0, mayStore = 0, Defs = [MODE], Uses = [MODE] 917 918class SOPK_WAITCNT<string opName, list<dag> pat=[]> : 919 SOPK_Pseudo< 920 opName, 921 (outs), 922 (ins SReg_32:$sdst, s16imm:$simm16), 923 "$sdst, $simm16", 924 pat> { 925 let hasSideEffects = 1; 926 let mayLoad = 1; 927 let mayStore = 1; 928 let has_sdst = 1; // First source takes place of sdst in encoding 929} 930 931let SubtargetPredicate = isGFX9Plus in { 932 def S_CALL_B64 : SOPK_Pseudo< 933 "s_call_b64", 934 (outs SReg_64:$sdst), 935 (ins sopp_brtarget:$simm16), 936 "$sdst, $simm16"> { 937 let isCall = 1; 938 } 939} // End SubtargetPredicate = isGFX9Plus 940 941let SubtargetPredicate = isGFX10Plus in { 942 def S_VERSION : SOPK_Pseudo< 943 "s_version", 944 (outs), 945 (ins s16imm:$simm16), 946 "$simm16"> { 947 let has_sdst = 0; 948 } 949 950 def S_SUBVECTOR_LOOP_BEGIN : SOPK_32_BR<"s_subvector_loop_begin">; 951 def S_SUBVECTOR_LOOP_END : SOPK_32_BR<"s_subvector_loop_end">; 952 953 def S_WAITCNT_VSCNT : SOPK_WAITCNT<"s_waitcnt_vscnt">; 954 def S_WAITCNT_VMCNT : SOPK_WAITCNT<"s_waitcnt_vmcnt">; 955 def S_WAITCNT_EXPCNT : SOPK_WAITCNT<"s_waitcnt_expcnt">; 956 def S_WAITCNT_LGKMCNT : SOPK_WAITCNT<"s_waitcnt_lgkmcnt">; 957} // End SubtargetPredicate = isGFX10Plus 958 959//===----------------------------------------------------------------------===// 960// SOPC Instructions 961//===----------------------------------------------------------------------===// 962 963class SOPC_Pseudo<string opName, dag outs, dag ins, 964 string asmOps, list<dag> pattern=[]> : 965 SOP_Pseudo<opName, outs, ins, asmOps, pattern> { 966 let mayLoad = 0; 967 let mayStore = 0; 968 let hasSideEffects = 0; 969 let SALU = 1; 970 let SOPC = 1; 971 let Defs = [SCC]; 972 let SchedRW = [WriteSALU]; 973 let UseNamedOperandTable = 1; 974} 975 976class SOPC_Real<bits<7> op, SOPC_Pseudo ps, string real_name = ps.Mnemonic> : 977 InstSI <ps.OutOperandList, ps.InOperandList, 978 real_name # " " # ps.AsmOperands, []>, 979 Enc32 { 980 let SALU = 1; 981 let SOPC = 1; 982 let isPseudo = 0; 983 let isCodeGenOnly = 0; 984 985 // copy relevant pseudo op flags 986 let SubtargetPredicate = ps.SubtargetPredicate; 987 let OtherPredicates = ps.OtherPredicates; 988 let AsmMatchConverter = ps.AsmMatchConverter; 989 let UseNamedOperandTable = ps.UseNamedOperandTable; 990 let TSFlags = ps.TSFlags; 991 let SchedRW = ps.SchedRW; 992 let mayLoad = ps.mayLoad; 993 let mayStore = ps.mayStore; 994 995 // encoding 996 bits<8> src0; 997 bits<8> src1; 998 999 let Inst{7-0} = src0; 1000 let Inst{15-8} = src1; 1001 let Inst{22-16} = op; 1002 let Inst{31-23} = 0x17e; 1003} 1004 1005class SOPC_Base <RegisterOperand rc0, RegisterOperand rc1, 1006 string opName, list<dag> pattern = []> : SOPC_Pseudo < 1007 opName, (outs), (ins rc0:$src0, rc1:$src1), 1008 "$src0, $src1", pattern > { 1009} 1010 1011class SOPC_Helper <RegisterOperand rc, ValueType vt, 1012 string opName, SDPatternOperator cond> : SOPC_Base < 1013 rc, rc, opName, 1014 [(set SCC, (si_setcc_uniform vt:$src0, vt:$src1, cond))] > { 1015} 1016 1017class SOPC_CMP_32<string opName, 1018 SDPatternOperator cond = COND_NULL, string revOp = opName> 1019 : SOPC_Helper<SSrc_b32, i32, opName, cond>, 1020 Commutable_REV<revOp, !eq(revOp, opName)>, 1021 SOPKInstTable<0, opName> { 1022 let isCompare = 1; 1023 let isCommutable = 1; 1024} 1025 1026class SOPC_CMP_64<string opName, 1027 SDPatternOperator cond = COND_NULL, string revOp = opName> 1028 : SOPC_Helper<SSrc_b64, i64, opName, cond>, 1029 Commutable_REV<revOp, !eq(revOp, opName)> { 1030 let isCompare = 1; 1031 let isCommutable = 1; 1032} 1033 1034class SOPC_32<string opName, list<dag> pattern = []> 1035 : SOPC_Base<SSrc_b32, SSrc_b32, opName, pattern>; 1036 1037class SOPC_64_32<string opName, list<dag> pattern = []> 1038 : SOPC_Base<SSrc_b64, SSrc_b32, opName, pattern>; 1039 1040def S_CMP_EQ_I32 : SOPC_CMP_32 <"s_cmp_eq_i32">; 1041def S_CMP_LG_I32 : SOPC_CMP_32 <"s_cmp_lg_i32">; 1042def S_CMP_GT_I32 : SOPC_CMP_32 <"s_cmp_gt_i32", COND_SGT>; 1043def S_CMP_GE_I32 : SOPC_CMP_32 <"s_cmp_ge_i32", COND_SGE>; 1044def S_CMP_LT_I32 : SOPC_CMP_32 <"s_cmp_lt_i32", COND_SLT, "s_cmp_gt_i32">; 1045def S_CMP_LE_I32 : SOPC_CMP_32 <"s_cmp_le_i32", COND_SLE, "s_cmp_ge_i32">; 1046def S_CMP_EQ_U32 : SOPC_CMP_32 <"s_cmp_eq_u32", COND_EQ>; 1047def S_CMP_LG_U32 : SOPC_CMP_32 <"s_cmp_lg_u32", COND_NE>; 1048def S_CMP_GT_U32 : SOPC_CMP_32 <"s_cmp_gt_u32", COND_UGT>; 1049def S_CMP_GE_U32 : SOPC_CMP_32 <"s_cmp_ge_u32", COND_UGE>; 1050def S_CMP_LT_U32 : SOPC_CMP_32 <"s_cmp_lt_u32", COND_ULT, "s_cmp_gt_u32">; 1051def S_CMP_LE_U32 : SOPC_CMP_32 <"s_cmp_le_u32", COND_ULE, "s_cmp_ge_u32">; 1052 1053def S_BITCMP0_B32 : SOPC_32 <"s_bitcmp0_b32">; 1054def S_BITCMP1_B32 : SOPC_32 <"s_bitcmp1_b32">; 1055def S_BITCMP0_B64 : SOPC_64_32 <"s_bitcmp0_b64">; 1056def S_BITCMP1_B64 : SOPC_64_32 <"s_bitcmp1_b64">; 1057let SubtargetPredicate = isGFX6GFX7GFX8GFX9 in 1058def S_SETVSKIP : SOPC_32 <"s_setvskip">; 1059 1060let SubtargetPredicate = isGFX8Plus in { 1061def S_CMP_EQ_U64 : SOPC_CMP_64 <"s_cmp_eq_u64", COND_EQ>; 1062def S_CMP_LG_U64 : SOPC_CMP_64 <"s_cmp_lg_u64", COND_NE>; 1063} // End SubtargetPredicate = isGFX8Plus 1064 1065let SubtargetPredicate = HasVGPRIndexMode in { 1066// Setting the GPR index mode is really writing the fields in the mode 1067// register. We don't want to add mode register uses to every 1068// instruction, and it's too complicated to deal with anyway. This is 1069// modeled just as a side effect. 1070def S_SET_GPR_IDX_ON : SOPC_Pseudo < 1071 "s_set_gpr_idx_on" , 1072 (outs), 1073 (ins SSrc_b32:$src0, GPRIdxMode:$src1), 1074 "$src0, $src1"> { 1075 let Defs = [M0, MODE]; // No scc def 1076 let Uses = [M0, MODE]; // Other bits of mode, m0 unmodified. 1077 let hasSideEffects = 1; // Sets mode.gpr_idx_en 1078 let FixedSize = 1; 1079} 1080} 1081 1082//===----------------------------------------------------------------------===// 1083// SOPP Instructions 1084//===----------------------------------------------------------------------===// 1085 1086class SOPP_Pseudo<string opName, dag ins, 1087 string asmOps = "", list<dag> pattern=[], string keyName = opName> : 1088 SOP_Pseudo<opName, (outs), ins, asmOps, pattern> { 1089 let isPseudo = 1; 1090 let isCodeGenOnly = 1; 1091 let mayLoad = 0; 1092 let mayStore = 0; 1093 let hasSideEffects = 0; 1094 let SALU = 1; 1095 let SOPP = 1; 1096 let FixedSize = 1; 1097 let SchedRW = [WriteSALU]; 1098 let UseNamedOperandTable = 1; 1099 bits <16> simm16; 1100 bits <1> fixed_imm = 0; 1101 string KeyName = keyName; 1102} 1103 1104class SOPPRelaxTable <bit isRelaxed, string keyName, string gfxip> { 1105 bit IsRelaxed = isRelaxed; 1106 string KeyName = keyName # gfxip; 1107} 1108 1109//spaces inserted in realname on instantiation of this record to allow s_endpgm to omit whitespace 1110class SOPP_Real<bits<7> op, SOPP_Pseudo ps, string real_name = ps.Mnemonic> : 1111 InstSI <ps.OutOperandList, ps.InOperandList, 1112 real_name # ps.AsmOperands, []> { 1113 let SALU = 1; 1114 let SOPP = 1; 1115 let isPseudo = 0; 1116 let isCodeGenOnly = 0; 1117 1118 // copy relevant pseudo op flags 1119 let SubtargetPredicate = ps.SubtargetPredicate; 1120 let OtherPredicates = ps.OtherPredicates; 1121 let AsmMatchConverter = ps.AsmMatchConverter; 1122 let UseNamedOperandTable = ps.UseNamedOperandTable; 1123 let TSFlags = ps.TSFlags; 1124 let SchedRW = ps.SchedRW; 1125 let mayLoad = ps.mayLoad; 1126 let mayStore = ps.mayStore; 1127 bits <16> simm16; 1128} 1129 1130class SOPP_Real_32 <bits<7> op, SOPP_Pseudo ps, string real_name = ps.Mnemonic> : SOPP_Real<op, ps, real_name>, 1131Enc32 { 1132 let Inst{15-0} = !if(ps.fixed_imm, ps.simm16, simm16); 1133 let Inst{22-16} = op; 1134 let Inst{31-23} = 0x17f; 1135} 1136 1137class SOPP_Real_64 <bits<7> op, SOPP_Pseudo ps, string real_name = ps.Mnemonic> : SOPP_Real<op, ps, real_name>, 1138Enc64 { 1139 // encoding 1140 let Inst{15-0} = !if(ps.fixed_imm, ps.simm16, simm16); 1141 let Inst{22-16} = op; 1142 let Inst{31-23} = 0x17f; 1143 //effectively a nop 1144 let Inst{47-32} = 0x0; 1145 let Inst{54-48} = 0x0; 1146 let Inst{63-55} = 0x17f; 1147} 1148 1149multiclass SOPP_With_Relaxation <string opName, dag ins, 1150 string asmOps, list<dag> pattern=[]> { 1151 def "" : SOPP_Pseudo <opName, ins, asmOps, pattern>; 1152 def _pad_s_nop : SOPP_Pseudo <opName # "_pad_s_nop", ins, asmOps, pattern, opName>; 1153} 1154 1155def S_NOP : SOPP_Pseudo<"s_nop" , (ins i16imm:$simm16), "$simm16">; 1156 1157let isTerminator = 1 in { 1158def S_ENDPGM : SOPP_Pseudo<"s_endpgm", (ins EndpgmImm:$simm16), "$simm16"> { 1159 let isBarrier = 1; 1160 let isReturn = 1; 1161 let hasSideEffects = 1; 1162} 1163 1164def S_ENDPGM_SAVED : SOPP_Pseudo<"s_endpgm_saved", (ins)> { 1165 let SubtargetPredicate = isGFX8Plus; 1166 let simm16 = 0; 1167 let fixed_imm = 1; 1168 let isBarrier = 1; 1169 let isReturn = 1; 1170} 1171 1172let SubtargetPredicate = isGFX9Plus in { 1173 let isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1 in { 1174 def S_ENDPGM_ORDERED_PS_DONE : 1175 SOPP_Pseudo<"s_endpgm_ordered_ps_done", (ins)>; 1176 } // End isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1 1177} // End SubtargetPredicate = isGFX9Plus 1178 1179let SubtargetPredicate = isGFX10Plus in { 1180 let isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1 in { 1181 def S_CODE_END : 1182 SOPP_Pseudo<"s_code_end", (ins)>; 1183 } // End isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1 1184} // End SubtargetPredicate = isGFX10Plus 1185 1186let isBranch = 1, SchedRW = [WriteBranch] in { 1187let isBarrier = 1 in { 1188defm S_BRANCH : SOPP_With_Relaxation< 1189 "s_branch" , (ins sopp_brtarget:$simm16), "$simm16", 1190 [(br bb:$simm16)]>; 1191} 1192 1193let Uses = [SCC] in { 1194defm S_CBRANCH_SCC0 : SOPP_With_Relaxation< 1195 "s_cbranch_scc0" , (ins sopp_brtarget:$simm16), 1196 "$simm16" 1197>; 1198defm S_CBRANCH_SCC1 : SOPP_With_Relaxation < 1199 "s_cbranch_scc1" , (ins sopp_brtarget:$simm16), 1200 "$simm16" 1201>; 1202} // End Uses = [SCC] 1203 1204let Uses = [VCC] in { 1205defm S_CBRANCH_VCCZ : SOPP_With_Relaxation < 1206 "s_cbranch_vccz" , (ins sopp_brtarget:$simm16), 1207 "$simm16" 1208>; 1209defm S_CBRANCH_VCCNZ : SOPP_With_Relaxation < 1210 "s_cbranch_vccnz" , (ins sopp_brtarget:$simm16), 1211 "$simm16" 1212>; 1213} // End Uses = [VCC] 1214 1215let Uses = [EXEC] in { 1216defm S_CBRANCH_EXECZ : SOPP_With_Relaxation < 1217 "s_cbranch_execz" , (ins sopp_brtarget:$simm16), 1218 "$simm16" 1219>; 1220defm S_CBRANCH_EXECNZ : SOPP_With_Relaxation < 1221 "s_cbranch_execnz" , (ins sopp_brtarget:$simm16), 1222 "$simm16" 1223>; 1224} // End Uses = [EXEC] 1225 1226defm S_CBRANCH_CDBGSYS : SOPP_With_Relaxation < 1227 "s_cbranch_cdbgsys" , (ins sopp_brtarget:$simm16), 1228 "$simm16" 1229>; 1230 1231defm S_CBRANCH_CDBGSYS_AND_USER : SOPP_With_Relaxation < 1232 "s_cbranch_cdbgsys_and_user" , (ins sopp_brtarget:$simm16), 1233 "$simm16" 1234>; 1235 1236defm S_CBRANCH_CDBGSYS_OR_USER : SOPP_With_Relaxation < 1237 "s_cbranch_cdbgsys_or_user" , (ins sopp_brtarget:$simm16), 1238 "$simm16" 1239>; 1240 1241defm S_CBRANCH_CDBGUSER : SOPP_With_Relaxation < 1242 "s_cbranch_cdbguser" , (ins sopp_brtarget:$simm16), 1243 "$simm16" 1244>; 1245 1246} // End isBranch = 1 1247} // End isTerminator = 1 1248 1249let hasSideEffects = 1 in { 1250def S_BARRIER : SOPP_Pseudo <"s_barrier", (ins), "", 1251 [(int_amdgcn_s_barrier)]> { 1252 let SchedRW = [WriteBarrier]; 1253 let simm16 = 0; 1254 let fixed_imm = 1; 1255 let isConvergent = 1; 1256} 1257 1258def S_WAKEUP : SOPP_Pseudo <"s_wakeup", (ins) > { 1259 let SubtargetPredicate = isGFX8Plus; 1260 let simm16 = 0; 1261 let fixed_imm = 1; 1262 let mayLoad = 1; 1263 let mayStore = 1; 1264} 1265 1266let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in 1267def S_WAITCNT : SOPP_Pseudo <"s_waitcnt" , (ins WAIT_FLAG:$simm16), "$simm16", 1268 [(int_amdgcn_s_waitcnt timm:$simm16)]>; 1269def S_SETHALT : SOPP_Pseudo <"s_sethalt" , (ins i32imm:$simm16), "$simm16", 1270 [(int_amdgcn_s_sethalt timm:$simm16)]>; 1271def S_SETKILL : SOPP_Pseudo <"s_setkill" , (ins i16imm:$simm16), "$simm16">; 1272 1273// On SI the documentation says sleep for approximately 64 * low 2 1274// bits, consistent with the reported maximum of 448. On VI the 1275// maximum reported is 960 cycles, so 960 / 64 = 15 max, so is the 1276// maximum really 15 on VI? 1277def S_SLEEP : SOPP_Pseudo <"s_sleep", (ins i32imm:$simm16), 1278 "$simm16", [(int_amdgcn_s_sleep timm:$simm16)]> { 1279 let hasSideEffects = 1; 1280 let mayLoad = 0; 1281 let mayStore = 0; 1282} 1283 1284def S_SETPRIO : SOPP_Pseudo <"s_setprio" , (ins i16imm:$simm16), "$simm16">; 1285 1286let Uses = [EXEC, M0] in { 1287// FIXME: Should this be mayLoad+mayStore? 1288def S_SENDMSG : SOPP_Pseudo <"s_sendmsg" , (ins SendMsgImm:$simm16), "$simm16", 1289 [(int_amdgcn_s_sendmsg (i32 timm:$simm16), M0)]>; 1290 1291def S_SENDMSGHALT : SOPP_Pseudo <"s_sendmsghalt" , (ins SendMsgImm:$simm16), "$simm16", 1292 [(int_amdgcn_s_sendmsghalt (i32 timm:$simm16), M0)]>; 1293 1294} // End Uses = [EXEC, M0] 1295 1296def S_TRAP : SOPP_Pseudo <"s_trap" , (ins i16imm:$simm16), "$simm16"> { 1297 let isTrap = 1; 1298} 1299 1300def S_ICACHE_INV : SOPP_Pseudo <"s_icache_inv", (ins)> { 1301 let simm16 = 0; 1302 let fixed_imm = 1; 1303} 1304def S_INCPERFLEVEL : SOPP_Pseudo <"s_incperflevel", (ins i32imm:$simm16), "$simm16", 1305 [(int_amdgcn_s_incperflevel timm:$simm16)]> { 1306 let hasSideEffects = 1; 1307 let mayLoad = 0; 1308 let mayStore = 0; 1309} 1310def S_DECPERFLEVEL : SOPP_Pseudo <"s_decperflevel", (ins i32imm:$simm16), "$simm16", 1311 [(int_amdgcn_s_decperflevel timm:$simm16)]> { 1312 let hasSideEffects = 1; 1313 let mayLoad = 0; 1314 let mayStore = 0; 1315} 1316def S_TTRACEDATA : SOPP_Pseudo <"s_ttracedata", (ins)> { 1317 let simm16 = 0; 1318 let fixed_imm = 1; 1319} 1320 1321let SubtargetPredicate = HasVGPRIndexMode in { 1322def S_SET_GPR_IDX_OFF : SOPP_Pseudo<"s_set_gpr_idx_off", (ins) > { 1323 let simm16 = 0; 1324 let fixed_imm = 1; 1325 let Defs = [MODE]; 1326 let Uses = [MODE]; 1327} 1328} 1329} // End hasSideEffects 1330 1331let SubtargetPredicate = HasVGPRIndexMode in { 1332def S_SET_GPR_IDX_MODE : SOPP_Pseudo<"s_set_gpr_idx_mode", (ins GPRIdxMode:$simm16), 1333 "$simm16"> { 1334 let Defs = [M0, MODE]; 1335 let Uses = [MODE]; 1336} 1337} 1338 1339let SubtargetPredicate = isGFX10Plus in { 1340 def S_INST_PREFETCH : 1341 SOPP_Pseudo<"s_inst_prefetch", (ins s16imm:$simm16), "$simm16">; 1342 def S_CLAUSE : 1343 SOPP_Pseudo<"s_clause", (ins s16imm:$simm16), "$simm16">; 1344 def S_WAIT_IDLE : 1345 SOPP_Pseudo <"s_wait_idle", (ins), ""> { 1346 let simm16 = 0; 1347 let fixed_imm = 1; 1348 } 1349 def S_WAITCNT_DEPCTR : 1350 SOPP_Pseudo <"s_waitcnt_depctr" , (ins s16imm:$simm16), "$simm16">; 1351 1352 let hasSideEffects = 0, Uses = [MODE], Defs = [MODE] in { 1353 def S_ROUND_MODE : 1354 SOPP_Pseudo<"s_round_mode", (ins s16imm:$simm16), "$simm16">; 1355 def S_DENORM_MODE : 1356 SOPP_Pseudo<"s_denorm_mode", (ins i32imm:$simm16), "$simm16", 1357 [(SIdenorm_mode (i32 timm:$simm16))]>; 1358 } 1359 1360 def S_TTRACEDATA_IMM : 1361 SOPP_Pseudo<"s_ttracedata_imm", (ins s16imm:$simm16), "$simm16">; 1362} // End SubtargetPredicate = isGFX10Plus 1363 1364//===----------------------------------------------------------------------===// 1365// SOP1 Patterns 1366//===----------------------------------------------------------------------===// 1367 1368def : GCNPat < 1369 (AMDGPUendpgm), 1370 (S_ENDPGM (i16 0)) 1371>; 1372 1373def : GCNPat < 1374 (int_amdgcn_endpgm), 1375 (S_ENDPGM (i16 0)) 1376>; 1377 1378def : GCNPat < 1379 (i64 (ctpop i64:$src)), 1380 (i64 (REG_SEQUENCE SReg_64, 1381 (i32 (COPY_TO_REGCLASS (S_BCNT1_I32_B64 $src), SReg_32)), sub0, 1382 (S_MOV_B32 (i32 0)), sub1)) 1383>; 1384 1385def : GCNPat < 1386 (i32 (smax i32:$x, (i32 (ineg i32:$x)))), 1387 (S_ABS_I32 SReg_32:$x) 1388>; 1389 1390def : GCNPat < 1391 (i16 imm:$imm), 1392 (S_MOV_B32 imm:$imm) 1393>; 1394 1395// Same as a 32-bit inreg 1396def : GCNPat< 1397 (i32 (UniformUnaryFrag<sext> i16:$src)), 1398 (S_SEXT_I32_I16 $src) 1399>; 1400 1401 1402//===----------------------------------------------------------------------===// 1403// SOP2 Patterns 1404//===----------------------------------------------------------------------===// 1405 1406// V_ADD_I32_e32/S_ADD_U32 produces carry in VCC/SCC. For the vector 1407// case, the sgpr-copies pass will fix this to use the vector version. 1408def : GCNPat < 1409 (i32 (addc i32:$src0, i32:$src1)), 1410 (S_ADD_U32 $src0, $src1) 1411>; 1412 1413// FIXME: We need to use COPY_TO_REGCLASS to work-around the fact that 1414// REG_SEQUENCE patterns don't support instructions with multiple 1415// outputs. 1416def : GCNPat< 1417 (i64 (zext i16:$src)), 1418 (REG_SEQUENCE SReg_64, 1419 (i32 (COPY_TO_REGCLASS (S_AND_B32 $src, (S_MOV_B32 (i32 0xffff))), SGPR_32)), sub0, 1420 (S_MOV_B32 (i32 0)), sub1) 1421>; 1422 1423def : GCNPat < 1424 (i64 (UniformUnaryFrag<sext> i16:$src)), 1425 (REG_SEQUENCE SReg_64, (i32 (S_SEXT_I32_I16 $src)), sub0, 1426 (i32 (COPY_TO_REGCLASS (S_ASHR_I32 (i32 (S_SEXT_I32_I16 $src)), (S_MOV_B32 (i32 31))), SGPR_32)), sub1) 1427>; 1428 1429def : GCNPat< 1430 (i32 (zext i16:$src)), 1431 (S_AND_B32 (S_MOV_B32 (i32 0xffff)), $src) 1432>; 1433 1434// FIXME: ValueType should have isVector field 1435class ScalarNot2Pat<Instruction inst, SDPatternOperator op, ValueType vt, 1436 bit isVector = 1> : GCNPat< 1437 (UniformBinFrag<op> vt:$src0, (UniformUnaryFrag<!if(isVector, vnot, not)> vt:$src1)), 1438 (inst getSOPSrcForVT<vt>.ret:$src0, getSOPSrcForVT<vt>.ret:$src1) 1439>; 1440 1441// Match these for some more types 1442// TODO: i1 1443def : ScalarNot2Pat<S_ANDN2_B32, and, i16, 0>; 1444def : ScalarNot2Pat<S_ANDN2_B32, and, v2i16>; 1445def : ScalarNot2Pat<S_ANDN2_B64, and, v4i16>; 1446def : ScalarNot2Pat<S_ANDN2_B64, and, v2i32>; 1447 1448def : ScalarNot2Pat<S_ORN2_B32, or, i16, 0>; 1449def : ScalarNot2Pat<S_ORN2_B32, or, v2i16>; 1450def : ScalarNot2Pat<S_ORN2_B64, or, v4i16>; 1451def : ScalarNot2Pat<S_ORN2_B64, or, v2i32>; 1452 1453//===----------------------------------------------------------------------===// 1454// Target-specific instruction encodings. 1455//===----------------------------------------------------------------------===// 1456 1457class Select_gfx10<string opName> : SIMCInstr<opName, SIEncodingFamily.GFX10> { 1458 Predicate AssemblerPredicate = isGFX10Plus; 1459 string DecoderNamespace = "GFX10"; 1460} 1461 1462class Select_vi<string opName> : SIMCInstr<opName, SIEncodingFamily.VI> { 1463 Predicate AssemblerPredicate = isGFX8GFX9; 1464 string DecoderNamespace = "GFX8"; 1465} 1466 1467class Select_gfx6_gfx7<string opName> : SIMCInstr<opName, SIEncodingFamily.SI> { 1468 Predicate AssemblerPredicate = isGFX6GFX7; 1469 string DecoderNamespace = "GFX6GFX7"; 1470} 1471 1472//===----------------------------------------------------------------------===// 1473// SOP1 - GFX10. 1474//===----------------------------------------------------------------------===// 1475 1476multiclass SOP1_Real_gfx10<bits<8> op> { 1477 defvar ps = !cast<SOP1_Pseudo>(NAME); 1478 def _gfx10 : SOP1_Real<op, ps>, 1479 Select_gfx10<ps.Mnemonic>; 1480} 1481 1482defm S_ANDN1_SAVEEXEC_B64 : SOP1_Real_gfx10<0x037>; 1483defm S_ORN1_SAVEEXEC_B64 : SOP1_Real_gfx10<0x038>; 1484defm S_ANDN1_WREXEC_B64 : SOP1_Real_gfx10<0x039>; 1485defm S_ANDN2_WREXEC_B64 : SOP1_Real_gfx10<0x03a>; 1486defm S_BITREPLICATE_B64_B32 : SOP1_Real_gfx10<0x03b>; 1487defm S_AND_SAVEEXEC_B32 : SOP1_Real_gfx10<0x03c>; 1488defm S_OR_SAVEEXEC_B32 : SOP1_Real_gfx10<0x03d>; 1489defm S_XOR_SAVEEXEC_B32 : SOP1_Real_gfx10<0x03e>; 1490defm S_ANDN2_SAVEEXEC_B32 : SOP1_Real_gfx10<0x03f>; 1491defm S_ORN2_SAVEEXEC_B32 : SOP1_Real_gfx10<0x040>; 1492defm S_NAND_SAVEEXEC_B32 : SOP1_Real_gfx10<0x041>; 1493defm S_NOR_SAVEEXEC_B32 : SOP1_Real_gfx10<0x042>; 1494defm S_XNOR_SAVEEXEC_B32 : SOP1_Real_gfx10<0x043>; 1495defm S_ANDN1_SAVEEXEC_B32 : SOP1_Real_gfx10<0x044>; 1496defm S_ORN1_SAVEEXEC_B32 : SOP1_Real_gfx10<0x045>; 1497defm S_ANDN1_WREXEC_B32 : SOP1_Real_gfx10<0x046>; 1498defm S_ANDN2_WREXEC_B32 : SOP1_Real_gfx10<0x047>; 1499defm S_MOVRELSD_2_B32 : SOP1_Real_gfx10<0x049>; 1500 1501//===----------------------------------------------------------------------===// 1502// SOP1 - GFX6, GFX7. 1503//===----------------------------------------------------------------------===// 1504 1505 1506multiclass SOP1_Real_gfx6_gfx7<bits<8> op> { 1507 defvar ps = !cast<SOP1_Pseudo>(NAME); 1508 def _gfx6_gfx7 : SOP1_Real<op, ps>, 1509 Select_gfx6_gfx7<ps.Mnemonic>; 1510} 1511 1512multiclass SOP1_Real_gfx6_gfx7_gfx10<bits<8> op> : 1513 SOP1_Real_gfx6_gfx7<op>, SOP1_Real_gfx10<op>; 1514 1515defm S_CBRANCH_JOIN : SOP1_Real_gfx6_gfx7<0x032>; 1516 1517defm S_MOV_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x003>; 1518defm S_MOV_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x004>; 1519defm S_CMOV_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x005>; 1520defm S_CMOV_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x006>; 1521defm S_NOT_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x007>; 1522defm S_NOT_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x008>; 1523defm S_WQM_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x009>; 1524defm S_WQM_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x00a>; 1525defm S_BREV_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x00b>; 1526defm S_BREV_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x00c>; 1527defm S_BCNT0_I32_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x00d>; 1528defm S_BCNT0_I32_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x00e>; 1529defm S_BCNT1_I32_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x00f>; 1530defm S_BCNT1_I32_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x010>; 1531defm S_FF0_I32_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x011>; 1532defm S_FF0_I32_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x012>; 1533defm S_FF1_I32_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x013>; 1534defm S_FF1_I32_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x014>; 1535defm S_FLBIT_I32_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x015>; 1536defm S_FLBIT_I32_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x016>; 1537defm S_FLBIT_I32 : SOP1_Real_gfx6_gfx7_gfx10<0x017>; 1538defm S_FLBIT_I32_I64 : SOP1_Real_gfx6_gfx7_gfx10<0x018>; 1539defm S_SEXT_I32_I8 : SOP1_Real_gfx6_gfx7_gfx10<0x019>; 1540defm S_SEXT_I32_I16 : SOP1_Real_gfx6_gfx7_gfx10<0x01a>; 1541defm S_BITSET0_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x01b>; 1542defm S_BITSET0_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x01c>; 1543defm S_BITSET1_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x01d>; 1544defm S_BITSET1_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x01e>; 1545defm S_GETPC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x01f>; 1546defm S_SETPC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x020>; 1547defm S_SWAPPC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x021>; 1548defm S_RFE_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x022>; 1549defm S_AND_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x024>; 1550defm S_OR_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x025>; 1551defm S_XOR_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x026>; 1552defm S_ANDN2_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x027>; 1553defm S_ORN2_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x028>; 1554defm S_NAND_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x029>; 1555defm S_NOR_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x02a>; 1556defm S_XNOR_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x02b>; 1557defm S_QUADMASK_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x02c>; 1558defm S_QUADMASK_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x02d>; 1559defm S_MOVRELS_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x02e>; 1560defm S_MOVRELS_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x02f>; 1561defm S_MOVRELD_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x030>; 1562defm S_MOVRELD_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x031>; 1563defm S_ABS_I32 : SOP1_Real_gfx6_gfx7_gfx10<0x034>; 1564 1565//===----------------------------------------------------------------------===// 1566// SOP2 - GFX10. 1567//===----------------------------------------------------------------------===// 1568 1569multiclass SOP2_Real_gfx10<bits<7> op> { 1570 defvar ps = !cast<SOP2_Pseudo>(NAME); 1571 def _gfx10 : SOP2_Real<op, ps>, 1572 Select_gfx10<ps.Mnemonic>; 1573} 1574 1575defm S_LSHL1_ADD_U32 : SOP2_Real_gfx10<0x02e>; 1576defm S_LSHL2_ADD_U32 : SOP2_Real_gfx10<0x02f>; 1577defm S_LSHL3_ADD_U32 : SOP2_Real_gfx10<0x030>; 1578defm S_LSHL4_ADD_U32 : SOP2_Real_gfx10<0x031>; 1579defm S_PACK_LL_B32_B16 : SOP2_Real_gfx10<0x032>; 1580defm S_PACK_LH_B32_B16 : SOP2_Real_gfx10<0x033>; 1581defm S_PACK_HH_B32_B16 : SOP2_Real_gfx10<0x034>; 1582defm S_MUL_HI_U32 : SOP2_Real_gfx10<0x035>; 1583defm S_MUL_HI_I32 : SOP2_Real_gfx10<0x036>; 1584 1585//===----------------------------------------------------------------------===// 1586// SOP2 - GFX6, GFX7. 1587//===----------------------------------------------------------------------===// 1588 1589multiclass SOP2_Real_gfx6_gfx7<bits<7> op> { 1590 defvar ps = !cast<SOP_Pseudo>(NAME); 1591 def _gfx6_gfx7 : SOP2_Real<op, ps>, 1592 Select_gfx6_gfx7<ps.Mnemonic>; 1593} 1594 1595multiclass SOP2_Real_gfx6_gfx7_gfx10<bits<7> op> : 1596 SOP2_Real_gfx6_gfx7<op>, SOP2_Real_gfx10<op>; 1597 1598defm S_CBRANCH_G_FORK : SOP2_Real_gfx6_gfx7<0x02b>; 1599 1600defm S_ADD_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x000>; 1601defm S_SUB_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x001>; 1602defm S_ADD_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x002>; 1603defm S_SUB_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x003>; 1604defm S_ADDC_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x004>; 1605defm S_SUBB_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x005>; 1606defm S_MIN_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x006>; 1607defm S_MIN_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x007>; 1608defm S_MAX_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x008>; 1609defm S_MAX_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x009>; 1610defm S_CSELECT_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x00a>; 1611defm S_CSELECT_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x00b>; 1612defm S_AND_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x00e>; 1613defm S_AND_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x00f>; 1614defm S_OR_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x010>; 1615defm S_OR_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x011>; 1616defm S_XOR_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x012>; 1617defm S_XOR_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x013>; 1618defm S_ANDN2_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x014>; 1619defm S_ANDN2_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x015>; 1620defm S_ORN2_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x016>; 1621defm S_ORN2_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x017>; 1622defm S_NAND_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x018>; 1623defm S_NAND_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x019>; 1624defm S_NOR_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x01a>; 1625defm S_NOR_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x01b>; 1626defm S_XNOR_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x01c>; 1627defm S_XNOR_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x01d>; 1628defm S_LSHL_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x01e>; 1629defm S_LSHL_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x01f>; 1630defm S_LSHR_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x020>; 1631defm S_LSHR_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x021>; 1632defm S_ASHR_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x022>; 1633defm S_ASHR_I64 : SOP2_Real_gfx6_gfx7_gfx10<0x023>; 1634defm S_BFM_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x024>; 1635defm S_BFM_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x025>; 1636defm S_MUL_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x026>; 1637defm S_BFE_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x027>; 1638defm S_BFE_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x028>; 1639defm S_BFE_U64 : SOP2_Real_gfx6_gfx7_gfx10<0x029>; 1640defm S_BFE_I64 : SOP2_Real_gfx6_gfx7_gfx10<0x02a>; 1641defm S_ABSDIFF_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x02c>; 1642 1643//===----------------------------------------------------------------------===// 1644// SOPK - GFX10. 1645//===----------------------------------------------------------------------===// 1646 1647multiclass SOPK_Real32_gfx10<bits<5> op> { 1648 defvar ps = !cast<SOPK_Pseudo>(NAME); 1649 def _gfx10 : SOPK_Real32<op, ps>, 1650 Select_gfx10<ps.Mnemonic>; 1651} 1652 1653multiclass SOPK_Real64_gfx10<bits<5> op> { 1654 defvar ps = !cast<SOPK_Pseudo>(NAME); 1655 def _gfx10 : SOPK_Real64<op, ps>, 1656 Select_gfx10<ps.Mnemonic>; 1657} 1658 1659defm S_VERSION : SOPK_Real32_gfx10<0x001>; 1660defm S_CALL_B64 : SOPK_Real32_gfx10<0x016>; 1661defm S_WAITCNT_VSCNT : SOPK_Real32_gfx10<0x017>; 1662defm S_WAITCNT_VMCNT : SOPK_Real32_gfx10<0x018>; 1663defm S_WAITCNT_EXPCNT : SOPK_Real32_gfx10<0x019>; 1664defm S_WAITCNT_LGKMCNT : SOPK_Real32_gfx10<0x01a>; 1665defm S_SUBVECTOR_LOOP_BEGIN : SOPK_Real32_gfx10<0x01b>; 1666defm S_SUBVECTOR_LOOP_END : SOPK_Real32_gfx10<0x01c>; 1667 1668//===----------------------------------------------------------------------===// 1669// SOPK - GFX6, GFX7. 1670//===----------------------------------------------------------------------===// 1671 1672multiclass SOPK_Real32_gfx6_gfx7<bits<5> op> { 1673 defvar ps = !cast<SOPK_Pseudo>(NAME); 1674 def _gfx6_gfx7 : SOPK_Real32<op, ps>, 1675 Select_gfx6_gfx7<ps.Mnemonic>; 1676} 1677 1678multiclass SOPK_Real64_gfx6_gfx7<bits<5> op> { 1679 defvar ps = !cast<SOPK_Pseudo>(NAME); 1680 def _gfx6_gfx7 : SOPK_Real64<op, ps>, 1681 Select_gfx6_gfx7<ps.Mnemonic>; 1682} 1683 1684multiclass SOPK_Real32_gfx6_gfx7_gfx10<bits<5> op> : 1685 SOPK_Real32_gfx6_gfx7<op>, SOPK_Real32_gfx10<op>; 1686 1687multiclass SOPK_Real64_gfx6_gfx7_gfx10<bits<5> op> : 1688 SOPK_Real64_gfx6_gfx7<op>, SOPK_Real64_gfx10<op>; 1689 1690defm S_CBRANCH_I_FORK : SOPK_Real32_gfx6_gfx7<0x011>; 1691 1692defm S_MOVK_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x000>; 1693defm S_CMOVK_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x002>; 1694defm S_CMPK_EQ_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x003>; 1695defm S_CMPK_LG_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x004>; 1696defm S_CMPK_GT_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x005>; 1697defm S_CMPK_GE_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x006>; 1698defm S_CMPK_LT_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x007>; 1699defm S_CMPK_LE_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x008>; 1700defm S_CMPK_EQ_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x009>; 1701defm S_CMPK_LG_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00a>; 1702defm S_CMPK_GT_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00b>; 1703defm S_CMPK_GE_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00c>; 1704defm S_CMPK_LT_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00d>; 1705defm S_CMPK_LE_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00e>; 1706defm S_ADDK_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00f>; 1707defm S_MULK_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x010>; 1708defm S_GETREG_B32 : SOPK_Real32_gfx6_gfx7_gfx10<0x012>; 1709defm S_SETREG_B32 : SOPK_Real32_gfx6_gfx7_gfx10<0x013>; 1710defm S_SETREG_IMM32_B32 : SOPK_Real64_gfx6_gfx7_gfx10<0x015>; 1711 1712//===----------------------------------------------------------------------===// 1713// SOPP - GFX6, GFX7, GFX8, GFX9, GFX10 1714//===----------------------------------------------------------------------===// 1715 1716multiclass SOPP_Real_32_gfx6_gfx7<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic> { 1717 defvar ps = !cast<SOPP_Pseudo>(NAME); 1718 def _gfx6_gfx7 : SOPP_Real_32<op, ps, real_name>, 1719 Select_gfx6_gfx7<ps.Mnemonic>, 1720 SOPPRelaxTable<0, ps.KeyName, "_gfx6_gfx7">; 1721} 1722 1723multiclass SOPP_Real_32_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> { 1724 defvar ps = !cast<SOPP_Pseudo>(NAME); 1725 def _vi : SOPP_Real_32<op, ps, real_name>, 1726 Select_vi<ps.Mnemonic>, 1727 SOPPRelaxTable<0, ps.KeyName, "_vi">; 1728} 1729 1730multiclass SOPP_Real_32_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> { 1731 defvar ps = !cast<SOPP_Pseudo>(NAME); 1732 def _gfx10 : SOPP_Real_32<op, ps, real_name>, 1733 Select_gfx10<ps.Mnemonic>, 1734 SOPPRelaxTable<0, ps.KeyName, "_gfx10">; 1735} 1736 1737multiclass SOPP_Real_32_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1738 SOPP_Real_32_gfx8_gfx9<op, real_name>, SOPP_Real_32_gfx10<op, real_name>; 1739 1740multiclass SOPP_Real_32_gfx6_gfx7_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1741 SOPP_Real_32_gfx6_gfx7<op, real_name>, SOPP_Real_32_gfx8_gfx9<op, real_name>; 1742 1743multiclass SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1744 SOPP_Real_32_gfx6_gfx7_gfx8_gfx9<op, real_name>, SOPP_Real_32_gfx10<op, real_name>; 1745 1746//64 bit encodings, for Relaxation 1747multiclass SOPP_Real_64_gfx6_gfx7<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> { 1748 defvar ps = !cast<SOPP_Pseudo>(NAME); 1749 def _gfx6_gfx7 : SOPP_Real_64<op, ps, real_name>, 1750 Select_gfx6_gfx7<ps.Mnemonic>, 1751 SOPPRelaxTable<1, ps.KeyName, "_gfx6_gfx7">; 1752} 1753 1754multiclass SOPP_Real_64_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> { 1755 defvar ps = !cast<SOPP_Pseudo>(NAME); 1756 def _vi : SOPP_Real_64<op, ps, real_name>, 1757 Select_vi<ps.Mnemonic>, 1758 SOPPRelaxTable<1, ps.KeyName, "_vi">; 1759} 1760 1761multiclass SOPP_Real_64_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> { 1762 defvar ps = !cast<SOPP_Pseudo>(NAME); 1763 def _gfx10 : SOPP_Real_64<op, ps, real_name>, 1764 Select_gfx10<ps.Mnemonic>, 1765 SOPPRelaxTable<1, ps.KeyName, "_gfx10">; 1766} 1767 1768multiclass SOPP_Real_64_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1769 SOPP_Real_64_gfx8_gfx9<op, real_name>, SOPP_Real_64_gfx10<op, real_name>; 1770 1771multiclass SOPP_Real_64_gfx6_gfx7_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1772 SOPP_Real_64_gfx6_gfx7<op, real_name>, SOPP_Real_64_gfx8_gfx9<op, real_name>; 1773 1774multiclass SOPP_Real_64_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1775 SOPP_Real_64_gfx6_gfx7_gfx8_gfx9<op, real_name>, SOPP_Real_64_gfx10<op, real_name>; 1776 1777//relaxation for insts with no operands not implemented 1778multiclass SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op> { 1779 defm "" : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<op>; 1780 defm _pad_s_nop : SOPP_Real_64_gfx6_gfx7_gfx8_gfx9_gfx10<op>; 1781} 1782 1783defm S_NOP : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x000>; 1784defm S_ENDPGM : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x001, "s_endpgm">; 1785defm S_WAKEUP : SOPP_Real_32_gfx8_gfx9_gfx10<0x003>; 1786defm S_BARRIER : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00a>; 1787defm S_WAITCNT : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00c>; 1788defm S_SETHALT : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00d>; 1789defm S_SETKILL : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00b>; 1790defm S_SLEEP : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00e>; 1791defm S_SETPRIO : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00f>; 1792defm S_SENDMSG : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x010>; 1793defm S_SENDMSGHALT : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x011>; 1794defm S_TRAP : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x012>; 1795defm S_ICACHE_INV : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x013>; 1796defm S_INCPERFLEVEL : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x014>; 1797defm S_DECPERFLEVEL : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x015>; 1798defm S_TTRACEDATA : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x016>; 1799defm S_ENDPGM_SAVED : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x01B>; 1800defm S_SET_GPR_IDX_OFF : SOPP_Real_32_gfx8_gfx9<0x01c>; 1801defm S_SET_GPR_IDX_MODE : SOPP_Real_32_gfx8_gfx9<0x01d>; 1802defm S_ENDPGM_ORDERED_PS_DONE : SOPP_Real_32_gfx8_gfx9_gfx10<0x01e>; 1803defm S_CODE_END : SOPP_Real_32_gfx10<0x01f>; 1804defm S_INST_PREFETCH : SOPP_Real_32_gfx10<0x020>; 1805defm S_CLAUSE : SOPP_Real_32_gfx10<0x021>; 1806defm S_WAIT_IDLE : SOPP_Real_32_gfx10<0x022>; 1807defm S_WAITCNT_DEPCTR : SOPP_Real_32_gfx10<0x023>; 1808defm S_ROUND_MODE : SOPP_Real_32_gfx10<0x024>; 1809defm S_DENORM_MODE : SOPP_Real_32_gfx10<0x025>; 1810defm S_TTRACEDATA_IMM : SOPP_Real_32_gfx10<0x028>; 1811 1812let isBranch = 1 in { 1813defm S_BRANCH : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x002>; 1814defm S_CBRANCH_SCC0 : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x004>; 1815defm S_CBRANCH_SCC1 : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x005>; 1816defm S_CBRANCH_VCCZ : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x006>; 1817defm S_CBRANCH_VCCNZ : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x007>; 1818defm S_CBRANCH_EXECZ : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x008>; 1819defm S_CBRANCH_EXECNZ : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x009>; 1820defm S_CBRANCH_CDBGSYS : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x017>; 1821defm S_CBRANCH_CDBGUSER : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x018>; 1822defm S_CBRANCH_CDBGSYS_OR_USER : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x019>; 1823defm S_CBRANCH_CDBGSYS_AND_USER : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x01A>; 1824} 1825 1826//===----------------------------------------------------------------------===// 1827// SOPC - GFX6, GFX7, GFX8, GFX9, GFX10 1828//===----------------------------------------------------------------------===// 1829 1830multiclass SOPC_Real_gfx6_gfx7<bits<7> op> { 1831 defvar ps = !cast<SOPC_Pseudo>(NAME); 1832 def _gfx6_gfx7 : SOPC_Real<op, ps>, 1833 Select_gfx6_gfx7<ps.Mnemonic>; 1834} 1835 1836multiclass SOPC_Real_gfx8_gfx9<bits<7> op> { 1837 defvar ps = !cast<SOPC_Pseudo>(NAME); 1838 def _vi : SOPC_Real<op, ps>, 1839 Select_vi<ps.Mnemonic>; 1840} 1841 1842multiclass SOPC_Real_gfx10<bits<7> op> { 1843 defvar ps = !cast<SOPC_Pseudo>(NAME); 1844 def _gfx10 : SOPC_Real<op, ps>, 1845 Select_gfx10<ps.Mnemonic>; 1846} 1847 1848multiclass SOPC_Real_gfx8_gfx9_gfx10<bits<7> op> : 1849 SOPC_Real_gfx8_gfx9<op>, SOPC_Real_gfx10<op>; 1850 1851multiclass SOPC_Real_gfx6_gfx7_gfx8_gfx9<bits<7> op> : 1852 SOPC_Real_gfx6_gfx7<op>, SOPC_Real_gfx8_gfx9<op>; 1853 1854multiclass SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op> : 1855 SOPC_Real_gfx6_gfx7_gfx8_gfx9<op>, SOPC_Real_gfx10<op>; 1856 1857defm S_CMP_EQ_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x00>; 1858defm S_CMP_LG_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x01>; 1859defm S_CMP_GT_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x02>; 1860defm S_CMP_GE_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x03>; 1861defm S_CMP_LT_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x04>; 1862defm S_CMP_LE_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x05>; 1863defm S_CMP_EQ_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x06>; 1864defm S_CMP_LG_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x07>; 1865defm S_CMP_GT_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x08>; 1866defm S_CMP_GE_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x09>; 1867defm S_CMP_LT_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0a>; 1868defm S_CMP_LE_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0b>; 1869defm S_BITCMP0_B32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0c>; 1870defm S_BITCMP1_B32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0d>; 1871defm S_BITCMP0_B64 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0e>; 1872defm S_BITCMP1_B64 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0f>; 1873defm S_SETVSKIP : SOPC_Real_gfx6_gfx7_gfx8_gfx9<0x10>; 1874defm S_SET_GPR_IDX_ON : SOPC_Real_gfx8_gfx9<0x11>; 1875defm S_CMP_EQ_U64 : SOPC_Real_gfx8_gfx9_gfx10<0x12>; 1876defm S_CMP_LG_U64 : SOPC_Real_gfx8_gfx9_gfx10<0x13>; 1877 1878//===----------------------------------------------------------------------===// 1879// GFX8 (VI), GFX9. 1880//===----------------------------------------------------------------------===// 1881 1882class SOP1_Real_vi<bits<8> op, SOP1_Pseudo ps> : 1883 SOP1_Real<op, ps>, 1884 Select_vi<ps.Mnemonic>; 1885 1886 1887class SOP2_Real_vi<bits<7> op, SOP2_Pseudo ps> : 1888 SOP2_Real<op, ps>, 1889 Select_vi<ps.Mnemonic>; 1890 1891class SOPK_Real_vi<bits<5> op, SOPK_Pseudo ps> : 1892 SOPK_Real32<op, ps>, 1893 Select_vi<ps.Mnemonic>; 1894 1895def S_MOV_B32_vi : SOP1_Real_vi <0x00, S_MOV_B32>; 1896def S_MOV_B64_vi : SOP1_Real_vi <0x01, S_MOV_B64>; 1897def S_CMOV_B32_vi : SOP1_Real_vi <0x02, S_CMOV_B32>; 1898def S_CMOV_B64_vi : SOP1_Real_vi <0x03, S_CMOV_B64>; 1899def S_NOT_B32_vi : SOP1_Real_vi <0x04, S_NOT_B32>; 1900def S_NOT_B64_vi : SOP1_Real_vi <0x05, S_NOT_B64>; 1901def S_WQM_B32_vi : SOP1_Real_vi <0x06, S_WQM_B32>; 1902def S_WQM_B64_vi : SOP1_Real_vi <0x07, S_WQM_B64>; 1903def S_BREV_B32_vi : SOP1_Real_vi <0x08, S_BREV_B32>; 1904def S_BREV_B64_vi : SOP1_Real_vi <0x09, S_BREV_B64>; 1905def S_BCNT0_I32_B32_vi : SOP1_Real_vi <0x0a, S_BCNT0_I32_B32>; 1906def S_BCNT0_I32_B64_vi : SOP1_Real_vi <0x0b, S_BCNT0_I32_B64>; 1907def S_BCNT1_I32_B32_vi : SOP1_Real_vi <0x0c, S_BCNT1_I32_B32>; 1908def S_BCNT1_I32_B64_vi : SOP1_Real_vi <0x0d, S_BCNT1_I32_B64>; 1909def S_FF0_I32_B32_vi : SOP1_Real_vi <0x0e, S_FF0_I32_B32>; 1910def S_FF0_I32_B64_vi : SOP1_Real_vi <0x0f, S_FF0_I32_B64>; 1911def S_FF1_I32_B32_vi : SOP1_Real_vi <0x10, S_FF1_I32_B32>; 1912def S_FF1_I32_B64_vi : SOP1_Real_vi <0x11, S_FF1_I32_B64>; 1913def S_FLBIT_I32_B32_vi : SOP1_Real_vi <0x12, S_FLBIT_I32_B32>; 1914def S_FLBIT_I32_B64_vi : SOP1_Real_vi <0x13, S_FLBIT_I32_B64>; 1915def S_FLBIT_I32_vi : SOP1_Real_vi <0x14, S_FLBIT_I32>; 1916def S_FLBIT_I32_I64_vi : SOP1_Real_vi <0x15, S_FLBIT_I32_I64>; 1917def S_SEXT_I32_I8_vi : SOP1_Real_vi <0x16, S_SEXT_I32_I8>; 1918def S_SEXT_I32_I16_vi : SOP1_Real_vi <0x17, S_SEXT_I32_I16>; 1919def S_BITSET0_B32_vi : SOP1_Real_vi <0x18, S_BITSET0_B32>; 1920def S_BITSET0_B64_vi : SOP1_Real_vi <0x19, S_BITSET0_B64>; 1921def S_BITSET1_B32_vi : SOP1_Real_vi <0x1a, S_BITSET1_B32>; 1922def S_BITSET1_B64_vi : SOP1_Real_vi <0x1b, S_BITSET1_B64>; 1923def S_GETPC_B64_vi : SOP1_Real_vi <0x1c, S_GETPC_B64>; 1924def S_SETPC_B64_vi : SOP1_Real_vi <0x1d, S_SETPC_B64>; 1925def S_SWAPPC_B64_vi : SOP1_Real_vi <0x1e, S_SWAPPC_B64>; 1926def S_RFE_B64_vi : SOP1_Real_vi <0x1f, S_RFE_B64>; 1927def S_AND_SAVEEXEC_B64_vi : SOP1_Real_vi <0x20, S_AND_SAVEEXEC_B64>; 1928def S_OR_SAVEEXEC_B64_vi : SOP1_Real_vi <0x21, S_OR_SAVEEXEC_B64>; 1929def S_XOR_SAVEEXEC_B64_vi : SOP1_Real_vi <0x22, S_XOR_SAVEEXEC_B64>; 1930def S_ANDN2_SAVEEXEC_B64_vi: SOP1_Real_vi <0x23, S_ANDN2_SAVEEXEC_B64>; 1931def S_ORN2_SAVEEXEC_B64_vi : SOP1_Real_vi <0x24, S_ORN2_SAVEEXEC_B64>; 1932def S_NAND_SAVEEXEC_B64_vi : SOP1_Real_vi <0x25, S_NAND_SAVEEXEC_B64>; 1933def S_NOR_SAVEEXEC_B64_vi : SOP1_Real_vi <0x26, S_NOR_SAVEEXEC_B64>; 1934def S_XNOR_SAVEEXEC_B64_vi : SOP1_Real_vi <0x27, S_XNOR_SAVEEXEC_B64>; 1935def S_QUADMASK_B32_vi : SOP1_Real_vi <0x28, S_QUADMASK_B32>; 1936def S_QUADMASK_B64_vi : SOP1_Real_vi <0x29, S_QUADMASK_B64>; 1937def S_MOVRELS_B32_vi : SOP1_Real_vi <0x2a, S_MOVRELS_B32>; 1938def S_MOVRELS_B64_vi : SOP1_Real_vi <0x2b, S_MOVRELS_B64>; 1939def S_MOVRELD_B32_vi : SOP1_Real_vi <0x2c, S_MOVRELD_B32>; 1940def S_MOVRELD_B64_vi : SOP1_Real_vi <0x2d, S_MOVRELD_B64>; 1941def S_CBRANCH_JOIN_vi : SOP1_Real_vi <0x2e, S_CBRANCH_JOIN>; 1942def S_ABS_I32_vi : SOP1_Real_vi <0x30, S_ABS_I32>; 1943def S_SET_GPR_IDX_IDX_vi : SOP1_Real_vi <0x32, S_SET_GPR_IDX_IDX>; 1944 1945def S_ADD_U32_vi : SOP2_Real_vi <0x00, S_ADD_U32>; 1946def S_ADD_I32_vi : SOP2_Real_vi <0x02, S_ADD_I32>; 1947def S_SUB_U32_vi : SOP2_Real_vi <0x01, S_SUB_U32>; 1948def S_SUB_I32_vi : SOP2_Real_vi <0x03, S_SUB_I32>; 1949def S_ADDC_U32_vi : SOP2_Real_vi <0x04, S_ADDC_U32>; 1950def S_SUBB_U32_vi : SOP2_Real_vi <0x05, S_SUBB_U32>; 1951def S_MIN_I32_vi : SOP2_Real_vi <0x06, S_MIN_I32>; 1952def S_MIN_U32_vi : SOP2_Real_vi <0x07, S_MIN_U32>; 1953def S_MAX_I32_vi : SOP2_Real_vi <0x08, S_MAX_I32>; 1954def S_MAX_U32_vi : SOP2_Real_vi <0x09, S_MAX_U32>; 1955def S_CSELECT_B32_vi : SOP2_Real_vi <0x0a, S_CSELECT_B32>; 1956def S_CSELECT_B64_vi : SOP2_Real_vi <0x0b, S_CSELECT_B64>; 1957def S_AND_B32_vi : SOP2_Real_vi <0x0c, S_AND_B32>; 1958def S_AND_B64_vi : SOP2_Real_vi <0x0d, S_AND_B64>; 1959def S_OR_B32_vi : SOP2_Real_vi <0x0e, S_OR_B32>; 1960def S_OR_B64_vi : SOP2_Real_vi <0x0f, S_OR_B64>; 1961def S_XOR_B32_vi : SOP2_Real_vi <0x10, S_XOR_B32>; 1962def S_XOR_B64_vi : SOP2_Real_vi <0x11, S_XOR_B64>; 1963def S_ANDN2_B32_vi : SOP2_Real_vi <0x12, S_ANDN2_B32>; 1964def S_ANDN2_B64_vi : SOP2_Real_vi <0x13, S_ANDN2_B64>; 1965def S_ORN2_B32_vi : SOP2_Real_vi <0x14, S_ORN2_B32>; 1966def S_ORN2_B64_vi : SOP2_Real_vi <0x15, S_ORN2_B64>; 1967def S_NAND_B32_vi : SOP2_Real_vi <0x16, S_NAND_B32>; 1968def S_NAND_B64_vi : SOP2_Real_vi <0x17, S_NAND_B64>; 1969def S_NOR_B32_vi : SOP2_Real_vi <0x18, S_NOR_B32>; 1970def S_NOR_B64_vi : SOP2_Real_vi <0x19, S_NOR_B64>; 1971def S_XNOR_B32_vi : SOP2_Real_vi <0x1a, S_XNOR_B32>; 1972def S_XNOR_B64_vi : SOP2_Real_vi <0x1b, S_XNOR_B64>; 1973def S_LSHL_B32_vi : SOP2_Real_vi <0x1c, S_LSHL_B32>; 1974def S_LSHL_B64_vi : SOP2_Real_vi <0x1d, S_LSHL_B64>; 1975def S_LSHR_B32_vi : SOP2_Real_vi <0x1e, S_LSHR_B32>; 1976def S_LSHR_B64_vi : SOP2_Real_vi <0x1f, S_LSHR_B64>; 1977def S_ASHR_I32_vi : SOP2_Real_vi <0x20, S_ASHR_I32>; 1978def S_ASHR_I64_vi : SOP2_Real_vi <0x21, S_ASHR_I64>; 1979def S_BFM_B32_vi : SOP2_Real_vi <0x22, S_BFM_B32>; 1980def S_BFM_B64_vi : SOP2_Real_vi <0x23, S_BFM_B64>; 1981def S_MUL_I32_vi : SOP2_Real_vi <0x24, S_MUL_I32>; 1982def S_BFE_U32_vi : SOP2_Real_vi <0x25, S_BFE_U32>; 1983def S_BFE_I32_vi : SOP2_Real_vi <0x26, S_BFE_I32>; 1984def S_BFE_U64_vi : SOP2_Real_vi <0x27, S_BFE_U64>; 1985def S_BFE_I64_vi : SOP2_Real_vi <0x28, S_BFE_I64>; 1986def S_CBRANCH_G_FORK_vi : SOP2_Real_vi <0x29, S_CBRANCH_G_FORK>; 1987def S_ABSDIFF_I32_vi : SOP2_Real_vi <0x2a, S_ABSDIFF_I32>; 1988def S_PACK_LL_B32_B16_vi : SOP2_Real_vi <0x32, S_PACK_LL_B32_B16>; 1989def S_PACK_LH_B32_B16_vi : SOP2_Real_vi <0x33, S_PACK_LH_B32_B16>; 1990def S_PACK_HH_B32_B16_vi : SOP2_Real_vi <0x34, S_PACK_HH_B32_B16>; 1991def S_RFE_RESTORE_B64_vi : SOP2_Real_vi <0x2b, S_RFE_RESTORE_B64>; 1992 1993def S_MOVK_I32_vi : SOPK_Real_vi <0x00, S_MOVK_I32>; 1994def S_CMOVK_I32_vi : SOPK_Real_vi <0x01, S_CMOVK_I32>; 1995def S_CMPK_EQ_I32_vi : SOPK_Real_vi <0x02, S_CMPK_EQ_I32>; 1996def S_CMPK_LG_I32_vi : SOPK_Real_vi <0x03, S_CMPK_LG_I32>; 1997def S_CMPK_GT_I32_vi : SOPK_Real_vi <0x04, S_CMPK_GT_I32>; 1998def S_CMPK_GE_I32_vi : SOPK_Real_vi <0x05, S_CMPK_GE_I32>; 1999def S_CMPK_LT_I32_vi : SOPK_Real_vi <0x06, S_CMPK_LT_I32>; 2000def S_CMPK_LE_I32_vi : SOPK_Real_vi <0x07, S_CMPK_LE_I32>; 2001def S_CMPK_EQ_U32_vi : SOPK_Real_vi <0x08, S_CMPK_EQ_U32>; 2002def S_CMPK_LG_U32_vi : SOPK_Real_vi <0x09, S_CMPK_LG_U32>; 2003def S_CMPK_GT_U32_vi : SOPK_Real_vi <0x0A, S_CMPK_GT_U32>; 2004def S_CMPK_GE_U32_vi : SOPK_Real_vi <0x0B, S_CMPK_GE_U32>; 2005def S_CMPK_LT_U32_vi : SOPK_Real_vi <0x0C, S_CMPK_LT_U32>; 2006def S_CMPK_LE_U32_vi : SOPK_Real_vi <0x0D, S_CMPK_LE_U32>; 2007def S_ADDK_I32_vi : SOPK_Real_vi <0x0E, S_ADDK_I32>; 2008def S_MULK_I32_vi : SOPK_Real_vi <0x0F, S_MULK_I32>; 2009def S_CBRANCH_I_FORK_vi : SOPK_Real_vi <0x10, S_CBRANCH_I_FORK>; 2010def S_GETREG_B32_vi : SOPK_Real_vi <0x11, S_GETREG_B32>; 2011def S_SETREG_B32_vi : SOPK_Real_vi <0x12, S_SETREG_B32>; 2012//def S_GETREG_REGRD_B32_vi : SOPK_Real_vi <0x13, S_GETREG_REGRD_B32>; // see pseudo for comments 2013def S_SETREG_IMM32_B32_vi : SOPK_Real64<0x14, S_SETREG_IMM32_B32>, 2014 Select_vi<S_SETREG_IMM32_B32.Mnemonic>; 2015 2016def S_CALL_B64_vi : SOPK_Real_vi <0x15, S_CALL_B64>; 2017 2018//===----------------------------------------------------------------------===// 2019// SOP1 - GFX9. 2020//===----------------------------------------------------------------------===// 2021 2022def S_ANDN1_SAVEEXEC_B64_vi : SOP1_Real_vi<0x33, S_ANDN1_SAVEEXEC_B64>; 2023def S_ORN1_SAVEEXEC_B64_vi : SOP1_Real_vi<0x34, S_ORN1_SAVEEXEC_B64>; 2024def S_ANDN1_WREXEC_B64_vi : SOP1_Real_vi<0x35, S_ANDN1_WREXEC_B64>; 2025def S_ANDN2_WREXEC_B64_vi : SOP1_Real_vi<0x36, S_ANDN2_WREXEC_B64>; 2026def S_BITREPLICATE_B64_B32_vi : SOP1_Real_vi<0x37, S_BITREPLICATE_B64_B32>; 2027 2028//===----------------------------------------------------------------------===// 2029// SOP2 - GFX9. 2030//===----------------------------------------------------------------------===// 2031 2032def S_LSHL1_ADD_U32_vi : SOP2_Real_vi<0x2e, S_LSHL1_ADD_U32>; 2033def S_LSHL2_ADD_U32_vi : SOP2_Real_vi<0x2f, S_LSHL2_ADD_U32>; 2034def S_LSHL3_ADD_U32_vi : SOP2_Real_vi<0x30, S_LSHL3_ADD_U32>; 2035def S_LSHL4_ADD_U32_vi : SOP2_Real_vi<0x31, S_LSHL4_ADD_U32>; 2036def S_MUL_HI_U32_vi : SOP2_Real_vi<0x2c, S_MUL_HI_U32>; 2037def S_MUL_HI_I32_vi : SOP2_Real_vi<0x2d, S_MUL_HI_I32>; 2038