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 /// \brief 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  // \brief 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  if (!isSMRD(MI))
424  return false;
425 
426  // Check that it is using a buffer resource.
427  int Idx = AMDGPU::getNamedOperandIdx(MI.getOpcode(), AMDGPU::OpName::sbase);
428  if (Idx == -1) // e.g. s_memtime
429  return false;
430 
431  const auto RCID = MI.getDesc().OpInfo[Idx].RegClass;
432  return RCID == AMDGPU::SReg_128RegClassID;
433  }
434 
435  static bool isDS(const MachineInstr &MI) {
436  return MI.getDesc().TSFlags & SIInstrFlags::DS;
437  }
438 
439  bool isDS(uint16_t Opcode) const {
440  return get(Opcode).TSFlags & SIInstrFlags::DS;
441  }
442 
443  static bool isMIMG(const MachineInstr &MI) {
444  return MI.getDesc().TSFlags & SIInstrFlags::MIMG;
445  }
446 
447  bool isMIMG(uint16_t Opcode) const {
448  return get(Opcode).TSFlags & SIInstrFlags::MIMG;
449  }
450 
451  static bool isGather4(const MachineInstr &MI) {
452  return MI.getDesc().TSFlags & SIInstrFlags::Gather4;
453  }
454 
455  bool isGather4(uint16_t Opcode) const {
456  return get(Opcode).TSFlags & SIInstrFlags::Gather4;
457  }
458 
459  static bool isD16(const MachineInstr &MI) {
460  return MI.getDesc().TSFlags & SIInstrFlags::D16;
461  }
462 
463  bool isD16(uint16_t Opcode) const {
464  return get(Opcode).TSFlags & SIInstrFlags::D16;
465  }
466 
467  static bool isFLAT(const MachineInstr &MI) {
468  return MI.getDesc().TSFlags & SIInstrFlags::FLAT;
469  }
470 
471  // Is a FLAT encoded instruction which accesses a specific segment,
472  // i.e. global_* or scratch_*.
473  static bool isSegmentSpecificFLAT(const MachineInstr &MI) {
474  auto Flags = MI.getDesc().TSFlags;
475  return (Flags & SIInstrFlags::FLAT) && !(Flags & SIInstrFlags::LGKM_CNT);
476  }
477 
478  // Any FLAT encoded instruction, including global_* and scratch_*.
479  bool isFLAT(uint16_t Opcode) const {
480  return get(Opcode).TSFlags & SIInstrFlags::FLAT;
481  }
482 
483  static bool isEXP(const MachineInstr &MI) {
484  return MI.getDesc().TSFlags & SIInstrFlags::EXP;
485  }
486 
487  bool isEXP(uint16_t Opcode) const {
488  return get(Opcode).TSFlags & SIInstrFlags::EXP;
489  }
490 
491  static bool isWQM(const MachineInstr &MI) {
492  return MI.getDesc().TSFlags & SIInstrFlags::WQM;
493  }
494 
495  bool isWQM(uint16_t Opcode) const {
496  return get(Opcode).TSFlags & SIInstrFlags::WQM;
497  }
498 
499  static bool isDisableWQM(const MachineInstr &MI) {
501  }
502 
503  bool isDisableWQM(uint16_t Opcode) const {
504  return get(Opcode).TSFlags & SIInstrFlags::DisableWQM;
505  }
506 
507  static bool isVGPRSpill(const MachineInstr &MI) {
509  }
510 
511  bool isVGPRSpill(uint16_t Opcode) const {
512  return get(Opcode).TSFlags & SIInstrFlags::VGPRSpill;
513  }
514 
515  static bool isSGPRSpill(const MachineInstr &MI) {
517  }
518 
519  bool isSGPRSpill(uint16_t Opcode) const {
520  return get(Opcode).TSFlags & SIInstrFlags::SGPRSpill;
521  }
522 
523  static bool isDPP(const MachineInstr &MI) {
524  return MI.getDesc().TSFlags & SIInstrFlags::DPP;
525  }
526 
527  bool isDPP(uint16_t Opcode) const {
528  return get(Opcode).TSFlags & SIInstrFlags::DPP;
529  }
530 
531  static bool isVOP3P(const MachineInstr &MI) {
532  return MI.getDesc().TSFlags & SIInstrFlags::VOP3P;
533  }
534 
535  bool isVOP3P(uint16_t Opcode) const {
536  return get(Opcode).TSFlags & SIInstrFlags::VOP3P;
537  }
538 
539  static bool isVINTRP(const MachineInstr &MI) {
540  return MI.getDesc().TSFlags & SIInstrFlags::VINTRP;
541  }
542 
543  bool isVINTRP(uint16_t Opcode) const {
544  return get(Opcode).TSFlags & SIInstrFlags::VINTRP;
545  }
546 
547  static bool isScalarUnit(const MachineInstr &MI) {
549  }
550 
551  static bool usesVM_CNT(const MachineInstr &MI) {
552  return MI.getDesc().TSFlags & SIInstrFlags::VM_CNT;
553  }
554 
555  static bool usesLGKM_CNT(const MachineInstr &MI) {
556  return MI.getDesc().TSFlags & SIInstrFlags::LGKM_CNT;
557  }
558 
559  static bool sopkIsZext(const MachineInstr &MI) {
561  }
562 
563  bool sopkIsZext(uint16_t Opcode) const {
564  return get(Opcode).TSFlags & SIInstrFlags::SOPK_ZEXT;
565  }
566 
567  /// \returns true if this is an s_store_dword* instruction. This is more
568  /// specific than than isSMEM && mayStore.
569  static bool isScalarStore(const MachineInstr &MI) {
571  }
572 
573  bool isScalarStore(uint16_t Opcode) const {
574  return get(Opcode).TSFlags & SIInstrFlags::SCALAR_STORE;
575  }
576 
577  static bool isFixedSize(const MachineInstr &MI) {
579  }
580 
581  bool isFixedSize(uint16_t Opcode) const {
582  return get(Opcode).TSFlags & SIInstrFlags::FIXED_SIZE;
583  }
584 
585  static bool hasFPClamp(const MachineInstr &MI) {
586  return MI.getDesc().TSFlags & SIInstrFlags::FPClamp;
587  }
588 
589  bool hasFPClamp(uint16_t Opcode) const {
590  return get(Opcode).TSFlags & SIInstrFlags::FPClamp;
591  }
592 
593  static bool hasIntClamp(const MachineInstr &MI) {
594  return MI.getDesc().TSFlags & SIInstrFlags::IntClamp;
595  }
596 
597  uint64_t getClampMask(const MachineInstr &MI) const {
598  const uint64_t ClampFlags = SIInstrFlags::FPClamp |
602  return MI.getDesc().TSFlags & ClampFlags;
603  }
604 
605  bool isVGPRCopy(const MachineInstr &MI) const {
606  assert(MI.isCopy());
607  unsigned Dest = MI.getOperand(0).getReg();
608  const MachineFunction &MF = *MI.getParent()->getParent();
609  const MachineRegisterInfo &MRI = MF.getRegInfo();
610  return !RI.isSGPRReg(MRI, Dest);
611  }
612 
613  bool isInlineConstant(const APInt &Imm) const;
614 
615  bool isInlineConstant(const MachineOperand &MO, uint8_t OperandType) const;
616 
618  const MCOperandInfo &OpInfo) const {
619  return isInlineConstant(MO, OpInfo.OperandType);
620  }
621 
622  /// \p returns true if \p UseMO is substituted with \p DefMO in \p MI it would
623  /// be an inline immediate.
625  const MachineOperand &UseMO,
626  const MachineOperand &DefMO) const {
627  assert(UseMO.getParent() == &MI);
628  int OpIdx = MI.getOperandNo(&UseMO);
629  if (!MI.getDesc().OpInfo || OpIdx >= MI.getDesc().NumOperands) {
630  return false;
631  }
632 
633  return isInlineConstant(DefMO, MI.getDesc().OpInfo[OpIdx]);
634  }
635 
636  /// \p returns true if the operand \p OpIdx in \p MI is a valid inline
637  /// immediate.
638  bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx) const {
639  const MachineOperand &MO = MI.getOperand(OpIdx);
640  return isInlineConstant(MO, MI.getDesc().OpInfo[OpIdx].OperandType);
641  }
642 
643  bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx,
644  const MachineOperand &MO) const {
645  if (!MI.getDesc().OpInfo || OpIdx >= MI.getDesc().NumOperands)
646  return false;
647 
648  if (MI.isCopy()) {
649  unsigned Size = getOpSize(MI, OpIdx);
650  assert(Size == 8 || Size == 4);
651 
652  uint8_t OpType = (Size == 8) ?
654  return isInlineConstant(MO, OpType);
655  }
656 
657  return isInlineConstant(MO, MI.getDesc().OpInfo[OpIdx].OperandType);
658  }
659 
660  bool isInlineConstant(const MachineOperand &MO) const {
661  const MachineInstr *Parent = MO.getParent();
662  return isInlineConstant(*Parent, Parent->getOperandNo(&MO));
663  }
664 
666  const MCOperandInfo &OpInfo) const {
667  return MO.isImm() && !isInlineConstant(MO, OpInfo.OperandType);
668  }
669 
670  bool isLiteralConstant(const MachineInstr &MI, int OpIdx) const {
671  const MachineOperand &MO = MI.getOperand(OpIdx);
672  return MO.isImm() && !isInlineConstant(MI, OpIdx);
673  }
674 
675  // Returns true if this operand could potentially require a 32-bit literal
676  // operand, but not necessarily. A FrameIndex for example could resolve to an
677  // inline immediate value that will not require an additional 4-bytes; this
678  // assumes that it will.
679  bool isLiteralConstantLike(const MachineOperand &MO,
680  const MCOperandInfo &OpInfo) const;
681 
682  bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo,
683  const MachineOperand &MO) const;
684 
685  /// \brief Return true if this 64-bit VALU instruction has a 32-bit encoding.
686  /// This function will return false if you pass it a 32-bit instruction.
687  bool hasVALU32BitEncoding(unsigned Opcode) const;
688 
689  /// \brief Returns true if this operand uses the constant bus.
690  bool usesConstantBus(const MachineRegisterInfo &MRI,
691  const MachineOperand &MO,
692  const MCOperandInfo &OpInfo) const;
693 
694  /// \brief Return true if this instruction has any modifiers.
695  /// e.g. src[012]_mod, omod, clamp.
696  bool hasModifiers(unsigned Opcode) const;
697 
698  bool hasModifiersSet(const MachineInstr &MI,
699  unsigned OpName) const;
700  bool hasAnyModifiersSet(const MachineInstr &MI) const;
701 
702  bool verifyInstruction(const MachineInstr &MI,
703  StringRef &ErrInfo) const override;
704 
705  unsigned getVALUOp(const MachineInstr &MI) const;
706 
707  /// \brief Return the correct register class for \p OpNo. For target-specific
708  /// instructions, this will return the register class that has been defined
709  /// in tablegen. For generic instructions, like REG_SEQUENCE it will return
710  /// the register class of its machine operand.
711  /// to infer the correct register class base on the other operands.
713  unsigned OpNo) const;
714 
715  /// \brief Return the size in bytes of the operand OpNo on the given
716  // instruction opcode.
717  unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const {
718  const MCOperandInfo &OpInfo = get(Opcode).OpInfo[OpNo];
719 
720  if (OpInfo.RegClass == -1) {
721  // If this is an immediate operand, this must be a 32-bit literal.
723  return 4;
724  }
725 
726  return RI.getRegSizeInBits(*RI.getRegClass(OpInfo.RegClass)) / 8;
727  }
728 
729  /// \brief This form should usually be preferred since it handles operands
730  /// with unknown register classes.
731  unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const {
732  return RI.getRegSizeInBits(*getOpRegClass(MI, OpNo)) / 8;
733  }
734 
735  /// \returns true if it is legal for the operand at index \p OpNo
736  /// to read a VGPR.
737  bool canReadVGPR(const MachineInstr &MI, unsigned OpNo) const;
738 
739  /// \brief Legalize the \p OpIndex operand of this instruction by inserting
740  /// a MOV. For example:
741  /// ADD_I32_e32 VGPR0, 15
742  /// to
743  /// MOV VGPR1, 15
744  /// ADD_I32_e32 VGPR0, VGPR1
745  ///
746  /// If the operand being legalized is a register, then a COPY will be used
747  /// instead of MOV.
748  void legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const;
749 
750  /// \brief Check if \p MO is a legal operand if it was the \p OpIdx Operand
751  /// for \p MI.
752  bool isOperandLegal(const MachineInstr &MI, unsigned OpIdx,
753  const MachineOperand *MO = nullptr) const;
754 
755  /// \brief Check if \p MO would be a valid operand for the given operand
756  /// definition \p OpInfo. Note this does not attempt to validate constant bus
757  /// restrictions (e.g. literal constant usage).
758  bool isLegalVSrcOperand(const MachineRegisterInfo &MRI,
759  const MCOperandInfo &OpInfo,
760  const MachineOperand &MO) const;
761 
762  /// \brief Check if \p MO (a register operand) is a legal register for the
763  /// given operand description.
764  bool isLegalRegOperand(const MachineRegisterInfo &MRI,
765  const MCOperandInfo &OpInfo,
766  const MachineOperand &MO) const;
767 
768  /// \brief Legalize operands in \p MI by either commuting it or inserting a
769  /// copy of src1.
771 
772  /// \brief Fix operands in \p MI to satisfy constant bus requirements.
774 
775  /// Copy a value from a VGPR (\p SrcReg) to SGPR. This function can only
776  /// be used when it is know that the value in SrcReg is same across all
777  /// threads in the wave.
778  /// \returns The SGPR register that \p SrcReg was copied to.
779  unsigned readlaneVGPRToSGPR(unsigned SrcReg, MachineInstr &UseMI,
780  MachineRegisterInfo &MRI) const;
781 
783 
786  const TargetRegisterClass *DstRC,
788  const DebugLoc &DL) const;
789 
790  /// \brief Legalize all operands in this instruction. This function may
791  /// create new instruction and insert them before \p MI.
792  void legalizeOperands(MachineInstr &MI) const;
793 
794  /// \brief Replace this instruction's opcode with the equivalent VALU
795  /// opcode. This function will also move the users of \p MI to the
796  /// VALU if necessary.
797  void moveToVALU(MachineInstr &MI) const;
798 
800  int Count) const;
801 
802  void insertNoop(MachineBasicBlock &MBB,
803  MachineBasicBlock::iterator MI) const override;
804 
805  void insertReturn(MachineBasicBlock &MBB) const;
806  /// \brief Return the number of wait states that result from executing this
807  /// instruction.
808  unsigned getNumWaitStates(const MachineInstr &MI) const;
809 
810  /// \brief Returns the operand named \p Op. If \p MI does not have an
811  /// operand named \c Op, this function returns nullptr.
813  MachineOperand *getNamedOperand(MachineInstr &MI, unsigned OperandName) const;
814 
817  unsigned OpName) const {
818  return getNamedOperand(const_cast<MachineInstr &>(MI), OpName);
819  }
820 
821  /// Get required immediate operand
822  int64_t getNamedImmOperand(const MachineInstr &MI, unsigned OpName) const {
823  int Idx = AMDGPU::getNamedOperandIdx(MI.getOpcode(), OpName);
824  return MI.getOperand(Idx).getImm();
825  }
826 
827  uint64_t getDefaultRsrcDataFormat() const;
828  uint64_t getScratchRsrcWords23() const;
829 
830  bool isLowLatencyInstruction(const MachineInstr &MI) const;
831  bool isHighLatencyInstruction(const MachineInstr &MI) const;
832 
833  /// \brief Return the descriptor of the target-specific machine instruction
834  /// that corresponds to the specified pseudo or native opcode.
835  const MCInstrDesc &getMCOpcodeFromPseudo(unsigned Opcode) const {
836  return get(pseudoToMCOpcode(Opcode));
837  }
838 
839  unsigned isStackAccess(const MachineInstr &MI, int &FrameIndex) const;
840  unsigned isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex) const;
841 
842  unsigned isLoadFromStackSlot(const MachineInstr &MI,
843  int &FrameIndex) const override;
844  unsigned isStoreToStackSlot(const MachineInstr &MI,
845  int &FrameIndex) const override;
846 
847  unsigned getInstBundleSize(const MachineInstr &MI) const;
848  unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
849 
850  bool mayAccessFlatAddressSpace(const MachineInstr &MI) const;
851 
852  bool isNonUniformBranchInstr(MachineInstr &Instr) const;
853 
855  MachineBasicBlock *IfEnd) const;
856 
858  MachineBasicBlock *LoopEnd) const;
859 
860  std::pair<unsigned, unsigned>
861  decomposeMachineOperandsTargetFlags(unsigned TF) const override;
862 
864  getSerializableTargetIndices() const override;
865 
868 
871  const ScheduleDAG *DAG) const override;
872 
874  CreateTargetPostRAHazardRecognizer(const MachineFunction &MF) const override;
875 
876  bool isBasicBlockPrologue(const MachineInstr &MI) const override;
877 
878  /// \brief Return a partially built integer add instruction without carry.
879  /// Caller must add source operands.
880  /// For pre-GFX9 it will generate unused carry destination operand.
881  /// TODO: After GFX9 it should return a no-carry operation.
884  const DebugLoc &DL,
885  unsigned DestReg) const;
886 
887  static bool isKillTerminator(unsigned Opcode);
888  const MCInstrDesc &getKillTerminatorFromPseudo(unsigned Opcode) const;
889 
890  static bool isLegalMUBUFImmOffset(unsigned Imm) {
891  return isUInt<12>(Imm);
892  }
893 };
894 
895 namespace AMDGPU {
896 
898  int getVOPe64(uint16_t Opcode);
899 
901  int getVOPe32(uint16_t Opcode);
902 
904  int getSDWAOp(uint16_t Opcode);
905 
907  int getBasicFromSDWAOp(uint16_t Opcode);
908 
910  int getCommuteRev(uint16_t Opcode);
911 
913  int getCommuteOrig(uint16_t Opcode);
914 
916  int getAddr64Inst(uint16_t Opcode);
917 
919  int getAtomicRetOp(uint16_t Opcode);
920 
922  int getAtomicNoRetOp(uint16_t Opcode);
923 
925  int getSOPKOp(uint16_t Opcode);
926 
927  const uint64_t RSRC_DATA_FORMAT = 0xf00000000000LL;
928  const uint64_t RSRC_ELEMENT_SIZE_SHIFT = (32 + 19);
929  const uint64_t RSRC_INDEX_STRIDE_SHIFT = (32 + 21);
930  const uint64_t RSRC_TID_ENABLE = UINT64_C(1) << (32 + 23);
931 
932  // For MachineOperands.
933  enum TargetFlags {
936  };
937 
938 } // end namespace AMDGPU
939 
940 namespace SI {
941 namespace KernelInputOffsets {
942 
943 /// Offsets in bytes from the start of the input buffer
944 enum Offsets {
954 };
955 
956 } // end namespace KernelInputOffsets
957 } // end namespace SI
958 
959 } // end namespace llvm
960 
961 #endif // LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H
bool isFLAT(uint16_t Opcode) const
Definition: SIInstrInfo.h:479
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:515
Interface definition for SIRegisterInfo.
bool sopkIsZext(uint16_t Opcode) const
Definition: SIInstrInfo.h:563
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:605
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:569
static bool sopkIsZext(const MachineInstr &MI)
Definition: SIInstrInfo.h:559
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:163
unsigned getReg() const
getReg - Returns the register number.
static bool isVINTRP(const MachineInstr &MI)
Definition: SIInstrInfo.h:539
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
Definition: MachineInstr.h:387
unsigned insertNE(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned SrcReg, int Value) const
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:944
bool isMIMG(uint16_t Opcode) const
Definition: SIInstrInfo.h:447
int64_t getNamedImmOperand(const MachineInstr &MI, unsigned OpName) const
Get required immediate operand.
Definition: SIInstrInfo.h:822
A debug info location.
Definition: DebugLoc.h:34
bool isDPP(uint16_t Opcode) const
Definition: SIInstrInfo.h:527
bool isGather4(uint16_t Opcode) const
Definition: SIInstrInfo.h:455
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:577
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:435
bool isEXP(uint16_t Opcode) const
Definition: SIInstrInfo.h:487
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:467
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:451
static bool isMIMG(const MachineInstr &MI)
Definition: SIInstrInfo.h:443
bool isVINTRP(uint16_t Opcode) const
Definition: SIInstrInfo.h:543
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
Reg
All possible values of the reg field in the ModR/M byte.
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:293
bool isLiteralConstant(const MachineInstr &MI, int OpIdx) const
Definition: SIInstrInfo.h:670
const MCInstrDesc & getMCOpcodeFromPseudo(unsigned Opcode) const
Return the descriptor of the target-specific machine instruction that corresponds to the specified ps...
Definition: SIInstrInfo.h:835
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:717
uint8_t OperandType
Information about the type of the operand.
Definition: MCInstrDesc.h:82
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
Definition: MachineInstr.h:290
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:927
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:519
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:463
bool isBasicBlockPrologue(const MachineInstr &MI) const override
bool isInlineConstant(const MachineOperand &MO) const
Definition: SIInstrInfo.h:660
unsigned short NumOperands
Definition: MCInstrDesc.h:166
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:523
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:617
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:551
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:72
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:643
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:585
bool expandPostRAPseudo(MachineInstr &MI) const override
bool isFixedSize(uint16_t Opcode) const
Definition: SIInstrInfo.h:581
void insertReturn(MachineBasicBlock &MBB) const
bool isDS(uint16_t Opcode) const
Definition: SIInstrInfo.h:439
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:495
bool hasFPClamp(uint16_t Opcode) const
Definition: SIInstrInfo.h:589
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:860
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:531
bool isSOP2(uint16_t Opcode) const
Definition: SIInstrInfo.h:330
const uint64_t RSRC_TID_ENABLE
Definition: SIInstrInfo.h:930
static bool isWQM(const MachineInstr &MI)
Definition: SIInstrInfo.h:491
bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg, MachineRegisterInfo *MRI) const final
static bool isEXP(const MachineInstr &MI)
Definition: SIInstrInfo.h:483
bool shouldClusterMemOps(MachineInstr &FirstLdSt, unsigned BaseReg1, MachineInstr &SecondLdSt, unsigned BaseReg2, unsigned NumLoads) const final
bool isScalarStore(uint16_t Opcode) const
Definition: SIInstrInfo.h:573
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 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:597
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:929
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:503
bool hasModifiers(unsigned Opcode) const
Return true if this instruction has any modifiers.
static bool isSegmentSpecificFLAT(const MachineInstr &MI)
Definition: SIInstrInfo.h:473
static bool isVOP3(const MachineInstr &MI)
Definition: SIInstrInfo.h:374
bool isLiteralConstant(const MachineOperand &MO, const MCOperandInfo &OpInfo) const
Definition: SIInstrInfo.h:665
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:142
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:638
Representation of each machine instruction.
Definition: MachineInstr.h:60
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
static bool isMTBUF(const MachineInstr &MI)
Definition: SIInstrInfo.h:406
OperandType
Types of operands to CF instructions.
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:76
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
#define LLVM_READONLY
Definition: Compiler.h:168
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:535
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 isBufferSMRD(const MachineInstr &MI) const
Definition: SIInstrInfo.h:422
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:890
const uint64_t RSRC_ELEMENT_SIZE_SHIFT
Definition: SIInstrInfo.h:928
static bool isScalarUnit(const MachineInstr &MI)
Definition: SIInstrInfo.h:547
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:593
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:507
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:731
unsigned getMachineCSELookAheadLimit() const override
Definition: SIInstrInfo.h:284
const MCOperandInfo * OpInfo
Definition: MCInstrDesc.h:174
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:624
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:70
static bool usesLGKM_CNT(const MachineInstr &MI)
Definition: SIInstrInfo.h:555
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:298
static bool isVOP1(const MachineInstr &MI)
Definition: SIInstrInfo.h:358
void convertNonUniformIfRegion(MachineBasicBlock *IfEntry, MachineBasicBlock *IfEnd) const
static bool isDisableWQM(const MachineInstr &MI)
Definition: SIInstrInfo.h:499
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:816
bool isVGPRSpill(uint16_t Opcode) const
Definition: SIInstrInfo.h:511
static bool isD16(const MachineInstr &MI)
Definition: SIInstrInfo.h:459