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