LLVM 22.0.0git
SIInstrInfo.h
Go to the documentation of this file.
1//===- SIInstrInfo.h - SI Instruction Info Interface ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// Interface definition for SIInstrInfo.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H
15#define LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H
16
17#include "AMDGPUMIRFormatter.h"
19#include "SIRegisterInfo.h"
21#include "llvm/ADT/SetVector.h"
24
25#define GET_INSTRINFO_HEADER
26#include "AMDGPUGenInstrInfo.inc"
27
28namespace llvm {
29
30class APInt;
31class GCNSubtarget;
32class LiveVariables;
33class MachineDominatorTree;
34class MachineRegisterInfo;
35class RegScavenger;
36class SIMachineFunctionInfo;
37class TargetRegisterClass;
38class ScheduleHazardRecognizer;
39
40constexpr unsigned DefaultMemoryClusterDWordsLimit = 8;
41
42/// Mark the MMO of a uniform load if there are no potentially clobbering stores
43/// on any path from the start of an entry function to this load.
46
47/// Mark the MMO of a load as the last use.
50
51/// Utility to store machine instructions worklist.
53 SIInstrWorklist() = default;
54
55 void insert(MachineInstr *MI);
56
57 MachineInstr *top() const {
58 const auto *iter = InstrList.begin();
59 return *iter;
60 }
61
62 void erase_top() {
63 const auto *iter = InstrList.begin();
64 InstrList.erase(iter);
65 }
66
67 bool empty() const { return InstrList.empty(); }
68
69 void clear() {
70 InstrList.clear();
71 DeferredList.clear();
72 }
73
75
76 SetVector<MachineInstr *> &getDeferredList() { return DeferredList; }
77
78private:
79 /// InstrList contains the MachineInstrs.
81 /// Deferred instructions are specific MachineInstr
82 /// that will be added by insert method.
83 SetVector<MachineInstr *> DeferredList;
84};
85
86class SIInstrInfo final : public AMDGPUGenInstrInfo {
87private:
88 const SIRegisterInfo RI;
89 const GCNSubtarget &ST;
90 TargetSchedModel SchedModel;
91 mutable std::unique_ptr<AMDGPUMIRFormatter> Formatter;
92
93 // The inverse predicate should have the negative value.
94 enum BranchPredicate {
95 INVALID_BR = 0,
96 SCC_TRUE = 1,
97 SCC_FALSE = -1,
98 VCCNZ = 2,
99 VCCZ = -2,
100 EXECNZ = -3,
101 EXECZ = 3
102 };
103
105
106 static unsigned getBranchOpcode(BranchPredicate Cond);
107 static BranchPredicate getBranchPredicate(unsigned Opcode);
108
109public:
112 const MachineOperand &SuperReg,
113 const TargetRegisterClass *SuperRC,
114 unsigned SubIdx,
115 const TargetRegisterClass *SubRC) const;
118 const MachineOperand &SuperReg, const TargetRegisterClass *SuperRC,
119 unsigned SubIdx, const TargetRegisterClass *SubRC) const;
120
121private:
122 void swapOperands(MachineInstr &Inst) const;
123
124 std::pair<bool, MachineBasicBlock *>
125 moveScalarAddSub(SIInstrWorklist &Worklist, MachineInstr &Inst,
126 MachineDominatorTree *MDT = nullptr) const;
127
128 void lowerSelect(SIInstrWorklist &Worklist, MachineInstr &Inst,
129 MachineDominatorTree *MDT = nullptr) const;
130
131 void lowerScalarAbs(SIInstrWorklist &Worklist, MachineInstr &Inst) const;
132
133 void lowerScalarXnor(SIInstrWorklist &Worklist, MachineInstr &Inst) const;
134
135 void splitScalarNotBinop(SIInstrWorklist &Worklist, MachineInstr &Inst,
136 unsigned Opcode) const;
137
138 void splitScalarBinOpN2(SIInstrWorklist &Worklist, MachineInstr &Inst,
139 unsigned Opcode) const;
140
141 void splitScalar64BitUnaryOp(SIInstrWorklist &Worklist, MachineInstr &Inst,
142 unsigned Opcode, bool Swap = false) const;
143
144 void splitScalar64BitBinaryOp(SIInstrWorklist &Worklist, MachineInstr &Inst,
145 unsigned Opcode,
146 MachineDominatorTree *MDT = nullptr) const;
147
148 void splitScalarSMulU64(SIInstrWorklist &Worklist, MachineInstr &Inst,
149 MachineDominatorTree *MDT) const;
150
151 void splitScalarSMulPseudo(SIInstrWorklist &Worklist, MachineInstr &Inst,
152 MachineDominatorTree *MDT) const;
153
154 void splitScalar64BitXnor(SIInstrWorklist &Worklist, MachineInstr &Inst,
155 MachineDominatorTree *MDT = nullptr) const;
156
157 void splitScalar64BitBCNT(SIInstrWorklist &Worklist,
158 MachineInstr &Inst) const;
159 void splitScalar64BitBFE(SIInstrWorklist &Worklist, MachineInstr &Inst) const;
160 void splitScalar64BitCountOp(SIInstrWorklist &Worklist, MachineInstr &Inst,
161 unsigned Opcode,
162 MachineDominatorTree *MDT = nullptr) const;
163 void movePackToVALU(SIInstrWorklist &Worklist, MachineRegisterInfo &MRI,
164 MachineInstr &Inst) const;
165
166 void addUsersToMoveToVALUWorklist(Register Reg, MachineRegisterInfo &MRI,
167 SIInstrWorklist &Worklist) const;
168
169 void addSCCDefUsersToVALUWorklist(MachineOperand &Op,
170 MachineInstr &SCCDefInst,
171 SIInstrWorklist &Worklist,
172 Register NewCond = Register()) const;
173 void addSCCDefsToVALUWorklist(MachineInstr *SCCUseInst,
174 SIInstrWorklist &Worklist) const;
175
176 const TargetRegisterClass *
177 getDestEquivalentVGPRClass(const MachineInstr &Inst) const;
178
179 bool checkInstOffsetsDoNotOverlap(const MachineInstr &MIa,
180 const MachineInstr &MIb) const;
181
182 Register findUsedSGPR(const MachineInstr &MI, int OpIndices[3]) const;
183
184 bool verifyCopy(const MachineInstr &MI, const MachineRegisterInfo &MRI,
185 StringRef &ErrInfo) const;
186
187 bool resultDependsOnExec(const MachineInstr &MI) const;
188
189protected:
190 /// If the specific machine instruction is a instruction that moves/copies
191 /// value from one register to another register return destination and source
192 /// registers as machine operands.
193 std::optional<DestSourcePair>
194 isCopyInstrImpl(const MachineInstr &MI) const override;
195
197 AMDGPU::OpName Src0OpName, MachineOperand &Src1,
198 AMDGPU::OpName Src1OpName) const;
199 bool isLegalToSwap(const MachineInstr &MI, unsigned fromIdx,
200 unsigned toIdx) const;
202 unsigned OpIdx0,
203 unsigned OpIdx1) const override;
204
205public:
207 MO_MASK = 0xf,
208
210 // MO_GOTPCREL -> symbol@GOTPCREL -> R_AMDGPU_GOTPCREL.
212 // MO_GOTPCREL32_LO -> symbol@gotpcrel32@lo -> R_AMDGPU_GOTPCREL32_LO.
215 // MO_GOTPCREL32_HI -> symbol@gotpcrel32@hi -> R_AMDGPU_GOTPCREL32_HI.
217 // MO_GOTPCREL64 -> symbol@GOTPCREL -> R_AMDGPU_GOTPCREL.
219 // MO_REL32_LO -> symbol@rel32@lo -> R_AMDGPU_REL32_LO.
222 // MO_REL32_HI -> symbol@rel32@hi -> R_AMDGPU_REL32_HI.
225
227
231 };
232
233 explicit SIInstrInfo(const GCNSubtarget &ST);
234
236 return RI;
237 }
238
239 const GCNSubtarget &getSubtarget() const {
240 return ST;
241 }
242
243 bool isReallyTriviallyReMaterializable(const MachineInstr &MI) const override;
244
245 bool isIgnorableUse(const MachineOperand &MO) const override;
246
247 bool isSafeToSink(MachineInstr &MI, MachineBasicBlock *SuccToSinkTo,
248 MachineCycleInfo *CI) const override;
249
250 bool areLoadsFromSameBasePtr(SDNode *Load0, SDNode *Load1, int64_t &Offset0,
251 int64_t &Offset1) const override;
252
253 bool isGlobalMemoryObject(const MachineInstr *MI) const override;
254
256 const MachineInstr &LdSt,
258 bool &OffsetIsScalable, LocationSize &Width,
259 const TargetRegisterInfo *TRI) const final;
260
262 int64_t Offset1, bool OffsetIsScalable1,
264 int64_t Offset2, bool OffsetIsScalable2,
265 unsigned ClusterSize,
266 unsigned NumBytes) const override;
267
268 bool shouldScheduleLoadsNear(SDNode *Load0, SDNode *Load1, int64_t Offset0,
269 int64_t Offset1, unsigned NumLoads) const override;
270
272 const DebugLoc &DL, Register DestReg, Register SrcReg,
273 bool KillSrc, bool RenamableDest = false,
274 bool RenamableSrc = false) const override;
275
277 unsigned Size) const;
278
281 Register SrcReg, int Value) const;
282
285 Register SrcReg, int Value) const;
286
288 int64_t &ImmVal) const override;
289
291 const TargetRegisterClass *RC,
292 unsigned Size,
293 const SIMachineFunctionInfo &MFI) const;
294 unsigned
296 unsigned Size,
297 const SIMachineFunctionInfo &MFI) const;
298
301 bool isKill, int FrameIndex, const TargetRegisterClass *RC,
302 const TargetRegisterInfo *TRI, Register VReg,
303 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
304
307 int FrameIndex, const TargetRegisterClass *RC,
308 const TargetRegisterInfo *TRI, Register VReg,
309 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
310
311 bool expandPostRAPseudo(MachineInstr &MI) const override;
312
314 Register DestReg, unsigned SubIdx,
315 const MachineInstr &Orig,
316 const TargetRegisterInfo &TRI) const override;
317
318 // Splits a V_MOV_B64_DPP_PSEUDO opcode into a pair of v_mov_b32_dpp
319 // instructions. Returns a pair of generated instructions.
320 // Can split either post-RA with physical registers or pre-RA with
321 // virtual registers. In latter case IR needs to be in SSA form and
322 // and a REG_SEQUENCE is produced to define original register.
323 std::pair<MachineInstr*, MachineInstr*>
325
326 // Returns an opcode that can be used to move a value to a \p DstRC
327 // register. If there is no hardware instruction that can store to \p
328 // DstRC, then AMDGPU::COPY is returned.
329 unsigned getMovOpcode(const TargetRegisterClass *DstRC) const;
330
331 const MCInstrDesc &getIndirectRegWriteMovRelPseudo(unsigned VecSize,
332 unsigned EltSize,
333 bool IsSGPR) const;
334
335 const MCInstrDesc &getIndirectGPRIDXPseudo(unsigned VecSize,
336 bool IsIndirectSrc) const;
338 int commuteOpcode(unsigned Opc) const;
339
341 inline int commuteOpcode(const MachineInstr &MI) const {
342 return commuteOpcode(MI.getOpcode());
343 }
344
345 bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx0,
346 unsigned &SrcOpIdx1) const override;
347
348 bool findCommutedOpIndices(const MCInstrDesc &Desc, unsigned &SrcOpIdx0,
349 unsigned &SrcOpIdx1) const;
350
351 bool isBranchOffsetInRange(unsigned BranchOpc,
352 int64_t BrOffset) const override;
353
354 MachineBasicBlock *getBranchDestBlock(const MachineInstr &MI) const override;
355
356 /// Return whether the block terminate with divergent branch.
357 /// Note this only work before lowering the pseudo control flow instructions.
358 bool hasDivergentBranch(const MachineBasicBlock *MBB) const;
359
361 MachineBasicBlock &NewDestBB,
362 MachineBasicBlock &RestoreBB, const DebugLoc &DL,
363 int64_t BrOffset, RegScavenger *RS) const override;
364
368 MachineBasicBlock *&FBB,
370 bool AllowModify) const;
371
373 MachineBasicBlock *&FBB,
375 bool AllowModify = false) const override;
376
378 int *BytesRemoved = nullptr) const override;
379
382 const DebugLoc &DL,
383 int *BytesAdded = nullptr) const override;
384
386 SmallVectorImpl<MachineOperand> &Cond) const override;
387
390 Register TrueReg, Register FalseReg, int &CondCycles,
391 int &TrueCycles, int &FalseCycles) const override;
392
396 Register TrueReg, Register FalseReg) const override;
397
401 Register TrueReg, Register FalseReg) const;
402
403 bool analyzeCompare(const MachineInstr &MI, Register &SrcReg,
404 Register &SrcReg2, int64_t &CmpMask,
405 int64_t &CmpValue) const override;
406
407 bool optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg,
408 Register SrcReg2, int64_t CmpMask, int64_t CmpValue,
409 const MachineRegisterInfo *MRI) const override;
410
411 bool
413 const MachineInstr &MIb) const override;
414
415 static bool isFoldableCopy(const MachineInstr &MI);
416
417 void removeModOperands(MachineInstr &MI) const;
418
419 /// Return the extracted immediate value in a subregister use from a constant
420 /// materialized in a super register.
421 ///
422 /// e.g. %imm = S_MOV_B64 K[0:63]
423 /// USE %imm.sub1
424 /// This will return K[32:63]
425 static std::optional<int64_t> extractSubregFromImm(int64_t ImmVal,
426 unsigned SubRegIndex);
427
429 MachineRegisterInfo *MRI) const final;
430
431 unsigned getMachineCSELookAheadLimit() const override { return 500; }
432
434 LiveIntervals *LIS) const override;
435
437 const MachineBasicBlock *MBB,
438 const MachineFunction &MF) const override;
439
440 static bool isSALU(const MachineInstr &MI) {
441 return MI.getDesc().TSFlags & SIInstrFlags::SALU;
442 }
443
444 bool isSALU(uint16_t Opcode) const {
445 return get(Opcode).TSFlags & SIInstrFlags::SALU;
446 }
447
448 static bool isVALU(const MachineInstr &MI) {
449 return MI.getDesc().TSFlags & SIInstrFlags::VALU;
450 }
451
452 bool isVALU(uint16_t Opcode) const {
453 return get(Opcode).TSFlags & SIInstrFlags::VALU;
454 }
455
456 static bool isImage(const MachineInstr &MI) {
457 return isMIMG(MI) || isVSAMPLE(MI) || isVIMAGE(MI);
458 }
459
460 bool isImage(uint16_t Opcode) const {
461 return isMIMG(Opcode) || isVSAMPLE(Opcode) || isVIMAGE(Opcode);
462 }
463
464 static bool isVMEM(const MachineInstr &MI) {
465 return isMUBUF(MI) || isMTBUF(MI) || isImage(MI) || isFLAT(MI);
466 }
467
468 bool isVMEM(uint16_t Opcode) const {
469 return isMUBUF(Opcode) || isMTBUF(Opcode) || isImage(Opcode);
470 }
471
472 static bool isSOP1(const MachineInstr &MI) {
473 return MI.getDesc().TSFlags & SIInstrFlags::SOP1;
474 }
475
476 bool isSOP1(uint16_t Opcode) const {
477 return get(Opcode).TSFlags & SIInstrFlags::SOP1;
478 }
479
480 static bool isSOP2(const MachineInstr &MI) {
481 return MI.getDesc().TSFlags & SIInstrFlags::SOP2;
482 }
483
484 bool isSOP2(uint16_t Opcode) const {
485 return get(Opcode).TSFlags & SIInstrFlags::SOP2;
486 }
487
488 static bool isSOPC(const MachineInstr &MI) {
489 return MI.getDesc().TSFlags & SIInstrFlags::SOPC;
490 }
491
492 bool isSOPC(uint16_t Opcode) const {
493 return get(Opcode).TSFlags & SIInstrFlags::SOPC;
494 }
495
496 static bool isSOPK(const MachineInstr &MI) {
497 return MI.getDesc().TSFlags & SIInstrFlags::SOPK;
498 }
499
500 bool isSOPK(uint16_t Opcode) const {
501 return get(Opcode).TSFlags & SIInstrFlags::SOPK;
502 }
503
504 static bool isSOPP(const MachineInstr &MI) {
505 return MI.getDesc().TSFlags & SIInstrFlags::SOPP;
506 }
507
508 bool isSOPP(uint16_t Opcode) const {
509 return get(Opcode).TSFlags & SIInstrFlags::SOPP;
510 }
511
512 static bool isPacked(const MachineInstr &MI) {
513 return MI.getDesc().TSFlags & SIInstrFlags::IsPacked;
514 }
515
516 bool isPacked(uint16_t Opcode) const {
517 return get(Opcode).TSFlags & SIInstrFlags::IsPacked;
518 }
519
520 static bool isVOP1(const MachineInstr &MI) {
521 return MI.getDesc().TSFlags & SIInstrFlags::VOP1;
522 }
523
524 bool isVOP1(uint16_t Opcode) const {
525 return get(Opcode).TSFlags & SIInstrFlags::VOP1;
526 }
527
528 static bool isVOP2(const MachineInstr &MI) {
529 return MI.getDesc().TSFlags & SIInstrFlags::VOP2;
530 }
531
532 bool isVOP2(uint16_t Opcode) const {
533 return get(Opcode).TSFlags & SIInstrFlags::VOP2;
534 }
535
536 static bool isVOP3(const MachineInstr &MI) {
537 return MI.getDesc().TSFlags & SIInstrFlags::VOP3;
538 }
539
540 bool isVOP3(uint16_t Opcode) const {
541 return get(Opcode).TSFlags & SIInstrFlags::VOP3;
542 }
543
544 static bool isSDWA(const MachineInstr &MI) {
545 return MI.getDesc().TSFlags & SIInstrFlags::SDWA;
546 }
547
548 bool isSDWA(uint16_t Opcode) const {
549 return get(Opcode).TSFlags & SIInstrFlags::SDWA;
550 }
551
552 static bool isVOPC(const MachineInstr &MI) {
553 return MI.getDesc().TSFlags & SIInstrFlags::VOPC;
554 }
555
556 bool isVOPC(uint16_t Opcode) const {
557 return get(Opcode).TSFlags & SIInstrFlags::VOPC;
558 }
559
560 static bool isMUBUF(const MachineInstr &MI) {
561 return MI.getDesc().TSFlags & SIInstrFlags::MUBUF;
562 }
563
564 bool isMUBUF(uint16_t Opcode) const {
565 return get(Opcode).TSFlags & SIInstrFlags::MUBUF;
566 }
567
568 static bool isMTBUF(const MachineInstr &MI) {
569 return MI.getDesc().TSFlags & SIInstrFlags::MTBUF;
570 }
571
572 bool isMTBUF(uint16_t Opcode) const {
573 return get(Opcode).TSFlags & SIInstrFlags::MTBUF;
574 }
575
576 static bool isSMRD(const MachineInstr &MI) {
577 return MI.getDesc().TSFlags & SIInstrFlags::SMRD;
578 }
579
580 bool isSMRD(uint16_t Opcode) const {
581 return get(Opcode).TSFlags & SIInstrFlags::SMRD;
582 }
583
584 bool isBufferSMRD(const MachineInstr &MI) const;
585
586 static bool isDS(const MachineInstr &MI) {
587 return MI.getDesc().TSFlags & SIInstrFlags::DS;
588 }
589
590 bool isDS(uint16_t Opcode) const {
591 return get(Opcode).TSFlags & SIInstrFlags::DS;
592 }
593
594 static bool isLDSDMA(const MachineInstr &MI) {
595 return isVALU(MI) && (isMUBUF(MI) || isFLAT(MI));
596 }
597
598 bool isLDSDMA(uint16_t Opcode) {
599 return isVALU(Opcode) && (isMUBUF(Opcode) || isFLAT(Opcode));
600 }
601
602 static bool isGWS(const MachineInstr &MI) {
603 return MI.getDesc().TSFlags & SIInstrFlags::GWS;
604 }
605
606 bool isGWS(uint16_t Opcode) const {
607 return get(Opcode).TSFlags & SIInstrFlags::GWS;
608 }
609
610 bool isAlwaysGDS(uint16_t Opcode) const;
611
612 static bool isMIMG(const MachineInstr &MI) {
613 return MI.getDesc().TSFlags & SIInstrFlags::MIMG;
614 }
615
616 bool isMIMG(uint16_t Opcode) const {
617 return get(Opcode).TSFlags & SIInstrFlags::MIMG;
618 }
619
620 static bool isVIMAGE(const MachineInstr &MI) {
621 return MI.getDesc().TSFlags & SIInstrFlags::VIMAGE;
622 }
623
624 bool isVIMAGE(uint16_t Opcode) const {
625 return get(Opcode).TSFlags & SIInstrFlags::VIMAGE;
626 }
627
628 static bool isVSAMPLE(const MachineInstr &MI) {
629 return MI.getDesc().TSFlags & SIInstrFlags::VSAMPLE;
630 }
631
632 bool isVSAMPLE(uint16_t Opcode) const {
633 return get(Opcode).TSFlags & SIInstrFlags::VSAMPLE;
634 }
635
636 static bool isGather4(const MachineInstr &MI) {
637 return MI.getDesc().TSFlags & SIInstrFlags::Gather4;
638 }
639
640 bool isGather4(uint16_t Opcode) const {
641 return get(Opcode).TSFlags & SIInstrFlags::Gather4;
642 }
643
644 static bool isFLAT(const MachineInstr &MI) {
645 return MI.getDesc().TSFlags & SIInstrFlags::FLAT;
646 }
647
648 // Is a FLAT encoded instruction which accesses a specific segment,
649 // i.e. global_* or scratch_*.
651 auto Flags = MI.getDesc().TSFlags;
653 }
654
655 bool isSegmentSpecificFLAT(uint16_t Opcode) const {
656 auto Flags = get(Opcode).TSFlags;
658 }
659
660 static bool isFLATGlobal(const MachineInstr &MI) {
661 return MI.getDesc().TSFlags & SIInstrFlags::FlatGlobal;
662 }
663
664 bool isFLATGlobal(uint16_t Opcode) const {
665 return get(Opcode).TSFlags & SIInstrFlags::FlatGlobal;
666 }
667
668 static bool isFLATScratch(const MachineInstr &MI) {
669 return MI.getDesc().TSFlags & SIInstrFlags::FlatScratch;
670 }
671
672 bool isFLATScratch(uint16_t Opcode) const {
673 return get(Opcode).TSFlags & SIInstrFlags::FlatScratch;
674 }
675
676 // Any FLAT encoded instruction, including global_* and scratch_*.
677 bool isFLAT(uint16_t Opcode) const {
678 return get(Opcode).TSFlags & SIInstrFlags::FLAT;
679 }
680
681 /// \returns true for SCRATCH_ instructions, or FLAT_ instructions with
682 /// SCRATCH_ memory operands.
683 /// Conservatively correct; will return true if \p MI cannot be proven
684 /// to not hit scratch.
686
687 static bool isBlockLoadStore(uint16_t Opcode) {
688 switch (Opcode) {
689 case AMDGPU::SI_BLOCK_SPILL_V1024_SAVE:
690 case AMDGPU::SI_BLOCK_SPILL_V1024_RESTORE:
691 case AMDGPU::SCRATCH_STORE_BLOCK_SADDR:
692 case AMDGPU::SCRATCH_LOAD_BLOCK_SADDR:
693 case AMDGPU::SCRATCH_STORE_BLOCK_SVS:
694 case AMDGPU::SCRATCH_LOAD_BLOCK_SVS:
695 return true;
696 default:
697 return false;
698 }
699 }
700
701 static bool isEXP(const MachineInstr &MI) {
702 return MI.getDesc().TSFlags & SIInstrFlags::EXP;
703 }
704
706 if (!isEXP(MI))
707 return false;
708 unsigned Target = MI.getOperand(0).getImm();
711 }
712
713 bool isEXP(uint16_t Opcode) const {
714 return get(Opcode).TSFlags & SIInstrFlags::EXP;
715 }
716
717 static bool isAtomicNoRet(const MachineInstr &MI) {
718 return MI.getDesc().TSFlags & SIInstrFlags::IsAtomicNoRet;
719 }
720
721 bool isAtomicNoRet(uint16_t Opcode) const {
722 return get(Opcode).TSFlags & SIInstrFlags::IsAtomicNoRet;
723 }
724
725 static bool isAtomicRet(const MachineInstr &MI) {
726 return MI.getDesc().TSFlags & SIInstrFlags::IsAtomicRet;
727 }
728
729 bool isAtomicRet(uint16_t Opcode) const {
730 return get(Opcode).TSFlags & SIInstrFlags::IsAtomicRet;
731 }
732
733 static bool isAtomic(const MachineInstr &MI) {
734 return MI.getDesc().TSFlags & (SIInstrFlags::IsAtomicRet |
736 }
737
738 bool isAtomic(uint16_t Opcode) const {
739 return get(Opcode).TSFlags & (SIInstrFlags::IsAtomicRet |
741 }
742
744 return isLDSDMA(MI) && MI.getOpcode() != AMDGPU::BUFFER_STORE_LDS_DWORD;
745 }
746
747 static bool isWQM(const MachineInstr &MI) {
748 return MI.getDesc().TSFlags & SIInstrFlags::WQM;
749 }
750
751 bool isWQM(uint16_t Opcode) const {
752 return get(Opcode).TSFlags & SIInstrFlags::WQM;
753 }
754
755 static bool isDisableWQM(const MachineInstr &MI) {
756 return MI.getDesc().TSFlags & SIInstrFlags::DisableWQM;
757 }
758
759 bool isDisableWQM(uint16_t Opcode) const {
760 return get(Opcode).TSFlags & SIInstrFlags::DisableWQM;
761 }
762
763 // SI_SPILL_S32_TO_VGPR and SI_RESTORE_S32_FROM_VGPR form a special case of
764 // SGPRs spilling to VGPRs which are SGPR spills but from VALU instructions
765 // therefore we need an explicit check for them since just checking if the
766 // Spill bit is set and what instruction type it came from misclassifies
767 // them.
768 static bool isVGPRSpill(const MachineInstr &MI) {
769 return MI.getOpcode() != AMDGPU::SI_SPILL_S32_TO_VGPR &&
770 MI.getOpcode() != AMDGPU::SI_RESTORE_S32_FROM_VGPR &&
771 (isSpill(MI) && isVALU(MI));
772 }
773
774 bool isVGPRSpill(uint16_t Opcode) const {
775 return Opcode != AMDGPU::SI_SPILL_S32_TO_VGPR &&
776 Opcode != AMDGPU::SI_RESTORE_S32_FROM_VGPR &&
777 (isSpill(Opcode) && isVALU(Opcode));
778 }
779
780 static bool isSGPRSpill(const MachineInstr &MI) {
781 return MI.getOpcode() == AMDGPU::SI_SPILL_S32_TO_VGPR ||
782 MI.getOpcode() == AMDGPU::SI_RESTORE_S32_FROM_VGPR ||
783 (isSpill(MI) && isSALU(MI));
784 }
785
786 bool isSGPRSpill(uint16_t Opcode) const {
787 return Opcode == AMDGPU::SI_SPILL_S32_TO_VGPR ||
788 Opcode == AMDGPU::SI_RESTORE_S32_FROM_VGPR ||
789 (isSpill(Opcode) && isSALU(Opcode));
790 }
791
792 bool isSpill(uint16_t Opcode) const {
793 return get(Opcode).TSFlags & SIInstrFlags::Spill;
794 }
795
796 static bool isSpill(const MachineInstr &MI) {
797 return MI.getDesc().TSFlags & SIInstrFlags::Spill;
798 }
799
800 static bool isWWMRegSpillOpcode(uint16_t Opcode) {
801 return Opcode == AMDGPU::SI_SPILL_WWM_V32_SAVE ||
802 Opcode == AMDGPU::SI_SPILL_WWM_AV32_SAVE ||
803 Opcode == AMDGPU::SI_SPILL_WWM_V32_RESTORE ||
804 Opcode == AMDGPU::SI_SPILL_WWM_AV32_RESTORE;
805 }
806
807 static bool isChainCallOpcode(uint64_t Opcode) {
808 return Opcode == AMDGPU::SI_CS_CHAIN_TC_W32 ||
809 Opcode == AMDGPU::SI_CS_CHAIN_TC_W64;
810 }
811
812 static bool isDPP(const MachineInstr &MI) {
813 return MI.getDesc().TSFlags & SIInstrFlags::DPP;
814 }
815
816 bool isDPP(uint16_t Opcode) const {
817 return get(Opcode).TSFlags & SIInstrFlags::DPP;
818 }
819
820 static bool isTRANS(const MachineInstr &MI) {
821 return MI.getDesc().TSFlags & SIInstrFlags::TRANS;
822 }
823
824 bool isTRANS(uint16_t Opcode) const {
825 return get(Opcode).TSFlags & SIInstrFlags::TRANS;
826 }
827
828 static bool isVOP3P(const MachineInstr &MI) {
829 return MI.getDesc().TSFlags & SIInstrFlags::VOP3P;
830 }
831
832 bool isVOP3P(uint16_t Opcode) const {
833 return get(Opcode).TSFlags & SIInstrFlags::VOP3P;
834 }
835
836 static bool isVINTRP(const MachineInstr &MI) {
837 return MI.getDesc().TSFlags & SIInstrFlags::VINTRP;
838 }
839
840 bool isVINTRP(uint16_t Opcode) const {
841 return get(Opcode).TSFlags & SIInstrFlags::VINTRP;
842 }
843
844 static bool isMAI(const MachineInstr &MI) {
845 return MI.getDesc().TSFlags & SIInstrFlags::IsMAI;
846 }
847
848 bool isMAI(uint16_t Opcode) const {
849 return get(Opcode).TSFlags & SIInstrFlags::IsMAI;
850 }
851
852 static bool isMFMA(const MachineInstr &MI) {
853 return isMAI(MI) && MI.getOpcode() != AMDGPU::V_ACCVGPR_WRITE_B32_e64 &&
854 MI.getOpcode() != AMDGPU::V_ACCVGPR_READ_B32_e64;
855 }
856
857 static bool isDOT(const MachineInstr &MI) {
858 return MI.getDesc().TSFlags & SIInstrFlags::IsDOT;
859 }
860
861 static bool isWMMA(const MachineInstr &MI) {
862 return MI.getDesc().TSFlags & SIInstrFlags::IsWMMA;
863 }
864
865 bool isWMMA(uint16_t Opcode) const {
866 return get(Opcode).TSFlags & SIInstrFlags::IsWMMA;
867 }
868
869 static bool isMFMAorWMMA(const MachineInstr &MI) {
870 return isMFMA(MI) || isWMMA(MI) || isSWMMAC(MI);
871 }
872
873 static bool isSWMMAC(const MachineInstr &MI) {
874 return MI.getDesc().TSFlags & SIInstrFlags::IsSWMMAC;
875 }
876
877 bool isSWMMAC(uint16_t Opcode) const {
878 return get(Opcode).TSFlags & SIInstrFlags::IsSWMMAC;
879 }
880
881 bool isDOT(uint16_t Opcode) const {
882 return get(Opcode).TSFlags & SIInstrFlags::IsDOT;
883 }
884
885 bool isXDLWMMA(const MachineInstr &MI) const;
886
887 bool isXDL(const MachineInstr &MI) const;
888
889 static bool isDGEMM(unsigned Opcode) { return AMDGPU::getMAIIsDGEMM(Opcode); }
890
891 static bool isLDSDIR(const MachineInstr &MI) {
892 return MI.getDesc().TSFlags & SIInstrFlags::LDSDIR;
893 }
894
895 bool isLDSDIR(uint16_t Opcode) const {
896 return get(Opcode).TSFlags & SIInstrFlags::LDSDIR;
897 }
898
899 static bool isVINTERP(const MachineInstr &MI) {
900 return MI.getDesc().TSFlags & SIInstrFlags::VINTERP;
901 }
902
903 bool isVINTERP(uint16_t Opcode) const {
904 return get(Opcode).TSFlags & SIInstrFlags::VINTERP;
905 }
906
907 static bool isScalarUnit(const MachineInstr &MI) {
908 return MI.getDesc().TSFlags & (SIInstrFlags::SALU | SIInstrFlags::SMRD);
909 }
910
911 static bool usesVM_CNT(const MachineInstr &MI) {
912 return MI.getDesc().TSFlags & SIInstrFlags::VM_CNT;
913 }
914
915 static bool usesLGKM_CNT(const MachineInstr &MI) {
916 return MI.getDesc().TSFlags & SIInstrFlags::LGKM_CNT;
917 }
918
919 // Most sopk treat the immediate as a signed 16-bit, however some
920 // use it as unsigned.
921 static bool sopkIsZext(unsigned Opcode) {
922 return Opcode == AMDGPU::S_CMPK_EQ_U32 || Opcode == AMDGPU::S_CMPK_LG_U32 ||
923 Opcode == AMDGPU::S_CMPK_GT_U32 || Opcode == AMDGPU::S_CMPK_GE_U32 ||
924 Opcode == AMDGPU::S_CMPK_LT_U32 || Opcode == AMDGPU::S_CMPK_LE_U32 ||
925 Opcode == AMDGPU::S_GETREG_B32;
926 }
927
928 /// \returns true if this is an s_store_dword* instruction. This is more
929 /// specific than isSMEM && mayStore.
930 static bool isScalarStore(const MachineInstr &MI) {
931 return MI.getDesc().TSFlags & SIInstrFlags::SCALAR_STORE;
932 }
933
934 bool isScalarStore(uint16_t Opcode) const {
935 return get(Opcode).TSFlags & SIInstrFlags::SCALAR_STORE;
936 }
937
938 static bool isFixedSize(const MachineInstr &MI) {
939 return MI.getDesc().TSFlags & SIInstrFlags::FIXED_SIZE;
940 }
941
942 bool isFixedSize(uint16_t Opcode) const {
943 return get(Opcode).TSFlags & SIInstrFlags::FIXED_SIZE;
944 }
945
946 static bool hasFPClamp(const MachineInstr &MI) {
947 return MI.getDesc().TSFlags & SIInstrFlags::FPClamp;
948 }
949
950 bool hasFPClamp(uint16_t Opcode) const {
951 return get(Opcode).TSFlags & SIInstrFlags::FPClamp;
952 }
953
954 static bool hasIntClamp(const MachineInstr &MI) {
955 return MI.getDesc().TSFlags & SIInstrFlags::IntClamp;
956 }
957
959 const uint64_t ClampFlags = SIInstrFlags::FPClamp |
963 return MI.getDesc().TSFlags & ClampFlags;
964 }
965
966 static bool usesFPDPRounding(const MachineInstr &MI) {
967 return MI.getDesc().TSFlags & SIInstrFlags::FPDPRounding;
968 }
969
970 bool usesFPDPRounding(uint16_t Opcode) const {
971 return get(Opcode).TSFlags & SIInstrFlags::FPDPRounding;
972 }
973
974 static bool isFPAtomic(const MachineInstr &MI) {
975 return MI.getDesc().TSFlags & SIInstrFlags::FPAtomic;
976 }
977
978 bool isFPAtomic(uint16_t Opcode) const {
979 return get(Opcode).TSFlags & SIInstrFlags::FPAtomic;
980 }
981
982 static bool isNeverUniform(const MachineInstr &MI) {
983 return MI.getDesc().TSFlags & SIInstrFlags::IsNeverUniform;
984 }
985
986 bool isBarrier(unsigned Opcode) const {
987 return Opcode == AMDGPU::S_BARRIER ||
988 Opcode == AMDGPU::S_BARRIER_SIGNAL_M0 ||
989 Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_M0 ||
990 Opcode == AMDGPU::S_BARRIER_SIGNAL_IMM ||
991 Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_IMM ||
992 Opcode == AMDGPU::S_BARRIER_WAIT ||
993 Opcode == AMDGPU::S_BARRIER_INIT_M0 ||
994 Opcode == AMDGPU::S_BARRIER_INIT_IMM ||
995 Opcode == AMDGPU::S_BARRIER_JOIN_IMM ||
996 Opcode == AMDGPU::S_BARRIER_LEAVE ||
997 Opcode == AMDGPU::S_BARRIER_LEAVE_IMM ||
998 Opcode == AMDGPU::DS_GWS_INIT || Opcode == AMDGPU::DS_GWS_BARRIER;
999 }
1000
1001 static bool isF16PseudoScalarTrans(unsigned Opcode) {
1002 return Opcode == AMDGPU::V_S_EXP_F16_e64 ||
1003 Opcode == AMDGPU::V_S_LOG_F16_e64 ||
1004 Opcode == AMDGPU::V_S_RCP_F16_e64 ||
1005 Opcode == AMDGPU::V_S_RSQ_F16_e64 ||
1006 Opcode == AMDGPU::V_S_SQRT_F16_e64;
1007 }
1008
1010 return MI.getDesc().TSFlags & SIInstrFlags::TiedSourceNotRead;
1011 }
1012
1013 bool doesNotReadTiedSource(uint16_t Opcode) const {
1014 return get(Opcode).TSFlags & SIInstrFlags::TiedSourceNotRead;
1015 }
1016
1017 bool isIGLP(unsigned Opcode) const {
1018 return Opcode == AMDGPU::SCHED_BARRIER ||
1019 Opcode == AMDGPU::SCHED_GROUP_BARRIER || Opcode == AMDGPU::IGLP_OPT;
1020 }
1021
1022 bool isIGLP(const MachineInstr &MI) const { return isIGLP(MI.getOpcode()); }
1023
1024 // Return true if the instruction is mutually exclusive with all non-IGLP DAG
1025 // mutations, requiring all other mutations to be disabled.
1026 bool isIGLPMutationOnly(unsigned Opcode) const {
1027 return Opcode == AMDGPU::SCHED_GROUP_BARRIER || Opcode == AMDGPU::IGLP_OPT;
1028 }
1029
1030 static unsigned getNonSoftWaitcntOpcode(unsigned Opcode) {
1031 switch (Opcode) {
1032 case AMDGPU::S_WAITCNT_soft:
1033 return AMDGPU::S_WAITCNT;
1034 case AMDGPU::S_WAITCNT_VSCNT_soft:
1035 return AMDGPU::S_WAITCNT_VSCNT;
1036 case AMDGPU::S_WAIT_LOADCNT_soft:
1037 return AMDGPU::S_WAIT_LOADCNT;
1038 case AMDGPU::S_WAIT_STORECNT_soft:
1039 return AMDGPU::S_WAIT_STORECNT;
1040 case AMDGPU::S_WAIT_SAMPLECNT_soft:
1041 return AMDGPU::S_WAIT_SAMPLECNT;
1042 case AMDGPU::S_WAIT_BVHCNT_soft:
1043 return AMDGPU::S_WAIT_BVHCNT;
1044 case AMDGPU::S_WAIT_DSCNT_soft:
1045 return AMDGPU::S_WAIT_DSCNT;
1046 case AMDGPU::S_WAIT_KMCNT_soft:
1047 return AMDGPU::S_WAIT_KMCNT;
1048 default:
1049 return Opcode;
1050 }
1051 }
1052
1053 static bool isWaitcnt(unsigned Opcode) {
1054 switch (getNonSoftWaitcntOpcode(Opcode)) {
1055 case AMDGPU::S_WAITCNT:
1056 case AMDGPU::S_WAITCNT_VSCNT:
1057 case AMDGPU::S_WAITCNT_VMCNT:
1058 case AMDGPU::S_WAITCNT_EXPCNT:
1059 case AMDGPU::S_WAITCNT_LGKMCNT:
1060 case AMDGPU::S_WAIT_LOADCNT:
1061 case AMDGPU::S_WAIT_LOADCNT_DSCNT:
1062 case AMDGPU::S_WAIT_STORECNT:
1063 case AMDGPU::S_WAIT_STORECNT_DSCNT:
1064 case AMDGPU::S_WAIT_SAMPLECNT:
1065 case AMDGPU::S_WAIT_BVHCNT:
1066 case AMDGPU::S_WAIT_EXPCNT:
1067 case AMDGPU::S_WAIT_DSCNT:
1068 case AMDGPU::S_WAIT_KMCNT:
1069 case AMDGPU::S_WAIT_IDLE:
1070 return true;
1071 default:
1072 return false;
1073 }
1074 }
1075
1076 bool isVGPRCopy(const MachineInstr &MI) const {
1077 assert(isCopyInstr(MI));
1078 Register Dest = MI.getOperand(0).getReg();
1079 const MachineFunction &MF = *MI.getParent()->getParent();
1080 const MachineRegisterInfo &MRI = MF.getRegInfo();
1081 return !RI.isSGPRReg(MRI, Dest);
1082 }
1083
1084 bool hasVGPRUses(const MachineInstr &MI) const {
1085 const MachineFunction &MF = *MI.getParent()->getParent();
1086 const MachineRegisterInfo &MRI = MF.getRegInfo();
1087 return llvm::any_of(MI.explicit_uses(),
1088 [&MRI, this](const MachineOperand &MO) {
1089 return MO.isReg() && RI.isVGPR(MRI, MO.getReg());});
1090 }
1091
1092 /// Return true if the instruction modifies the mode register.q
1093 static bool modifiesModeRegister(const MachineInstr &MI);
1094
1095 /// This function is used to determine if an instruction can be safely
1096 /// executed under EXEC = 0 without hardware error, indeterminate results,
1097 /// and/or visible effects on future vector execution or outside the shader.
1098 /// Note: as of 2024 the only use of this is SIPreEmitPeephole where it is
1099 /// used in removing branches over short EXEC = 0 sequences.
1100 /// As such it embeds certain assumptions which may not apply to every case
1101 /// of EXEC = 0 execution.
1103
1104 /// Returns true if the instruction could potentially depend on the value of
1105 /// exec. If false, exec dependencies may safely be ignored.
1106 bool mayReadEXEC(const MachineRegisterInfo &MRI, const MachineInstr &MI) const;
1107
1108 bool isInlineConstant(const APInt &Imm) const;
1109
1110 bool isInlineConstant(const APFloat &Imm) const;
1111
1112 // Returns true if this non-register operand definitely does not need to be
1113 // encoded as a 32-bit literal. Note that this function handles all kinds of
1114 // operands, not just immediates.
1115 //
1116 // Some operands like FrameIndexes could resolve to an inline immediate value
1117 // that will not require an additional 4-bytes; this function assumes that it
1118 // will.
1119 bool isInlineConstant(const MachineOperand &MO, uint8_t OperandType) const {
1120 if (!MO.isImm())
1121 return false;
1122 return isInlineConstant(MO.getImm(), OperandType);
1123 }
1124 bool isInlineConstant(int64_t ImmVal, uint8_t OperandType) const;
1125
1127 const MCOperandInfo &OpInfo) const {
1128 return isInlineConstant(MO, OpInfo.OperandType);
1129 }
1130
1131 /// \p returns true if \p UseMO is substituted with \p DefMO in \p MI it would
1132 /// be an inline immediate.
1134 const MachineOperand &UseMO,
1135 const MachineOperand &DefMO) const {
1136 assert(UseMO.getParent() == &MI);
1137 int OpIdx = UseMO.getOperandNo();
1138 if (OpIdx >= MI.getDesc().NumOperands)
1139 return false;
1140
1141 return isInlineConstant(DefMO, MI.getDesc().operands()[OpIdx]);
1142 }
1143
1144 /// \p returns true if the operand \p OpIdx in \p MI is a valid inline
1145 /// immediate.
1146 bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx) const {
1147 const MachineOperand &MO = MI.getOperand(OpIdx);
1148 return isInlineConstant(MO, MI.getDesc().operands()[OpIdx].OperandType);
1149 }
1150
1151 bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx,
1152 int64_t ImmVal) const {
1153 if (OpIdx >= MI.getDesc().NumOperands)
1154 return false;
1155
1156 if (isCopyInstr(MI)) {
1157 unsigned Size = getOpSize(MI, OpIdx);
1158 assert(Size == 8 || Size == 4);
1159
1160 uint8_t OpType = (Size == 8) ?
1162 return isInlineConstant(ImmVal, OpType);
1163 }
1164
1165 return isInlineConstant(ImmVal, MI.getDesc().operands()[OpIdx].OperandType);
1166 }
1167
1168 bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx,
1169 const MachineOperand &MO) const {
1170 return isInlineConstant(MI, OpIdx, MO.getImm());
1171 }
1172
1173 bool isInlineConstant(const MachineOperand &MO) const {
1174 return isInlineConstant(*MO.getParent(), MO.getOperandNo());
1175 }
1176
1177 bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo,
1178 const MachineOperand &MO) const;
1179
1180 /// Check if this immediate value can be used for AV_MOV_B64_IMM_PSEUDO.
1181 bool isLegalAV64PseudoImm(uint64_t Imm) const;
1182
1183 /// Return true if this 64-bit VALU instruction has a 32-bit encoding.
1184 /// This function will return false if you pass it a 32-bit instruction.
1185 bool hasVALU32BitEncoding(unsigned Opcode) const;
1186
1187 /// Returns true if this operand uses the constant bus.
1189 const MachineOperand &MO,
1190 const MCOperandInfo &OpInfo) const;
1191
1193 int OpIdx) const {
1194 return usesConstantBus(MRI, MI.getOperand(OpIdx),
1195 MI.getDesc().operands()[OpIdx]);
1196 }
1197
1198 /// Return true if this instruction has any modifiers.
1199 /// e.g. src[012]_mod, omod, clamp.
1200 bool hasModifiers(unsigned Opcode) const;
1201
1202 bool hasModifiersSet(const MachineInstr &MI, AMDGPU::OpName OpName) const;
1203 bool hasAnyModifiersSet(const MachineInstr &MI) const;
1204
1205 bool canShrink(const MachineInstr &MI,
1206 const MachineRegisterInfo &MRI) const;
1207
1209 unsigned NewOpcode) const;
1210
1211 bool verifyInstruction(const MachineInstr &MI,
1212 StringRef &ErrInfo) const override;
1213
1214 unsigned getVALUOp(const MachineInstr &MI) const;
1215
1218 const DebugLoc &DL, Register Reg, bool IsSCCLive,
1219 SlotIndexes *Indexes = nullptr) const;
1220
1223 Register Reg, SlotIndexes *Indexes = nullptr) const;
1224
1226
1227 /// Return the correct register class for \p OpNo. For target-specific
1228 /// instructions, this will return the register class that has been defined
1229 /// in tablegen. For generic instructions, like REG_SEQUENCE it will return
1230 /// the register class of its machine operand.
1231 /// to infer the correct register class base on the other operands.
1233 unsigned OpNo) const;
1234
1235 /// Return the size in bytes of the operand OpNo on the given
1236 // instruction opcode.
1237 unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const {
1238 const MCOperandInfo &OpInfo = get(Opcode).operands()[OpNo];
1239
1240 if (OpInfo.RegClass == -1) {
1241 // If this is an immediate operand, this must be a 32-bit literal.
1243 return 4;
1244 }
1245
1246 return RI.getRegSizeInBits(*RI.getRegClass(OpInfo.RegClass)) / 8;
1247 }
1248
1249 /// This form should usually be preferred since it handles operands
1250 /// with unknown register classes.
1251 unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const {
1252 const MachineOperand &MO = MI.getOperand(OpNo);
1253 if (MO.isReg()) {
1254 if (unsigned SubReg = MO.getSubReg()) {
1255 return RI.getSubRegIdxSize(SubReg) / 8;
1256 }
1257 }
1258 return RI.getRegSizeInBits(*getOpRegClass(MI, OpNo)) / 8;
1259 }
1260
1261 /// Legalize the \p OpIndex operand of this instruction by inserting
1262 /// a MOV. For example:
1263 /// ADD_I32_e32 VGPR0, 15
1264 /// to
1265 /// MOV VGPR1, 15
1266 /// ADD_I32_e32 VGPR0, VGPR1
1267 ///
1268 /// If the operand being legalized is a register, then a COPY will be used
1269 /// instead of MOV.
1270 void legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const;
1271
1272 /// Check if \p MO is a legal operand if it was the \p OpIdx Operand
1273 /// for \p MI.
1274 bool isOperandLegal(const MachineInstr &MI, unsigned OpIdx,
1275 const MachineOperand *MO = nullptr) const;
1276
1277 /// Check if \p MO would be a valid operand for the given operand
1278 /// definition \p OpInfo. Note this does not attempt to validate constant bus
1279 /// restrictions (e.g. literal constant usage).
1281 const MCOperandInfo &OpInfo,
1282 const MachineOperand &MO) const;
1283
1284 /// Check if \p MO (a register operand) is a legal register for the
1285 /// given operand description or operand index.
1286 /// The operand index version provide more legality checks
1288 const MCOperandInfo &OpInfo,
1289 const MachineOperand &MO) const;
1290 bool isLegalRegOperand(const MachineInstr &MI, unsigned OpIdx,
1291 const MachineOperand &MO) const;
1292
1293 /// Check if \p MO would be a legal operand for gfx12+ packed math FP32
1294 /// instructions. Packed math FP32 instructions typically accept SGPRs or
1295 /// VGPRs as source operands. On gfx12+, if a source operand uses SGPRs, the
1296 /// HW can only read the first SGPR and use it for both the low and high
1297 /// operations.
1298 /// \p SrcN can be 0, 1, or 2, representing src0, src1, and src2,
1299 /// respectively. If \p MO is nullptr, the operand corresponding to SrcN will
1300 /// be used.
1302 const MachineRegisterInfo &MRI, const MachineInstr &MI, unsigned SrcN,
1303 const MachineOperand *MO = nullptr) const;
1304
1305 /// Legalize operands in \p MI by either commuting it or inserting a
1306 /// copy of src1.
1308
1309 /// Fix operands in \p MI to satisfy constant bus requirements.
1311
1312 /// Copy a value from a VGPR (\p SrcReg) to SGPR. The desired register class
1313 /// for the dst register (\p DstRC) can be optionally supplied. This function
1314 /// can only be used when it is know that the value in SrcReg is same across
1315 /// all threads in the wave.
1316 /// \returns The SGPR register that \p SrcReg was copied to.
1319 const TargetRegisterClass *DstRC = nullptr) const;
1320
1323
1326 const TargetRegisterClass *DstRC,
1328 const DebugLoc &DL) const;
1329
1330 /// Legalize all operands in this instruction. This function may create new
1331 /// instructions and control-flow around \p MI. If present, \p MDT is
1332 /// updated.
1333 /// \returns A new basic block that contains \p MI if new blocks were created.
1335 legalizeOperands(MachineInstr &MI, MachineDominatorTree *MDT = nullptr) const;
1336
1337 /// Change SADDR form of a FLAT \p Inst to its VADDR form if saddr operand
1338 /// was moved to VGPR. \returns true if succeeded.
1339 bool moveFlatAddrToVGPR(MachineInstr &Inst) const;
1340
1341 /// Fix operands in Inst to fix 16bit SALU to VALU lowering.
1343 MachineRegisterInfo &MRI) const;
1344 void legalizeOperandsVALUt16(MachineInstr &Inst, unsigned OpIdx,
1345 MachineRegisterInfo &MRI) const;
1346
1347 /// Replace the instructions opcode with the equivalent VALU
1348 /// opcode. This function will also move the users of MachineInstruntions
1349 /// in the \p WorkList to the VALU if necessary. If present, \p MDT is
1350 /// updated.
1351 void moveToVALU(SIInstrWorklist &Worklist, MachineDominatorTree *MDT) const;
1352
1354 MachineInstr &Inst) const;
1355
1357 MachineBasicBlock::iterator MI) const override;
1358
1360 unsigned Quantity) const override;
1361
1362 void insertReturn(MachineBasicBlock &MBB) const;
1363
1364 /// Build instructions that simulate the behavior of a `s_trap 2` instructions
1365 /// for hardware (namely, gfx11) that runs in PRIV=1 mode. There, s_trap is
1366 /// interpreted as a nop.
1370 const DebugLoc &DL) const;
1371
1372 /// Return the number of wait states that result from executing this
1373 /// instruction.
1374 static unsigned getNumWaitStates(const MachineInstr &MI);
1375
1376 /// Returns the operand named \p Op. If \p MI does not have an
1377 /// operand named \c Op, this function returns nullptr.
1380 AMDGPU::OpName OperandName) const;
1381
1384 AMDGPU::OpName OperandName) const {
1385 return getNamedOperand(const_cast<MachineInstr &>(MI), OperandName);
1386 }
1387
1388 /// Get required immediate operand
1390 AMDGPU::OpName OperandName) const {
1391 int Idx = AMDGPU::getNamedOperandIdx(MI.getOpcode(), OperandName);
1392 return MI.getOperand(Idx).getImm();
1393 }
1394
1397
1398 bool isLowLatencyInstruction(const MachineInstr &MI) const;
1399 bool isHighLatencyDef(int Opc) const override;
1400
1401 /// Return the descriptor of the target-specific machine instruction
1402 /// that corresponds to the specified pseudo or native opcode.
1403 const MCInstrDesc &getMCOpcodeFromPseudo(unsigned Opcode) const {
1404 return get(pseudoToMCOpcode(Opcode));
1405 }
1406
1407 Register isStackAccess(const MachineInstr &MI, int &FrameIndex) const;
1408 Register isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex) const;
1409
1411 int &FrameIndex) const override;
1413 int &FrameIndex) const override;
1414
1415 unsigned getInstBundleSize(const MachineInstr &MI) const;
1416 unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
1417
1418 bool mayAccessFlatAddressSpace(const MachineInstr &MI) const;
1419
1420 std::pair<unsigned, unsigned>
1421 decomposeMachineOperandsTargetFlags(unsigned TF) const override;
1422
1424 getSerializableTargetIndices() const override;
1425
1428
1431
1434 const ScheduleDAG *DAG) const override;
1435
1437 CreateTargetPostRAHazardRecognizer(const MachineFunction &MF) const override;
1438
1441 const ScheduleDAGMI *DAG) const override;
1442
1444 const MachineFunction &MF) const override;
1445
1447 Register Reg = Register()) const override;
1448
1451 const DebugLoc &DL, Register Src,
1452 Register Dst) const override;
1453
1456 const DebugLoc &DL, Register Src,
1457 unsigned SrcSubReg,
1458 Register Dst) const override;
1459
1460 bool isWave32() const;
1461
1462 /// Return a partially built integer add instruction without carry.
1463 /// Caller must add source operands.
1464 /// For pre-GFX9 it will generate unused carry destination operand.
1465 /// TODO: After GFX9 it should return a no-carry operation.
1468 const DebugLoc &DL,
1469 Register DestReg) const;
1470
1473 const DebugLoc &DL,
1474 Register DestReg,
1475 RegScavenger &RS) const;
1476
1477 static bool isKillTerminator(unsigned Opcode);
1478 const MCInstrDesc &getKillTerminatorFromPseudo(unsigned Opcode) const;
1479
1480 bool isLegalMUBUFImmOffset(unsigned Imm) const;
1481
1482 static unsigned getMaxMUBUFImmOffset(const GCNSubtarget &ST);
1483
1484 bool splitMUBUFOffset(uint32_t Imm, uint32_t &SOffset, uint32_t &ImmOffset,
1485 Align Alignment = Align(4)) const;
1486
1487 /// Returns if \p Offset is legal for the subtarget as the offset to a FLAT
1488 /// encoded instruction with the given \p FlatVariant.
1489 bool isLegalFLATOffset(int64_t Offset, unsigned AddrSpace,
1490 uint64_t FlatVariant) const;
1491
1492 /// Split \p COffsetVal into {immediate offset field, remainder offset}
1493 /// values.
1494 std::pair<int64_t, int64_t> splitFlatOffset(int64_t COffsetVal,
1495 unsigned AddrSpace,
1496 uint64_t FlatVariant) const;
1497
1498 /// Returns true if negative offsets are allowed for the given \p FlatVariant.
1499 bool allowNegativeFlatOffset(uint64_t FlatVariant) const;
1500
1501 /// \brief Return a target-specific opcode if Opcode is a pseudo instruction.
1502 /// Return -1 if the target-specific opcode for the pseudo instruction does
1503 /// not exist. If Opcode is not a pseudo instruction, this is identity.
1504 int pseudoToMCOpcode(int Opcode) const;
1505
1506 /// \brief Check if this instruction should only be used by assembler.
1507 /// Return true if this opcode should not be used by codegen.
1508 bool isAsmOnlyOpcode(int MCOp) const;
1509
1510 const TargetRegisterClass *getRegClass(const MCInstrDesc &TID, unsigned OpNum,
1511 const TargetRegisterInfo *TRI,
1512 const MachineFunction &MF)
1513 const override;
1514
1515 void fixImplicitOperands(MachineInstr &MI) const;
1516
1520 int FrameIndex,
1521 LiveIntervals *LIS = nullptr,
1522 VirtRegMap *VRM = nullptr) const override;
1523
1524 unsigned getInstrLatency(const InstrItineraryData *ItinData,
1525 const MachineInstr &MI,
1526 unsigned *PredCost = nullptr) const override;
1527
1529 getInstructionUniformity(const MachineInstr &MI) const override final;
1530
1533
1534 const MIRFormatter *getMIRFormatter() const override {
1535 if (!Formatter)
1536 Formatter = std::make_unique<AMDGPUMIRFormatter>();
1537 return Formatter.get();
1538 }
1539
1540 static unsigned getDSShaderTypeValue(const MachineFunction &MF);
1541
1542 const TargetSchedModel &getSchedModel() const { return SchedModel; }
1543
1544 // Enforce operand's \p OpName even alignment if required by target.
1545 // This is used if an operand is a 32 bit register but needs to be aligned
1546 // regardless.
1547 void enforceOperandRCAlignment(MachineInstr &MI, AMDGPU::OpName OpName) const;
1548};
1549
1550/// \brief Returns true if a reg:subreg pair P has a TRC class
1552 const TargetRegisterClass &TRC,
1554 auto *RC = MRI.getRegClass(P.Reg);
1555 if (!P.SubReg)
1556 return RC == &TRC;
1557 auto *TRI = MRI.getTargetRegisterInfo();
1558 return RC == TRI->getMatchingSuperRegClass(RC, &TRC, P.SubReg);
1559}
1560
1561/// \brief Create RegSubRegPair from a register MachineOperand
1562inline
1564 assert(O.isReg());
1565 return TargetInstrInfo::RegSubRegPair(O.getReg(), O.getSubReg());
1566}
1567
1568/// \brief Return the SubReg component from REG_SEQUENCE
1569TargetInstrInfo::RegSubRegPair getRegSequenceSubReg(MachineInstr &MI,
1570 unsigned SubReg);
1571
1572/// \brief Return the defining instruction for a given reg:subreg pair
1573/// skipping copy like instructions and subreg-manipulation pseudos.
1574/// Following another subreg of a reg:subreg isn't supported.
1575MachineInstr *getVRegSubRegDef(const TargetInstrInfo::RegSubRegPair &P,
1576 MachineRegisterInfo &MRI);
1577
1578/// \brief Return false if EXEC is not changed between the def of \p VReg at \p
1579/// DefMI and the use at \p UseMI. Should be run on SSA. Currently does not
1580/// attempt to track between blocks.
1581bool execMayBeModifiedBeforeUse(const MachineRegisterInfo &MRI,
1582 Register VReg,
1583 const MachineInstr &DefMI,
1584 const MachineInstr &UseMI);
1585
1586/// \brief Return false if EXEC is not changed between the def of \p VReg at \p
1587/// DefMI and all its uses. Should be run on SSA. Currently does not attempt to
1588/// track between blocks.
1589bool execMayBeModifiedBeforeAnyUse(const MachineRegisterInfo &MRI,
1590 Register VReg,
1591 const MachineInstr &DefMI);
1592
1593namespace AMDGPU {
1594
1596 int getVOPe64(uint16_t Opcode);
1597
1599 int getVOPe32(uint16_t Opcode);
1600
1602 int getSDWAOp(uint16_t Opcode);
1603
1606
1609
1612
1615
1618
1621
1622 /// Check if \p Opcode is an Addr64 opcode.
1623 ///
1624 /// \returns \p Opcode if it is an Addr64 opcode, otherwise -1.
1627
1629 int getSOPKOp(uint16_t Opcode);
1630
1631 /// \returns SADDR form of a FLAT Global instruction given an \p Opcode
1632 /// of a VADDR form.
1635
1636 /// \returns VADDR form of a FLAT Global instruction given an \p Opcode
1637 /// of a SADDR form.
1640
1643
1644 /// \returns ST form with only immediate offset of a FLAT Scratch instruction
1645 /// given an \p Opcode of an SS (SADDR) form.
1648
1649 /// \returns SV (VADDR) form of a FLAT Scratch instruction given an \p Opcode
1650 /// of an SVS (SADDR + VADDR) form.
1653
1654 /// \returns SS (SADDR) form of a FLAT Scratch instruction given an \p Opcode
1655 /// of an SV (VADDR) form.
1658
1659 /// \returns SV (VADDR) form of a FLAT Scratch instruction given an \p Opcode
1660 /// of an SS (SADDR) form.
1663
1664 /// \returns earlyclobber version of a MAC MFMA is exists.
1667
1668 /// \returns Version of an MFMA instruction which uses AGPRs for srcC and
1669 /// vdst, given an \p Opcode of an MFMA which uses VGPRs for srcC/vdst.
1672
1673 /// \returns v_cmpx version of a v_cmp instruction.
1676
1677 const uint64_t RSRC_DATA_FORMAT = 0xf00000000000LL;
1680 const uint64_t RSRC_TID_ENABLE = UINT64_C(1) << (32 + 23);
1681
1682} // end namespace AMDGPU
1683
1684namespace AMDGPU {
1686 // For sgpr to vgpr spill instructions
1689} // namespace AMDGPU
1690
1691namespace SI {
1692namespace KernelInputOffsets {
1693
1694/// Offsets in bytes from the start of the input buffer
1704 LOCAL_SIZE_Z = 32
1706
1707} // end namespace KernelInputOffsets
1708} // end namespace SI
1709
1710} // end namespace llvm
1711
1712#endif // LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H
unsigned SubReg
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Provides AMDGPU specific target descriptions.
AMDGPU specific overrides of MIRFormatter.
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
#define LLVM_READONLY
Definition: Compiler.h:322
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
uint64_t Size
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition: MD5.cpp:58
Register Reg
Register const TargetRegisterInfo * TRI
MachineInstr unsigned OpIdx
uint64_t IntrinsicInst * II
#define P(N)
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
Interface definition for SIRegisterInfo.
This file implements a set that has insertion order iteration characteristics.
Class for arbitrary precision integers.
Definition: APInt.h:78
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
This class represents an Operation in the Expression.
A debug info location.
Definition: DebugLoc.h:124
Itinerary data supplied by a subtarget to be used by a target.
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:199
This holds information about one operand of a machine instruction, indicating the register class for ...
Definition: MCInstrDesc.h:86
uint8_t OperandType
Information about the type of the operand.
Definition: MCInstrDesc.h:98
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
Definition: MCInstrDesc.h:92
MIRFormater - Interface to format MIR operand based on target.
Definition: MIRFormatter.h:33
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Representation of each machine instruction.
Definition: MachineInstr.h:72
Flags
Flags values. These may be or'd together.
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
LLVM_ABI unsigned getOperandNo() const
Returns the index of this operand in the instruction that it belongs to.
int64_t getImm() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
Represents one node in the SelectionDAG.
bool isLegalMUBUFImmOffset(unsigned Imm) const
bool isFLATGlobal(uint16_t Opcode) const
Definition: SIInstrInfo.h:664
bool isInlineConstant(const APInt &Imm) const
static bool isMAI(const MachineInstr &MI)
Definition: SIInstrInfo.h:844
void legalizeOperandsVOP3(MachineRegisterInfo &MRI, MachineInstr &MI) const
Fix operands in MI to satisfy constant bus requirements.
static bool isDS(const MachineInstr &MI)
Definition: SIInstrInfo.h:586
static bool isVMEM(const MachineInstr &MI)
Definition: SIInstrInfo.h:464
MachineBasicBlock * legalizeOperands(MachineInstr &MI, MachineDominatorTree *MDT=nullptr) const
Legalize all operands in this instruction.
bool areLoadsFromSameBasePtr(SDNode *Load0, SDNode *Load1, int64_t &Offset0, int64_t &Offset1) const override
static bool isVOP3(const MachineInstr &MI)
Definition: SIInstrInfo.h:536
unsigned getLiveRangeSplitOpcode(Register Reg, const MachineFunction &MF) const override
bool isSMRD(uint16_t Opcode) const
Definition: SIInstrInfo.h:580
bool getMemOperandsWithOffsetWidth(const MachineInstr &LdSt, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, LocationSize &Width, const TargetRegisterInfo *TRI) const final
Register isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex) const
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
static bool isNeverUniform(const MachineInstr &MI)
Definition: SIInstrInfo.h:982
unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const
Return the size in bytes of the operand OpNo on the given.
Definition: SIInstrInfo.h:1237
bool isAtomic(uint16_t Opcode) const
Definition: SIInstrInfo.h:738
bool isXDLWMMA(const MachineInstr &MI) const
bool isBasicBlockPrologue(const MachineInstr &MI, Register Reg=Register()) const override
bool isLDSDIR(uint16_t Opcode) const
Definition: SIInstrInfo.h:895
bool isFLATScratch(uint16_t Opcode) const
Definition: SIInstrInfo.h:672
uint64_t getDefaultRsrcDataFormat() const
static bool isSOPP(const MachineInstr &MI)
Definition: SIInstrInfo.h:504
InstructionUniformity getGenericInstructionUniformity(const MachineInstr &MI) const
bool hasVGPRUses(const MachineInstr &MI) const
Definition: SIInstrInfo.h:1084
uint64_t getClampMask(const MachineInstr &MI) const
Definition: SIInstrInfo.h:958
bool isIGLP(unsigned Opcode) const
Definition: SIInstrInfo.h:1017
static bool isFLATScratch(const MachineInstr &MI)
Definition: SIInstrInfo.h:668
const MCInstrDesc & getIndirectRegWriteMovRelPseudo(unsigned VecSize, unsigned EltSize, bool IsSGPR) const
static bool isSpill(const MachineInstr &MI)
Definition: SIInstrInfo.h:796
MachineInstrBuilder getAddNoCarry(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg) const
Return a partially built integer add instruction without carry.
bool mayAccessFlatAddressSpace(const MachineInstr &MI) const
bool shouldScheduleLoadsNear(SDNode *Load0, SDNode *Load1, int64_t Offset0, int64_t Offset1, unsigned NumLoads) const override
bool splitMUBUFOffset(uint32_t Imm, uint32_t &SOffset, uint32_t &ImmOffset, Align Alignment=Align(4)) const
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
void moveToVALU(SIInstrWorklist &Worklist, MachineDominatorTree *MDT) const
Replace the instructions opcode with the equivalent VALU opcode.
static bool isSMRD(const MachineInstr &MI)
Definition: SIInstrInfo.h:576
void restoreExec(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, Register Reg, SlotIndexes *Indexes=nullptr) const
bool isVGPRSpill(uint16_t Opcode) const
Definition: SIInstrInfo.h:774
bool usesConstantBus(const MachineRegisterInfo &MRI, const MachineOperand &MO, const MCOperandInfo &OpInfo) const
Returns true if this operand uses the constant bus.
static unsigned getMaxMUBUFImmOffset(const GCNSubtarget &ST)
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool mayAccessScratchThroughFlat(const MachineInstr &MI) const
void legalizeOperandsFLAT(MachineRegisterInfo &MRI, MachineInstr &MI) const
bool optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg, Register SrcReg2, int64_t CmpMask, int64_t CmpValue, const MachineRegisterInfo *MRI) const override
bool isSegmentSpecificFLAT(uint16_t Opcode) const
Definition: SIInstrInfo.h:655
bool usesConstantBus(const MachineRegisterInfo &MRI, const MachineInstr &MI, int OpIdx) const
Definition: SIInstrInfo.h:1192
bool isVSAMPLE(uint16_t Opcode) const
Definition: SIInstrInfo.h:632
static std::optional< int64_t > extractSubregFromImm(int64_t ImmVal, unsigned SubRegIndex)
Return the extracted immediate value in a subregister use from a constant materialized in a super reg...
Register isStackAccess(const MachineInstr &MI, int &FrameIndex) const
bool isPacked(uint16_t Opcode) const
Definition: SIInstrInfo.h:516
static bool isMTBUF(const MachineInstr &MI)
Definition: SIInstrInfo.h:568
const MCInstrDesc & getIndirectGPRIDXPseudo(unsigned VecSize, bool IsIndirectSrc) const
void insertReturn(MachineBasicBlock &MBB) const
static bool isDGEMM(unsigned Opcode)
Definition: SIInstrInfo.h:889
static bool isEXP(const MachineInstr &MI)
Definition: SIInstrInfo.h:701
static bool isSALU(const MachineInstr &MI)
Definition: SIInstrInfo.h:440
bool isVIMAGE(uint16_t Opcode) const
Definition: SIInstrInfo.h:624
void legalizeGenericOperand(MachineBasicBlock &InsertMBB, MachineBasicBlock::iterator I, const TargetRegisterClass *DstRC, MachineOperand &Op, MachineRegisterInfo &MRI, const DebugLoc &DL) const
MachineInstr * buildShrunkInst(MachineInstr &MI, unsigned NewOpcode) const
unsigned getInstBundleSize(const MachineInstr &MI) const
static bool isVOP2(const MachineInstr &MI)
Definition: SIInstrInfo.h:528
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
static bool isSDWA(const MachineInstr &MI)
Definition: SIInstrInfo.h:544
bool isSOP1(uint16_t Opcode) const
Definition: SIInstrInfo.h:476
const MCInstrDesc & getKillTerminatorFromPseudo(unsigned Opcode) const
static bool mayWriteLDSThroughDMA(const MachineInstr &MI)
Definition: SIInstrInfo.h:743
void insertNoops(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned Quantity) const override
static bool isVINTRP(const MachineInstr &MI)
Definition: SIInstrInfo.h:836
bool isIGLPMutationOnly(unsigned Opcode) const
Definition: SIInstrInfo.h:1026
bool isSWMMAC(uint16_t Opcode) const
Definition: SIInstrInfo.h:877
bool isAtomicRet(uint16_t Opcode) const
Definition: SIInstrInfo.h:729
static bool isGather4(const MachineInstr &MI)
Definition: SIInstrInfo.h:636
MachineInstr * getWholeWaveFunctionSetup(MachineFunction &MF) const
static bool isMFMAorWMMA(const MachineInstr &MI)
Definition: SIInstrInfo.h:869
static bool isWQM(const MachineInstr &MI)
Definition: SIInstrInfo.h:747
static bool doesNotReadTiedSource(const MachineInstr &MI)
Definition: SIInstrInfo.h:1009
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.
bool isSOPC(uint16_t Opcode) const
Definition: SIInstrInfo.h:492
static bool isDOT(const MachineInstr &MI)
Definition: SIInstrInfo.h:857
static bool usesFPDPRounding(const MachineInstr &MI)
Definition: SIInstrInfo.h:966
bool isFixedSize(uint16_t Opcode) const
Definition: SIInstrInfo.h:942
bool isImage(uint16_t Opcode) const
Definition: SIInstrInfo.h:460
MachineInstr * createPHISourceCopy(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt, const DebugLoc &DL, Register Src, unsigned SrcSubReg, Register Dst) const override
bool isGWS(uint16_t Opcode) const
Definition: SIInstrInfo.h:606
bool isInlineConstant(const MachineOperand &MO) const
Definition: SIInstrInfo.h:1173
bool hasModifiers(unsigned Opcode) const
Return true if this instruction has any modifiers.
bool isVOP3(uint16_t Opcode) const
Definition: SIInstrInfo.h:540
bool shouldClusterMemOps(ArrayRef< const MachineOperand * > BaseOps1, int64_t Offset1, bool OffsetIsScalable1, ArrayRef< const MachineOperand * > BaseOps2, int64_t Offset2, bool OffsetIsScalable2, unsigned ClusterSize, unsigned NumBytes) const override
static bool isSWMMAC(const MachineInstr &MI)
Definition: SIInstrInfo.h:873
ScheduleHazardRecognizer * CreateTargetMIHazardRecognizer(const InstrItineraryData *II, const ScheduleDAGMI *DAG) const override
bool isDOT(uint16_t Opcode) const
Definition: SIInstrInfo.h:881
bool isWave32() const
bool isHighLatencyDef(int Opc) const override
void legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const
Legalize the OpIndex operand of this instruction by inserting a MOV.
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
static bool isVOPC(const MachineInstr &MI)
Definition: SIInstrInfo.h:552
void removeModOperands(MachineInstr &MI) const
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx, int64_t ImmVal) const
Definition: SIInstrInfo.h:1151
std::pair< int64_t, int64_t > splitFlatOffset(int64_t COffsetVal, unsigned AddrSpace, uint64_t FlatVariant) const
Split COffsetVal into {immediate offset field, remainder offset} values.
bool isGather4(uint16_t Opcode) const
Definition: SIInstrInfo.h:640
bool isSpill(uint16_t Opcode) const
Definition: SIInstrInfo.h:792
unsigned getVectorRegSpillRestoreOpcode(Register Reg, const TargetRegisterClass *RC, unsigned Size, const SIMachineFunctionInfo &MFI) const
bool isXDL(const MachineInstr &MI) const
bool isFLAT(uint16_t Opcode) const
Definition: SIInstrInfo.h:677
static bool isVIMAGE(const MachineInstr &MI)
Definition: SIInstrInfo.h:620
static bool isLDSDIR(const MachineInstr &MI)
Definition: SIInstrInfo.h:891
void enforceOperandRCAlignment(MachineInstr &MI, AMDGPU::OpName OpName) const
static bool isSOP2(const MachineInstr &MI)
Definition: SIInstrInfo.h:480
LLVM_READONLY const MachineOperand * getNamedOperand(const MachineInstr &MI, AMDGPU::OpName OperandName) const
Definition: SIInstrInfo.h:1383
static bool isGWS(const MachineInstr &MI)
Definition: SIInstrInfo.h:602
bool isLegalAV64PseudoImm(uint64_t Imm) const
Check if this immediate value can be used for AV_MOV_B64_IMM_PSEUDO.
const TargetSchedModel & getSchedModel() const
Definition: SIInstrInfo.h:1542
bool isVOPC(uint16_t Opcode) const
Definition: SIInstrInfo.h:556
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:1133
const MIRFormatter * getMIRFormatter() const override
Definition: SIInstrInfo.h:1534
bool hasModifiersSet(const MachineInstr &MI, AMDGPU::OpName OpName) const
const TargetRegisterClass * getPreferredSelectRegClass(unsigned Size) const
bool isLegalToSwap(const MachineInstr &MI, unsigned fromIdx, unsigned toIdx) const
bool isReallyTriviallyReMaterializable(const MachineInstr &MI) const override
bool isMAI(uint16_t Opcode) const
Definition: SIInstrInfo.h:848
static bool isFLATGlobal(const MachineInstr &MI)
Definition: SIInstrInfo.h:660
unsigned getMachineCSELookAheadLimit() const override
Definition: SIInstrInfo.h:431
bool isGlobalMemoryObject(const MachineInstr *MI) const override
static bool isVSAMPLE(const MachineInstr &MI)
Definition: SIInstrInfo.h:628
static bool isAtomicRet(const MachineInstr &MI)
Definition: SIInstrInfo.h:725
bool isBufferSMRD(const MachineInstr &MI) const
static bool isKillTerminator(unsigned Opcode)
bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx0, unsigned &SrcOpIdx1) const override
const GCNSubtarget & getSubtarget() const
Definition: SIInstrInfo.h:239
bool isDS(uint16_t Opcode) const
Definition: SIInstrInfo.h:590
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
void insertScratchExecCopy(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, Register Reg, bool IsSCCLive, SlotIndexes *Indexes=nullptr) const
bool isFPAtomic(uint16_t Opcode) const
Definition: SIInstrInfo.h:978
bool hasVALU32BitEncoding(unsigned Opcode) const
Return true if this 64-bit VALU instruction has a 32-bit encoding.
static bool isDisableWQM(const MachineInstr &MI)
Definition: SIInstrInfo.h:755
bool isAtomicNoRet(uint16_t Opcode) const
Definition: SIInstrInfo.h:721
unsigned getMovOpcode(const TargetRegisterClass *DstRC) const
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, unsigned SubIdx, const MachineInstr &Orig, const TargetRegisterInfo &TRI) const override
unsigned buildExtractSubReg(MachineBasicBlock::iterator MI, MachineRegisterInfo &MRI, const MachineOperand &SuperReg, const TargetRegisterClass *SuperRC, unsigned SubIdx, const TargetRegisterClass *SubRC) const
void legalizeOperandsVOP2(MachineRegisterInfo &MRI, MachineInstr &MI) const
Legalize operands in MI by either commuting it or inserting a copy of src1.
bool foldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, Register Reg, MachineRegisterInfo *MRI) const final
static bool isTRANS(const MachineInstr &MI)
Definition: SIInstrInfo.h:820
static bool isImage(const MachineInstr &MI)
Definition: SIInstrInfo.h:456
static bool isSOPK(const MachineInstr &MI)
Definition: SIInstrInfo.h:496
const TargetRegisterClass * getOpRegClass(const MachineInstr &MI, unsigned OpNo) const
Return the correct register class for OpNo.
MachineBasicBlock * insertSimulatedTrap(MachineRegisterInfo &MRI, MachineBasicBlock &MBB, MachineInstr &MI, const DebugLoc &DL) const
Build instructions that simulate the behavior of a s_trap 2 instructions for hardware (namely,...
static unsigned getNonSoftWaitcntOpcode(unsigned Opcode)
Definition: SIInstrInfo.h:1030
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx) const
returns true if the operand OpIdx in MI is a valid inline immediate.
Definition: SIInstrInfo.h:1146
static unsigned getDSShaderTypeValue(const MachineFunction &MF)
static bool isFoldableCopy(const MachineInstr &MI)
bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo, const MachineOperand &MO) const
bool isIgnorableUse(const MachineOperand &MO) const override
static bool isVINTERP(const MachineInstr &MI)
Definition: SIInstrInfo.h:899
static bool isMUBUF(const MachineInstr &MI)
Definition: SIInstrInfo.h:560
bool expandPostRAPseudo(MachineInstr &MI) const override
bool analyzeCompare(const MachineInstr &MI, Register &SrcReg, Register &SrcReg2, int64_t &CmpMask, int64_t &CmpValue) const override
bool isSALU(uint16_t Opcode) const
Definition: SIInstrInfo.h:444
bool isVOP2(uint16_t Opcode) const
Definition: SIInstrInfo.h:532
static bool hasFPClamp(const MachineInstr &MI)
Definition: SIInstrInfo.h:946
InstructionUniformity getInstructionUniformity(const MachineInstr &MI) const override final
static bool isSegmentSpecificFLAT(const MachineInstr &MI)
Definition: SIInstrInfo.h:650
static bool isWaitcnt(unsigned Opcode)
Definition: SIInstrInfo.h:1053
bool isSDWA(uint16_t Opcode) const
Definition: SIInstrInfo.h:548
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:1251
bool isInlineConstant(const MachineOperand &MO, const MCOperandInfo &OpInfo) const
Definition: SIInstrInfo.h:1126
bool isSOPK(uint16_t Opcode) const
Definition: SIInstrInfo.h:500
static bool isF16PseudoScalarTrans(unsigned Opcode)
Definition: SIInstrInfo.h:1001
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DstReg, ArrayRef< MachineOperand > Cond, Register TrueReg, Register FalseReg) const override
static bool isChainCallOpcode(uint64_t Opcode)
Definition: SIInstrInfo.h:807
static bool isDPP(const MachineInstr &MI)
Definition: SIInstrInfo.h:812
bool analyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const
static bool isMFMA(const MachineInstr &MI)
Definition: SIInstrInfo.h:852
bool isSGPRSpill(uint16_t Opcode) const
Definition: SIInstrInfo.h:786
bool isLowLatencyInstruction(const MachineInstr &MI) const
bool isIGLP(const MachineInstr &MI) const
Definition: SIInstrInfo.h:1022
static bool isScalarStore(const MachineInstr &MI)
Definition: SIInstrInfo.h:930
bool isTRANS(uint16_t Opcode) const
Definition: SIInstrInfo.h:824
bool isLDSDMA(uint16_t Opcode)
Definition: SIInstrInfo.h:598
std::optional< DestSourcePair > isCopyInstrImpl(const MachineInstr &MI) const override
If the specific machine instruction is a instruction that moves/copies value from one register to ano...
bool isSOP2(uint16_t Opcode) const
Definition: SIInstrInfo.h:484
bool isVALU(uint16_t Opcode) const
Definition: SIInstrInfo.h:452
bool isVOP1(uint16_t Opcode) const
Definition: SIInstrInfo.h:524
bool isAlwaysGDS(uint16_t Opcode) const
bool isMUBUF(uint16_t Opcode) const
Definition: SIInstrInfo.h:564
static bool isFPAtomic(const MachineInstr &MI)
Definition: SIInstrInfo.h:974
static bool usesLGKM_CNT(const MachineInstr &MI)
Definition: SIInstrInfo.h:915
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
void legalizeOperandsVALUt16(MachineInstr &Inst, MachineRegisterInfo &MRI) const
Fix operands in Inst to fix 16bit SALU to VALU lowering.
void moveToVALUImpl(SIInstrWorklist &Worklist, MachineDominatorTree *MDT, MachineInstr &Inst) const
static bool isPacked(const MachineInstr &MI)
Definition: SIInstrInfo.h:512
bool canShrink(const MachineInstr &MI, const MachineRegisterInfo &MRI) const
static bool isBlockLoadStore(uint16_t Opcode)
Definition: SIInstrInfo.h:687
bool isAsmOnlyOpcode(int MCOp) const
Check if this instruction should only be used by assembler.
bool isWMMA(uint16_t Opcode) const
Definition: SIInstrInfo.h:865
bool isMTBUF(uint16_t Opcode) const
Definition: SIInstrInfo.h:572
bool isDisableWQM(uint16_t Opcode) const
Definition: SIInstrInfo.h:759
static bool isVGPRSpill(const MachineInstr &MI)
Definition: SIInstrInfo.h:768
ScheduleHazardRecognizer * CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II, const ScheduleDAG *DAG) const override
This is used by the post-RA scheduler (SchedulePostRAList.cpp).
bool verifyInstruction(const MachineInstr &MI, StringRef &ErrInfo) const override
bool isLegalFLATOffset(int64_t Offset, unsigned AddrSpace, uint64_t FlatVariant) const
Returns if Offset is legal for the subtarget as the offset to a FLAT encoded instruction with the giv...
static bool isWWMRegSpillOpcode(uint16_t Opcode)
Definition: SIInstrInfo.h:800
unsigned getInstrLatency(const InstrItineraryData *ItinData, const MachineInstr &MI, unsigned *PredCost=nullptr) const override
bool isVMEM(uint16_t Opcode) const
Definition: SIInstrInfo.h:468
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
int64_t getNamedImmOperand(const MachineInstr &MI, AMDGPU::OpName OperandName) const
Get required immediate operand.
Definition: SIInstrInfo.h:1389
ArrayRef< std::pair< int, const char * > > getSerializableTargetIndices() const override
bool isVINTRP(uint16_t Opcode) const
Definition: SIInstrInfo.h:840
bool isVGPRCopy(const MachineInstr &MI) const
Definition: SIInstrInfo.h:1076
bool isScalarStore(uint16_t Opcode) const
Definition: SIInstrInfo.h:934
static bool isMIMG(const MachineInstr &MI)
Definition: SIInstrInfo.h:612
MachineOperand buildExtractSubRegOrImm(MachineBasicBlock::iterator MI, MachineRegisterInfo &MRI, const MachineOperand &SuperReg, const TargetRegisterClass *SuperRC, unsigned SubIdx, const TargetRegisterClass *SubRC) const
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
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 or operand ind...
bool allowNegativeFlatOffset(uint64_t FlatVariant) const
Returns true if negative offsets are allowed for the given FlatVariant.
LLVM_READONLY int commuteOpcode(const MachineInstr &MI) const
Definition: SIInstrInfo.h:341
static unsigned getNumWaitStates(const MachineInstr &MI)
Return the number of wait states that result from executing this instruction.
const TargetRegisterClass * getRegClass(const MCInstrDesc &TID, unsigned OpNum, const TargetRegisterInfo *TRI, const MachineFunction &MF) const override
static bool isVOP3P(const MachineInstr &MI)
Definition: SIInstrInfo.h:828
unsigned getVectorRegSpillSaveOpcode(Register Reg, const TargetRegisterClass *RC, unsigned Size, const SIMachineFunctionInfo &MFI) const
bool isWQM(uint16_t Opcode) const
Definition: SIInstrInfo.h:751
unsigned getVALUOp(const MachineInstr &MI) const
static bool modifiesModeRegister(const MachineInstr &MI)
Return true if the instruction modifies the mode register.q.
Register readlaneVGPRToSGPR(Register SrcReg, MachineInstr &UseMI, MachineRegisterInfo &MRI, const TargetRegisterClass *DstRC=nullptr) const
Copy a value from a VGPR (SrcReg) to SGPR.
bool hasDivergentBranch(const MachineBasicBlock *MBB) const
Return whether the block terminate with divergent branch.
bool isInlineConstant(const MachineOperand &MO, uint8_t OperandType) const
Definition: SIInstrInfo.h:1119
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
void fixImplicitOperands(MachineInstr &MI) const
bool moveFlatAddrToVGPR(MachineInstr &Inst) const
Change SADDR form of a FLAT Inst to its VADDR form if saddr operand was moved to VGPR.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
bool isVOP3P(uint16_t Opcode) const
Definition: SIInstrInfo.h:832
bool swapSourceModifiers(MachineInstr &MI, MachineOperand &Src0, AMDGPU::OpName Src0OpName, MachineOperand &Src1, AMDGPU::OpName Src1OpName) const
bool isEXP(uint16_t Opcode) const
Definition: SIInstrInfo.h:713
Register insertNE(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register SrcReg, int Value) const
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
static bool isDualSourceBlendEXP(const MachineInstr &MI)
Definition: SIInstrInfo.h:705
bool hasUnwantedEffectsWhenEXECEmpty(const MachineInstr &MI) const
This function is used to determine if an instruction can be safely executed under EXEC = 0 without ha...
bool getConstValDefinedInReg(const MachineInstr &MI, const Register Reg, int64_t &ImmVal) const override
static bool isAtomic(const MachineInstr &MI)
Definition: SIInstrInfo.h:733
bool canInsertSelect(const MachineBasicBlock &MBB, ArrayRef< MachineOperand > Cond, Register DstReg, Register TrueReg, Register FalseReg, int &CondCycles, int &TrueCycles, int &FalseCycles) const override
static bool sopkIsZext(unsigned Opcode)
Definition: SIInstrInfo.h:921
static bool isSGPRSpill(const MachineInstr &MI)
Definition: SIInstrInfo.h:780
static bool isWMMA(const MachineInstr &MI)
Definition: SIInstrInfo.h:861
ArrayRef< std::pair< MachineMemOperand::Flags, const char * > > getSerializableMachineMemOperandTargetFlags() const override
bool isVINTERP(uint16_t Opcode) const
Definition: SIInstrInfo.h:903
MachineInstr * convertToThreeAddress(MachineInstr &MI, LiveVariables *LV, LiveIntervals *LIS) const override
bool mayReadEXEC(const MachineRegisterInfo &MRI, const MachineInstr &MI) const
Returns true if the instruction could potentially depend on the value of exec.
void legalizeOperandsSMRD(MachineRegisterInfo &MRI, MachineInstr &MI) const
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
bool doesNotReadTiedSource(uint16_t Opcode) const
Definition: SIInstrInfo.h:1013
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
bool isDPP(uint16_t Opcode) const
Definition: SIInstrInfo.h:816
void insertVectorSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DstReg, ArrayRef< MachineOperand > Cond, Register TrueReg, Register FalseReg) const
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
std::pair< MachineInstr *, MachineInstr * > expandMovDPP64(MachineInstr &MI) const
Register insertEQ(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register SrcReg, int Value) const
static bool isSOP1(const MachineInstr &MI)
Definition: SIInstrInfo.h:472
static bool isSOPC(const MachineInstr &MI)
Definition: SIInstrInfo.h:488
static bool isFLAT(const MachineInstr &MI)
Definition: SIInstrInfo.h:644
const SIRegisterInfo & getRegisterInfo() const
Definition: SIInstrInfo.h:235
static bool isVALU(const MachineInstr &MI)
Definition: SIInstrInfo.h:448
bool isBarrier(unsigned Opcode) const
Definition: SIInstrInfo.h:986
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx0, unsigned OpIdx1) const override
static bool hasIntClamp(const MachineInstr &MI)
Definition: SIInstrInfo.h:954
int pseudoToMCOpcode(int Opcode) const
Return a target-specific opcode if Opcode is a pseudo instruction.
const MCInstrDesc & getMCOpcodeFromPseudo(unsigned Opcode) const
Return the descriptor of the target-specific machine instruction that corresponds to the specified ps...
Definition: SIInstrInfo.h:1403
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx, const MachineOperand &MO) const
Definition: SIInstrInfo.h:1168
static bool isScalarUnit(const MachineInstr &MI)
Definition: SIInstrInfo.h:907
bool isSOPP(uint16_t Opcode) const
Definition: SIInstrInfo.h:508
bool isLegalGFX12PlusPackedMathFP32Operand(const MachineRegisterInfo &MRI, const MachineInstr &MI, unsigned SrcN, const MachineOperand *MO=nullptr) const
Check if MO would be a legal operand for gfx12+ packed math FP32 instructions.
bool isMIMG(uint16_t Opcode) const
Definition: SIInstrInfo.h:616
bool hasFPClamp(uint16_t Opcode) const
Definition: SIInstrInfo.h:950
static bool usesVM_CNT(const MachineInstr &MI)
Definition: SIInstrInfo.h:911
bool usesFPDPRounding(uint16_t Opcode) const
Definition: SIInstrInfo.h:970
MachineInstr * createPHIDestinationCopy(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt, const DebugLoc &DL, Register Src, Register Dst) const override
static bool isFixedSize(const MachineInstr &MI)
Definition: SIInstrInfo.h:938
bool isSafeToSink(MachineInstr &MI, MachineBasicBlock *SuccToSinkTo, MachineCycleInfo *CI) const override
LLVM_READONLY int commuteOpcode(unsigned Opc) const
uint64_t getScratchRsrcWords23() const
LLVM_READONLY MachineOperand * getNamedOperand(MachineInstr &MI, AMDGPU::OpName OperandName) const
Returns the operand named Op.
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
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.
static bool isLDSDMA(const MachineInstr &MI)
Definition: SIInstrInfo.h:594
static bool isAtomicNoRet(const MachineInstr &MI)
Definition: SIInstrInfo.h:717
static bool isVOP1(const MachineInstr &MI)
Definition: SIInstrInfo.h:520
void insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, MachineBasicBlock &RestoreBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS) const override
bool hasAnyModifiersSet(const MachineInstr &MI) const
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
const TargetRegisterClass * getRegClass(unsigned RCID) const
bool isSGPRReg(const MachineRegisterInfo &MRI, Register Reg) const
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
HazardRecognizer - This determines whether or not an instruction can be issued this cycle,...
A vector that has set insertion semantics.
Definition: SetVector.h:59
SlotIndexes pass.
Definition: SlotIndexes.h:298
A SetVector that performs no allocations if smaller than a certain size.
Definition: SetVector.h:356
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Provide an instruction scheduling machine model to CodeGen passes.
Target - Wrapper for Target specific information.
LLVM Value Representation.
Definition: Value.h:75
const uint64_t RSRC_DATA_FORMAT
Definition: SIInstrInfo.h:1677
LLVM_READONLY int getBasicFromSDWAOp(uint16_t Opcode)
LLVM_READONLY int getGlobalSaddrOp(uint16_t Opcode)
LLVM_READONLY int getSOPKOp(uint16_t Opcode)
LLVM_READONLY int getVOPe32(uint16_t Opcode)
LLVM_READONLY int getDPPOp32(uint16_t Opcode)
LLVM_READONLY int getFlatScratchInstSVfromSS(uint16_t Opcode)
LLVM_READONLY int getFlatScratchInstSTfromSS(uint16_t Opcode)
LLVM_READONLY int getGlobalVaddrOp(uint16_t Opcode)
const uint64_t RSRC_ELEMENT_SIZE_SHIFT
Definition: SIInstrInfo.h:1678
LLVM_READONLY int getFlatScratchInstSVfromSVS(uint16_t Opcode)
LLVM_READONLY int getAddr64Inst(uint16_t Opcode)
LLVM_READONLY int getMFMAEarlyClobberOp(uint16_t Opcode)
LLVM_READONLY int getVCMPXOpFromVCMP(uint16_t Opcode)
LLVM_READONLY int getSDWAOp(uint16_t Opcode)
LLVM_READONLY int getMFMASrcCVDstAGPROp(uint16_t Opcode)
const uint64_t RSRC_TID_ENABLE
Definition: SIInstrInfo.h:1680
LLVM_READONLY int getCommuteRev(uint16_t Opcode)
LLVM_READONLY int getDPPOp64(uint16_t Opcode)
LLVM_READONLY int getVOPe64(uint16_t Opcode)
@ OPERAND_REG_IMM_INT64
Definition: SIDefines.h:202
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
Definition: SIDefines.h:201
LLVM_READONLY int getCommuteOrig(uint16_t Opcode)
const uint64_t RSRC_INDEX_STRIDE_SHIFT
Definition: SIInstrInfo.h:1679
bool getMAIIsDGEMM(unsigned Opc)
Returns true if MAI operation is a double precision GEMM.
LLVM_READONLY int getFlatScratchInstSSfromSV(uint16_t Opcode)
LLVM_READONLY int getVCMPXNoSDstOp(uint16_t Opcode)
LLVM_READONLY int getIfAddr64Inst(uint16_t Opcode)
Check if Opcode is an Addr64 opcode.
@ OPERAND_IMMEDIATE
Definition: MCInstrDesc.h:61
Offsets
Offsets in bytes from the start of the input buffer.
Definition: SIInstrInfo.h:1695
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:477
TargetInstrInfo::RegSubRegPair getRegSubRegPair(const MachineOperand &O)
Create RegSubRegPair from a register MachineOperand.
Definition: SIInstrInfo.h:1563
bool execMayBeModifiedBeforeUse(const MachineRegisterInfo &MRI, Register VReg, const MachineInstr &DefMI, const MachineInstr &UseMI)
Return false if EXEC is not changed between the def of VReg at DefMI and the use at UseMI.
TargetInstrInfo::RegSubRegPair getRegSequenceSubReg(MachineInstr &MI, unsigned SubReg)
Return the SubReg component from REG_SEQUENCE.
static const MachineMemOperand::Flags MONoClobber
Mark the MMO of a uniform load if there are no potentially clobbering stores on any path from the sta...
Definition: SIInstrInfo.h:44
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1751
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
MachineInstr * getVRegSubRegDef(const TargetInstrInfo::RegSubRegPair &P, MachineRegisterInfo &MRI)
Return the defining instruction for a given reg:subreg pair skipping copy like instructions and subre...
constexpr unsigned DefaultMemoryClusterDWordsLimit
Definition: SIInstrInfo.h:40
static const MachineMemOperand::Flags MOLastUse
Mark the MMO of a load as the last use.
Definition: SIInstrInfo.h:48
bool isOfRegClass(const TargetInstrInfo::RegSubRegPair &P, const TargetRegisterClass &TRC, MachineRegisterInfo &MRI)
Returns true if a reg:subreg pair P has a TRC class.
Definition: SIInstrInfo.h:1551
InstructionUniformity
Enum describing how instructions behave with respect to uniformity and divergence,...
Definition: Uniformity.h:18
bool execMayBeModifiedBeforeAnyUse(const MachineRegisterInfo &MRI, Register VReg, const MachineInstr &DefMI)
Return false if EXEC is not changed between the def of VReg at DefMI and all its uses.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Description of the encoding of one expression Op.
Utility to store machine instructions worklist.
Definition: SIInstrInfo.h:52
MachineInstr * top() const
Definition: SIInstrInfo.h:57
bool empty() const
Definition: SIInstrInfo.h:67
bool isDeferred(MachineInstr *MI)
SetVector< MachineInstr * > & getDeferredList()
Definition: SIInstrInfo.h:76
void insert(MachineInstr *MI)
A pair composed of a register and a sub-register index.