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