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 160class UniformUnaryFrag<SDPatternOperator Op> : PatFrag < 161 (ops node:$src0), 162 (Op $src0), 163 [{ return !N->isDivergent(); }]> { 164 // This check is unnecessary as it's captured by the result register 165 // bank constraint. 166 // 167 // FIXME: Should add a way for the emitter to recognize this is a 168 // trivially true predicate to eliminate the check. 169 let GISelPredicateCode = [{return true;}]; 170} 171 172class UniformBinFrag<SDPatternOperator Op> : PatFrag < 173 (ops node:$src0, node:$src1), 174 (Op $src0, $src1), 175 [{ return !N->isDivergent(); }]> { 176 // This check is unnecessary as it's captured by the result register 177 // bank constraint. 178 // 179 // FIXME: Should add a way for the emitter to recognize this is a 180 // trivially true predicate to eliminate the check. 181 let GISelPredicateCode = [{return true;}]; 182} 183 184class DivergentBinFrag<SDPatternOperator Op> : PatFrag < 185 (ops node:$src0, node:$src1), 186 (Op $src0, $src1), 187 [{ return N->isDivergent(); }]> { 188 // This check is unnecessary as it's captured by the result register 189 // bank constraint. 190 // 191 // FIXME: Should add a way for the emitter to recognize this is a 192 // trivially true predicate to eliminate the check. 193 let GISelPredicateCode = [{return true;}]; 194} 195 196 197let isMoveImm = 1 in { 198 let isReMaterializable = 1, isAsCheapAsAMove = 1 in { 199 def S_MOV_B32 : SOP1_32 <"s_mov_b32">; 200 def S_MOV_B64 : SOP1_64 <"s_mov_b64">; 201 } // End isReMaterializable = 1 202 203 let Uses = [SCC] in { 204 def S_CMOV_B32 : SOP1_32 <"s_cmov_b32">; 205 def S_CMOV_B64 : SOP1_64 <"s_cmov_b64">; 206 } // End Uses = [SCC] 207} // End isMoveImm = 1 208 209let Defs = [SCC] in { 210 def S_NOT_B32 : SOP1_32 <"s_not_b32", 211 [(set i32:$sdst, (UniformUnaryFrag<not> i32:$src0))] 212 >; 213 214 def S_NOT_B64 : SOP1_64 <"s_not_b64", 215 [(set i64:$sdst, (UniformUnaryFrag<not> i64:$src0))] 216 >; 217 def S_WQM_B32 : SOP1_32 <"s_wqm_b32">; 218 def S_WQM_B64 : SOP1_64 <"s_wqm_b64">; 219} // End Defs = [SCC] 220 221 222let WaveSizePredicate = isWave32 in { 223def : GCNPat < 224 (int_amdgcn_wqm_vote i1:$src0), 225 (S_WQM_B32 SSrc_b32:$src0) 226>; 227} 228 229let WaveSizePredicate = isWave64 in { 230def : GCNPat < 231 (int_amdgcn_wqm_vote i1:$src0), 232 (S_WQM_B64 SSrc_b64:$src0) 233>; 234} 235 236let isReMaterializable = 1, isAsCheapAsAMove = 1 in { 237def S_BREV_B32 : SOP1_32 <"s_brev_b32", 238 [(set i32:$sdst, (bitreverse i32:$src0))] 239>; 240def S_BREV_B64 : SOP1_64 <"s_brev_b64", 241 [(set i64:$sdst, (bitreverse i64:$src0))] 242>; 243} // End isReMaterializable = 1, isAsCheapAsAMove = 1 244 245let Defs = [SCC] in { 246def S_BCNT0_I32_B32 : SOP1_32 <"s_bcnt0_i32_b32">; 247def S_BCNT0_I32_B64 : SOP1_32_64 <"s_bcnt0_i32_b64">; 248def S_BCNT1_I32_B32 : SOP1_32 <"s_bcnt1_i32_b32", 249 [(set i32:$sdst, (UniformUnaryFrag<ctpop> i32:$src0))] 250>; 251def S_BCNT1_I32_B64 : SOP1_32_64 <"s_bcnt1_i32_b64", 252 [(set i32:$sdst, (UniformUnaryFrag<ctpop> i64:$src0))] 253>; 254} // End Defs = [SCC] 255 256let isReMaterializable = 1 in { 257def S_FF0_I32_B32 : SOP1_32 <"s_ff0_i32_b32">; 258def S_FF0_I32_B64 : SOP1_32_64 <"s_ff0_i32_b64">; 259def S_FF1_I32_B64 : SOP1_32_64 <"s_ff1_i32_b64", 260 [(set i32:$sdst, (UniformUnaryFrag<AMDGPUffbl_b32> i64:$src0))] 261>; 262 263def S_FF1_I32_B32 : SOP1_32 <"s_ff1_i32_b32", 264 [(set i32:$sdst, (UniformUnaryFrag<AMDGPUffbl_b32> i32:$src0))] 265>; 266 267def S_FLBIT_I32_B32 : SOP1_32 <"s_flbit_i32_b32", 268 [(set i32:$sdst, (UniformUnaryFrag<AMDGPUffbh_u32> i32:$src0))] 269>; 270 271def S_FLBIT_I32_B64 : SOP1_32_64 <"s_flbit_i32_b64", 272 [(set i32:$sdst, (UniformUnaryFrag<AMDGPUffbh_u32> i64:$src0))] 273>; 274def S_FLBIT_I32 : SOP1_32 <"s_flbit_i32", 275 [(set i32:$sdst, (UniformUnaryFrag<AMDGPUffbh_i32> i32:$src0))] 276>; 277def S_FLBIT_I32_I64 : SOP1_32_64 <"s_flbit_i32_i64">; 278def S_SEXT_I32_I8 : SOP1_32 <"s_sext_i32_i8", 279 [(set i32:$sdst, (sext_inreg i32:$src0, i8))] 280>; 281def S_SEXT_I32_I16 : SOP1_32 <"s_sext_i32_i16", 282 [(set i32:$sdst, (sext_inreg i32:$src0, i16))] 283>; 284} // End isReMaterializable = 1 285 286def S_BITSET0_B32 : SOP1_32 <"s_bitset0_b32", [], 1>; 287def S_BITSET0_B64 : SOP1_64_32 <"s_bitset0_b64", [], 1>; 288def S_BITSET1_B32 : SOP1_32 <"s_bitset1_b32", [], 1>; 289def S_BITSET1_B64 : SOP1_64_32 <"s_bitset1_b64", [], 1>; 290 291def S_GETPC_B64 : SOP1_64_0 <"s_getpc_b64", 292 [(set i64:$sdst, (int_amdgcn_s_getpc))] 293>; 294 295let isTerminator = 1, isBarrier = 1, SchedRW = [WriteBranch] in { 296 297let isBranch = 1, isIndirectBranch = 1 in { 298def S_SETPC_B64 : SOP1_1 <"s_setpc_b64">; 299} // End isBranch = 1, isIndirectBranch = 1 300 301let isReturn = 1 in { 302// Define variant marked as return rather than branch. 303def S_SETPC_B64_return : SOP1_1<"", CCR_SGPR_64, [(AMDGPUret_flag i64:$src0)]>; 304def S_SETPC_B64_return_gfx : SOP1_1<"", Gfx_CCR_SGPR_64, [(AMDGPUret_gfx_flag i64:$src0)]>; 305} 306} // End isTerminator = 1, isBarrier = 1 307 308let isCall = 1 in { 309def S_SWAPPC_B64 : SOP1_64 <"s_swappc_b64" 310>; 311} 312 313def S_RFE_B64 : SOP1_1 <"s_rfe_b64">; 314 315let hasSideEffects = 1, Uses = [EXEC], Defs = [EXEC, SCC] in { 316 317def S_AND_SAVEEXEC_B64 : SOP1_64 <"s_and_saveexec_b64">; 318def S_OR_SAVEEXEC_B64 : SOP1_64 <"s_or_saveexec_b64">; 319def S_XOR_SAVEEXEC_B64 : SOP1_64 <"s_xor_saveexec_b64">; 320def S_ANDN2_SAVEEXEC_B64 : SOP1_64 <"s_andn2_saveexec_b64">; 321def S_ORN2_SAVEEXEC_B64 : SOP1_64 <"s_orn2_saveexec_b64">; 322def S_NAND_SAVEEXEC_B64 : SOP1_64 <"s_nand_saveexec_b64">; 323def S_NOR_SAVEEXEC_B64 : SOP1_64 <"s_nor_saveexec_b64">; 324def S_XNOR_SAVEEXEC_B64 : SOP1_64 <"s_xnor_saveexec_b64">; 325 326} // End hasSideEffects = 1, Uses = [EXEC], Defs = [EXEC, SCC] 327 328def S_QUADMASK_B32 : SOP1_32 <"s_quadmask_b32">; 329def S_QUADMASK_B64 : SOP1_64 <"s_quadmask_b64">; 330 331let Uses = [M0] in { 332def S_MOVRELS_B32 : SOP1_32R <"s_movrels_b32">; 333def S_MOVRELS_B64 : SOP1_64R <"s_movrels_b64">; 334def S_MOVRELD_B32 : SOP1_32_movreld <"s_movreld_b32">; 335def S_MOVRELD_B64 : SOP1_64_movreld <"s_movreld_b64">; 336} // End Uses = [M0] 337 338let SubtargetPredicate = isGFX6GFX7GFX8GFX9 in { 339def S_CBRANCH_JOIN : SOP1_0_32R <"s_cbranch_join">; 340} // End SubtargetPredicate = isGFX6GFX7GFX8GFX9 341 342let Defs = [SCC] in { 343def S_ABS_I32 : SOP1_32 <"s_abs_i32", 344 [(set i32:$sdst, (abs i32:$src0))] 345 >; 346} // End Defs = [SCC] 347 348let SubtargetPredicate = HasVGPRIndexMode in { 349def S_SET_GPR_IDX_IDX : SOP1_0_32<"s_set_gpr_idx_idx"> { 350 let Uses = [M0, MODE]; 351 let Defs = [M0, MODE]; 352} 353} 354 355let SubtargetPredicate = isGFX9Plus in { 356 let hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] in { 357 def S_ANDN1_SAVEEXEC_B64 : SOP1_64<"s_andn1_saveexec_b64">; 358 def S_ORN1_SAVEEXEC_B64 : SOP1_64<"s_orn1_saveexec_b64">; 359 def S_ANDN1_WREXEC_B64 : SOP1_64<"s_andn1_wrexec_b64">; 360 def S_ANDN2_WREXEC_B64 : SOP1_64<"s_andn2_wrexec_b64">; 361 } // End hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] 362 363 let isReMaterializable = 1 in 364 def S_BITREPLICATE_B64_B32 : SOP1_64_32<"s_bitreplicate_b64_b32">; 365} // End SubtargetPredicate = isGFX9Plus 366 367let SubtargetPredicate = isGFX10Plus in { 368 let hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] in { 369 def S_AND_SAVEEXEC_B32 : SOP1_32<"s_and_saveexec_b32">; 370 def S_OR_SAVEEXEC_B32 : SOP1_32<"s_or_saveexec_b32">; 371 def S_XOR_SAVEEXEC_B32 : SOP1_32<"s_xor_saveexec_b32">; 372 def S_ANDN2_SAVEEXEC_B32 : SOP1_32<"s_andn2_saveexec_b32">; 373 def S_ORN2_SAVEEXEC_B32 : SOP1_32<"s_orn2_saveexec_b32">; 374 def S_NAND_SAVEEXEC_B32 : SOP1_32<"s_nand_saveexec_b32">; 375 def S_NOR_SAVEEXEC_B32 : SOP1_32<"s_nor_saveexec_b32">; 376 def S_XNOR_SAVEEXEC_B32 : SOP1_32<"s_xnor_saveexec_b32">; 377 def S_ANDN1_SAVEEXEC_B32 : SOP1_32<"s_andn1_saveexec_b32">; 378 def S_ORN1_SAVEEXEC_B32 : SOP1_32<"s_orn1_saveexec_b32">; 379 def S_ANDN1_WREXEC_B32 : SOP1_32<"s_andn1_wrexec_b32">; 380 def S_ANDN2_WREXEC_B32 : SOP1_32<"s_andn2_wrexec_b32">; 381 } // End hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] 382 383 let Uses = [M0] in { 384 def S_MOVRELSD_2_B32 : SOP1_32<"s_movrelsd_2_b32">; 385 } // End Uses = [M0] 386} // End SubtargetPredicate = isGFX10Plus 387 388//===----------------------------------------------------------------------===// 389// SOP2 Instructions 390//===----------------------------------------------------------------------===// 391 392class SOP2_Pseudo<string opName, dag outs, dag ins, 393 string asmOps, list<dag> pattern=[]> : 394 SOP_Pseudo<opName, outs, ins, asmOps, pattern> { 395 396 let mayLoad = 0; 397 let mayStore = 0; 398 let hasSideEffects = 0; 399 let SALU = 1; 400 let SOP2 = 1; 401 let SchedRW = [WriteSALU]; 402 let UseNamedOperandTable = 1; 403 404 let has_sdst = 1; 405 406 // Pseudo instructions have no encodings, but adding this field here allows 407 // us to do: 408 // let sdst = xxx in { 409 // for multiclasses that include both real and pseudo instructions. 410 // field bits<7> sdst = 0; 411 // let Size = 4; // Do we need size here? 412} 413 414class SOP2_Real<bits<7> op, SOP_Pseudo ps, string real_name = ps.Mnemonic> : 415 InstSI <ps.OutOperandList, ps.InOperandList, 416 real_name # " " # ps.AsmOperands, []>, 417 Enc32 { 418 let SALU = 1; 419 let SOP2 = 1; 420 let isPseudo = 0; 421 let isCodeGenOnly = 0; 422 423 // copy relevant pseudo op flags 424 let SubtargetPredicate = ps.SubtargetPredicate; 425 let AsmMatchConverter = ps.AsmMatchConverter; 426 let UseNamedOperandTable = ps.UseNamedOperandTable; 427 let TSFlags = ps.TSFlags; 428 let SchedRW = ps.SchedRW; 429 let mayLoad = ps.mayLoad; 430 let mayStore = ps.mayStore; 431 432 // encoding 433 bits<7> sdst; 434 bits<8> src0; 435 bits<8> src1; 436 437 let Inst{7-0} = src0; 438 let Inst{15-8} = src1; 439 let Inst{22-16} = !if(ps.has_sdst, sdst, ?); 440 let Inst{29-23} = op; 441 let Inst{31-30} = 0x2; // encoding 442} 443 444 445class SOP2_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo < 446 opName, (outs SReg_32:$sdst), (ins SSrc_b32:$src0, SSrc_b32:$src1), 447 "$sdst, $src0, $src1", pattern 448>; 449 450class SOP2_64 <string opName, list<dag> pattern=[]> : SOP2_Pseudo < 451 opName, (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1), 452 "$sdst, $src0, $src1", pattern 453>; 454 455class SOP2_64_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo < 456 opName, (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b32:$src1), 457 "$sdst, $src0, $src1", pattern 458>; 459 460class SOP2_64_32_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo < 461 opName, (outs SReg_64:$sdst), (ins SSrc_b32:$src0, SSrc_b32:$src1), 462 "$sdst, $src0, $src1", pattern 463>; 464 465 466let Defs = [SCC] in { // Carry out goes to SCC 467let isCommutable = 1 in { 468def S_ADD_U32 : SOP2_32 <"s_add_u32">; 469def S_ADD_I32 : SOP2_32 <"s_add_i32", 470 [(set i32:$sdst, (UniformBinFrag<add> SSrc_b32:$src0, SSrc_b32:$src1))] 471>; 472} // End isCommutable = 1 473 474def S_SUB_U32 : SOP2_32 <"s_sub_u32">; 475def S_SUB_I32 : SOP2_32 <"s_sub_i32", 476 [(set i32:$sdst, (UniformBinFrag<sub> SSrc_b32:$src0, SSrc_b32:$src1))] 477>; 478 479let Uses = [SCC] in { // Carry in comes from SCC 480let isCommutable = 1 in { 481def S_ADDC_U32 : SOP2_32 <"s_addc_u32", 482 [(set i32:$sdst, (UniformBinFrag<adde> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]>; 483} // End isCommutable = 1 484 485def S_SUBB_U32 : SOP2_32 <"s_subb_u32", 486 [(set i32:$sdst, (UniformBinFrag<sube> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]>; 487} // End Uses = [SCC] 488 489let isCommutable = 1 in { 490def S_MIN_I32 : SOP2_32 <"s_min_i32", 491 [(set i32:$sdst, (UniformBinFrag<smin> i32:$src0, i32:$src1))] 492>; 493def S_MIN_U32 : SOP2_32 <"s_min_u32", 494 [(set i32:$sdst, (UniformBinFrag<umin> i32:$src0, i32:$src1))] 495>; 496def S_MAX_I32 : SOP2_32 <"s_max_i32", 497 [(set i32:$sdst, (UniformBinFrag<smax> i32:$src0, i32:$src1))] 498>; 499def S_MAX_U32 : SOP2_32 <"s_max_u32", 500 [(set i32:$sdst, (UniformBinFrag<umax> i32:$src0, i32:$src1))] 501>; 502} // End isCommutable = 1 503} // End Defs = [SCC] 504 505// This pattern is restricted to certain subtargets (practically GFX8Plus) 506// because isel sometimes produces an sreg_64 copy to SCC as a by-product 507// of this pattern, and only for subtargets with hasScalarCompareEq64 508// is it possible to map such copy to a single instruction (S_CMP_LG_U64). 509class SelectPat<SDPatternOperator select> : PatFrag < 510 (ops node:$src1, node:$src2), 511 (select SCC, $src1, $src2), 512 [{ return Subtarget->hasScalarCompareEq64() && 513 N->getOperand(0)->hasOneUse() && !N->isDivergent(); }] 514>; 515 516let Uses = [SCC] in { 517 let AddedComplexity = 20 in { 518 def S_CSELECT_B32 : SOP2_32 <"s_cselect_b32", 519 [(set i32:$sdst, (SelectPat<select> i32:$src0, i32:$src1))] 520 >; 521 } 522 523 def S_CSELECT_B64 : SOP2_64 <"s_cselect_b64">; 524} // End Uses = [SCC] 525 526let Defs = [SCC] in { 527let isCommutable = 1 in { 528def S_AND_B32 : SOP2_32 <"s_and_b32", 529 [(set i32:$sdst, (UniformBinFrag<and> i32:$src0, i32:$src1))] 530>; 531 532def S_AND_B64 : SOP2_64 <"s_and_b64", 533 [(set i64:$sdst, (UniformBinFrag<and> i64:$src0, i64:$src1))] 534>; 535 536def S_OR_B32 : SOP2_32 <"s_or_b32", 537 [(set i32:$sdst, (UniformBinFrag<or> i32:$src0, i32:$src1))] 538>; 539 540def S_OR_B64 : SOP2_64 <"s_or_b64", 541 [(set i64:$sdst, (UniformBinFrag<or> i64:$src0, i64:$src1))] 542>; 543 544def S_XOR_B32 : SOP2_32 <"s_xor_b32", 545 [(set i32:$sdst, (UniformBinFrag<xor> i32:$src0, i32:$src1))] 546>; 547 548def S_XOR_B64 : SOP2_64 <"s_xor_b64", 549 [(set i64:$sdst, (UniformBinFrag<xor> i64:$src0, i64:$src1))] 550>; 551 552def S_XNOR_B32 : SOP2_32 <"s_xnor_b32", 553 [(set i32:$sdst, (UniformUnaryFrag<not> (xor_oneuse i32:$src0, i32:$src1)))] 554>; 555 556def S_XNOR_B64 : SOP2_64 <"s_xnor_b64", 557 [(set i64:$sdst, (UniformUnaryFrag<not> (xor_oneuse i64:$src0, i64:$src1)))] 558>; 559 560def S_NAND_B32 : SOP2_32 <"s_nand_b32", 561 [(set i32:$sdst, (UniformUnaryFrag<not> (and_oneuse i32:$src0, i32:$src1)))] 562>; 563 564def S_NAND_B64 : SOP2_64 <"s_nand_b64", 565 [(set i64:$sdst, (UniformUnaryFrag<not> (and_oneuse i64:$src0, i64:$src1)))] 566>; 567 568def S_NOR_B32 : SOP2_32 <"s_nor_b32", 569 [(set i32:$sdst, (UniformUnaryFrag<not> (or_oneuse i32:$src0, i32:$src1)))] 570>; 571 572def S_NOR_B64 : SOP2_64 <"s_nor_b64", 573 [(set i64:$sdst, (UniformUnaryFrag<not> (or_oneuse i64:$src0, i64:$src1)))] 574>; 575} // End isCommutable = 1 576 577// There are also separate patterns for types other than i32 578def S_ANDN2_B32 : SOP2_32 <"s_andn2_b32", 579 [(set i32:$sdst, (UniformBinFrag<and> i32:$src0, (UniformUnaryFrag<not> i32:$src1)))] 580>; 581 582def S_ANDN2_B64 : SOP2_64 <"s_andn2_b64", 583 [(set i64:$sdst, (UniformBinFrag<and> i64:$src0, (UniformUnaryFrag<not> i64:$src1)))] 584>; 585 586def S_ORN2_B32 : SOP2_32 <"s_orn2_b32", 587 [(set i32:$sdst, (UniformBinFrag<or> i32:$src0, (UniformUnaryFrag<not> i32:$src1)))] 588>; 589 590def S_ORN2_B64 : SOP2_64 <"s_orn2_b64", 591 [(set i64:$sdst, (UniformBinFrag<or> i64:$src0, (UniformUnaryFrag<not> i64:$src1)))] 592>; 593} // End Defs = [SCC] 594 595// Use added complexity so these patterns are preferred to the VALU patterns. 596let AddedComplexity = 1 in { 597 598let Defs = [SCC] in { 599// TODO: b64 versions require VOP3 change since v_lshlrev_b64 is VOP3 600def S_LSHL_B32 : SOP2_32 <"s_lshl_b32", 601 [(set SReg_32:$sdst, (UniformBinFrag<cshl_32> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))] 602>; 603def S_LSHL_B64 : SOP2_64_32 <"s_lshl_b64", 604 [(set SReg_64:$sdst, (UniformBinFrag<cshl_64> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))] 605>; 606def S_LSHR_B32 : SOP2_32 <"s_lshr_b32", 607 [(set SReg_32:$sdst, (UniformBinFrag<csrl_32> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))] 608>; 609def S_LSHR_B64 : SOP2_64_32 <"s_lshr_b64", 610 [(set SReg_64:$sdst, (UniformBinFrag<csrl_64> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))] 611>; 612def S_ASHR_I32 : SOP2_32 <"s_ashr_i32", 613 [(set SReg_32:$sdst, (UniformBinFrag<csra_32> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))] 614>; 615def S_ASHR_I64 : SOP2_64_32 <"s_ashr_i64", 616 [(set SReg_64:$sdst, (UniformBinFrag<csra_64> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))] 617>; 618} // End Defs = [SCC] 619 620let isReMaterializable = 1 in { 621def S_BFM_B32 : SOP2_32 <"s_bfm_b32", 622 [(set i32:$sdst, (UniformBinFrag<AMDGPUbfm> i32:$src0, i32:$src1))]>; 623def S_BFM_B64 : SOP2_64_32_32 <"s_bfm_b64">; 624 625def S_MUL_I32 : SOP2_32 <"s_mul_i32", 626 [(set i32:$sdst, (UniformBinFrag<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<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 <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<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 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 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<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<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<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 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} 1281 1282def S_SETPRIO : SOPP_Pseudo <"s_setprio" , (ins i16imm:$simm16), "$simm16">; 1283 1284let Uses = [EXEC, M0] in { 1285// FIXME: Should this be mayLoad+mayStore? 1286def S_SENDMSG : SOPP_Pseudo <"s_sendmsg" , (ins SendMsgImm:$simm16), "$simm16", 1287 [(int_amdgcn_s_sendmsg (i32 timm:$simm16), M0)]>; 1288 1289def S_SENDMSGHALT : SOPP_Pseudo <"s_sendmsghalt" , (ins SendMsgImm:$simm16), "$simm16", 1290 [(int_amdgcn_s_sendmsghalt (i32 timm:$simm16), M0)]>; 1291 1292} // End Uses = [EXEC, M0] 1293 1294def S_TRAP : SOPP_Pseudo <"s_trap" , (ins i16imm:$simm16), "$simm16"> { 1295 let isTrap = 1; 1296} 1297 1298def S_ICACHE_INV : SOPP_Pseudo <"s_icache_inv", (ins)> { 1299 let simm16 = 0; 1300 let fixed_imm = 1; 1301} 1302def S_INCPERFLEVEL : SOPP_Pseudo <"s_incperflevel", (ins i32imm:$simm16), "$simm16", 1303 [(int_amdgcn_s_incperflevel timm:$simm16)]> { 1304 let hasSideEffects = 1; 1305} 1306def S_DECPERFLEVEL : SOPP_Pseudo <"s_decperflevel", (ins i32imm:$simm16), "$simm16", 1307 [(int_amdgcn_s_decperflevel timm:$simm16)]> { 1308 let hasSideEffects = 1; 1309} 1310def S_TTRACEDATA : SOPP_Pseudo <"s_ttracedata", (ins)> { 1311 let simm16 = 0; 1312 let fixed_imm = 1; 1313} 1314 1315let SubtargetPredicate = HasVGPRIndexMode in { 1316def S_SET_GPR_IDX_OFF : SOPP_Pseudo<"s_set_gpr_idx_off", (ins) > { 1317 let simm16 = 0; 1318 let fixed_imm = 1; 1319 let Defs = [MODE]; 1320 let Uses = [MODE]; 1321} 1322} 1323} // End hasSideEffects 1324 1325let SubtargetPredicate = HasVGPRIndexMode in { 1326def S_SET_GPR_IDX_MODE : SOPP_Pseudo<"s_set_gpr_idx_mode", (ins GPRIdxMode:$simm16), 1327 "$simm16"> { 1328 let Defs = [M0, MODE]; 1329 let Uses = [MODE]; 1330} 1331} 1332 1333let SubtargetPredicate = isGFX10Plus in { 1334 def S_INST_PREFETCH : 1335 SOPP_Pseudo<"s_inst_prefetch", (ins s16imm:$simm16), "$simm16">; 1336 def S_CLAUSE : 1337 SOPP_Pseudo<"s_clause", (ins s16imm:$simm16), "$simm16">; 1338 def S_WAIT_IDLE : 1339 SOPP_Pseudo <"s_wait_idle", (ins), ""> { 1340 let simm16 = 0; 1341 let fixed_imm = 1; 1342 } 1343 def S_WAITCNT_DEPCTR : 1344 SOPP_Pseudo <"s_waitcnt_depctr" , (ins s16imm:$simm16), "$simm16">; 1345 1346 let hasSideEffects = 0, Uses = [MODE], Defs = [MODE] in { 1347 def S_ROUND_MODE : 1348 SOPP_Pseudo<"s_round_mode", (ins s16imm:$simm16), "$simm16">; 1349 def S_DENORM_MODE : 1350 SOPP_Pseudo<"s_denorm_mode", (ins i32imm:$simm16), "$simm16", 1351 [(SIdenorm_mode (i32 timm:$simm16))]>; 1352 } 1353 1354 def S_TTRACEDATA_IMM : 1355 SOPP_Pseudo<"s_ttracedata_imm", (ins s16imm:$simm16), "$simm16">; 1356} // End SubtargetPredicate = isGFX10Plus 1357 1358//===----------------------------------------------------------------------===// 1359// SOP1 Patterns 1360//===----------------------------------------------------------------------===// 1361 1362def : GCNPat < 1363 (AMDGPUendpgm), 1364 (S_ENDPGM (i16 0)) 1365>; 1366 1367def : GCNPat < 1368 (int_amdgcn_endpgm), 1369 (S_ENDPGM (i16 0)) 1370>; 1371 1372def : GCNPat < 1373 (i64 (UniformUnaryFrag<ctpop> i64:$src)), 1374 (i64 (REG_SEQUENCE SReg_64, 1375 (i32 (COPY_TO_REGCLASS (S_BCNT1_I32_B64 $src), SReg_32)), sub0, 1376 (S_MOV_B32 (i32 0)), sub1)) 1377>; 1378 1379def : GCNPat < 1380 (i32 (smax i32:$x, (i32 (ineg i32:$x)))), 1381 (S_ABS_I32 SReg_32:$x) 1382>; 1383 1384def : GCNPat < 1385 (i16 imm:$imm), 1386 (S_MOV_B32 imm:$imm) 1387>; 1388 1389// Same as a 32-bit inreg 1390def : GCNPat< 1391 (i32 (UniformUnaryFrag<sext> i16:$src)), 1392 (S_SEXT_I32_I16 $src) 1393>; 1394 1395 1396//===----------------------------------------------------------------------===// 1397// SOP2 Patterns 1398//===----------------------------------------------------------------------===// 1399 1400// V_ADD_I32_e32/S_ADD_U32 produces carry in VCC/SCC. For the vector 1401// case, the sgpr-copies pass will fix this to use the vector version. 1402def : GCNPat < 1403 (i32 (addc i32:$src0, i32:$src1)), 1404 (S_ADD_U32 $src0, $src1) 1405>; 1406 1407// FIXME: We need to use COPY_TO_REGCLASS to work-around the fact that 1408// REG_SEQUENCE patterns don't support instructions with multiple 1409// outputs. 1410def : GCNPat< 1411 (i64 (zext i16:$src)), 1412 (REG_SEQUENCE SReg_64, 1413 (i32 (COPY_TO_REGCLASS (S_AND_B32 $src, (S_MOV_B32 (i32 0xffff))), SGPR_32)), sub0, 1414 (S_MOV_B32 (i32 0)), sub1) 1415>; 1416 1417def : GCNPat < 1418 (i64 (UniformUnaryFrag<sext> i16:$src)), 1419 (REG_SEQUENCE SReg_64, (i32 (S_SEXT_I32_I16 $src)), sub0, 1420 (i32 (COPY_TO_REGCLASS (S_ASHR_I32 (i32 (S_SEXT_I32_I16 $src)), (S_MOV_B32 (i32 31))), SGPR_32)), sub1) 1421>; 1422 1423def : GCNPat< 1424 (i32 (zext i16:$src)), 1425 (S_AND_B32 (S_MOV_B32 (i32 0xffff)), $src) 1426>; 1427 1428// FIXME: ValueType should have isVector field 1429class ScalarNot2Pat<Instruction inst, SDPatternOperator op, ValueType vt, 1430 bit isVector = 1> : GCNPat< 1431 (UniformBinFrag<op> vt:$src0, (UniformUnaryFrag<!if(isVector, vnot, not)> vt:$src1)), 1432 (inst getSOPSrcForVT<vt>.ret:$src0, getSOPSrcForVT<vt>.ret:$src1) 1433>; 1434 1435// Match these for some more types 1436// TODO: i1 1437def : ScalarNot2Pat<S_ANDN2_B32, and, i16, 0>; 1438def : ScalarNot2Pat<S_ANDN2_B32, and, v2i16>; 1439def : ScalarNot2Pat<S_ANDN2_B64, and, v4i16>; 1440def : ScalarNot2Pat<S_ANDN2_B64, and, v2i32>; 1441 1442def : ScalarNot2Pat<S_ORN2_B32, or, i16, 0>; 1443def : ScalarNot2Pat<S_ORN2_B32, or, v2i16>; 1444def : ScalarNot2Pat<S_ORN2_B64, or, v4i16>; 1445def : ScalarNot2Pat<S_ORN2_B64, or, v2i32>; 1446 1447//===----------------------------------------------------------------------===// 1448// Target-specific instruction encodings. 1449//===----------------------------------------------------------------------===// 1450 1451class Select_gfx10<string opName> : SIMCInstr<opName, SIEncodingFamily.GFX10> { 1452 Predicate AssemblerPredicate = isGFX10Plus; 1453 string DecoderNamespace = "GFX10"; 1454} 1455 1456class Select_vi<string opName> : SIMCInstr<opName, SIEncodingFamily.VI> { 1457 Predicate AssemblerPredicate = isGFX8GFX9; 1458 string DecoderNamespace = "GFX8"; 1459} 1460 1461class Select_gfx6_gfx7<string opName> : SIMCInstr<opName, SIEncodingFamily.SI> { 1462 Predicate AssemblerPredicate = isGFX6GFX7; 1463 string DecoderNamespace = "GFX6GFX7"; 1464} 1465 1466//===----------------------------------------------------------------------===// 1467// SOP1 - GFX10. 1468//===----------------------------------------------------------------------===// 1469 1470multiclass SOP1_Real_gfx10<bits<8> op> { 1471 defvar ps = !cast<SOP1_Pseudo>(NAME); 1472 def _gfx10 : SOP1_Real<op, ps>, 1473 Select_gfx10<ps.Mnemonic>; 1474} 1475 1476defm S_ANDN1_SAVEEXEC_B64 : SOP1_Real_gfx10<0x037>; 1477defm S_ORN1_SAVEEXEC_B64 : SOP1_Real_gfx10<0x038>; 1478defm S_ANDN1_WREXEC_B64 : SOP1_Real_gfx10<0x039>; 1479defm S_ANDN2_WREXEC_B64 : SOP1_Real_gfx10<0x03a>; 1480defm S_BITREPLICATE_B64_B32 : SOP1_Real_gfx10<0x03b>; 1481defm S_AND_SAVEEXEC_B32 : SOP1_Real_gfx10<0x03c>; 1482defm S_OR_SAVEEXEC_B32 : SOP1_Real_gfx10<0x03d>; 1483defm S_XOR_SAVEEXEC_B32 : SOP1_Real_gfx10<0x03e>; 1484defm S_ANDN2_SAVEEXEC_B32 : SOP1_Real_gfx10<0x03f>; 1485defm S_ORN2_SAVEEXEC_B32 : SOP1_Real_gfx10<0x040>; 1486defm S_NAND_SAVEEXEC_B32 : SOP1_Real_gfx10<0x041>; 1487defm S_NOR_SAVEEXEC_B32 : SOP1_Real_gfx10<0x042>; 1488defm S_XNOR_SAVEEXEC_B32 : SOP1_Real_gfx10<0x043>; 1489defm S_ANDN1_SAVEEXEC_B32 : SOP1_Real_gfx10<0x044>; 1490defm S_ORN1_SAVEEXEC_B32 : SOP1_Real_gfx10<0x045>; 1491defm S_ANDN1_WREXEC_B32 : SOP1_Real_gfx10<0x046>; 1492defm S_ANDN2_WREXEC_B32 : SOP1_Real_gfx10<0x047>; 1493defm S_MOVRELSD_2_B32 : SOP1_Real_gfx10<0x049>; 1494 1495//===----------------------------------------------------------------------===// 1496// SOP1 - GFX6, GFX7. 1497//===----------------------------------------------------------------------===// 1498 1499 1500multiclass SOP1_Real_gfx6_gfx7<bits<8> op> { 1501 defvar ps = !cast<SOP1_Pseudo>(NAME); 1502 def _gfx6_gfx7 : SOP1_Real<op, ps>, 1503 Select_gfx6_gfx7<ps.Mnemonic>; 1504} 1505 1506multiclass SOP1_Real_gfx6_gfx7_gfx10<bits<8> op> : 1507 SOP1_Real_gfx6_gfx7<op>, SOP1_Real_gfx10<op>; 1508 1509defm S_CBRANCH_JOIN : SOP1_Real_gfx6_gfx7<0x032>; 1510 1511defm S_MOV_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x003>; 1512defm S_MOV_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x004>; 1513defm S_CMOV_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x005>; 1514defm S_CMOV_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x006>; 1515defm S_NOT_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x007>; 1516defm S_NOT_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x008>; 1517defm S_WQM_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x009>; 1518defm S_WQM_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x00a>; 1519defm S_BREV_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x00b>; 1520defm S_BREV_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x00c>; 1521defm S_BCNT0_I32_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x00d>; 1522defm S_BCNT0_I32_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x00e>; 1523defm S_BCNT1_I32_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x00f>; 1524defm S_BCNT1_I32_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x010>; 1525defm S_FF0_I32_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x011>; 1526defm S_FF0_I32_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x012>; 1527defm S_FF1_I32_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x013>; 1528defm S_FF1_I32_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x014>; 1529defm S_FLBIT_I32_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x015>; 1530defm S_FLBIT_I32_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x016>; 1531defm S_FLBIT_I32 : SOP1_Real_gfx6_gfx7_gfx10<0x017>; 1532defm S_FLBIT_I32_I64 : SOP1_Real_gfx6_gfx7_gfx10<0x018>; 1533defm S_SEXT_I32_I8 : SOP1_Real_gfx6_gfx7_gfx10<0x019>; 1534defm S_SEXT_I32_I16 : SOP1_Real_gfx6_gfx7_gfx10<0x01a>; 1535defm S_BITSET0_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x01b>; 1536defm S_BITSET0_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x01c>; 1537defm S_BITSET1_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x01d>; 1538defm S_BITSET1_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x01e>; 1539defm S_GETPC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x01f>; 1540defm S_SETPC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x020>; 1541defm S_SWAPPC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x021>; 1542defm S_RFE_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x022>; 1543defm S_AND_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x024>; 1544defm S_OR_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x025>; 1545defm S_XOR_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x026>; 1546defm S_ANDN2_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x027>; 1547defm S_ORN2_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x028>; 1548defm S_NAND_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x029>; 1549defm S_NOR_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x02a>; 1550defm S_XNOR_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x02b>; 1551defm S_QUADMASK_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x02c>; 1552defm S_QUADMASK_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x02d>; 1553defm S_MOVRELS_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x02e>; 1554defm S_MOVRELS_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x02f>; 1555defm S_MOVRELD_B32 : SOP1_Real_gfx6_gfx7_gfx10<0x030>; 1556defm S_MOVRELD_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x031>; 1557defm S_ABS_I32 : SOP1_Real_gfx6_gfx7_gfx10<0x034>; 1558 1559//===----------------------------------------------------------------------===// 1560// SOP2 - GFX10. 1561//===----------------------------------------------------------------------===// 1562 1563multiclass SOP2_Real_gfx10<bits<7> op> { 1564 defvar ps = !cast<SOP2_Pseudo>(NAME); 1565 def _gfx10 : SOP2_Real<op, ps>, 1566 Select_gfx10<ps.Mnemonic>; 1567} 1568 1569defm S_LSHL1_ADD_U32 : SOP2_Real_gfx10<0x02e>; 1570defm S_LSHL2_ADD_U32 : SOP2_Real_gfx10<0x02f>; 1571defm S_LSHL3_ADD_U32 : SOP2_Real_gfx10<0x030>; 1572defm S_LSHL4_ADD_U32 : SOP2_Real_gfx10<0x031>; 1573defm S_PACK_LL_B32_B16 : SOP2_Real_gfx10<0x032>; 1574defm S_PACK_LH_B32_B16 : SOP2_Real_gfx10<0x033>; 1575defm S_PACK_HH_B32_B16 : SOP2_Real_gfx10<0x034>; 1576defm S_MUL_HI_U32 : SOP2_Real_gfx10<0x035>; 1577defm S_MUL_HI_I32 : SOP2_Real_gfx10<0x036>; 1578 1579//===----------------------------------------------------------------------===// 1580// SOP2 - GFX6, GFX7. 1581//===----------------------------------------------------------------------===// 1582 1583multiclass SOP2_Real_gfx6_gfx7<bits<7> op> { 1584 defvar ps = !cast<SOP_Pseudo>(NAME); 1585 def _gfx6_gfx7 : SOP2_Real<op, ps>, 1586 Select_gfx6_gfx7<ps.Mnemonic>; 1587} 1588 1589multiclass SOP2_Real_gfx6_gfx7_gfx10<bits<7> op> : 1590 SOP2_Real_gfx6_gfx7<op>, SOP2_Real_gfx10<op>; 1591 1592defm S_CBRANCH_G_FORK : SOP2_Real_gfx6_gfx7<0x02b>; 1593 1594defm S_ADD_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x000>; 1595defm S_SUB_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x001>; 1596defm S_ADD_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x002>; 1597defm S_SUB_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x003>; 1598defm S_ADDC_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x004>; 1599defm S_SUBB_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x005>; 1600defm S_MIN_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x006>; 1601defm S_MIN_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x007>; 1602defm S_MAX_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x008>; 1603defm S_MAX_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x009>; 1604defm S_CSELECT_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x00a>; 1605defm S_CSELECT_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x00b>; 1606defm S_AND_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x00e>; 1607defm S_AND_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x00f>; 1608defm S_OR_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x010>; 1609defm S_OR_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x011>; 1610defm S_XOR_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x012>; 1611defm S_XOR_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x013>; 1612defm S_ANDN2_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x014>; 1613defm S_ANDN2_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x015>; 1614defm S_ORN2_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x016>; 1615defm S_ORN2_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x017>; 1616defm S_NAND_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x018>; 1617defm S_NAND_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x019>; 1618defm S_NOR_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x01a>; 1619defm S_NOR_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x01b>; 1620defm S_XNOR_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x01c>; 1621defm S_XNOR_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x01d>; 1622defm S_LSHL_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x01e>; 1623defm S_LSHL_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x01f>; 1624defm S_LSHR_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x020>; 1625defm S_LSHR_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x021>; 1626defm S_ASHR_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x022>; 1627defm S_ASHR_I64 : SOP2_Real_gfx6_gfx7_gfx10<0x023>; 1628defm S_BFM_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x024>; 1629defm S_BFM_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x025>; 1630defm S_MUL_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x026>; 1631defm S_BFE_U32 : SOP2_Real_gfx6_gfx7_gfx10<0x027>; 1632defm S_BFE_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x028>; 1633defm S_BFE_U64 : SOP2_Real_gfx6_gfx7_gfx10<0x029>; 1634defm S_BFE_I64 : SOP2_Real_gfx6_gfx7_gfx10<0x02a>; 1635defm S_ABSDIFF_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x02c>; 1636 1637//===----------------------------------------------------------------------===// 1638// SOPK - GFX10. 1639//===----------------------------------------------------------------------===// 1640 1641multiclass SOPK_Real32_gfx10<bits<5> op> { 1642 defvar ps = !cast<SOPK_Pseudo>(NAME); 1643 def _gfx10 : SOPK_Real32<op, ps>, 1644 Select_gfx10<ps.Mnemonic>; 1645} 1646 1647multiclass SOPK_Real64_gfx10<bits<5> op> { 1648 defvar ps = !cast<SOPK_Pseudo>(NAME); 1649 def _gfx10 : SOPK_Real64<op, ps>, 1650 Select_gfx10<ps.Mnemonic>; 1651} 1652 1653defm S_VERSION : SOPK_Real32_gfx10<0x001>; 1654defm S_CALL_B64 : SOPK_Real32_gfx10<0x016>; 1655defm S_WAITCNT_VSCNT : SOPK_Real32_gfx10<0x017>; 1656defm S_WAITCNT_VMCNT : SOPK_Real32_gfx10<0x018>; 1657defm S_WAITCNT_EXPCNT : SOPK_Real32_gfx10<0x019>; 1658defm S_WAITCNT_LGKMCNT : SOPK_Real32_gfx10<0x01a>; 1659defm S_SUBVECTOR_LOOP_BEGIN : SOPK_Real32_gfx10<0x01b>; 1660defm S_SUBVECTOR_LOOP_END : SOPK_Real32_gfx10<0x01c>; 1661 1662//===----------------------------------------------------------------------===// 1663// SOPK - GFX6, GFX7. 1664//===----------------------------------------------------------------------===// 1665 1666multiclass SOPK_Real32_gfx6_gfx7<bits<5> op> { 1667 defvar ps = !cast<SOPK_Pseudo>(NAME); 1668 def _gfx6_gfx7 : SOPK_Real32<op, ps>, 1669 Select_gfx6_gfx7<ps.Mnemonic>; 1670} 1671 1672multiclass SOPK_Real64_gfx6_gfx7<bits<5> op> { 1673 defvar ps = !cast<SOPK_Pseudo>(NAME); 1674 def _gfx6_gfx7 : SOPK_Real64<op, ps>, 1675 Select_gfx6_gfx7<ps.Mnemonic>; 1676} 1677 1678multiclass SOPK_Real32_gfx6_gfx7_gfx10<bits<5> op> : 1679 SOPK_Real32_gfx6_gfx7<op>, SOPK_Real32_gfx10<op>; 1680 1681multiclass SOPK_Real64_gfx6_gfx7_gfx10<bits<5> op> : 1682 SOPK_Real64_gfx6_gfx7<op>, SOPK_Real64_gfx10<op>; 1683 1684defm S_CBRANCH_I_FORK : SOPK_Real32_gfx6_gfx7<0x011>; 1685 1686defm S_MOVK_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x000>; 1687defm S_CMOVK_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x002>; 1688defm S_CMPK_EQ_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x003>; 1689defm S_CMPK_LG_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x004>; 1690defm S_CMPK_GT_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x005>; 1691defm S_CMPK_GE_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x006>; 1692defm S_CMPK_LT_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x007>; 1693defm S_CMPK_LE_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x008>; 1694defm S_CMPK_EQ_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x009>; 1695defm S_CMPK_LG_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00a>; 1696defm S_CMPK_GT_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00b>; 1697defm S_CMPK_GE_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00c>; 1698defm S_CMPK_LT_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00d>; 1699defm S_CMPK_LE_U32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00e>; 1700defm S_ADDK_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x00f>; 1701defm S_MULK_I32 : SOPK_Real32_gfx6_gfx7_gfx10<0x010>; 1702defm S_GETREG_B32 : SOPK_Real32_gfx6_gfx7_gfx10<0x012>; 1703defm S_SETREG_B32 : SOPK_Real32_gfx6_gfx7_gfx10<0x013>; 1704defm S_SETREG_IMM32_B32 : SOPK_Real64_gfx6_gfx7_gfx10<0x015>; 1705 1706//===----------------------------------------------------------------------===// 1707// SOPP - GFX6, GFX7, GFX8, GFX9, GFX10 1708//===----------------------------------------------------------------------===// 1709 1710multiclass SOPP_Real_32_gfx6_gfx7<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic> { 1711 defvar ps = !cast<SOPP_Pseudo>(NAME); 1712 def _gfx6_gfx7 : SOPP_Real_32<op, ps, real_name>, 1713 Select_gfx6_gfx7<ps.Mnemonic>, 1714 SOPPRelaxTable<0, ps.KeyName, "_gfx6_gfx7">; 1715} 1716 1717multiclass SOPP_Real_32_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> { 1718 defvar ps = !cast<SOPP_Pseudo>(NAME); 1719 def _vi : SOPP_Real_32<op, ps, real_name>, 1720 Select_vi<ps.Mnemonic>, 1721 SOPPRelaxTable<0, ps.KeyName, "_vi">; 1722} 1723 1724multiclass SOPP_Real_32_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> { 1725 defvar ps = !cast<SOPP_Pseudo>(NAME); 1726 def _gfx10 : SOPP_Real_32<op, ps, real_name>, 1727 Select_gfx10<ps.Mnemonic>, 1728 SOPPRelaxTable<0, ps.KeyName, "_gfx10">; 1729} 1730 1731multiclass SOPP_Real_32_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1732 SOPP_Real_32_gfx8_gfx9<op, real_name>, SOPP_Real_32_gfx10<op, real_name>; 1733 1734multiclass SOPP_Real_32_gfx6_gfx7_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1735 SOPP_Real_32_gfx6_gfx7<op, real_name>, SOPP_Real_32_gfx8_gfx9<op, real_name>; 1736 1737multiclass SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1738 SOPP_Real_32_gfx6_gfx7_gfx8_gfx9<op, real_name>, SOPP_Real_32_gfx10<op, real_name>; 1739 1740//64 bit encodings, for Relaxation 1741multiclass SOPP_Real_64_gfx6_gfx7<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> { 1742 defvar ps = !cast<SOPP_Pseudo>(NAME); 1743 def _gfx6_gfx7 : SOPP_Real_64<op, ps, real_name>, 1744 Select_gfx6_gfx7<ps.Mnemonic>, 1745 SOPPRelaxTable<1, ps.KeyName, "_gfx6_gfx7">; 1746} 1747 1748multiclass SOPP_Real_64_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> { 1749 defvar ps = !cast<SOPP_Pseudo>(NAME); 1750 def _vi : SOPP_Real_64<op, ps, real_name>, 1751 Select_vi<ps.Mnemonic>, 1752 SOPPRelaxTable<1, ps.KeyName, "_vi">; 1753} 1754 1755multiclass SOPP_Real_64_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> { 1756 defvar ps = !cast<SOPP_Pseudo>(NAME); 1757 def _gfx10 : SOPP_Real_64<op, ps, real_name>, 1758 Select_gfx10<ps.Mnemonic>, 1759 SOPPRelaxTable<1, ps.KeyName, "_gfx10">; 1760} 1761 1762multiclass SOPP_Real_64_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1763 SOPP_Real_64_gfx8_gfx9<op, real_name>, SOPP_Real_64_gfx10<op, real_name>; 1764 1765multiclass SOPP_Real_64_gfx6_gfx7_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1766 SOPP_Real_64_gfx6_gfx7<op, real_name>, SOPP_Real_64_gfx8_gfx9<op, real_name>; 1767 1768multiclass SOPP_Real_64_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> : 1769 SOPP_Real_64_gfx6_gfx7_gfx8_gfx9<op, real_name>, SOPP_Real_64_gfx10<op, real_name>; 1770 1771//relaxation for insts with no operands not implemented 1772multiclass SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op> { 1773 defm "" : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<op>; 1774 defm _pad_s_nop : SOPP_Real_64_gfx6_gfx7_gfx8_gfx9_gfx10<op>; 1775} 1776 1777defm S_NOP : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x000>; 1778defm S_ENDPGM : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x001, "s_endpgm">; 1779defm S_WAKEUP : SOPP_Real_32_gfx8_gfx9_gfx10<0x003>; 1780defm S_BARRIER : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00a>; 1781defm S_WAITCNT : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00c>; 1782defm S_SETHALT : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00d>; 1783defm S_SETKILL : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00b>; 1784defm S_SLEEP : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00e>; 1785defm S_SETPRIO : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00f>; 1786defm S_SENDMSG : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x010>; 1787defm S_SENDMSGHALT : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x011>; 1788defm S_TRAP : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x012>; 1789defm S_ICACHE_INV : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x013>; 1790defm S_INCPERFLEVEL : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x014>; 1791defm S_DECPERFLEVEL : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x015>; 1792defm S_TTRACEDATA : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x016>; 1793defm S_ENDPGM_SAVED : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x01B>; 1794defm S_SET_GPR_IDX_OFF : SOPP_Real_32_gfx8_gfx9<0x01c>; 1795defm S_SET_GPR_IDX_MODE : SOPP_Real_32_gfx8_gfx9<0x01d>; 1796defm S_ENDPGM_ORDERED_PS_DONE : SOPP_Real_32_gfx8_gfx9_gfx10<0x01e>; 1797defm S_CODE_END : SOPP_Real_32_gfx10<0x01f>; 1798defm S_INST_PREFETCH : SOPP_Real_32_gfx10<0x020>; 1799defm S_CLAUSE : SOPP_Real_32_gfx10<0x021>; 1800defm S_WAIT_IDLE : SOPP_Real_32_gfx10<0x022>; 1801defm S_WAITCNT_DEPCTR : SOPP_Real_32_gfx10<0x023>; 1802defm S_ROUND_MODE : SOPP_Real_32_gfx10<0x024>; 1803defm S_DENORM_MODE : SOPP_Real_32_gfx10<0x025>; 1804defm S_TTRACEDATA_IMM : SOPP_Real_32_gfx10<0x028>; 1805 1806let isBranch = 1 in { 1807defm S_BRANCH : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x002>; 1808defm S_CBRANCH_SCC0 : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x004>; 1809defm S_CBRANCH_SCC1 : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x005>; 1810defm S_CBRANCH_VCCZ : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x006>; 1811defm S_CBRANCH_VCCNZ : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x007>; 1812defm S_CBRANCH_EXECZ : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x008>; 1813defm S_CBRANCH_EXECNZ : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x009>; 1814defm S_CBRANCH_CDBGSYS : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x017>; 1815defm S_CBRANCH_CDBGUSER : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x018>; 1816defm S_CBRANCH_CDBGSYS_OR_USER : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x019>; 1817defm S_CBRANCH_CDBGSYS_AND_USER : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x01A>; 1818} 1819 1820//===----------------------------------------------------------------------===// 1821// SOPC - GFX6, GFX7, GFX8, GFX9, GFX10 1822//===----------------------------------------------------------------------===// 1823 1824multiclass SOPC_Real_gfx6_gfx7<bits<7> op> { 1825 defvar ps = !cast<SOPC_Pseudo>(NAME); 1826 def _gfx6_gfx7 : SOPC_Real<op, ps>, 1827 Select_gfx6_gfx7<ps.Mnemonic>; 1828} 1829 1830multiclass SOPC_Real_gfx8_gfx9<bits<7> op> { 1831 defvar ps = !cast<SOPC_Pseudo>(NAME); 1832 def _vi : SOPC_Real<op, ps>, 1833 Select_vi<ps.Mnemonic>; 1834} 1835 1836multiclass SOPC_Real_gfx10<bits<7> op> { 1837 defvar ps = !cast<SOPC_Pseudo>(NAME); 1838 def _gfx10 : SOPC_Real<op, ps>, 1839 Select_gfx10<ps.Mnemonic>; 1840} 1841 1842multiclass SOPC_Real_gfx8_gfx9_gfx10<bits<7> op> : 1843 SOPC_Real_gfx8_gfx9<op>, SOPC_Real_gfx10<op>; 1844 1845multiclass SOPC_Real_gfx6_gfx7_gfx8_gfx9<bits<7> op> : 1846 SOPC_Real_gfx6_gfx7<op>, SOPC_Real_gfx8_gfx9<op>; 1847 1848multiclass SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op> : 1849 SOPC_Real_gfx6_gfx7_gfx8_gfx9<op>, SOPC_Real_gfx10<op>; 1850 1851defm S_CMP_EQ_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x00>; 1852defm S_CMP_LG_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x01>; 1853defm S_CMP_GT_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x02>; 1854defm S_CMP_GE_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x03>; 1855defm S_CMP_LT_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x04>; 1856defm S_CMP_LE_I32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x05>; 1857defm S_CMP_EQ_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x06>; 1858defm S_CMP_LG_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x07>; 1859defm S_CMP_GT_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x08>; 1860defm S_CMP_GE_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x09>; 1861defm S_CMP_LT_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0a>; 1862defm S_CMP_LE_U32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0b>; 1863defm S_BITCMP0_B32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0c>; 1864defm S_BITCMP1_B32 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0d>; 1865defm S_BITCMP0_B64 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0e>; 1866defm S_BITCMP1_B64 : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0f>; 1867defm S_SETVSKIP : SOPC_Real_gfx6_gfx7_gfx8_gfx9<0x10>; 1868defm S_SET_GPR_IDX_ON : SOPC_Real_gfx8_gfx9<0x11>; 1869defm S_CMP_EQ_U64 : SOPC_Real_gfx8_gfx9_gfx10<0x12>; 1870defm S_CMP_LG_U64 : SOPC_Real_gfx8_gfx9_gfx10<0x13>; 1871 1872//===----------------------------------------------------------------------===// 1873// GFX8 (VI), GFX9. 1874//===----------------------------------------------------------------------===// 1875 1876class SOP1_Real_vi<bits<8> op, SOP1_Pseudo ps> : 1877 SOP1_Real<op, ps>, 1878 Select_vi<ps.Mnemonic>; 1879 1880 1881class SOP2_Real_vi<bits<7> op, SOP2_Pseudo ps> : 1882 SOP2_Real<op, ps>, 1883 Select_vi<ps.Mnemonic>; 1884 1885class SOPK_Real_vi<bits<5> op, SOPK_Pseudo ps> : 1886 SOPK_Real32<op, ps>, 1887 Select_vi<ps.Mnemonic>; 1888 1889def S_MOV_B32_vi : SOP1_Real_vi <0x00, S_MOV_B32>; 1890def S_MOV_B64_vi : SOP1_Real_vi <0x01, S_MOV_B64>; 1891def S_CMOV_B32_vi : SOP1_Real_vi <0x02, S_CMOV_B32>; 1892def S_CMOV_B64_vi : SOP1_Real_vi <0x03, S_CMOV_B64>; 1893def S_NOT_B32_vi : SOP1_Real_vi <0x04, S_NOT_B32>; 1894def S_NOT_B64_vi : SOP1_Real_vi <0x05, S_NOT_B64>; 1895def S_WQM_B32_vi : SOP1_Real_vi <0x06, S_WQM_B32>; 1896def S_WQM_B64_vi : SOP1_Real_vi <0x07, S_WQM_B64>; 1897def S_BREV_B32_vi : SOP1_Real_vi <0x08, S_BREV_B32>; 1898def S_BREV_B64_vi : SOP1_Real_vi <0x09, S_BREV_B64>; 1899def S_BCNT0_I32_B32_vi : SOP1_Real_vi <0x0a, S_BCNT0_I32_B32>; 1900def S_BCNT0_I32_B64_vi : SOP1_Real_vi <0x0b, S_BCNT0_I32_B64>; 1901def S_BCNT1_I32_B32_vi : SOP1_Real_vi <0x0c, S_BCNT1_I32_B32>; 1902def S_BCNT1_I32_B64_vi : SOP1_Real_vi <0x0d, S_BCNT1_I32_B64>; 1903def S_FF0_I32_B32_vi : SOP1_Real_vi <0x0e, S_FF0_I32_B32>; 1904def S_FF0_I32_B64_vi : SOP1_Real_vi <0x0f, S_FF0_I32_B64>; 1905def S_FF1_I32_B32_vi : SOP1_Real_vi <0x10, S_FF1_I32_B32>; 1906def S_FF1_I32_B64_vi : SOP1_Real_vi <0x11, S_FF1_I32_B64>; 1907def S_FLBIT_I32_B32_vi : SOP1_Real_vi <0x12, S_FLBIT_I32_B32>; 1908def S_FLBIT_I32_B64_vi : SOP1_Real_vi <0x13, S_FLBIT_I32_B64>; 1909def S_FLBIT_I32_vi : SOP1_Real_vi <0x14, S_FLBIT_I32>; 1910def S_FLBIT_I32_I64_vi : SOP1_Real_vi <0x15, S_FLBIT_I32_I64>; 1911def S_SEXT_I32_I8_vi : SOP1_Real_vi <0x16, S_SEXT_I32_I8>; 1912def S_SEXT_I32_I16_vi : SOP1_Real_vi <0x17, S_SEXT_I32_I16>; 1913def S_BITSET0_B32_vi : SOP1_Real_vi <0x18, S_BITSET0_B32>; 1914def S_BITSET0_B64_vi : SOP1_Real_vi <0x19, S_BITSET0_B64>; 1915def S_BITSET1_B32_vi : SOP1_Real_vi <0x1a, S_BITSET1_B32>; 1916def S_BITSET1_B64_vi : SOP1_Real_vi <0x1b, S_BITSET1_B64>; 1917def S_GETPC_B64_vi : SOP1_Real_vi <0x1c, S_GETPC_B64>; 1918def S_SETPC_B64_vi : SOP1_Real_vi <0x1d, S_SETPC_B64>; 1919def S_SWAPPC_B64_vi : SOP1_Real_vi <0x1e, S_SWAPPC_B64>; 1920def S_RFE_B64_vi : SOP1_Real_vi <0x1f, S_RFE_B64>; 1921def S_AND_SAVEEXEC_B64_vi : SOP1_Real_vi <0x20, S_AND_SAVEEXEC_B64>; 1922def S_OR_SAVEEXEC_B64_vi : SOP1_Real_vi <0x21, S_OR_SAVEEXEC_B64>; 1923def S_XOR_SAVEEXEC_B64_vi : SOP1_Real_vi <0x22, S_XOR_SAVEEXEC_B64>; 1924def S_ANDN2_SAVEEXEC_B64_vi: SOP1_Real_vi <0x23, S_ANDN2_SAVEEXEC_B64>; 1925def S_ORN2_SAVEEXEC_B64_vi : SOP1_Real_vi <0x24, S_ORN2_SAVEEXEC_B64>; 1926def S_NAND_SAVEEXEC_B64_vi : SOP1_Real_vi <0x25, S_NAND_SAVEEXEC_B64>; 1927def S_NOR_SAVEEXEC_B64_vi : SOP1_Real_vi <0x26, S_NOR_SAVEEXEC_B64>; 1928def S_XNOR_SAVEEXEC_B64_vi : SOP1_Real_vi <0x27, S_XNOR_SAVEEXEC_B64>; 1929def S_QUADMASK_B32_vi : SOP1_Real_vi <0x28, S_QUADMASK_B32>; 1930def S_QUADMASK_B64_vi : SOP1_Real_vi <0x29, S_QUADMASK_B64>; 1931def S_MOVRELS_B32_vi : SOP1_Real_vi <0x2a, S_MOVRELS_B32>; 1932def S_MOVRELS_B64_vi : SOP1_Real_vi <0x2b, S_MOVRELS_B64>; 1933def S_MOVRELD_B32_vi : SOP1_Real_vi <0x2c, S_MOVRELD_B32>; 1934def S_MOVRELD_B64_vi : SOP1_Real_vi <0x2d, S_MOVRELD_B64>; 1935def S_CBRANCH_JOIN_vi : SOP1_Real_vi <0x2e, S_CBRANCH_JOIN>; 1936def S_ABS_I32_vi : SOP1_Real_vi <0x30, S_ABS_I32>; 1937def S_SET_GPR_IDX_IDX_vi : SOP1_Real_vi <0x32, S_SET_GPR_IDX_IDX>; 1938 1939def S_ADD_U32_vi : SOP2_Real_vi <0x00, S_ADD_U32>; 1940def S_ADD_I32_vi : SOP2_Real_vi <0x02, S_ADD_I32>; 1941def S_SUB_U32_vi : SOP2_Real_vi <0x01, S_SUB_U32>; 1942def S_SUB_I32_vi : SOP2_Real_vi <0x03, S_SUB_I32>; 1943def S_ADDC_U32_vi : SOP2_Real_vi <0x04, S_ADDC_U32>; 1944def S_SUBB_U32_vi : SOP2_Real_vi <0x05, S_SUBB_U32>; 1945def S_MIN_I32_vi : SOP2_Real_vi <0x06, S_MIN_I32>; 1946def S_MIN_U32_vi : SOP2_Real_vi <0x07, S_MIN_U32>; 1947def S_MAX_I32_vi : SOP2_Real_vi <0x08, S_MAX_I32>; 1948def S_MAX_U32_vi : SOP2_Real_vi <0x09, S_MAX_U32>; 1949def S_CSELECT_B32_vi : SOP2_Real_vi <0x0a, S_CSELECT_B32>; 1950def S_CSELECT_B64_vi : SOP2_Real_vi <0x0b, S_CSELECT_B64>; 1951def S_AND_B32_vi : SOP2_Real_vi <0x0c, S_AND_B32>; 1952def S_AND_B64_vi : SOP2_Real_vi <0x0d, S_AND_B64>; 1953def S_OR_B32_vi : SOP2_Real_vi <0x0e, S_OR_B32>; 1954def S_OR_B64_vi : SOP2_Real_vi <0x0f, S_OR_B64>; 1955def S_XOR_B32_vi : SOP2_Real_vi <0x10, S_XOR_B32>; 1956def S_XOR_B64_vi : SOP2_Real_vi <0x11, S_XOR_B64>; 1957def S_ANDN2_B32_vi : SOP2_Real_vi <0x12, S_ANDN2_B32>; 1958def S_ANDN2_B64_vi : SOP2_Real_vi <0x13, S_ANDN2_B64>; 1959def S_ORN2_B32_vi : SOP2_Real_vi <0x14, S_ORN2_B32>; 1960def S_ORN2_B64_vi : SOP2_Real_vi <0x15, S_ORN2_B64>; 1961def S_NAND_B32_vi : SOP2_Real_vi <0x16, S_NAND_B32>; 1962def S_NAND_B64_vi : SOP2_Real_vi <0x17, S_NAND_B64>; 1963def S_NOR_B32_vi : SOP2_Real_vi <0x18, S_NOR_B32>; 1964def S_NOR_B64_vi : SOP2_Real_vi <0x19, S_NOR_B64>; 1965def S_XNOR_B32_vi : SOP2_Real_vi <0x1a, S_XNOR_B32>; 1966def S_XNOR_B64_vi : SOP2_Real_vi <0x1b, S_XNOR_B64>; 1967def S_LSHL_B32_vi : SOP2_Real_vi <0x1c, S_LSHL_B32>; 1968def S_LSHL_B64_vi : SOP2_Real_vi <0x1d, S_LSHL_B64>; 1969def S_LSHR_B32_vi : SOP2_Real_vi <0x1e, S_LSHR_B32>; 1970def S_LSHR_B64_vi : SOP2_Real_vi <0x1f, S_LSHR_B64>; 1971def S_ASHR_I32_vi : SOP2_Real_vi <0x20, S_ASHR_I32>; 1972def S_ASHR_I64_vi : SOP2_Real_vi <0x21, S_ASHR_I64>; 1973def S_BFM_B32_vi : SOP2_Real_vi <0x22, S_BFM_B32>; 1974def S_BFM_B64_vi : SOP2_Real_vi <0x23, S_BFM_B64>; 1975def S_MUL_I32_vi : SOP2_Real_vi <0x24, S_MUL_I32>; 1976def S_BFE_U32_vi : SOP2_Real_vi <0x25, S_BFE_U32>; 1977def S_BFE_I32_vi : SOP2_Real_vi <0x26, S_BFE_I32>; 1978def S_BFE_U64_vi : SOP2_Real_vi <0x27, S_BFE_U64>; 1979def S_BFE_I64_vi : SOP2_Real_vi <0x28, S_BFE_I64>; 1980def S_CBRANCH_G_FORK_vi : SOP2_Real_vi <0x29, S_CBRANCH_G_FORK>; 1981def S_ABSDIFF_I32_vi : SOP2_Real_vi <0x2a, S_ABSDIFF_I32>; 1982def S_PACK_LL_B32_B16_vi : SOP2_Real_vi <0x32, S_PACK_LL_B32_B16>; 1983def S_PACK_LH_B32_B16_vi : SOP2_Real_vi <0x33, S_PACK_LH_B32_B16>; 1984def S_PACK_HH_B32_B16_vi : SOP2_Real_vi <0x34, S_PACK_HH_B32_B16>; 1985def S_RFE_RESTORE_B64_vi : SOP2_Real_vi <0x2b, S_RFE_RESTORE_B64>; 1986 1987def S_MOVK_I32_vi : SOPK_Real_vi <0x00, S_MOVK_I32>; 1988def S_CMOVK_I32_vi : SOPK_Real_vi <0x01, S_CMOVK_I32>; 1989def S_CMPK_EQ_I32_vi : SOPK_Real_vi <0x02, S_CMPK_EQ_I32>; 1990def S_CMPK_LG_I32_vi : SOPK_Real_vi <0x03, S_CMPK_LG_I32>; 1991def S_CMPK_GT_I32_vi : SOPK_Real_vi <0x04, S_CMPK_GT_I32>; 1992def S_CMPK_GE_I32_vi : SOPK_Real_vi <0x05, S_CMPK_GE_I32>; 1993def S_CMPK_LT_I32_vi : SOPK_Real_vi <0x06, S_CMPK_LT_I32>; 1994def S_CMPK_LE_I32_vi : SOPK_Real_vi <0x07, S_CMPK_LE_I32>; 1995def S_CMPK_EQ_U32_vi : SOPK_Real_vi <0x08, S_CMPK_EQ_U32>; 1996def S_CMPK_LG_U32_vi : SOPK_Real_vi <0x09, S_CMPK_LG_U32>; 1997def S_CMPK_GT_U32_vi : SOPK_Real_vi <0x0A, S_CMPK_GT_U32>; 1998def S_CMPK_GE_U32_vi : SOPK_Real_vi <0x0B, S_CMPK_GE_U32>; 1999def S_CMPK_LT_U32_vi : SOPK_Real_vi <0x0C, S_CMPK_LT_U32>; 2000def S_CMPK_LE_U32_vi : SOPK_Real_vi <0x0D, S_CMPK_LE_U32>; 2001def S_ADDK_I32_vi : SOPK_Real_vi <0x0E, S_ADDK_I32>; 2002def S_MULK_I32_vi : SOPK_Real_vi <0x0F, S_MULK_I32>; 2003def S_CBRANCH_I_FORK_vi : SOPK_Real_vi <0x10, S_CBRANCH_I_FORK>; 2004def S_GETREG_B32_vi : SOPK_Real_vi <0x11, S_GETREG_B32>; 2005def S_SETREG_B32_vi : SOPK_Real_vi <0x12, S_SETREG_B32>; 2006//def S_GETREG_REGRD_B32_vi : SOPK_Real_vi <0x13, S_GETREG_REGRD_B32>; // see pseudo for comments 2007def S_SETREG_IMM32_B32_vi : SOPK_Real64<0x14, S_SETREG_IMM32_B32>, 2008 Select_vi<S_SETREG_IMM32_B32.Mnemonic>; 2009 2010def S_CALL_B64_vi : SOPK_Real_vi <0x15, S_CALL_B64>; 2011 2012//===----------------------------------------------------------------------===// 2013// SOP1 - GFX9. 2014//===----------------------------------------------------------------------===// 2015 2016def S_ANDN1_SAVEEXEC_B64_vi : SOP1_Real_vi<0x33, S_ANDN1_SAVEEXEC_B64>; 2017def S_ORN1_SAVEEXEC_B64_vi : SOP1_Real_vi<0x34, S_ORN1_SAVEEXEC_B64>; 2018def S_ANDN1_WREXEC_B64_vi : SOP1_Real_vi<0x35, S_ANDN1_WREXEC_B64>; 2019def S_ANDN2_WREXEC_B64_vi : SOP1_Real_vi<0x36, S_ANDN2_WREXEC_B64>; 2020def S_BITREPLICATE_B64_B32_vi : SOP1_Real_vi<0x37, S_BITREPLICATE_B64_B32>; 2021 2022//===----------------------------------------------------------------------===// 2023// SOP2 - GFX9. 2024//===----------------------------------------------------------------------===// 2025 2026def S_LSHL1_ADD_U32_vi : SOP2_Real_vi<0x2e, S_LSHL1_ADD_U32>; 2027def S_LSHL2_ADD_U32_vi : SOP2_Real_vi<0x2f, S_LSHL2_ADD_U32>; 2028def S_LSHL3_ADD_U32_vi : SOP2_Real_vi<0x30, S_LSHL3_ADD_U32>; 2029def S_LSHL4_ADD_U32_vi : SOP2_Real_vi<0x31, S_LSHL4_ADD_U32>; 2030def S_MUL_HI_U32_vi : SOP2_Real_vi<0x2c, S_MUL_HI_U32>; 2031def S_MUL_HI_I32_vi : SOP2_Real_vi<0x2d, S_MUL_HI_I32>; 2032