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