1 //===-- SIInstrInfo.h - SI Instruction Info Interface -----------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 /// \file 11 /// \brief Interface definition for SIInstrInfo. 12 // 13 //===----------------------------------------------------------------------===// 14 15 16 #ifndef LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H 17 #define LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H 18 19 #include "AMDGPUInstrInfo.h" 20 #include "SIDefines.h" 21 #include "SIRegisterInfo.h" 22 23 namespace llvm { 24 25 class SIInstrInfo final : public AMDGPUInstrInfo { 26 private: 27 const SIRegisterInfo RI; 28 const SISubtarget &ST; 29 30 // The the inverse predicate should have the negative value. 31 enum BranchPredicate { 32 INVALID_BR = 0, 33 SCC_TRUE = 1, 34 SCC_FALSE = -1, 35 VCCNZ = 2, 36 VCCZ = -2, 37 EXECNZ = -3, 38 EXECZ = 3 39 }; 40 41 static unsigned getBranchOpcode(BranchPredicate Cond); 42 static BranchPredicate getBranchPredicate(unsigned Opcode); 43 44 unsigned buildExtractSubReg(MachineBasicBlock::iterator MI, 45 MachineRegisterInfo &MRI, 46 MachineOperand &SuperReg, 47 const TargetRegisterClass *SuperRC, 48 unsigned SubIdx, 49 const TargetRegisterClass *SubRC) const; 50 MachineOperand buildExtractSubRegOrImm(MachineBasicBlock::iterator MI, 51 MachineRegisterInfo &MRI, 52 MachineOperand &SuperReg, 53 const TargetRegisterClass *SuperRC, 54 unsigned SubIdx, 55 const TargetRegisterClass *SubRC) const; 56 57 void swapOperands(MachineInstr &Inst) const; 58 59 void lowerScalarAbs(SmallVectorImpl<MachineInstr *> &Worklist, 60 MachineInstr &Inst) const; 61 62 void splitScalar64BitUnaryOp(SmallVectorImpl<MachineInstr *> &Worklist, 63 MachineInstr &Inst, unsigned Opcode) const; 64 65 void splitScalar64BitBinaryOp(SmallVectorImpl<MachineInstr *> &Worklist, 66 MachineInstr &Inst, unsigned Opcode) const; 67 68 void splitScalar64BitBCNT(SmallVectorImpl<MachineInstr *> &Worklist, 69 MachineInstr &Inst) const; 70 void splitScalar64BitBFE(SmallVectorImpl<MachineInstr *> &Worklist, 71 MachineInstr &Inst) const; 72 73 void addUsersToMoveToVALUWorklist( 74 unsigned Reg, MachineRegisterInfo &MRI, 75 SmallVectorImpl<MachineInstr *> &Worklist) const; 76 77 void 78 addSCCDefUsersToVALUWorklist(MachineInstr &SCCDefInst, 79 SmallVectorImpl<MachineInstr *> &Worklist) const; 80 81 const TargetRegisterClass * 82 getDestEquivalentVGPRClass(const MachineInstr &Inst) const; 83 84 bool checkInstOffsetsDoNotOverlap(MachineInstr &MIa, MachineInstr &MIb) const; 85 86 unsigned findUsedSGPR(const MachineInstr &MI, int OpIndices[3]) const; 87 88 protected: 89 bool swapSourceModifiers(MachineInstr &MI, 90 MachineOperand &Src0, unsigned Src0OpName, 91 MachineOperand &Src1, unsigned Src1OpName) const; 92 93 MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI, 94 unsigned OpIdx0, 95 unsigned OpIdx1) const override; 96 97 public: 98 99 enum TargetOperandFlags { 100 MO_NONE = 0, 101 MO_GOTPCREL = 1 102 }; 103 104 explicit SIInstrInfo(const SISubtarget &); 105 106 const SIRegisterInfo &getRegisterInfo() const { 107 return RI; 108 } 109 110 bool isReallyTriviallyReMaterializable(const MachineInstr &MI, 111 AliasAnalysis *AA) const override; 112 113 bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2, 114 int64_t &Offset1, 115 int64_t &Offset2) const override; 116 117 bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg, 118 int64_t &Offset, 119 const TargetRegisterInfo *TRI) const final; 120 121 bool shouldClusterMemOps(MachineInstr &FirstLdSt, MachineInstr &SecondLdSt, 122 unsigned NumLoads) const final; 123 124 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, 125 const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, 126 bool KillSrc) const override; 127 128 unsigned calculateLDSSpillAddress(MachineBasicBlock &MBB, MachineInstr &MI, 129 RegScavenger *RS, unsigned TmpReg, 130 unsigned Offset, unsigned Size) const; 131 132 void storeRegToStackSlot(MachineBasicBlock &MBB, 133 MachineBasicBlock::iterator MI, unsigned SrcReg, 134 bool isKill, int FrameIndex, 135 const TargetRegisterClass *RC, 136 const TargetRegisterInfo *TRI) const override; 137 138 void loadRegFromStackSlot(MachineBasicBlock &MBB, 139 MachineBasicBlock::iterator MI, unsigned DestReg, 140 int FrameIndex, const TargetRegisterClass *RC, 141 const TargetRegisterInfo *TRI) const override; 142 143 bool expandPostRAPseudo(MachineInstr &MI) const override; 144 145 // \brief Returns an opcode that can be used to move a value to a \p DstRC 146 // register. If there is no hardware instruction that can store to \p 147 // DstRC, then AMDGPU::COPY is returned. 148 unsigned getMovOpcode(const TargetRegisterClass *DstRC) const; 149 150 LLVM_READONLY 151 int commuteOpcode(unsigned Opc) const; 152 153 LLVM_READONLY 154 inline int commuteOpcode(const MachineInstr &MI) const { 155 return commuteOpcode(MI.getOpcode()); 156 } 157 158 bool findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1, 159 unsigned &SrcOpIdx2) const override; 160 161 bool isBranchOffsetInRange(unsigned BranchOpc, 162 int64_t BrOffset) const override; 163 164 MachineBasicBlock *getBranchDestBlock(const MachineInstr &MI) const override; 165 166 unsigned insertIndirectBranch(MachineBasicBlock &MBB, 167 MachineBasicBlock &NewDestBB, 168 const DebugLoc &DL, 169 int64_t BrOffset, 170 RegScavenger *RS = nullptr) const override; 171 172 bool analyzeBranchImpl(MachineBasicBlock &MBB, 173 MachineBasicBlock::iterator I, 174 MachineBasicBlock *&TBB, 175 MachineBasicBlock *&FBB, 176 SmallVectorImpl<MachineOperand> &Cond, 177 bool AllowModify) const; 178 179 bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, 180 MachineBasicBlock *&FBB, 181 SmallVectorImpl<MachineOperand> &Cond, 182 bool AllowModify) const override; 183 184 unsigned removeBranch(MachineBasicBlock &MBB, 185 int *BytesRemoved = nullptr) const override; 186 187 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, 188 MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond, 189 const DebugLoc &DL, 190 int *BytesAdded = nullptr) const override; 191 192 bool reverseBranchCondition( 193 SmallVectorImpl<MachineOperand> &Cond) const override; 194 195 bool 196 areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb, 197 AliasAnalysis *AA = nullptr) const override; 198 199 bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg, 200 MachineRegisterInfo *MRI) const final; 201 202 unsigned getMachineCSELookAheadLimit() const override { return 500; } 203 204 MachineInstr *convertToThreeAddress(MachineFunction::iterator &MBB, 205 MachineInstr &MI, 206 LiveVariables *LV) const override; 207 208 bool isSchedulingBoundary(const MachineInstr &MI, 209 const MachineBasicBlock *MBB, 210 const MachineFunction &MF) const override; 211 212 static bool isSALU(const MachineInstr &MI) { 213 return MI.getDesc().TSFlags & SIInstrFlags::SALU; 214 } 215 216 bool isSALU(uint16_t Opcode) const { 217 return get(Opcode).TSFlags & SIInstrFlags::SALU; 218 } 219 220 static bool isVALU(const MachineInstr &MI) { 221 return MI.getDesc().TSFlags & SIInstrFlags::VALU; 222 } 223 224 bool isVALU(uint16_t Opcode) const { 225 return get(Opcode).TSFlags & SIInstrFlags::VALU; 226 } 227 228 static bool isVMEM(const MachineInstr &MI) { 229 return isMUBUF(MI) || isMTBUF(MI) || isMIMG(MI); 230 } 231 232 bool isVMEM(uint16_t Opcode) const { 233 return isMUBUF(Opcode) || isMTBUF(Opcode) || isMIMG(Opcode); 234 } 235 236 static bool isSOP1(const MachineInstr &MI) { 237 return MI.getDesc().TSFlags & SIInstrFlags::SOP1; 238 } 239 240 bool isSOP1(uint16_t Opcode) const { 241 return get(Opcode).TSFlags & SIInstrFlags::SOP1; 242 } 243 244 static bool isSOP2(const MachineInstr &MI) { 245 return MI.getDesc().TSFlags & SIInstrFlags::SOP2; 246 } 247 248 bool isSOP2(uint16_t Opcode) const { 249 return get(Opcode).TSFlags & SIInstrFlags::SOP2; 250 } 251 252 static bool isSOPC(const MachineInstr &MI) { 253 return MI.getDesc().TSFlags & SIInstrFlags::SOPC; 254 } 255 256 bool isSOPC(uint16_t Opcode) const { 257 return get(Opcode).TSFlags & SIInstrFlags::SOPC; 258 } 259 260 static bool isSOPK(const MachineInstr &MI) { 261 return MI.getDesc().TSFlags & SIInstrFlags::SOPK; 262 } 263 264 bool isSOPK(uint16_t Opcode) const { 265 return get(Opcode).TSFlags & SIInstrFlags::SOPK; 266 } 267 268 static bool isSOPP(const MachineInstr &MI) { 269 return MI.getDesc().TSFlags & SIInstrFlags::SOPP; 270 } 271 272 bool isSOPP(uint16_t Opcode) const { 273 return get(Opcode).TSFlags & SIInstrFlags::SOPP; 274 } 275 276 static bool isVOP1(const MachineInstr &MI) { 277 return MI.getDesc().TSFlags & SIInstrFlags::VOP1; 278 } 279 280 bool isVOP1(uint16_t Opcode) const { 281 return get(Opcode).TSFlags & SIInstrFlags::VOP1; 282 } 283 284 static bool isVOP2(const MachineInstr &MI) { 285 return MI.getDesc().TSFlags & SIInstrFlags::VOP2; 286 } 287 288 bool isVOP2(uint16_t Opcode) const { 289 return get(Opcode).TSFlags & SIInstrFlags::VOP2; 290 } 291 292 static bool isVOP3(const MachineInstr &MI) { 293 return MI.getDesc().TSFlags & SIInstrFlags::VOP3; 294 } 295 296 bool isVOP3(uint16_t Opcode) const { 297 return get(Opcode).TSFlags & SIInstrFlags::VOP3; 298 } 299 300 static bool isVOPC(const MachineInstr &MI) { 301 return MI.getDesc().TSFlags & SIInstrFlags::VOPC; 302 } 303 304 bool isVOPC(uint16_t Opcode) const { 305 return get(Opcode).TSFlags & SIInstrFlags::VOPC; 306 } 307 308 static bool isMUBUF(const MachineInstr &MI) { 309 return MI.getDesc().TSFlags & SIInstrFlags::MUBUF; 310 } 311 312 bool isMUBUF(uint16_t Opcode) const { 313 return get(Opcode).TSFlags & SIInstrFlags::MUBUF; 314 } 315 316 static bool isMTBUF(const MachineInstr &MI) { 317 return MI.getDesc().TSFlags & SIInstrFlags::MTBUF; 318 } 319 320 bool isMTBUF(uint16_t Opcode) const { 321 return get(Opcode).TSFlags & SIInstrFlags::MTBUF; 322 } 323 324 static bool isSMRD(const MachineInstr &MI) { 325 return MI.getDesc().TSFlags & SIInstrFlags::SMRD; 326 } 327 328 bool isSMRD(uint16_t Opcode) const { 329 return get(Opcode).TSFlags & SIInstrFlags::SMRD; 330 } 331 332 static bool isDS(const MachineInstr &MI) { 333 return MI.getDesc().TSFlags & SIInstrFlags::DS; 334 } 335 336 bool isDS(uint16_t Opcode) const { 337 return get(Opcode).TSFlags & SIInstrFlags::DS; 338 } 339 340 static bool isMIMG(const MachineInstr &MI) { 341 return MI.getDesc().TSFlags & SIInstrFlags::MIMG; 342 } 343 344 bool isMIMG(uint16_t Opcode) const { 345 return get(Opcode).TSFlags & SIInstrFlags::MIMG; 346 } 347 348 static bool isGather4(const MachineInstr &MI) { 349 return MI.getDesc().TSFlags & SIInstrFlags::Gather4; 350 } 351 352 bool isGather4(uint16_t Opcode) const { 353 return get(Opcode).TSFlags & SIInstrFlags::Gather4; 354 } 355 356 static bool isFLAT(const MachineInstr &MI) { 357 return MI.getDesc().TSFlags & SIInstrFlags::FLAT; 358 } 359 360 bool isFLAT(uint16_t Opcode) const { 361 return get(Opcode).TSFlags & SIInstrFlags::FLAT; 362 } 363 364 static bool isWQM(const MachineInstr &MI) { 365 return MI.getDesc().TSFlags & SIInstrFlags::WQM; 366 } 367 368 bool isWQM(uint16_t Opcode) const { 369 return get(Opcode).TSFlags & SIInstrFlags::WQM; 370 } 371 372 static bool isDisableWQM(const MachineInstr &MI) { 373 return MI.getDesc().TSFlags & SIInstrFlags::DisableWQM; 374 } 375 376 bool isDisableWQM(uint16_t Opcode) const { 377 return get(Opcode).TSFlags & SIInstrFlags::DisableWQM; 378 } 379 380 static bool isVGPRSpill(const MachineInstr &MI) { 381 return MI.getDesc().TSFlags & SIInstrFlags::VGPRSpill; 382 } 383 384 bool isVGPRSpill(uint16_t Opcode) const { 385 return get(Opcode).TSFlags & SIInstrFlags::VGPRSpill; 386 } 387 388 static bool isSGPRSpill(const MachineInstr &MI) { 389 return MI.getDesc().TSFlags & SIInstrFlags::SGPRSpill; 390 } 391 392 bool isSGPRSpill(uint16_t Opcode) const { 393 return get(Opcode).TSFlags & SIInstrFlags::SGPRSpill; 394 } 395 396 static bool isDPP(const MachineInstr &MI) { 397 return MI.getDesc().TSFlags & SIInstrFlags::DPP; 398 } 399 400 bool isDPP(uint16_t Opcode) const { 401 return get(Opcode).TSFlags & SIInstrFlags::DPP; 402 } 403 404 static bool isScalarUnit(const MachineInstr &MI) { 405 return MI.getDesc().TSFlags & (SIInstrFlags::SALU | SIInstrFlags::SMRD); 406 } 407 408 static bool usesVM_CNT(const MachineInstr &MI) { 409 return MI.getDesc().TSFlags & SIInstrFlags::VM_CNT; 410 } 411 412 static bool sopkIsZext(const MachineInstr &MI) { 413 return MI.getDesc().TSFlags & SIInstrFlags::SOPK_ZEXT; 414 } 415 416 bool sopkIsZext(uint16_t Opcode) const { 417 return get(Opcode).TSFlags & SIInstrFlags::SOPK_ZEXT; 418 } 419 420 bool isVGPRCopy(const MachineInstr &MI) const { 421 assert(MI.isCopy()); 422 unsigned Dest = MI.getOperand(0).getReg(); 423 const MachineFunction &MF = *MI.getParent()->getParent(); 424 const MachineRegisterInfo &MRI = MF.getRegInfo(); 425 return !RI.isSGPRReg(MRI, Dest); 426 } 427 428 bool isInlineConstant(const APInt &Imm) const; 429 bool isInlineConstant(const MachineOperand &MO, unsigned OpSize) const; 430 bool isLiteralConstant(const MachineOperand &MO, unsigned OpSize) const; 431 432 // Returns true if this operand could potentially require a 32-bit literal 433 // operand, but not necessarily. A FrameIndex for example could resolve to an 434 // inline immediate value that will not require an additional 4-bytes; this 435 // assumes that it will. 436 bool isLiteralConstantLike(const MachineOperand &MO, unsigned OpSize) const; 437 438 bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo, 439 const MachineOperand &MO) const; 440 441 /// \brief Return true if this 64-bit VALU instruction has a 32-bit encoding. 442 /// This function will return false if you pass it a 32-bit instruction. 443 bool hasVALU32BitEncoding(unsigned Opcode) const; 444 445 /// \brief Returns true if this operand uses the constant bus. 446 bool usesConstantBus(const MachineRegisterInfo &MRI, 447 const MachineOperand &MO, 448 unsigned OpSize) const; 449 450 /// \brief Return true if this instruction has any modifiers. 451 /// e.g. src[012]_mod, omod, clamp. 452 bool hasModifiers(unsigned Opcode) const; 453 454 bool hasModifiersSet(const MachineInstr &MI, 455 unsigned OpName) const; 456 457 bool verifyInstruction(const MachineInstr &MI, 458 StringRef &ErrInfo) const override; 459 460 static unsigned getVALUOp(const MachineInstr &MI); 461 462 bool isSALUOpSupportedOnVALU(const MachineInstr &MI) const; 463 464 /// \brief Return the correct register class for \p OpNo. For target-specific 465 /// instructions, this will return the register class that has been defined 466 /// in tablegen. For generic instructions, like REG_SEQUENCE it will return 467 /// the register class of its machine operand. 468 /// to infer the correct register class base on the other operands. 469 const TargetRegisterClass *getOpRegClass(const MachineInstr &MI, 470 unsigned OpNo) const; 471 472 /// \brief Return the size in bytes of the operand OpNo on the given 473 // instruction opcode. 474 unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const { 475 const MCOperandInfo &OpInfo = get(Opcode).OpInfo[OpNo]; 476 477 if (OpInfo.RegClass == -1) { 478 // If this is an immediate operand, this must be a 32-bit literal. 479 assert(OpInfo.OperandType == MCOI::OPERAND_IMMEDIATE); 480 return 4; 481 } 482 483 return RI.getRegClass(OpInfo.RegClass)->getSize(); 484 } 485 486 /// \brief This form should usually be preferred since it handles operands 487 /// with unknown register classes. 488 unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const { 489 return getOpRegClass(MI, OpNo)->getSize(); 490 } 491 492 /// \returns true if it is legal for the operand at index \p OpNo 493 /// to read a VGPR. 494 bool canReadVGPR(const MachineInstr &MI, unsigned OpNo) const; 495 496 /// \brief Legalize the \p OpIndex operand of this instruction by inserting 497 /// a MOV. For example: 498 /// ADD_I32_e32 VGPR0, 15 499 /// to 500 /// MOV VGPR1, 15 501 /// ADD_I32_e32 VGPR0, VGPR1 502 /// 503 /// If the operand being legalized is a register, then a COPY will be used 504 /// instead of MOV. 505 void legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const; 506 507 /// \brief Check if \p MO is a legal operand if it was the \p OpIdx Operand 508 /// for \p MI. 509 bool isOperandLegal(const MachineInstr &MI, unsigned OpIdx, 510 const MachineOperand *MO = nullptr) const; 511 512 /// \brief Check if \p MO would be a valid operand for the given operand 513 /// definition \p OpInfo. Note this does not attempt to validate constant bus 514 /// restrictions (e.g. literal constant usage). 515 bool isLegalVSrcOperand(const MachineRegisterInfo &MRI, 516 const MCOperandInfo &OpInfo, 517 const MachineOperand &MO) const; 518 519 /// \brief Check if \p MO (a register operand) is a legal register for the 520 /// given operand description. 521 bool isLegalRegOperand(const MachineRegisterInfo &MRI, 522 const MCOperandInfo &OpInfo, 523 const MachineOperand &MO) const; 524 525 /// \brief Legalize operands in \p MI by either commuting it or inserting a 526 /// copy of src1. 527 void legalizeOperandsVOP2(MachineRegisterInfo &MRI, MachineInstr &MI) const; 528 529 /// \brief Fix operands in \p MI to satisfy constant bus requirements. 530 void legalizeOperandsVOP3(MachineRegisterInfo &MRI, MachineInstr &MI) const; 531 532 /// Copy a value from a VGPR (\p SrcReg) to SGPR. This function can only 533 /// be used when it is know that the value in SrcReg is same across all 534 /// threads in the wave. 535 /// \returns The SGPR register that \p SrcReg was copied to. 536 unsigned readlaneVGPRToSGPR(unsigned SrcReg, MachineInstr &UseMI, 537 MachineRegisterInfo &MRI) const; 538 539 void legalizeOperandsSMRD(MachineRegisterInfo &MRI, MachineInstr &MI) const; 540 541 /// \brief Legalize all operands in this instruction. This function may 542 /// create new instruction and insert them before \p MI. 543 void legalizeOperands(MachineInstr &MI) const; 544 545 /// \brief Replace this instruction's opcode with the equivalent VALU 546 /// opcode. This function will also move the users of \p MI to the 547 /// VALU if necessary. 548 void moveToVALU(MachineInstr &MI) const; 549 550 void insertWaitStates(MachineBasicBlock &MBB,MachineBasicBlock::iterator MI, 551 int Count) const; 552 553 void insertNoop(MachineBasicBlock &MBB, 554 MachineBasicBlock::iterator MI) const override; 555 556 /// \brief Return the number of wait states that result from executing this 557 /// instruction. 558 unsigned getNumWaitStates(const MachineInstr &MI) const; 559 560 /// \brief Returns the operand named \p Op. If \p MI does not have an 561 /// operand named \c Op, this function returns nullptr. 562 LLVM_READONLY 563 MachineOperand *getNamedOperand(MachineInstr &MI, unsigned OperandName) const; 564 565 LLVM_READONLY 566 const MachineOperand *getNamedOperand(const MachineInstr &MI, 567 unsigned OpName) const { 568 return getNamedOperand(const_cast<MachineInstr &>(MI), OpName); 569 } 570 571 /// Get required immediate operand 572 int64_t getNamedImmOperand(const MachineInstr &MI, unsigned OpName) const { 573 int Idx = AMDGPU::getNamedOperandIdx(MI.getOpcode(), OpName); 574 return MI.getOperand(Idx).getImm(); 575 } 576 577 uint64_t getDefaultRsrcDataFormat() const; 578 uint64_t getScratchRsrcWords23() const; 579 580 bool isLowLatencyInstruction(const MachineInstr &MI) const; 581 bool isHighLatencyInstruction(const MachineInstr &MI) const; 582 583 /// \brief Return the descriptor of the target-specific machine instruction 584 /// that corresponds to the specified pseudo or native opcode. 585 const MCInstrDesc &getMCOpcodeFromPseudo(unsigned Opcode) const { 586 return get(pseudoToMCOpcode(Opcode)); 587 } 588 589 unsigned isStackAccess(const MachineInstr &MI, int &FrameIndex) const; 590 unsigned isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex) const; 591 592 unsigned isLoadFromStackSlot(const MachineInstr &MI, 593 int &FrameIndex) const override; 594 unsigned isStoreToStackSlot(const MachineInstr &MI, 595 int &FrameIndex) const override; 596 597 unsigned getInstSizeInBytes(const MachineInstr &MI) const override; 598 599 ArrayRef<std::pair<int, const char *>> 600 getSerializableTargetIndices() const override; 601 602 ScheduleHazardRecognizer * 603 CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II, 604 const ScheduleDAG *DAG) const override; 605 606 ScheduleHazardRecognizer * 607 CreateTargetPostRAHazardRecognizer(const MachineFunction &MF) const override; 608 }; 609 610 namespace AMDGPU { 611 LLVM_READONLY 612 int getVOPe64(uint16_t Opcode); 613 614 LLVM_READONLY 615 int getVOPe32(uint16_t Opcode); 616 617 LLVM_READONLY 618 int getCommuteRev(uint16_t Opcode); 619 620 LLVM_READONLY 621 int getCommuteOrig(uint16_t Opcode); 622 623 LLVM_READONLY 624 int getAddr64Inst(uint16_t Opcode); 625 626 LLVM_READONLY 627 int getAtomicRetOp(uint16_t Opcode); 628 629 LLVM_READONLY 630 int getAtomicNoRetOp(uint16_t Opcode); 631 632 LLVM_READONLY 633 int getSOPKOp(uint16_t Opcode); 634 635 const uint64_t RSRC_DATA_FORMAT = 0xf00000000000LL; 636 const uint64_t RSRC_ELEMENT_SIZE_SHIFT = (32 + 19); 637 const uint64_t RSRC_INDEX_STRIDE_SHIFT = (32 + 21); 638 const uint64_t RSRC_TID_ENABLE = UINT64_C(1) << (32 + 23); 639 640 // For MachineOperands. 641 enum TargetFlags { 642 TF_LONG_BRANCH_FORWARD = 1 << 0, 643 TF_LONG_BRANCH_BACKWARD = 1 << 1 644 }; 645 } // End namespace AMDGPU 646 647 namespace SI { 648 namespace KernelInputOffsets { 649 650 /// Offsets in bytes from the start of the input buffer 651 enum Offsets { 652 NGROUPS_X = 0, 653 NGROUPS_Y = 4, 654 NGROUPS_Z = 8, 655 GLOBAL_SIZE_X = 12, 656 GLOBAL_SIZE_Y = 16, 657 GLOBAL_SIZE_Z = 20, 658 LOCAL_SIZE_X = 24, 659 LOCAL_SIZE_Y = 28, 660 LOCAL_SIZE_Z = 32 661 }; 662 663 } // End namespace KernelInputOffsets 664 } // End namespace SI 665 666 } // End namespace llvm 667 668 #endif 669