LLVM  7.0.0svn
SIInstrInfo.h
Go to the documentation of this file.
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 /// Interface definition for SIInstrInfo.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H
16 #define LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H
17 
18 #include "AMDGPUInstrInfo.h"
19 #include "SIDefines.h"
20 #include "SIRegisterInfo.h"
21 #include "Utils/AMDGPUBaseInfo.h"
22 #include "llvm/ADT/ArrayRef.h"
23 #include "llvm/ADT/SetVector.h"
29 #include "llvm/MC/MCInstrDesc.h"
30 #include "llvm/Support/Compiler.h"
31 #include <cassert>
32 #include <cstdint>
33 
34 namespace llvm {
35 
36 class APInt;
37 class MachineRegisterInfo;
38 class RegScavenger;
39 class SISubtarget;
40 class TargetRegisterClass;
41 
42 class SIInstrInfo final : public AMDGPUInstrInfo {
43 private:
44  const SIRegisterInfo RI;
45  const SISubtarget &ST;
46 
47  // The inverse predicate should have the negative value.
48  enum BranchPredicate {
49  INVALID_BR = 0,
50  SCC_TRUE = 1,
51  SCC_FALSE = -1,
52  VCCNZ = 2,
53  VCCZ = -2,
54  EXECNZ = -3,
55  EXECZ = 3
56  };
57 
59 
60  static unsigned getBranchOpcode(BranchPredicate Cond);
61  static BranchPredicate getBranchPredicate(unsigned Opcode);
62 
63 public:
66  MachineOperand &SuperReg,
67  const TargetRegisterClass *SuperRC,
68  unsigned SubIdx,
69  const TargetRegisterClass *SubRC) const;
72  MachineOperand &SuperReg,
73  const TargetRegisterClass *SuperRC,
74  unsigned SubIdx,
75  const TargetRegisterClass *SubRC) const;
76 private:
77  void swapOperands(MachineInstr &Inst) const;
78 
79  bool moveScalarAddSub(SetVectorType &Worklist,
80  MachineInstr &Inst) const;
81 
82  void lowerScalarAbs(SetVectorType &Worklist,
83  MachineInstr &Inst) const;
84 
85  void lowerScalarXnor(SetVectorType &Worklist,
86  MachineInstr &Inst) const;
87 
88  void splitScalar64BitUnaryOp(SetVectorType &Worklist,
89  MachineInstr &Inst, unsigned Opcode) const;
90 
91  void splitScalar64BitAddSub(SetVectorType &Worklist,
92  MachineInstr &Inst) const;
93 
94  void splitScalar64BitBinaryOp(SetVectorType &Worklist,
95  MachineInstr &Inst, unsigned Opcode) const;
96 
97  void splitScalar64BitBCNT(SetVectorType &Worklist,
98  MachineInstr &Inst) const;
99  void splitScalar64BitBFE(SetVectorType &Worklist,
100  MachineInstr &Inst) const;
101  void movePackToVALU(SetVectorType &Worklist,
102  MachineRegisterInfo &MRI,
103  MachineInstr &Inst) const;
104 
105  void addUsersToMoveToVALUWorklist(unsigned Reg, MachineRegisterInfo &MRI,
106  SetVectorType &Worklist) const;
107 
108  void
109  addSCCDefUsersToVALUWorklist(MachineInstr &SCCDefInst,
110  SetVectorType &Worklist) const;
111 
112  const TargetRegisterClass *
113  getDestEquivalentVGPRClass(const MachineInstr &Inst) const;
114 
115  bool checkInstOffsetsDoNotOverlap(MachineInstr &MIa, MachineInstr &MIb) const;
116 
117  unsigned findUsedSGPR(const MachineInstr &MI, int OpIndices[3]) const;
118 
119 protected:
121  MachineOperand &Src0, unsigned Src0OpName,
122  MachineOperand &Src1, unsigned Src1OpName) const;
123 
125  unsigned OpIdx0,
126  unsigned OpIdx1) const override;
127 
128 public:
130  MO_MASK = 0x7,
131 
132  MO_NONE = 0,
133  // MO_GOTPCREL -> symbol@GOTPCREL -> R_AMDGPU_GOTPCREL.
135  // MO_GOTPCREL32_LO -> symbol@gotpcrel32@lo -> R_AMDGPU_GOTPCREL32_LO.
138  // MO_GOTPCREL32_HI -> symbol@gotpcrel32@hi -> R_AMDGPU_GOTPCREL32_HI.
140  // MO_REL32_LO -> symbol@rel32@lo -> R_AMDGPU_REL32_LO.
141  MO_REL32 = 4,
143  // MO_REL32_HI -> symbol@rel32@hi -> R_AMDGPU_REL32_HI.
145  };
146 
147  explicit SIInstrInfo(const SISubtarget &ST);
148 
150  return RI;
151  }
152 
154  AliasAnalysis *AA) const override;
155 
156  bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2,
157  int64_t &Offset1,
158  int64_t &Offset2) const override;
159 
160  bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg,
161  int64_t &Offset,
162  const TargetRegisterInfo *TRI) const final;
163 
164  bool shouldClusterMemOps(MachineInstr &FirstLdSt, unsigned BaseReg1,
165  MachineInstr &SecondLdSt, unsigned BaseReg2,
166  unsigned NumLoads) const final;
167 
169  const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
170  bool KillSrc) const override;
171 
173  RegScavenger *RS, unsigned TmpReg,
174  unsigned Offset, unsigned Size) const;
175 
178  const DebugLoc &DL,
179  unsigned DestReg,
180  int64_t Value) const;
181 
183  unsigned Size) const;
184 
185  unsigned insertNE(MachineBasicBlock *MBB,
187  unsigned SrcReg, int Value) const;
188 
189  unsigned insertEQ(MachineBasicBlock *MBB,
191  unsigned SrcReg, int Value) const;
192 
194  MachineBasicBlock::iterator MI, unsigned SrcReg,
195  bool isKill, int FrameIndex,
196  const TargetRegisterClass *RC,
197  const TargetRegisterInfo *TRI) const override;
198 
200  MachineBasicBlock::iterator MI, unsigned DestReg,
201  int FrameIndex, const TargetRegisterClass *RC,
202  const TargetRegisterInfo *TRI) const override;
203 
204  bool expandPostRAPseudo(MachineInstr &MI) const override;
205 
206  // Returns an opcode that can be used to move a value to a \p DstRC
207  // register. If there is no hardware instruction that can store to \p
208  // DstRC, then AMDGPU::COPY is returned.
209  unsigned getMovOpcode(const TargetRegisterClass *DstRC) const;
210 
212  int commuteOpcode(unsigned Opc) const;
213 
215  inline int commuteOpcode(const MachineInstr &MI) const {
216  return commuteOpcode(MI.getOpcode());
217  }
218 
219  bool findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1,
220  unsigned &SrcOpIdx2) const override;
221 
222  bool isBranchOffsetInRange(unsigned BranchOpc,
223  int64_t BrOffset) const override;
224 
225  MachineBasicBlock *getBranchDestBlock(const MachineInstr &MI) const override;
226 
228  MachineBasicBlock &NewDestBB,
229  const DebugLoc &DL,
230  int64_t BrOffset,
231  RegScavenger *RS = nullptr) const override;
232 
235  MachineBasicBlock *&TBB,
236  MachineBasicBlock *&FBB,
238  bool AllowModify) const;
239 
241  MachineBasicBlock *&FBB,
243  bool AllowModify = false) const override;
244 
245  unsigned removeBranch(MachineBasicBlock &MBB,
246  int *BytesRemoved = nullptr) const override;
247 
250  const DebugLoc &DL,
251  int *BytesAdded = nullptr) const override;
252 
254  SmallVectorImpl<MachineOperand> &Cond) const override;
255 
256  bool canInsertSelect(const MachineBasicBlock &MBB,
258  unsigned TrueReg, unsigned FalseReg,
259  int &CondCycles,
260  int &TrueCycles, int &FalseCycles) const override;
261 
264  unsigned DstReg, ArrayRef<MachineOperand> Cond,
265  unsigned TrueReg, unsigned FalseReg) const override;
266 
269  unsigned DstReg, ArrayRef<MachineOperand> Cond,
270  unsigned TrueReg, unsigned FalseReg) const;
271 
273  PseudoSourceValue::PSVKind Kind) const override;
274 
275  bool
277  AliasAnalysis *AA = nullptr) const override;
278 
279  bool isFoldableCopy(const MachineInstr &MI) const;
280 
281  bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg,
282  MachineRegisterInfo *MRI) const final;
283 
284  unsigned getMachineCSELookAheadLimit() const override { return 500; }
285 
287  MachineInstr &MI,
288  LiveVariables *LV) const override;
289 
290  bool isSchedulingBoundary(const MachineInstr &MI,
291  const MachineBasicBlock *MBB,
292  const MachineFunction &MF) const override;
293 
294  static bool isSALU(const MachineInstr &MI) {
295  return MI.getDesc().TSFlags & SIInstrFlags::SALU;
296  }
297 
298  bool isSALU(uint16_t Opcode) const {
299  return get(Opcode).TSFlags & SIInstrFlags::SALU;
300  }
301 
302  static bool isVALU(const MachineInstr &MI) {
303  return MI.getDesc().TSFlags & SIInstrFlags::VALU;
304  }
305 
306  bool isVALU(uint16_t Opcode) const {
307  return get(Opcode).TSFlags & SIInstrFlags::VALU;
308  }
309 
310  static bool isVMEM(const MachineInstr &MI) {
311  return isMUBUF(MI) || isMTBUF(MI) || isMIMG(MI);
312  }
313 
314  bool isVMEM(uint16_t Opcode) const {
315  return isMUBUF(Opcode) || isMTBUF(Opcode) || isMIMG(Opcode);
316  }
317 
318  static bool isSOP1(const MachineInstr &MI) {
319  return MI.getDesc().TSFlags & SIInstrFlags::SOP1;
320  }
321 
322  bool isSOP1(uint16_t Opcode) const {
323  return get(Opcode).TSFlags & SIInstrFlags::SOP1;
324  }
325 
326  static bool isSOP2(const MachineInstr &MI) {
327  return MI.getDesc().TSFlags & SIInstrFlags::SOP2;
328  }
329 
330  bool isSOP2(uint16_t Opcode) const {
331  return get(Opcode).TSFlags & SIInstrFlags::SOP2;
332  }
333 
334  static bool isSOPC(const MachineInstr &MI) {
335  return MI.getDesc().TSFlags & SIInstrFlags::SOPC;
336  }
337 
338  bool isSOPC(uint16_t Opcode) const {
339  return get(Opcode).TSFlags & SIInstrFlags::SOPC;
340  }
341 
342  static bool isSOPK(const MachineInstr &MI) {
343  return MI.getDesc().TSFlags & SIInstrFlags::SOPK;
344  }
345 
346  bool isSOPK(uint16_t Opcode) const {
347  return get(Opcode).TSFlags & SIInstrFlags::SOPK;
348  }
349 
350  static bool isSOPP(const MachineInstr &MI) {
351  return MI.getDesc().TSFlags & SIInstrFlags::SOPP;
352  }
353 
354  bool isSOPP(uint16_t Opcode) const {
355  return get(Opcode).TSFlags & SIInstrFlags::SOPP;
356  }
357 
358  static bool isVOP1(const MachineInstr &MI) {
359  return MI.getDesc().TSFlags & SIInstrFlags::VOP1;
360  }
361 
362  bool isVOP1(uint16_t Opcode) const {
363  return get(Opcode).TSFlags & SIInstrFlags::VOP1;
364  }
365 
366  static bool isVOP2(const MachineInstr &MI) {
367  return MI.getDesc().TSFlags & SIInstrFlags::VOP2;
368  }
369 
370  bool isVOP2(uint16_t Opcode) const {
371  return get(Opcode).TSFlags & SIInstrFlags::VOP2;
372  }
373 
374  static bool isVOP3(const MachineInstr &MI) {
375  return MI.getDesc().TSFlags & SIInstrFlags::VOP3;
376  }
377 
378  bool isVOP3(uint16_t Opcode) const {
379  return get(Opcode).TSFlags & SIInstrFlags::VOP3;
380  }
381 
382  static bool isSDWA(const MachineInstr &MI) {
383  return MI.getDesc().TSFlags & SIInstrFlags::SDWA;
384  }
385 
386  bool isSDWA(uint16_t Opcode) const {
387  return get(Opcode).TSFlags & SIInstrFlags::SDWA;
388  }
389 
390  static bool isVOPC(const MachineInstr &MI) {
391  return MI.getDesc().TSFlags & SIInstrFlags::VOPC;
392  }
393 
394  bool isVOPC(uint16_t Opcode) const {
395  return get(Opcode).TSFlags & SIInstrFlags::VOPC;
396  }
397 
398  static bool isMUBUF(const MachineInstr &MI) {
399  return MI.getDesc().TSFlags & SIInstrFlags::MUBUF;
400  }
401 
402  bool isMUBUF(uint16_t Opcode) const {
403  return get(Opcode).TSFlags & SIInstrFlags::MUBUF;
404  }
405 
406  static bool isMTBUF(const MachineInstr &MI) {
407  return MI.getDesc().TSFlags & SIInstrFlags::MTBUF;
408  }
409 
410  bool isMTBUF(uint16_t Opcode) const {
411  return get(Opcode).TSFlags & SIInstrFlags::MTBUF;
412  }
413 
414  static bool isSMRD(const MachineInstr &MI) {
415  return MI.getDesc().TSFlags & SIInstrFlags::SMRD;
416  }
417 
418  bool isSMRD(uint16_t Opcode) const {
419  return get(Opcode).TSFlags & SIInstrFlags::SMRD;
420  }
421 
422  bool isBufferSMRD(const MachineInstr &MI) const;
423 
424  static bool isDS(const MachineInstr &MI) {
425  return MI.getDesc().TSFlags & SIInstrFlags::DS;
426  }
427 
428  bool isDS(uint16_t Opcode) const {
429  return get(Opcode).TSFlags & SIInstrFlags::DS;
430  }
431 
432  static bool isMIMG(const MachineInstr &MI) {
433  return MI.getDesc().TSFlags & SIInstrFlags::MIMG;
434  }
435 
436  bool isMIMG(uint16_t Opcode) const {
437  return get(Opcode).TSFlags & SIInstrFlags::MIMG;
438  }
439 
440  static bool isGather4(const MachineInstr &MI) {
441  return MI.getDesc().TSFlags & SIInstrFlags::Gather4;
442  }
443 
444  bool isGather4(uint16_t Opcode) const {
445  return get(Opcode).TSFlags & SIInstrFlags::Gather4;
446  }
447 
448  static bool isD16(const MachineInstr &MI) {
449  return MI.getDesc().TSFlags & SIInstrFlags::D16;
450  }
451 
452  bool isD16(uint16_t Opcode) const {
453  return get(Opcode).TSFlags & SIInstrFlags::D16;
454  }
455 
456  static bool isFLAT(const MachineInstr &MI) {
457  return MI.getDesc().TSFlags & SIInstrFlags::FLAT;
458  }
459 
460  // Is a FLAT encoded instruction which accesses a specific segment,
461  // i.e. global_* or scratch_*.
462  static bool isSegmentSpecificFLAT(const MachineInstr &MI) {
463  auto Flags = MI.getDesc().TSFlags;
464  return (Flags & SIInstrFlags::FLAT) && !(Flags & SIInstrFlags::LGKM_CNT);
465  }
466 
467  // Any FLAT encoded instruction, including global_* and scratch_*.
468  bool isFLAT(uint16_t Opcode) const {
469  return get(Opcode).TSFlags & SIInstrFlags::FLAT;
470  }
471 
472  static bool isEXP(const MachineInstr &MI) {
473  return MI.getDesc().TSFlags & SIInstrFlags::EXP;
474  }
475 
476  bool isEXP(uint16_t Opcode) const {
477  return get(Opcode).TSFlags & SIInstrFlags::EXP;
478  }
479 
480  static bool isWQM(const MachineInstr &MI) {
481  return MI.getDesc().TSFlags & SIInstrFlags::WQM;
482  }
483 
484  bool isWQM(uint16_t Opcode) const {
485  return get(Opcode).TSFlags & SIInstrFlags::WQM;
486  }
487 
488  static bool isDisableWQM(const MachineInstr &MI) {
490  }
491 
492  bool isDisableWQM(uint16_t Opcode) const {
493  return get(Opcode).TSFlags & SIInstrFlags::DisableWQM;
494  }
495 
496  static bool isVGPRSpill(const MachineInstr &MI) {
498  }
499 
500  bool isVGPRSpill(uint16_t Opcode) const {
501  return get(Opcode).TSFlags & SIInstrFlags::VGPRSpill;
502  }
503 
504  static bool isSGPRSpill(const MachineInstr &MI) {
506  }
507 
508  bool isSGPRSpill(uint16_t Opcode) const {
509  return get(Opcode).TSFlags & SIInstrFlags::SGPRSpill;
510  }
511 
512  static bool isDPP(const MachineInstr &MI) {
513  return MI.getDesc().TSFlags & SIInstrFlags::DPP;
514  }
515 
516  bool isDPP(uint16_t Opcode) const {
517  return get(Opcode).TSFlags & SIInstrFlags::DPP;
518  }
519 
520  static bool isVOP3P(const MachineInstr &MI) {
521  return MI.getDesc().TSFlags & SIInstrFlags::VOP3P;
522  }
523 
524  bool isVOP3P(uint16_t Opcode) const {
525  return get(Opcode).TSFlags & SIInstrFlags::VOP3P;
526  }
527 
528  static bool isVINTRP(const MachineInstr &MI) {
529  return MI.getDesc().TSFlags & SIInstrFlags::VINTRP;
530  }
531 
532  bool isVINTRP(uint16_t Opcode) const {
533  return get(Opcode).TSFlags & SIInstrFlags::VINTRP;
534  }
535 
536  static bool isScalarUnit(const MachineInstr &MI) {
538  }
539 
540  static bool usesVM_CNT(const MachineInstr &MI) {
541  return MI.getDesc().TSFlags & SIInstrFlags::VM_CNT;
542  }
543 
544  static bool usesLGKM_CNT(const MachineInstr &MI) {
545  return MI.getDesc().TSFlags & SIInstrFlags::LGKM_CNT;
546  }
547 
548  static bool sopkIsZext(const MachineInstr &MI) {
550  }
551 
552  bool sopkIsZext(uint16_t Opcode) const {
553  return get(Opcode).TSFlags & SIInstrFlags::SOPK_ZEXT;
554  }
555 
556  /// \returns true if this is an s_store_dword* instruction. This is more
557  /// specific than than isSMEM && mayStore.
558  static bool isScalarStore(const MachineInstr &MI) {
560  }
561 
562  bool isScalarStore(uint16_t Opcode) const {
563  return get(Opcode).TSFlags & SIInstrFlags::SCALAR_STORE;
564  }
565 
566  static bool isFixedSize(const MachineInstr &MI) {
568  }
569 
570  bool isFixedSize(uint16_t Opcode) const {
571  return get(Opcode).TSFlags & SIInstrFlags::FIXED_SIZE;
572  }
573 
574  static bool hasFPClamp(const MachineInstr &MI) {
575  return MI.getDesc().TSFlags & SIInstrFlags::FPClamp;
576  }
577 
578  bool hasFPClamp(uint16_t Opcode) const {
579  return get(Opcode).TSFlags & SIInstrFlags::FPClamp;
580  }
581 
582  static bool hasIntClamp(const MachineInstr &MI) {
583  return MI.getDesc().TSFlags & SIInstrFlags::IntClamp;
584  }
585 
586  uint64_t getClampMask(const MachineInstr &MI) const {
587  const uint64_t ClampFlags = SIInstrFlags::FPClamp |
591  return MI.getDesc().TSFlags & ClampFlags;
592  }
593 
594  bool isVGPRCopy(const MachineInstr &MI) const {
595  assert(MI.isCopy());
596  unsigned Dest = MI.getOperand(0).getReg();
597  const MachineFunction &MF = *MI.getParent()->getParent();
598  const MachineRegisterInfo &MRI = MF.getRegInfo();
599  return !RI.isSGPRReg(MRI, Dest);
600  }
601 
602  bool isInlineConstant(const APInt &Imm) const;
603 
604  bool isInlineConstant(const MachineOperand &MO, uint8_t OperandType) const;
605 
607  const MCOperandInfo &OpInfo) const {
608  return isInlineConstant(MO, OpInfo.OperandType);
609  }
610 
611  /// \p returns true if \p UseMO is substituted with \p DefMO in \p MI it would
612  /// be an inline immediate.
614  const MachineOperand &UseMO,
615  const MachineOperand &DefMO) const {
616  assert(UseMO.getParent() == &MI);
617  int OpIdx = MI.getOperandNo(&UseMO);
618  if (!MI.getDesc().OpInfo || OpIdx >= MI.getDesc().NumOperands) {
619  return false;
620  }
621 
622  return isInlineConstant(DefMO, MI.getDesc().OpInfo[OpIdx]);
623  }
624 
625  /// \p returns true if the operand \p OpIdx in \p MI is a valid inline
626  /// immediate.
627  bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx) const {
628  const MachineOperand &MO = MI.getOperand(OpIdx);
629  return isInlineConstant(MO, MI.getDesc().OpInfo[OpIdx].OperandType);
630  }
631 
632  bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx,
633  const MachineOperand &MO) const {
634  if (!MI.getDesc().OpInfo || OpIdx >= MI.getDesc().NumOperands)
635  return false;
636 
637  if (MI.isCopy()) {
638  unsigned Size = getOpSize(MI, OpIdx);
639  assert(Size == 8 || Size == 4);
640 
641  uint8_t OpType = (Size == 8) ?
643  return isInlineConstant(MO, OpType);
644  }
645 
646  return isInlineConstant(MO, MI.getDesc().OpInfo[OpIdx].OperandType);
647  }
648 
649  bool isInlineConstant(const MachineOperand &MO) const {
650  const MachineInstr *Parent = MO.getParent();
651  return isInlineConstant(*Parent, Parent->getOperandNo(&MO));
652  }
653 
655  const MCOperandInfo &OpInfo) const {
656  return MO.isImm() && !isInlineConstant(MO, OpInfo.OperandType);
657  }
658 
659  bool isLiteralConstant(const MachineInstr &MI, int OpIdx) const {
660  const MachineOperand &MO = MI.getOperand(OpIdx);
661  return MO.isImm() && !isInlineConstant(MI, OpIdx);
662  }
663 
664  // Returns true if this operand could potentially require a 32-bit literal
665  // operand, but not necessarily. A FrameIndex for example could resolve to an
666  // inline immediate value that will not require an additional 4-bytes; this
667  // assumes that it will.
668  bool isLiteralConstantLike(const MachineOperand &MO,
669  const MCOperandInfo &OpInfo) const;
670 
671  bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo,
672  const MachineOperand &MO) const;
673 
674  /// Return true if this 64-bit VALU instruction has a 32-bit encoding.
675  /// This function will return false if you pass it a 32-bit instruction.
676  bool hasVALU32BitEncoding(unsigned Opcode) const;
677 
678  /// Returns true if this operand uses the constant bus.
679  bool usesConstantBus(const MachineRegisterInfo &MRI,
680  const MachineOperand &MO,
681  const MCOperandInfo &OpInfo) const;
682 
683  /// Return true if this instruction has any modifiers.
684  /// e.g. src[012]_mod, omod, clamp.
685  bool hasModifiers(unsigned Opcode) const;
686 
687  bool hasModifiersSet(const MachineInstr &MI,
688  unsigned OpName) const;
689  bool hasAnyModifiersSet(const MachineInstr &MI) const;
690 
691  bool verifyInstruction(const MachineInstr &MI,
692  StringRef &ErrInfo) const override;
693 
694  unsigned getVALUOp(const MachineInstr &MI) const;
695 
696  /// Return the correct register class for \p OpNo. For target-specific
697  /// instructions, this will return the register class that has been defined
698  /// in tablegen. For generic instructions, like REG_SEQUENCE it will return
699  /// the register class of its machine operand.
700  /// to infer the correct register class base on the other operands.
702  unsigned OpNo) const;
703 
704  /// Return the size in bytes of the operand OpNo on the given
705  // instruction opcode.
706  unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const {
707  const MCOperandInfo &OpInfo = get(Opcode).OpInfo[OpNo];
708 
709  if (OpInfo.RegClass == -1) {
710  // If this is an immediate operand, this must be a 32-bit literal.
712  return 4;
713  }
714 
715  return RI.getRegSizeInBits(*RI.getRegClass(OpInfo.RegClass)) / 8;
716  }
717 
718  /// This form should usually be preferred since it handles operands
719  /// with unknown register classes.
720  unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const {
721  return RI.getRegSizeInBits(*getOpRegClass(MI, OpNo)) / 8;
722  }
723 
724  /// \returns true if it is legal for the operand at index \p OpNo
725  /// to read a VGPR.
726  bool canReadVGPR(const MachineInstr &MI, unsigned OpNo) const;
727 
728  /// Legalize the \p OpIndex operand of this instruction by inserting
729  /// a MOV. For example:
730  /// ADD_I32_e32 VGPR0, 15
731  /// to
732  /// MOV VGPR1, 15
733  /// ADD_I32_e32 VGPR0, VGPR1
734  ///
735  /// If the operand being legalized is a register, then a COPY will be used
736  /// instead of MOV.
737  void legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const;
738 
739  /// Check if \p MO is a legal operand if it was the \p OpIdx Operand
740  /// for \p MI.
741  bool isOperandLegal(const MachineInstr &MI, unsigned OpIdx,
742  const MachineOperand *MO = nullptr) const;
743 
744  /// Check if \p MO would be a valid operand for the given operand
745  /// definition \p OpInfo. Note this does not attempt to validate constant bus
746  /// restrictions (e.g. literal constant usage).
747  bool isLegalVSrcOperand(const MachineRegisterInfo &MRI,
748  const MCOperandInfo &OpInfo,
749  const MachineOperand &MO) const;
750 
751  /// Check if \p MO (a register operand) is a legal register for the
752  /// given operand description.
753  bool isLegalRegOperand(const MachineRegisterInfo &MRI,
754  const MCOperandInfo &OpInfo,
755  const MachineOperand &MO) const;
756 
757  /// Legalize operands in \p MI by either commuting it or inserting a
758  /// copy of src1.
760 
761  /// Fix operands in \p MI to satisfy constant bus requirements.
763 
764  /// Copy a value from a VGPR (\p SrcReg) to SGPR. This function can only
765  /// be used when it is know that the value in SrcReg is same across all
766  /// threads in the wave.
767  /// \returns The SGPR register that \p SrcReg was copied to.
768  unsigned readlaneVGPRToSGPR(unsigned SrcReg, MachineInstr &UseMI,
769  MachineRegisterInfo &MRI) const;
770 
772 
775  const TargetRegisterClass *DstRC,
777  const DebugLoc &DL) const;
778 
779  /// Legalize all operands in this instruction. This function may
780  /// create new instruction and insert them before \p MI.
781  void legalizeOperands(MachineInstr &MI) const;
782 
783  /// Replace this instruction's opcode with the equivalent VALU
784  /// opcode. This function will also move the users of \p MI to the
785  /// VALU if necessary.
786  void moveToVALU(MachineInstr &MI) const;
787 
789  int Count) const;
790 
791  void insertNoop(MachineBasicBlock &MBB,
792  MachineBasicBlock::iterator MI) const override;
793 
794  void insertReturn(MachineBasicBlock &MBB) const;
795  /// Return the number of wait states that result from executing this
796  /// instruction.
797  unsigned getNumWaitStates(const MachineInstr &MI) const;
798 
799  /// Returns the operand named \p Op. If \p MI does not have an
800  /// operand named \c Op, this function returns nullptr.
802  MachineOperand *getNamedOperand(MachineInstr &MI, unsigned OperandName) const;
803 
806  unsigned OpName) const {
807  return getNamedOperand(const_cast<MachineInstr &>(MI), OpName);
808  }
809 
810  /// Get required immediate operand
811  int64_t getNamedImmOperand(const MachineInstr &MI, unsigned OpName) const {
812  int Idx = AMDGPU::getNamedOperandIdx(MI.getOpcode(), OpName);
813  return MI.getOperand(Idx).getImm();
814  }
815 
816  uint64_t getDefaultRsrcDataFormat() const;
817  uint64_t getScratchRsrcWords23() const;
818 
819  bool isLowLatencyInstruction(const MachineInstr &MI) const;
820  bool isHighLatencyInstruction(const MachineInstr &MI) const;
821 
822  /// Return the descriptor of the target-specific machine instruction
823  /// that corresponds to the specified pseudo or native opcode.
824  const MCInstrDesc &getMCOpcodeFromPseudo(unsigned Opcode) const {
825  return get(pseudoToMCOpcode(Opcode));
826  }
827 
828  unsigned isStackAccess(const MachineInstr &MI, int &FrameIndex) const;
829  unsigned isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex) const;
830 
831  unsigned isLoadFromStackSlot(const MachineInstr &MI,
832  int &FrameIndex) const override;
833  unsigned isStoreToStackSlot(const MachineInstr &MI,
834  int &FrameIndex) const override;
835 
836  unsigned getInstBundleSize(const MachineInstr &MI) const;
837  unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
838 
839  bool mayAccessFlatAddressSpace(const MachineInstr &MI) const;
840 
841  bool isNonUniformBranchInstr(MachineInstr &Instr) const;
842 
844  MachineBasicBlock *IfEnd) const;
845 
847  MachineBasicBlock *LoopEnd) const;
848 
849  std::pair<unsigned, unsigned>
850  decomposeMachineOperandsTargetFlags(unsigned TF) const override;
851 
853  getSerializableTargetIndices() const override;
854 
857 
860  const ScheduleDAG *DAG) const override;
861 
863  CreateTargetPostRAHazardRecognizer(const MachineFunction &MF) const override;
864 
865  bool isBasicBlockPrologue(const MachineInstr &MI) const override;
866 
867  /// Return a partially built integer add instruction without carry.
868  /// Caller must add source operands.
869  /// For pre-GFX9 it will generate unused carry destination operand.
870  /// TODO: After GFX9 it should return a no-carry operation.
873  const DebugLoc &DL,
874  unsigned DestReg) const;
875 
876  static bool isKillTerminator(unsigned Opcode);
877  const MCInstrDesc &getKillTerminatorFromPseudo(unsigned Opcode) const;
878 
879  static bool isLegalMUBUFImmOffset(unsigned Imm) {
880  return isUInt<12>(Imm);
881  }
882 };
883 
884 namespace AMDGPU {
885 
887  int getVOPe64(uint16_t Opcode);
888 
890  int getVOPe32(uint16_t Opcode);
891 
893  int getSDWAOp(uint16_t Opcode);
894 
896  int getBasicFromSDWAOp(uint16_t Opcode);
897 
899  int getCommuteRev(uint16_t Opcode);
900 
902  int getCommuteOrig(uint16_t Opcode);
903 
905  int getAddr64Inst(uint16_t Opcode);
906 
908  int getMUBUFNoLdsInst(uint16_t Opcode);
909 
911  int getAtomicRetOp(uint16_t Opcode);
912 
914  int getAtomicNoRetOp(uint16_t Opcode);
915 
917  int getSOPKOp(uint16_t Opcode);
918 
919  const uint64_t RSRC_DATA_FORMAT = 0xf00000000000LL;
920  const uint64_t RSRC_ELEMENT_SIZE_SHIFT = (32 + 19);
921  const uint64_t RSRC_INDEX_STRIDE_SHIFT = (32 + 21);
922  const uint64_t RSRC_TID_ENABLE = UINT64_C(1) << (32 + 23);
923 
924  // For MachineOperands.
925  enum TargetFlags {
928  };
929 
930 } // end namespace AMDGPU
931 
932 namespace SI {
933 namespace KernelInputOffsets {
934 
935 /// Offsets in bytes from the start of the input buffer
936 enum Offsets {
946 };
947 
948 } // end namespace KernelInputOffsets
949 } // end namespace SI
950 
951 } // end namespace llvm
952 
953 #endif // LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H
bool isFLAT(uint16_t Opcode) const
Definition: SIInstrInfo.h:468
bool isLegalRegOperand(const MachineRegisterInfo &MRI, const MCOperandInfo &OpInfo, const MachineOperand &MO) const
Check if MO (a register operand) is a legal register for the given operand description.
unsigned buildExtractSubReg(MachineBasicBlock::iterator MI, MachineRegisterInfo &MRI, MachineOperand &SuperReg, const TargetRegisterClass *SuperRC, unsigned SubIdx, const TargetRegisterClass *SubRC) const
bool analyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const
unsigned getVALUOp(const MachineInstr &MI) const
void legalizeOperands(MachineInstr &MI) const
Legalize all operands in this instruction.
static bool isSGPRSpill(const MachineInstr &MI)
Definition: SIInstrInfo.h:504
Interface definition for SIRegisterInfo.
bool sopkIsZext(uint16_t Opcode) const
Definition: SIInstrInfo.h:552
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const override
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
bool canReadVGPR(const MachineInstr &MI, unsigned OpNo) const
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
bool isVGPRCopy(const MachineInstr &MI) const
Definition: SIInstrInfo.h:594
int pseudoToMCOpcode(int Opcode) const
Return a target-specific opcode if Opcode is a pseudo instruction.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
static bool isScalarStore(const MachineInstr &MI)
Definition: SIInstrInfo.h:558
static bool sopkIsZext(const MachineInstr &MI)
Definition: SIInstrInfo.h:548
uint64_t getDefaultRsrcDataFormat() const
bool isOperandLegal(const MachineInstr &MI, unsigned OpIdx, const MachineOperand *MO=nullptr) const
Check if MO is a legal operand if it was the OpIdx Operand for MI.
bool isSOPK(uint16_t Opcode) const
Definition: SIInstrInfo.h:346
bool canInsertSelect(const MachineBasicBlock &MBB, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg, int &CondCycles, int &TrueCycles, int &FalseCycles) const override
bool usesConstantBus(const MachineRegisterInfo &MRI, const MachineOperand &MO, const MCOperandInfo &OpInfo) const
Returns true if this operand uses the constant bus.
bool mayAccessFlatAddressSpace(const MachineInstr &MI) const
unsigned calculateLDSSpillAddress(MachineBasicBlock &MBB, MachineInstr &MI, RegScavenger *RS, unsigned TmpReg, unsigned Offset, unsigned Size) const
bool hasModifiersSet(const MachineInstr &MI, unsigned OpName) const
const TargetRegisterClass * getOpRegClass(const MachineInstr &MI, unsigned OpNo) const
Return the correct register class for OpNo.
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:161
unsigned getReg() const
getReg - Returns the register number.
static bool isVINTRP(const MachineInstr &MI)
Definition: SIInstrInfo.h:528
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
Definition: MachineInstr.h:405
unsigned insertNE(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned SrcReg, int Value) const
unsigned Reg
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
static bool isSOPK(const MachineInstr &MI)
Definition: SIInstrInfo.h:342
void legalizeOperandsVOP2(MachineRegisterInfo &MRI, MachineInstr &MI) const
Legalize operands in MI by either commuting it or inserting a copy of src1.
unsigned isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex) const
Offsets
Offsets in bytes from the start of the input buffer.
Definition: SIInstrInfo.h:936
bool isMIMG(uint16_t Opcode) const
Definition: SIInstrInfo.h:436
int64_t getNamedImmOperand(const MachineInstr &MI, unsigned OpName) const
Get required immediate operand.
Definition: SIInstrInfo.h:811
unsigned const TargetRegisterInfo * TRI
A debug info location.
Definition: DebugLoc.h:34
bool isDPP(uint16_t Opcode) const
Definition: SIInstrInfo.h:516
bool isGather4(uint16_t Opcode) const
Definition: SIInstrInfo.h:444
static bool isSOPP(const MachineInstr &MI)
Definition: SIInstrInfo.h:350
LLVM_READONLY int getAtomicNoRetOp(uint16_t Opcode)
bool isInlineConstant(const APInt &Imm) const
bool isMUBUF(uint16_t Opcode) const
Definition: SIInstrInfo.h:402
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
static bool isSOPC(const MachineInstr &MI)
Definition: SIInstrInfo.h:334
bool hasAnyModifiersSet(const MachineInstr &MI) const
static bool isSMRD(const MachineInstr &MI)
Definition: SIInstrInfo.h:414
const SIRegisterInfo & getRegisterInfo() const
Definition: SIInstrInfo.h:149
LLVM_READONLY int getVOPe64(uint16_t Opcode)
static bool isFixedSize(const MachineInstr &MI)
Definition: SIInstrInfo.h:566
LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx)
bool verifyInstruction(const MachineInstr &MI, StringRef &ErrInfo) const override
static bool isDS(const MachineInstr &MI)
Definition: SIInstrInfo.h:424
bool isEXP(uint16_t Opcode) const
Definition: SIInstrInfo.h:476
bool isSOPP(uint16_t Opcode) const
Definition: SIInstrInfo.h:354
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
LLVM_READONLY int getAtomicRetOp(uint16_t Opcode)
static bool isFLAT(const MachineInstr &MI)
Definition: SIInstrInfo.h:456
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
uint64_t getScratchRsrcWords23() const
bool isSGPRReg(const MachineRegisterInfo &MRI, unsigned Reg) const
static bool isGather4(const MachineInstr &MI)
Definition: SIInstrInfo.h:440
static bool isMIMG(const MachineInstr &MI)
Definition: SIInstrInfo.h:432
bool isVINTRP(uint16_t Opcode) const
Definition: SIInstrInfo.h:532
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
MachineOperand buildExtractSubRegOrImm(MachineBasicBlock::iterator MI, MachineRegisterInfo &MRI, MachineOperand &SuperReg, const TargetRegisterClass *SuperRC, unsigned SubIdx, const TargetRegisterClass *SubRC) const
void insertWaitStates(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, int Count) const
LLVM_READONLY int getCommuteOrig(uint16_t Opcode)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:311
bool isLiteralConstant(const MachineInstr &MI, int OpIdx) const
Definition: SIInstrInfo.h:659
const MCInstrDesc & getMCOpcodeFromPseudo(unsigned Opcode) const
Return the descriptor of the target-specific machine instruction that corresponds to the specified ps...
Definition: SIInstrInfo.h:824
static bool isVALU(const MachineInstr &MI)
Definition: SIInstrInfo.h:302
unsigned getAddressSpaceForPseudoSourceKind(PseudoSourceValue::PSVKind Kind) const override
void legalizeOperandsVOP3(MachineRegisterInfo &MRI, MachineInstr &MI) const
Fix operands in MI to satisfy constant bus requirements.
unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const
Return the size in bytes of the operand OpNo on the given.
Definition: SIInstrInfo.h:706
uint8_t OperandType
Information about the type of the operand.
Definition: MCInstrDesc.h:79
#define LLVM_READONLY
Definition: Compiler.h:168
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
Definition: MachineInstr.h:308
unsigned getInstBundleSize(const MachineInstr &MI) const
static bool isMUBUF(const MachineInstr &MI)
Definition: SIInstrInfo.h:398
LLVM_READONLY MachineOperand * getNamedOperand(MachineInstr &MI, unsigned OperandName) const
Returns the operand named Op.
void convertNonUniformLoopRegion(MachineBasicBlock *LoopEntry, MachineBasicBlock *LoopEnd) const
const uint64_t RSRC_DATA_FORMAT
Definition: SIInstrInfo.h:919
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx0, unsigned OpIdx1) const override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
bool isSGPRSpill(uint16_t Opcode) const
Definition: SIInstrInfo.h:508
bool isSDWA(uint16_t Opcode) const
Definition: SIInstrInfo.h:386
Itinerary data supplied by a subtarget to be used by a target.
bool isD16(uint16_t Opcode) const
Definition: SIInstrInfo.h:452
bool isBasicBlockPrologue(const MachineInstr &MI) const override
bool isInlineConstant(const MachineOperand &MO) const
Definition: SIInstrInfo.h:649
unsigned short NumOperands
Definition: MCInstrDesc.h:164
bool isVOP1(uint16_t Opcode) const
Definition: SIInstrInfo.h:362
LLVM_READONLY int getSDWAOp(uint16_t Opcode)
static bool isDPP(const MachineInstr &MI)
Definition: SIInstrInfo.h:512
bool isSOPC(uint16_t Opcode) const
Definition: SIInstrInfo.h:338
bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg, int64_t &Offset, const TargetRegisterInfo *TRI) const final
bool isInlineConstant(const MachineOperand &MO, const MCOperandInfo &OpInfo) const
Definition: SIInstrInfo.h:606
unsigned const MachineRegisterInfo * MRI
const MCInstrDesc & getKillTerminatorFromPseudo(unsigned Opcode) const
bool isFoldableCopy(const MachineInstr &MI) const
static bool usesVM_CNT(const MachineInstr &MI)
Definition: SIInstrInfo.h:540
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
const TargetRegisterClass * getPreferredSelectRegClass(unsigned Size) const
SIInstrInfo(const SISubtarget &ST)
Definition: SIInstrInfo.cpp:73
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
HazardRecognizer - This determines whether or not an instruction can be issued this cycle...
MachineInstrBuilder & UseMI
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, AliasAnalysis *AA) const override
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx, const MachineOperand &MO) const
Definition: SIInstrInfo.h:632
void insertVectorSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const
static bool hasFPClamp(const MachineInstr &MI)
Definition: SIInstrInfo.h:574
bool expandPostRAPseudo(MachineInstr &MI) const override
bool isFixedSize(uint16_t Opcode) const
Definition: SIInstrInfo.h:570
void insertReturn(MachineBasicBlock &MBB) const
bool isDS(uint16_t Opcode) const
Definition: SIInstrInfo.h:428
LLVM_READONLY int commuteOpcode(unsigned Opc) const
bool isVOPC(uint16_t Opcode) const
Definition: SIInstrInfo.h:394
unsigned insertEQ(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned SrcReg, int Value) const
LLVM_READONLY int getSOPKOp(uint16_t Opcode)
bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo, const MachineOperand &MO) const
bool isSOP1(uint16_t Opcode) const
Definition: SIInstrInfo.h:322
bool hasVALU32BitEncoding(unsigned Opcode) const
Return true if this 64-bit VALU instruction has a 32-bit encoding.
static bool isSOP2(const MachineInstr &MI)
Definition: SIInstrInfo.h:326
void materializeImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, int64_t Value) const
ScheduleHazardRecognizer * CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II, const ScheduleDAG *DAG) const override
This is used by the post-RA scheduler (SchedulePostRAList.cpp).
unsigned insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS=nullptr) const override
bool isWQM(uint16_t Opcode) const
Definition: SIInstrInfo.h:484
bool hasFPClamp(uint16_t Opcode) const
Definition: SIInstrInfo.h:578
static bool isVOP2(const MachineInstr &MI)
Definition: SIInstrInfo.h:366
bool isSMRD(uint16_t Opcode) const
Definition: SIInstrInfo.h:418
bool isCopy() const
Definition: MachineInstr.h:886
unsigned isStackAccess(const MachineInstr &MI, int &FrameIndex) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LLVM_READONLY int getBasicFromSDWAOp(uint16_t Opcode)
bool swapSourceModifiers(MachineInstr &MI, MachineOperand &Src0, unsigned Src0OpName, MachineOperand &Src1, unsigned Src1OpName) const
static bool isVOP3P(const MachineInstr &MI)
Definition: SIInstrInfo.h:520
bool isSOP2(uint16_t Opcode) const
Definition: SIInstrInfo.h:330
const uint64_t RSRC_TID_ENABLE
Definition: SIInstrInfo.h:922
static bool isWQM(const MachineInstr &MI)
Definition: SIInstrInfo.h:480
bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg, MachineRegisterInfo *MRI) const final
static bool isEXP(const MachineInstr &MI)
Definition: SIInstrInfo.h:472
bool shouldClusterMemOps(MachineInstr &FirstLdSt, unsigned BaseReg1, MachineInstr &SecondLdSt, unsigned BaseReg2, unsigned NumLoads) const final
bool isScalarStore(uint16_t Opcode) const
Definition: SIInstrInfo.h:562
unsigned getNumWaitStates(const MachineInstr &MI) const
Return the number of wait states that result from executing this instruction.
bool isVOP2(uint16_t Opcode) const
Definition: SIInstrInfo.h:370
A SetVector that performs no allocations if smaller than a certain size.
Definition: SetVector.h:298
Iterator for intrusive lists based on ilist_node.
LLVM_READONLY int getMUBUFNoLdsInst(uint16_t Opcode)
LLVM_READONLY int getVOPe32(uint16_t Opcode)
static bool isSALU(const MachineInstr &MI)
Definition: SIInstrInfo.h:294
MachineOperand class - Representation of each machine instruction operand.
bool isLiteralConstantLike(const MachineOperand &MO, const MCOperandInfo &OpInfo) const
MachineInstrBuilder MachineInstrBuilder & DefMI
uint64_t getClampMask(const MachineInstr &MI) const
Definition: SIInstrInfo.h:586
bool areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb, AliasAnalysis *AA=nullptr) const override
MachineInstrBuilder getAddNoCarry(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg) const
Return a partially built integer add instruction without carry.
bool isLegalVSrcOperand(const MachineRegisterInfo &MRI, const MCOperandInfo &OpInfo, const MachineOperand &MO) const
Check if MO would be a valid operand for the given operand definition OpInfo.
const uint64_t RSRC_INDEX_STRIDE_SHIFT
Definition: SIInstrInfo.h:921
bool isMTBUF(uint16_t Opcode) const
Definition: SIInstrInfo.h:410
Represents one node in the SelectionDAG.
int64_t getImm() const
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2, int64_t &Offset1, int64_t &Offset2) const override
Class for arbitrary precision integers.
Definition: APInt.h:69
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
bool isDisableWQM(uint16_t Opcode) const
Definition: SIInstrInfo.h:492
bool hasModifiers(unsigned Opcode) const
Return true if this instruction has any modifiers.
static bool isSegmentSpecificFLAT(const MachineInstr &MI)
Definition: SIInstrInfo.h:462
static bool isVOP3(const MachineInstr &MI)
Definition: SIInstrInfo.h:374
bool isLiteralConstant(const MachineOperand &MO, const MCOperandInfo &OpInfo) const
Definition: SIInstrInfo.h:654
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:156
Contains the definition of a TargetInstrInfo class that is common to all AMD GPUs.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx) const
returns true if the operand OpIdx in MI is a valid inline immediate.
Definition: SIInstrInfo.h:627
Representation of each machine instruction.
Definition: MachineInstr.h:60
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
OperandType
Operands are tagged with one of the values of this enum.
Definition: MCInstrDesc.h:44
static bool isMTBUF(const MachineInstr &MI)
Definition: SIInstrInfo.h:406
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static bool isVOPC(const MachineInstr &MI)
Definition: SIInstrInfo.h:390
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
Definition: MCInstrDesc.h:73
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
#define I(x, y, z)
Definition: MD5.cpp:58
static bool isVMEM(const MachineInstr &MI)
Definition: SIInstrInfo.h:310
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
bool isHighLatencyInstruction(const MachineInstr &MI) const
LLVM_READONLY int commuteOpcode(const MachineInstr &MI) const
Definition: SIInstrInfo.h:215
bool isLowLatencyInstruction(const MachineInstr &MI) const
bool isSALU(uint16_t Opcode) const
Definition: SIInstrInfo.h:298
ArrayRef< std::pair< int, const char * > > getSerializableTargetIndices() const override
unsigned getMovOpcode(const TargetRegisterClass *DstRC) const
bool isVMEM(uint16_t Opcode) const
Definition: SIInstrInfo.h:314
bool isVOP3P(uint16_t Opcode) const
Definition: SIInstrInfo.h:524
Operands with register or 32-bit immediate.
Definition: SIDefines.h:113
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
void moveToVALU(MachineInstr &MI) const
Replace this instruction&#39;s opcode with the equivalent VALU opcode.
const unsigned Kind
bool isNonUniformBranchInstr(MachineInstr &Instr) const
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isSOP1(const MachineInstr &MI)
Definition: SIInstrInfo.h:318
void legalizeOperandsSMRD(MachineRegisterInfo &MRI, MachineInstr &MI) const
static bool isLegalMUBUFImmOffset(unsigned Imm)
Definition: SIInstrInfo.h:879
const uint64_t RSRC_ELEMENT_SIZE_SHIFT
Definition: SIInstrInfo.h:920
static bool isScalarUnit(const MachineInstr &MI)
Definition: SIInstrInfo.h:536
unsigned readlaneVGPRToSGPR(unsigned SrcReg, MachineInstr &UseMI, MachineRegisterInfo &MRI) const
Copy a value from a VGPR (SrcReg) to SGPR.
static bool hasIntClamp(const MachineInstr &MI)
Definition: SIInstrInfo.h:582
LLVM Value Representation.
Definition: Value.h:73
static bool isSDWA(const MachineInstr &MI)
Definition: SIInstrInfo.h:382
void legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const
Legalize the OpIndex operand of this instruction by inserting a MOV.
MachineInstr * convertToThreeAddress(MachineFunction::iterator &MBB, MachineInstr &MI, LiveVariables *LV) const override
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static bool isVGPRSpill(const MachineInstr &MI)
Definition: SIInstrInfo.h:496
unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const
This form should usually be preferred since it handles operands with unknown register classes...
Definition: SIInstrInfo.h:720
unsigned getMachineCSELookAheadLimit() const override
Definition: SIInstrInfo.h:284
const MCOperandInfo * OpInfo
Definition: MCInstrDesc.h:172
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
bool isInlineConstant(const MachineInstr &MI, const MachineOperand &UseMO, const MachineOperand &DefMO) const
returns true if UseMO is substituted with DefMO in MI it would be an inline immediate.
Definition: SIInstrInfo.h:613
void legalizeGenericOperand(MachineBasicBlock &InsertMBB, MachineBasicBlock::iterator I, const TargetRegisterClass *DstRC, MachineOperand &Op, MachineRegisterInfo &MRI, const DebugLoc &DL) const
bool isVOP3(uint16_t Opcode) const
Definition: SIInstrInfo.h:378
static bool isKillTerminator(unsigned Opcode)
LLVM_READONLY int getAddr64Inst(uint16_t Opcode)
This holds information about one operand of a machine instruction, indicating the register class for ...
Definition: MCInstrDesc.h:67
static bool usesLGKM_CNT(const MachineInstr &MI)
Definition: SIInstrInfo.h:544
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:316
static bool isVOP1(const MachineInstr &MI)
Definition: SIInstrInfo.h:358
void convertNonUniformIfRegion(MachineBasicBlock *IfEntry, MachineBasicBlock *IfEnd) const
bool isBufferSMRD(const MachineInstr &MI) const
static bool isDisableWQM(const MachineInstr &MI)
Definition: SIInstrInfo.h:488
bool findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const override
bool isVALU(uint16_t Opcode) const
Definition: SIInstrInfo.h:306
LLVM_READONLY int getCommuteRev(uint16_t Opcode)
LLVM_READONLY const MachineOperand * getNamedOperand(const MachineInstr &MI, unsigned OpName) const
Definition: SIInstrInfo.h:805
bool isVGPRSpill(uint16_t Opcode) const
Definition: SIInstrInfo.h:500
static bool isD16(const MachineInstr &MI)
Definition: SIInstrInfo.h:448