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/// Mark the MMO of cooperative load/store atomics.
54
55/// Utility to store machine instructions worklist.
57 SIInstrWorklist() = default;
58
59 void insert(MachineInstr *MI);
60
61 MachineInstr *top() const {
62 const auto *iter = InstrList.begin();
63 return *iter;
64 }
65
66 void erase_top() {
67 const auto *iter = InstrList.begin();
68 InstrList.erase(iter);
69 }
70
71 bool empty() const { return InstrList.empty(); }
72
73 void clear() {
74 InstrList.clear();
75 DeferredList.clear();
76 }
77
79
80 SetVector<MachineInstr *> &getDeferredList() { return DeferredList; }
81
82private:
83 /// InstrList contains the MachineInstrs.
85 /// Deferred instructions are specific MachineInstr
86 /// that will be added by insert method.
87 SetVector<MachineInstr *> DeferredList;
88};
89
90class SIInstrInfo final : public AMDGPUGenInstrInfo {
91private:
92 const SIRegisterInfo RI;
93 const GCNSubtarget &ST;
94 TargetSchedModel SchedModel;
95 mutable std::unique_ptr<AMDGPUMIRFormatter> Formatter;
96
97 // The inverse predicate should have the negative value.
98 enum BranchPredicate {
99 INVALID_BR = 0,
100 SCC_TRUE = 1,
101 SCC_FALSE = -1,
102 VCCNZ = 2,
103 VCCZ = -2,
104 EXECNZ = -3,
105 EXECZ = 3
106 };
107
108 using SetVectorType = SmallSetVector<MachineInstr *, 32>;
109
110 static unsigned getBranchOpcode(BranchPredicate Cond);
111 static BranchPredicate getBranchPredicate(unsigned Opcode);
112
113public:
116 const MachineOperand &SuperReg,
117 const TargetRegisterClass *SuperRC,
118 unsigned SubIdx,
119 const TargetRegisterClass *SubRC) const;
122 const MachineOperand &SuperReg, const TargetRegisterClass *SuperRC,
123 unsigned SubIdx, const TargetRegisterClass *SubRC) const;
124
125private:
126 void swapOperands(MachineInstr &Inst) const;
127
128 std::pair<bool, MachineBasicBlock *>
129 moveScalarAddSub(SIInstrWorklist &Worklist, MachineInstr &Inst,
130 MachineDominatorTree *MDT = nullptr) const;
131
132 void lowerSelect(SIInstrWorklist &Worklist, MachineInstr &Inst,
133 MachineDominatorTree *MDT = nullptr) const;
134
135 void lowerScalarAbs(SIInstrWorklist &Worklist, MachineInstr &Inst) const;
136
137 void lowerScalarXnor(SIInstrWorklist &Worklist, MachineInstr &Inst) const;
138
139 void splitScalarNotBinop(SIInstrWorklist &Worklist, MachineInstr &Inst,
140 unsigned Opcode) const;
141
142 void splitScalarBinOpN2(SIInstrWorklist &Worklist, MachineInstr &Inst,
143 unsigned Opcode) const;
144
145 void splitScalar64BitUnaryOp(SIInstrWorklist &Worklist, MachineInstr &Inst,
146 unsigned Opcode, bool Swap = false) const;
147
148 void splitScalar64BitBinaryOp(SIInstrWorklist &Worklist, MachineInstr &Inst,
149 unsigned Opcode,
150 MachineDominatorTree *MDT = nullptr) const;
151
152 void splitScalarSMulU64(SIInstrWorklist &Worklist, MachineInstr &Inst,
153 MachineDominatorTree *MDT) const;
154
155 void splitScalarSMulPseudo(SIInstrWorklist &Worklist, MachineInstr &Inst,
156 MachineDominatorTree *MDT) const;
157
158 void splitScalar64BitXnor(SIInstrWorklist &Worklist, MachineInstr &Inst,
159 MachineDominatorTree *MDT = nullptr) const;
160
161 void splitScalar64BitBCNT(SIInstrWorklist &Worklist,
162 MachineInstr &Inst) const;
163 void splitScalar64BitBFE(SIInstrWorklist &Worklist, MachineInstr &Inst) const;
164 void splitScalar64BitCountOp(SIInstrWorklist &Worklist, MachineInstr &Inst,
165 unsigned Opcode,
166 MachineDominatorTree *MDT = nullptr) const;
167 void movePackToVALU(SIInstrWorklist &Worklist, MachineRegisterInfo &MRI,
168 MachineInstr &Inst) const;
169
170 void addUsersToMoveToVALUWorklist(Register Reg, MachineRegisterInfo &MRI,
171 SIInstrWorklist &Worklist) const;
172
173 void addSCCDefUsersToVALUWorklist(MachineOperand &Op,
174 MachineInstr &SCCDefInst,
175 SIInstrWorklist &Worklist,
176 Register NewCond = Register()) const;
177 void addSCCDefsToVALUWorklist(MachineInstr *SCCUseInst,
178 SIInstrWorklist &Worklist) const;
179
180 const TargetRegisterClass *
181 getDestEquivalentVGPRClass(const MachineInstr &Inst) const;
182
183 bool checkInstOffsetsDoNotOverlap(const MachineInstr &MIa,
184 const MachineInstr &MIb) const;
185
186 Register findUsedSGPR(const MachineInstr &MI, int OpIndices[3]) const;
187
188 bool verifyCopy(const MachineInstr &MI, const MachineRegisterInfo &MRI,
189 StringRef &ErrInfo) const;
190
191 bool resultDependsOnExec(const MachineInstr &MI) const;
192
193protected:
194 /// If the specific machine instruction is a instruction that moves/copies
195 /// value from one register to another register return destination and source
196 /// registers as machine operands.
197 std::optional<DestSourcePair>
198 isCopyInstrImpl(const MachineInstr &MI) const override;
199
201 AMDGPU::OpName Src0OpName, MachineOperand &Src1,
202 AMDGPU::OpName Src1OpName) const;
203 bool isLegalToSwap(const MachineInstr &MI, unsigned fromIdx,
204 unsigned toIdx) const;
206 unsigned OpIdx0,
207 unsigned OpIdx1) const override;
208
209public:
211 MO_MASK = 0xf,
212
214 // MO_GOTPCREL -> symbol@GOTPCREL -> R_AMDGPU_GOTPCREL.
216 // MO_GOTPCREL32_LO -> symbol@gotpcrel32@lo -> R_AMDGPU_GOTPCREL32_LO.
219 // MO_GOTPCREL32_HI -> symbol@gotpcrel32@hi -> R_AMDGPU_GOTPCREL32_HI.
221 // MO_GOTPCREL64 -> symbol@GOTPCREL -> R_AMDGPU_GOTPCREL.
223 // MO_REL32_LO -> symbol@rel32@lo -> R_AMDGPU_REL32_LO.
226 // MO_REL32_HI -> symbol@rel32@hi -> R_AMDGPU_REL32_HI.
229
231
235 };
236
237 explicit SIInstrInfo(const GCNSubtarget &ST);
238
240 return RI;
241 }
242
243 const GCNSubtarget &getSubtarget() const {
244 return ST;
245 }
246
247 bool isReMaterializableImpl(const MachineInstr &MI) const override;
248
249 bool isIgnorableUse(const MachineOperand &MO) const override;
250
251 bool isSafeToSink(MachineInstr &MI, MachineBasicBlock *SuccToSinkTo,
252 MachineCycleInfo *CI) const override;
253
254 bool areLoadsFromSameBasePtr(SDNode *Load0, SDNode *Load1, int64_t &Offset0,
255 int64_t &Offset1) const override;
256
257 bool isGlobalMemoryObject(const MachineInstr *MI) const override;
258
260 const MachineInstr &LdSt,
262 bool &OffsetIsScalable, LocationSize &Width,
263 const TargetRegisterInfo *TRI) const final;
264
266 int64_t Offset1, bool OffsetIsScalable1,
268 int64_t Offset2, bool OffsetIsScalable2,
269 unsigned ClusterSize,
270 unsigned NumBytes) const override;
271
272 bool shouldScheduleLoadsNear(SDNode *Load0, SDNode *Load1, int64_t Offset0,
273 int64_t Offset1, unsigned NumLoads) const override;
274
276 const DebugLoc &DL, Register DestReg, Register SrcReg,
277 bool KillSrc, bool RenamableDest = false,
278 bool RenamableSrc = false) const override;
279
281 unsigned Size) const;
282
285 Register SrcReg, int Value) const;
286
289 Register SrcReg, int Value) const;
290
292 int64_t &ImmVal) const override;
293
295 const TargetRegisterClass *RC,
296 unsigned Size,
297 const SIMachineFunctionInfo &MFI) const;
298 unsigned
300 unsigned Size,
301 const SIMachineFunctionInfo &MFI) const;
302
305 bool isKill, int FrameIndex, const TargetRegisterClass *RC,
306 const TargetRegisterInfo *TRI, Register VReg,
307 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
308
311 int FrameIndex, const TargetRegisterClass *RC,
312 const TargetRegisterInfo *TRI, Register VReg,
313 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
314
315 bool expandPostRAPseudo(MachineInstr &MI) const override;
316
318 Register DestReg, unsigned SubIdx,
319 const MachineInstr &Orig,
320 const TargetRegisterInfo &TRI) const override;
321
322 // Splits a V_MOV_B64_DPP_PSEUDO opcode into a pair of v_mov_b32_dpp
323 // instructions. Returns a pair of generated instructions.
324 // Can split either post-RA with physical registers or pre-RA with
325 // virtual registers. In latter case IR needs to be in SSA form and
326 // and a REG_SEQUENCE is produced to define original register.
327 std::pair<MachineInstr*, MachineInstr*>
329
330 // Returns an opcode that can be used to move a value to a \p DstRC
331 // register. If there is no hardware instruction that can store to \p
332 // DstRC, then AMDGPU::COPY is returned.
333 unsigned getMovOpcode(const TargetRegisterClass *DstRC) const;
334
335 const MCInstrDesc &getIndirectRegWriteMovRelPseudo(unsigned VecSize,
336 unsigned EltSize,
337 bool IsSGPR) const;
338
339 const MCInstrDesc &getIndirectGPRIDXPseudo(unsigned VecSize,
340 bool IsIndirectSrc) const;
342 int commuteOpcode(unsigned Opc) const;
343
345 inline int commuteOpcode(const MachineInstr &MI) const {
346 return commuteOpcode(MI.getOpcode());
347 }
348
349 bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx0,
350 unsigned &SrcOpIdx1) const override;
351
352 bool findCommutedOpIndices(const MCInstrDesc &Desc, unsigned &SrcOpIdx0,
353 unsigned &SrcOpIdx1) const;
354
355 bool isBranchOffsetInRange(unsigned BranchOpc,
356 int64_t BrOffset) const override;
357
358 MachineBasicBlock *getBranchDestBlock(const MachineInstr &MI) const override;
359
360 /// Return whether the block terminate with divergent branch.
361 /// Note this only work before lowering the pseudo control flow instructions.
362 bool hasDivergentBranch(const MachineBasicBlock *MBB) const;
363
365 MachineBasicBlock &NewDestBB,
366 MachineBasicBlock &RestoreBB, const DebugLoc &DL,
367 int64_t BrOffset, RegScavenger *RS) const override;
368
372 MachineBasicBlock *&FBB,
374 bool AllowModify) const;
375
377 MachineBasicBlock *&FBB,
379 bool AllowModify = false) const override;
380
382 int *BytesRemoved = nullptr) const override;
383
386 const DebugLoc &DL,
387 int *BytesAdded = nullptr) const override;
388
390 SmallVectorImpl<MachineOperand> &Cond) const override;
391
394 Register TrueReg, Register FalseReg, int &CondCycles,
395 int &TrueCycles, int &FalseCycles) const override;
396
400 Register TrueReg, Register FalseReg) const override;
401
405 Register TrueReg, Register FalseReg) const;
406
407 bool analyzeCompare(const MachineInstr &MI, Register &SrcReg,
408 Register &SrcReg2, int64_t &CmpMask,
409 int64_t &CmpValue) const override;
410
411 bool optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg,
412 Register SrcReg2, int64_t CmpMask, int64_t CmpValue,
413 const MachineRegisterInfo *MRI) const override;
414
415 bool
417 const MachineInstr &MIb) const override;
418
419 static bool isFoldableCopy(const MachineInstr &MI);
420 static unsigned getFoldableCopySrcIdx(const MachineInstr &MI);
421
422 void removeModOperands(MachineInstr &MI) const;
423
424 /// Return the extracted immediate value in a subregister use from a constant
425 /// materialized in a super register.
426 ///
427 /// e.g. %imm = S_MOV_B64 K[0:63]
428 /// USE %imm.sub1
429 /// This will return K[32:63]
430 static std::optional<int64_t> extractSubregFromImm(int64_t ImmVal,
431 unsigned SubRegIndex);
432
434 MachineRegisterInfo *MRI) const final;
435
436 unsigned getMachineCSELookAheadLimit() const override { return 500; }
437
439 LiveIntervals *LIS) const override;
440
442 const MachineBasicBlock *MBB,
443 const MachineFunction &MF) const override;
444
445 static bool isSALU(const MachineInstr &MI) {
446 return MI.getDesc().TSFlags & SIInstrFlags::SALU;
447 }
448
449 bool isSALU(uint16_t Opcode) const {
450 return get(Opcode).TSFlags & SIInstrFlags::SALU;
451 }
452
453 static bool isVALU(const MachineInstr &MI) {
454 return MI.getDesc().TSFlags & SIInstrFlags::VALU;
455 }
456
457 bool isVALU(uint16_t Opcode) const {
458 return get(Opcode).TSFlags & SIInstrFlags::VALU;
459 }
460
461 static bool isImage(const MachineInstr &MI) {
462 return isMIMG(MI) || isVSAMPLE(MI) || isVIMAGE(MI);
463 }
464
465 bool isImage(uint16_t Opcode) const {
466 return isMIMG(Opcode) || isVSAMPLE(Opcode) || isVIMAGE(Opcode);
467 }
468
469 static bool isVMEM(const MachineInstr &MI) {
470 return isMUBUF(MI) || isMTBUF(MI) || isImage(MI) || isFLAT(MI);
471 }
472
473 bool isVMEM(uint16_t Opcode) const {
474 return isMUBUF(Opcode) || isMTBUF(Opcode) || isImage(Opcode);
475 }
476
477 static bool isSOP1(const MachineInstr &MI) {
478 return MI.getDesc().TSFlags & SIInstrFlags::SOP1;
479 }
480
481 bool isSOP1(uint16_t Opcode) const {
482 return get(Opcode).TSFlags & SIInstrFlags::SOP1;
483 }
484
485 static bool isSOP2(const MachineInstr &MI) {
486 return MI.getDesc().TSFlags & SIInstrFlags::SOP2;
487 }
488
489 bool isSOP2(uint16_t Opcode) const {
490 return get(Opcode).TSFlags & SIInstrFlags::SOP2;
491 }
492
493 static bool isSOPC(const MachineInstr &MI) {
494 return MI.getDesc().TSFlags & SIInstrFlags::SOPC;
495 }
496
497 bool isSOPC(uint16_t Opcode) const {
498 return get(Opcode).TSFlags & SIInstrFlags::SOPC;
499 }
500
501 static bool isSOPK(const MachineInstr &MI) {
502 return MI.getDesc().TSFlags & SIInstrFlags::SOPK;
503 }
504
505 bool isSOPK(uint16_t Opcode) const {
506 return get(Opcode).TSFlags & SIInstrFlags::SOPK;
507 }
508
509 static bool isSOPP(const MachineInstr &MI) {
510 return MI.getDesc().TSFlags & SIInstrFlags::SOPP;
511 }
512
513 bool isSOPP(uint16_t Opcode) const {
514 return get(Opcode).TSFlags & SIInstrFlags::SOPP;
515 }
516
517 static bool isPacked(const MachineInstr &MI) {
518 return MI.getDesc().TSFlags & SIInstrFlags::IsPacked;
519 }
520
521 bool isPacked(uint16_t Opcode) const {
522 return get(Opcode).TSFlags & SIInstrFlags::IsPacked;
523 }
524
525 static bool isVOP1(const MachineInstr &MI) {
526 return MI.getDesc().TSFlags & SIInstrFlags::VOP1;
527 }
528
529 bool isVOP1(uint16_t Opcode) const {
530 return get(Opcode).TSFlags & SIInstrFlags::VOP1;
531 }
532
533 static bool isVOP2(const MachineInstr &MI) {
534 return MI.getDesc().TSFlags & SIInstrFlags::VOP2;
535 }
536
537 bool isVOP2(uint16_t Opcode) const {
538 return get(Opcode).TSFlags & SIInstrFlags::VOP2;
539 }
540
541 static bool isVOP3(const MCInstrDesc &Desc) {
542 return Desc.TSFlags & SIInstrFlags::VOP3;
543 }
544
545 static bool isVOP3(const MachineInstr &MI) { return isVOP3(MI.getDesc()); }
546
547 bool isVOP3(uint16_t Opcode) const { return isVOP3(get(Opcode)); }
548
549 static bool isSDWA(const MachineInstr &MI) {
550 return MI.getDesc().TSFlags & SIInstrFlags::SDWA;
551 }
552
553 bool isSDWA(uint16_t Opcode) const {
554 return get(Opcode).TSFlags & SIInstrFlags::SDWA;
555 }
556
557 static bool isVOPC(const MachineInstr &MI) {
558 return MI.getDesc().TSFlags & SIInstrFlags::VOPC;
559 }
560
561 bool isVOPC(uint16_t Opcode) const {
562 return get(Opcode).TSFlags & SIInstrFlags::VOPC;
563 }
564
565 static bool isMUBUF(const MachineInstr &MI) {
566 return MI.getDesc().TSFlags & SIInstrFlags::MUBUF;
567 }
568
569 bool isMUBUF(uint16_t Opcode) const {
570 return get(Opcode).TSFlags & SIInstrFlags::MUBUF;
571 }
572
573 static bool isMTBUF(const MachineInstr &MI) {
574 return MI.getDesc().TSFlags & SIInstrFlags::MTBUF;
575 }
576
577 bool isMTBUF(uint16_t Opcode) const {
578 return get(Opcode).TSFlags & SIInstrFlags::MTBUF;
579 }
580
581 static bool isSMRD(const MachineInstr &MI) {
582 return MI.getDesc().TSFlags & SIInstrFlags::SMRD;
583 }
584
585 bool isSMRD(uint16_t Opcode) const {
586 return get(Opcode).TSFlags & SIInstrFlags::SMRD;
587 }
588
589 bool isBufferSMRD(const MachineInstr &MI) const;
590
591 static bool isDS(const MachineInstr &MI) {
592 return MI.getDesc().TSFlags & SIInstrFlags::DS;
593 }
594
595 bool isDS(uint16_t Opcode) const {
596 return get(Opcode).TSFlags & SIInstrFlags::DS;
597 }
598
599 static bool isLDSDMA(const MachineInstr &MI) {
600 return isVALU(MI) && (isMUBUF(MI) || isFLAT(MI));
601 }
602
603 bool isLDSDMA(uint16_t Opcode) {
604 return isVALU(Opcode) && (isMUBUF(Opcode) || isFLAT(Opcode));
605 }
606
607 static bool isGWS(const MachineInstr &MI) {
608 return MI.getDesc().TSFlags & SIInstrFlags::GWS;
609 }
610
611 bool isGWS(uint16_t Opcode) const {
612 return get(Opcode).TSFlags & SIInstrFlags::GWS;
613 }
614
615 bool isAlwaysGDS(uint16_t Opcode) const;
616
617 static bool isMIMG(const MachineInstr &MI) {
618 return MI.getDesc().TSFlags & SIInstrFlags::MIMG;
619 }
620
621 bool isMIMG(uint16_t Opcode) const {
622 return get(Opcode).TSFlags & SIInstrFlags::MIMG;
623 }
624
625 static bool isVIMAGE(const MachineInstr &MI) {
626 return MI.getDesc().TSFlags & SIInstrFlags::VIMAGE;
627 }
628
629 bool isVIMAGE(uint16_t Opcode) const {
630 return get(Opcode).TSFlags & SIInstrFlags::VIMAGE;
631 }
632
633 static bool isVSAMPLE(const MachineInstr &MI) {
634 return MI.getDesc().TSFlags & SIInstrFlags::VSAMPLE;
635 }
636
637 bool isVSAMPLE(uint16_t Opcode) const {
638 return get(Opcode).TSFlags & SIInstrFlags::VSAMPLE;
639 }
640
641 static bool isGather4(const MachineInstr &MI) {
642 return MI.getDesc().TSFlags & SIInstrFlags::Gather4;
643 }
644
645 bool isGather4(uint16_t Opcode) const {
646 return get(Opcode).TSFlags & SIInstrFlags::Gather4;
647 }
648
649 static bool isFLAT(const MachineInstr &MI) {
650 return MI.getDesc().TSFlags & SIInstrFlags::FLAT;
651 }
652
653 // Is a FLAT encoded instruction which accesses a specific segment,
654 // i.e. global_* or scratch_*.
656 auto Flags = MI.getDesc().TSFlags;
658 }
659
660 bool isSegmentSpecificFLAT(uint16_t Opcode) const {
661 auto Flags = get(Opcode).TSFlags;
663 }
664
665 static bool isFLATGlobal(const MachineInstr &MI) {
666 return MI.getDesc().TSFlags & SIInstrFlags::FlatGlobal;
667 }
668
669 bool isFLATGlobal(uint16_t Opcode) const {
670 return get(Opcode).TSFlags & SIInstrFlags::FlatGlobal;
671 }
672
673 static bool isFLATScratch(const MachineInstr &MI) {
674 return MI.getDesc().TSFlags & SIInstrFlags::FlatScratch;
675 }
676
677 bool isFLATScratch(uint16_t Opcode) const {
678 return get(Opcode).TSFlags & SIInstrFlags::FlatScratch;
679 }
680
681 // Any FLAT encoded instruction, including global_* and scratch_*.
682 bool isFLAT(uint16_t Opcode) const {
683 return get(Opcode).TSFlags & SIInstrFlags::FLAT;
684 }
685
686 /// \returns true for SCRATCH_ instructions, or FLAT_ instructions with
687 /// SCRATCH_ memory operands.
688 /// Conservatively correct; will return true if \p MI cannot be proven
689 /// to not hit scratch.
691
692 /// \returns true for FLAT instructions that can access VMEM.
693 bool mayAccessVMEMThroughFlat(const MachineInstr &MI) const;
694
695 /// \returns true for FLAT instructions that can access LDS.
696 bool mayAccessLDSThroughFlat(const MachineInstr &MI) const;
697
698 static bool isBlockLoadStore(uint16_t Opcode) {
699 switch (Opcode) {
700 case AMDGPU::SI_BLOCK_SPILL_V1024_SAVE:
701 case AMDGPU::SI_BLOCK_SPILL_V1024_RESTORE:
702 case AMDGPU::SCRATCH_STORE_BLOCK_SADDR:
703 case AMDGPU::SCRATCH_LOAD_BLOCK_SADDR:
704 case AMDGPU::SCRATCH_STORE_BLOCK_SVS:
705 case AMDGPU::SCRATCH_LOAD_BLOCK_SVS:
706 return true;
707 default:
708 return false;
709 }
710 }
711
712 static bool isEXP(const MachineInstr &MI) {
713 return MI.getDesc().TSFlags & SIInstrFlags::EXP;
714 }
715
717 if (!isEXP(MI))
718 return false;
719 unsigned Target = MI.getOperand(0).getImm();
722 }
723
724 bool isEXP(uint16_t Opcode) const {
725 return get(Opcode).TSFlags & SIInstrFlags::EXP;
726 }
727
728 static bool isAtomicNoRet(const MachineInstr &MI) {
729 return MI.getDesc().TSFlags & SIInstrFlags::IsAtomicNoRet;
730 }
731
732 bool isAtomicNoRet(uint16_t Opcode) const {
733 return get(Opcode).TSFlags & SIInstrFlags::IsAtomicNoRet;
734 }
735
736 static bool isAtomicRet(const MachineInstr &MI) {
737 return MI.getDesc().TSFlags & SIInstrFlags::IsAtomicRet;
738 }
739
740 bool isAtomicRet(uint16_t Opcode) const {
741 return get(Opcode).TSFlags & SIInstrFlags::IsAtomicRet;
742 }
743
744 static bool isAtomic(const MachineInstr &MI) {
745 return MI.getDesc().TSFlags & (SIInstrFlags::IsAtomicRet |
747 }
748
749 bool isAtomic(uint16_t Opcode) const {
750 return get(Opcode).TSFlags & (SIInstrFlags::IsAtomicRet |
752 }
753
755 return isLDSDMA(MI) && MI.getOpcode() != AMDGPU::BUFFER_STORE_LDS_DWORD;
756 }
757
758 static bool isSBarrierSCCWrite(unsigned Opcode) {
759 return Opcode == AMDGPU::S_BARRIER_LEAVE ||
760 Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_IMM ||
761 Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_M0;
762 }
763
764 static bool isCBranchVCCZRead(const MachineInstr &MI) {
765 unsigned Opc = MI.getOpcode();
766 return (Opc == AMDGPU::S_CBRANCH_VCCNZ || Opc == AMDGPU::S_CBRANCH_VCCZ) &&
767 !MI.getOperand(1).isUndef();
768 }
769
770 static bool isWQM(const MachineInstr &MI) {
771 return MI.getDesc().TSFlags & SIInstrFlags::WQM;
772 }
773
774 bool isWQM(uint16_t Opcode) const {
775 return get(Opcode).TSFlags & SIInstrFlags::WQM;
776 }
777
778 static bool isDisableWQM(const MachineInstr &MI) {
779 return MI.getDesc().TSFlags & SIInstrFlags::DisableWQM;
780 }
781
782 bool isDisableWQM(uint16_t Opcode) const {
783 return get(Opcode).TSFlags & SIInstrFlags::DisableWQM;
784 }
785
786 // SI_SPILL_S32_TO_VGPR and SI_RESTORE_S32_FROM_VGPR form a special case of
787 // SGPRs spilling to VGPRs which are SGPR spills but from VALU instructions
788 // therefore we need an explicit check for them since just checking if the
789 // Spill bit is set and what instruction type it came from misclassifies
790 // them.
791 static bool isVGPRSpill(const MachineInstr &MI) {
792 return MI.getOpcode() != AMDGPU::SI_SPILL_S32_TO_VGPR &&
793 MI.getOpcode() != AMDGPU::SI_RESTORE_S32_FROM_VGPR &&
794 (isSpill(MI) && isVALU(MI));
795 }
796
797 bool isVGPRSpill(uint16_t Opcode) const {
798 return Opcode != AMDGPU::SI_SPILL_S32_TO_VGPR &&
799 Opcode != AMDGPU::SI_RESTORE_S32_FROM_VGPR &&
800 (isSpill(Opcode) && isVALU(Opcode));
801 }
802
803 static bool isSGPRSpill(const MachineInstr &MI) {
804 return MI.getOpcode() == AMDGPU::SI_SPILL_S32_TO_VGPR ||
805 MI.getOpcode() == AMDGPU::SI_RESTORE_S32_FROM_VGPR ||
806 (isSpill(MI) && isSALU(MI));
807 }
808
809 bool isSGPRSpill(uint16_t Opcode) const {
810 return Opcode == AMDGPU::SI_SPILL_S32_TO_VGPR ||
811 Opcode == AMDGPU::SI_RESTORE_S32_FROM_VGPR ||
812 (isSpill(Opcode) && isSALU(Opcode));
813 }
814
815 bool isSpill(uint16_t Opcode) const {
816 return get(Opcode).TSFlags & SIInstrFlags::Spill;
817 }
818
819 static bool isSpill(const MCInstrDesc &Desc) {
820 return Desc.TSFlags & SIInstrFlags::Spill;
821 }
822
823 static bool isSpill(const MachineInstr &MI) { return isSpill(MI.getDesc()); }
824
825 static bool isWWMRegSpillOpcode(uint16_t Opcode) {
826 return Opcode == AMDGPU::SI_SPILL_WWM_V32_SAVE ||
827 Opcode == AMDGPU::SI_SPILL_WWM_AV32_SAVE ||
828 Opcode == AMDGPU::SI_SPILL_WWM_V32_RESTORE ||
829 Opcode == AMDGPU::SI_SPILL_WWM_AV32_RESTORE;
830 }
831
832 static bool isChainCallOpcode(uint64_t Opcode) {
833 return Opcode == AMDGPU::SI_CS_CHAIN_TC_W32 ||
834 Opcode == AMDGPU::SI_CS_CHAIN_TC_W64;
835 }
836
837 static bool isDPP(const MachineInstr &MI) {
838 return MI.getDesc().TSFlags & SIInstrFlags::DPP;
839 }
840
841 bool isDPP(uint16_t Opcode) const {
842 return get(Opcode).TSFlags & SIInstrFlags::DPP;
843 }
844
845 static bool isTRANS(const MachineInstr &MI) {
846 return MI.getDesc().TSFlags & SIInstrFlags::TRANS;
847 }
848
849 bool isTRANS(uint16_t Opcode) const {
850 return get(Opcode).TSFlags & SIInstrFlags::TRANS;
851 }
852
853 static bool isVOP3P(const MachineInstr &MI) {
854 return MI.getDesc().TSFlags & SIInstrFlags::VOP3P;
855 }
856
857 bool isVOP3P(uint16_t Opcode) const {
858 return get(Opcode).TSFlags & SIInstrFlags::VOP3P;
859 }
860
861 static bool isVINTRP(const MachineInstr &MI) {
862 return MI.getDesc().TSFlags & SIInstrFlags::VINTRP;
863 }
864
865 bool isVINTRP(uint16_t Opcode) const {
866 return get(Opcode).TSFlags & SIInstrFlags::VINTRP;
867 }
868
869 static bool isMAI(const MCInstrDesc &Desc) {
870 return Desc.TSFlags & SIInstrFlags::IsMAI;
871 }
872
873 static bool isMAI(const MachineInstr &MI) { return isMAI(MI.getDesc()); }
874
875 bool isMAI(uint16_t Opcode) const { return isMAI(get(Opcode)); }
876
877 static bool isMFMA(const MachineInstr &MI) {
878 return isMAI(MI) && MI.getOpcode() != AMDGPU::V_ACCVGPR_WRITE_B32_e64 &&
879 MI.getOpcode() != AMDGPU::V_ACCVGPR_READ_B32_e64;
880 }
881
882 static bool isDOT(const MachineInstr &MI) {
883 return MI.getDesc().TSFlags & SIInstrFlags::IsDOT;
884 }
885
886 static bool isWMMA(const MachineInstr &MI) {
887 return MI.getDesc().TSFlags & SIInstrFlags::IsWMMA;
888 }
889
890 bool isWMMA(uint16_t Opcode) const {
891 return get(Opcode).TSFlags & SIInstrFlags::IsWMMA;
892 }
893
894 static bool isMFMAorWMMA(const MachineInstr &MI) {
895 return isMFMA(MI) || isWMMA(MI) || isSWMMAC(MI);
896 }
897
898 static bool isSWMMAC(const MachineInstr &MI) {
899 return MI.getDesc().TSFlags & SIInstrFlags::IsSWMMAC;
900 }
901
902 bool isSWMMAC(uint16_t Opcode) const {
903 return get(Opcode).TSFlags & SIInstrFlags::IsSWMMAC;
904 }
905
906 bool isDOT(uint16_t Opcode) const {
907 return get(Opcode).TSFlags & SIInstrFlags::IsDOT;
908 }
909
910 bool isXDLWMMA(const MachineInstr &MI) const;
911
912 bool isXDL(const MachineInstr &MI) const;
913
914 static bool isDGEMM(unsigned Opcode) { return AMDGPU::getMAIIsDGEMM(Opcode); }
915
916 static bool isLDSDIR(const MachineInstr &MI) {
917 return MI.getDesc().TSFlags & SIInstrFlags::LDSDIR;
918 }
919
920 bool isLDSDIR(uint16_t Opcode) const {
921 return get(Opcode).TSFlags & SIInstrFlags::LDSDIR;
922 }
923
924 static bool isVINTERP(const MachineInstr &MI) {
925 return MI.getDesc().TSFlags & SIInstrFlags::VINTERP;
926 }
927
928 bool isVINTERP(uint16_t Opcode) const {
929 return get(Opcode).TSFlags & SIInstrFlags::VINTERP;
930 }
931
932 static bool isScalarUnit(const MachineInstr &MI) {
933 return MI.getDesc().TSFlags & (SIInstrFlags::SALU | SIInstrFlags::SMRD);
934 }
935
936 static bool usesVM_CNT(const MachineInstr &MI) {
937 return MI.getDesc().TSFlags & SIInstrFlags::VM_CNT;
938 }
939
940 static bool usesLGKM_CNT(const MachineInstr &MI) {
941 return MI.getDesc().TSFlags & SIInstrFlags::LGKM_CNT;
942 }
943
944 // Most sopk treat the immediate as a signed 16-bit, however some
945 // use it as unsigned.
946 static bool sopkIsZext(unsigned Opcode) {
947 return Opcode == AMDGPU::S_CMPK_EQ_U32 || Opcode == AMDGPU::S_CMPK_LG_U32 ||
948 Opcode == AMDGPU::S_CMPK_GT_U32 || Opcode == AMDGPU::S_CMPK_GE_U32 ||
949 Opcode == AMDGPU::S_CMPK_LT_U32 || Opcode == AMDGPU::S_CMPK_LE_U32 ||
950 Opcode == AMDGPU::S_GETREG_B32 ||
951 Opcode == AMDGPU::S_GETREG_B32_const;
952 }
953
954 /// \returns true if this is an s_store_dword* instruction. This is more
955 /// specific than isSMEM && mayStore.
956 static bool isScalarStore(const MachineInstr &MI) {
957 return MI.getDesc().TSFlags & SIInstrFlags::SCALAR_STORE;
958 }
959
960 bool isScalarStore(uint16_t Opcode) const {
961 return get(Opcode).TSFlags & SIInstrFlags::SCALAR_STORE;
962 }
963
964 static bool isFixedSize(const MachineInstr &MI) {
965 return MI.getDesc().TSFlags & SIInstrFlags::FIXED_SIZE;
966 }
967
968 bool isFixedSize(uint16_t Opcode) const {
969 return get(Opcode).TSFlags & SIInstrFlags::FIXED_SIZE;
970 }
971
972 static bool hasFPClamp(const MachineInstr &MI) {
973 return MI.getDesc().TSFlags & SIInstrFlags::FPClamp;
974 }
975
976 bool hasFPClamp(uint16_t Opcode) const {
977 return get(Opcode).TSFlags & SIInstrFlags::FPClamp;
978 }
979
980 static bool hasIntClamp(const MachineInstr &MI) {
981 return MI.getDesc().TSFlags & SIInstrFlags::IntClamp;
982 }
983
985 const uint64_t ClampFlags = SIInstrFlags::FPClamp |
989 return MI.getDesc().TSFlags & ClampFlags;
990 }
991
992 static bool usesFPDPRounding(const MachineInstr &MI) {
993 return MI.getDesc().TSFlags & SIInstrFlags::FPDPRounding;
994 }
995
996 bool usesFPDPRounding(uint16_t Opcode) const {
997 return get(Opcode).TSFlags & SIInstrFlags::FPDPRounding;
998 }
999
1000 static bool isFPAtomic(const MachineInstr &MI) {
1001 return MI.getDesc().TSFlags & SIInstrFlags::FPAtomic;
1002 }
1003
1004 bool isFPAtomic(uint16_t Opcode) const {
1005 return get(Opcode).TSFlags & SIInstrFlags::FPAtomic;
1006 }
1007
1008 static bool isNeverUniform(const MachineInstr &MI) {
1009 return MI.getDesc().TSFlags & SIInstrFlags::IsNeverUniform;
1010 }
1011
1012 // Check to see if opcode is for a barrier start. Pre gfx12 this is just the
1013 // S_BARRIER, but after support for S_BARRIER_SIGNAL* / S_BARRIER_WAIT we want
1014 // to check for the barrier start (S_BARRIER_SIGNAL*)
1015 bool isBarrierStart(unsigned Opcode) const {
1016 return Opcode == AMDGPU::S_BARRIER ||
1017 Opcode == AMDGPU::S_BARRIER_SIGNAL_M0 ||
1018 Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_M0 ||
1019 Opcode == AMDGPU::S_BARRIER_SIGNAL_IMM ||
1020 Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_IMM;
1021 }
1022
1023 bool isBarrier(unsigned Opcode) const {
1024 return isBarrierStart(Opcode) || Opcode == AMDGPU::S_BARRIER_WAIT ||
1025 Opcode == AMDGPU::S_BARRIER_INIT_M0 ||
1026 Opcode == AMDGPU::S_BARRIER_INIT_IMM ||
1027 Opcode == AMDGPU::S_BARRIER_JOIN_IMM ||
1028 Opcode == AMDGPU::S_BARRIER_LEAVE || Opcode == AMDGPU::DS_GWS_INIT ||
1029 Opcode == AMDGPU::DS_GWS_BARRIER;
1030 }
1031
1032 static bool isGFX12CacheInvOrWBInst(unsigned Opc) {
1033 return Opc == AMDGPU::GLOBAL_INV || Opc == AMDGPU::GLOBAL_WB ||
1034 Opc == AMDGPU::GLOBAL_WBINV;
1035 }
1036
1037 static bool isF16PseudoScalarTrans(unsigned Opcode) {
1038 return Opcode == AMDGPU::V_S_EXP_F16_e64 ||
1039 Opcode == AMDGPU::V_S_LOG_F16_e64 ||
1040 Opcode == AMDGPU::V_S_RCP_F16_e64 ||
1041 Opcode == AMDGPU::V_S_RSQ_F16_e64 ||
1042 Opcode == AMDGPU::V_S_SQRT_F16_e64;
1043 }
1044
1046 return MI.getDesc().TSFlags & SIInstrFlags::TiedSourceNotRead;
1047 }
1048
1049 bool doesNotReadTiedSource(uint16_t Opcode) const {
1050 return get(Opcode).TSFlags & SIInstrFlags::TiedSourceNotRead;
1051 }
1052
1053 bool isIGLP(unsigned Opcode) const {
1054 return Opcode == AMDGPU::SCHED_BARRIER ||
1055 Opcode == AMDGPU::SCHED_GROUP_BARRIER || Opcode == AMDGPU::IGLP_OPT;
1056 }
1057
1058 bool isIGLP(const MachineInstr &MI) const { return isIGLP(MI.getOpcode()); }
1059
1060 // Return true if the instruction is mutually exclusive with all non-IGLP DAG
1061 // mutations, requiring all other mutations to be disabled.
1062 bool isIGLPMutationOnly(unsigned Opcode) const {
1063 return Opcode == AMDGPU::SCHED_GROUP_BARRIER || Opcode == AMDGPU::IGLP_OPT;
1064 }
1065
1066 static unsigned getNonSoftWaitcntOpcode(unsigned Opcode) {
1067 switch (Opcode) {
1068 case AMDGPU::S_WAITCNT_soft:
1069 return AMDGPU::S_WAITCNT;
1070 case AMDGPU::S_WAITCNT_VSCNT_soft:
1071 return AMDGPU::S_WAITCNT_VSCNT;
1072 case AMDGPU::S_WAIT_LOADCNT_soft:
1073 return AMDGPU::S_WAIT_LOADCNT;
1074 case AMDGPU::S_WAIT_STORECNT_soft:
1075 return AMDGPU::S_WAIT_STORECNT;
1076 case AMDGPU::S_WAIT_SAMPLECNT_soft:
1077 return AMDGPU::S_WAIT_SAMPLECNT;
1078 case AMDGPU::S_WAIT_BVHCNT_soft:
1079 return AMDGPU::S_WAIT_BVHCNT;
1080 case AMDGPU::S_WAIT_DSCNT_soft:
1081 return AMDGPU::S_WAIT_DSCNT;
1082 case AMDGPU::S_WAIT_KMCNT_soft:
1083 return AMDGPU::S_WAIT_KMCNT;
1084 case AMDGPU::S_WAIT_XCNT_soft:
1085 return AMDGPU::S_WAIT_XCNT;
1086 default:
1087 return Opcode;
1088 }
1089 }
1090
1091 static bool isWaitcnt(unsigned Opcode) {
1092 switch (getNonSoftWaitcntOpcode(Opcode)) {
1093 case AMDGPU::S_WAITCNT:
1094 case AMDGPU::S_WAITCNT_VSCNT:
1095 case AMDGPU::S_WAITCNT_VMCNT:
1096 case AMDGPU::S_WAITCNT_EXPCNT:
1097 case AMDGPU::S_WAITCNT_LGKMCNT:
1098 case AMDGPU::S_WAIT_LOADCNT:
1099 case AMDGPU::S_WAIT_LOADCNT_DSCNT:
1100 case AMDGPU::S_WAIT_STORECNT:
1101 case AMDGPU::S_WAIT_STORECNT_DSCNT:
1102 case AMDGPU::S_WAIT_SAMPLECNT:
1103 case AMDGPU::S_WAIT_BVHCNT:
1104 case AMDGPU::S_WAIT_EXPCNT:
1105 case AMDGPU::S_WAIT_DSCNT:
1106 case AMDGPU::S_WAIT_KMCNT:
1107 case AMDGPU::S_WAIT_IDLE:
1108 return true;
1109 default:
1110 return false;
1111 }
1112 }
1113
1114 bool isVGPRCopy(const MachineInstr &MI) const {
1115 assert(isCopyInstr(MI));
1116 Register Dest = MI.getOperand(0).getReg();
1117 const MachineFunction &MF = *MI.getParent()->getParent();
1118 const MachineRegisterInfo &MRI = MF.getRegInfo();
1119 return !RI.isSGPRReg(MRI, Dest);
1120 }
1121
1122 bool hasVGPRUses(const MachineInstr &MI) const {
1123 const MachineFunction &MF = *MI.getParent()->getParent();
1124 const MachineRegisterInfo &MRI = MF.getRegInfo();
1125 return llvm::any_of(MI.explicit_uses(),
1126 [&MRI, this](const MachineOperand &MO) {
1127 return MO.isReg() && RI.isVGPR(MRI, MO.getReg());});
1128 }
1129
1130 /// Return true if the instruction modifies the mode register.q
1131 static bool modifiesModeRegister(const MachineInstr &MI);
1132
1133 /// This function is used to determine if an instruction can be safely
1134 /// executed under EXEC = 0 without hardware error, indeterminate results,
1135 /// and/or visible effects on future vector execution or outside the shader.
1136 /// Note: as of 2024 the only use of this is SIPreEmitPeephole where it is
1137 /// used in removing branches over short EXEC = 0 sequences.
1138 /// As such it embeds certain assumptions which may not apply to every case
1139 /// of EXEC = 0 execution.
1141
1142 /// Returns true if the instruction could potentially depend on the value of
1143 /// exec. If false, exec dependencies may safely be ignored.
1144 bool mayReadEXEC(const MachineRegisterInfo &MRI, const MachineInstr &MI) const;
1145
1146 bool isInlineConstant(const APInt &Imm) const;
1147
1148 bool isInlineConstant(const APFloat &Imm) const;
1149
1150 // Returns true if this non-register operand definitely does not need to be
1151 // encoded as a 32-bit literal. Note that this function handles all kinds of
1152 // operands, not just immediates.
1153 //
1154 // Some operands like FrameIndexes could resolve to an inline immediate value
1155 // that will not require an additional 4-bytes; this function assumes that it
1156 // will.
1157 bool isInlineConstant(const MachineOperand &MO, uint8_t OperandType) const {
1158 if (!MO.isImm())
1159 return false;
1160 return isInlineConstant(MO.getImm(), OperandType);
1161 }
1162 bool isInlineConstant(int64_t ImmVal, uint8_t OperandType) const;
1163
1165 const MCOperandInfo &OpInfo) const {
1166 return isInlineConstant(MO, OpInfo.OperandType);
1167 }
1168
1169 /// \p returns true if \p UseMO is substituted with \p DefMO in \p MI it would
1170 /// be an inline immediate.
1172 const MachineOperand &UseMO,
1173 const MachineOperand &DefMO) const {
1174 assert(UseMO.getParent() == &MI);
1175 int OpIdx = UseMO.getOperandNo();
1176 if (OpIdx >= MI.getDesc().NumOperands)
1177 return false;
1178
1179 return isInlineConstant(DefMO, MI.getDesc().operands()[OpIdx]);
1180 }
1181
1182 /// \p returns true if the operand \p OpIdx in \p MI is a valid inline
1183 /// immediate.
1184 bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx) const {
1185 const MachineOperand &MO = MI.getOperand(OpIdx);
1186 return isInlineConstant(MO, MI.getDesc().operands()[OpIdx].OperandType);
1187 }
1188
1189 bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx,
1190 int64_t ImmVal) const {
1191 if (OpIdx >= MI.getDesc().NumOperands)
1192 return false;
1193
1194 if (isCopyInstr(MI)) {
1195 unsigned Size = getOpSize(MI, OpIdx);
1196 assert(Size == 8 || Size == 4);
1197
1198 uint8_t OpType = (Size == 8) ?
1200 return isInlineConstant(ImmVal, OpType);
1201 }
1202
1203 return isInlineConstant(ImmVal, MI.getDesc().operands()[OpIdx].OperandType);
1204 }
1205
1206 bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx,
1207 const MachineOperand &MO) const {
1208 return isInlineConstant(MI, OpIdx, MO.getImm());
1209 }
1210
1211 bool isInlineConstant(const MachineOperand &MO) const {
1212 return isInlineConstant(*MO.getParent(), MO.getOperandNo());
1213 }
1214
1215 bool isImmOperandLegal(const MCInstrDesc &InstDesc, unsigned OpNo,
1216 const MachineOperand &MO) const;
1217
1218 bool isLiteralOperandLegal(const MCInstrDesc &InstDesc,
1219 const MCOperandInfo &OpInfo) const;
1220
1221 bool isImmOperandLegal(const MCInstrDesc &InstDesc, unsigned OpNo,
1222 int64_t ImmVal) const;
1223
1224 bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo,
1225 const MachineOperand &MO) const {
1226 return isImmOperandLegal(MI.getDesc(), OpNo, MO);
1227 }
1228
1229 bool isNeverCoissue(MachineInstr &MI) const;
1230
1231 /// Check if this immediate value can be used for AV_MOV_B64_IMM_PSEUDO.
1232 bool isLegalAV64PseudoImm(uint64_t Imm) const;
1233
1234 /// Return true if this 64-bit VALU instruction has a 32-bit encoding.
1235 /// This function will return false if you pass it a 32-bit instruction.
1236 bool hasVALU32BitEncoding(unsigned Opcode) const;
1237
1238 bool physRegUsesConstantBus(const MachineOperand &Reg) const;
1240 const MachineRegisterInfo &MRI) const;
1241
1242 /// Returns true if this operand uses the constant bus.
1244 const MachineOperand &MO,
1245 const MCOperandInfo &OpInfo) const;
1246
1248 int OpIdx) const {
1249 return usesConstantBus(MRI, MI.getOperand(OpIdx),
1250 MI.getDesc().operands()[OpIdx]);
1251 }
1252
1253 /// Return true if this instruction has any modifiers.
1254 /// e.g. src[012]_mod, omod, clamp.
1255 bool hasModifiers(unsigned Opcode) const;
1256
1257 bool hasModifiersSet(const MachineInstr &MI, AMDGPU::OpName OpName) const;
1258 bool hasAnyModifiersSet(const MachineInstr &MI) const;
1259
1260 bool canShrink(const MachineInstr &MI,
1261 const MachineRegisterInfo &MRI) const;
1262
1264 unsigned NewOpcode) const;
1265
1266 bool verifyInstruction(const MachineInstr &MI,
1267 StringRef &ErrInfo) const override;
1268
1269 unsigned getVALUOp(const MachineInstr &MI) const;
1270
1273 const DebugLoc &DL, Register Reg, bool IsSCCLive,
1274 SlotIndexes *Indexes = nullptr) const;
1275
1278 Register Reg, SlotIndexes *Indexes = nullptr) const;
1279
1281
1282 /// Return the correct register class for \p OpNo. For target-specific
1283 /// instructions, this will return the register class that has been defined
1284 /// in tablegen. For generic instructions, like REG_SEQUENCE it will return
1285 /// the register class of its machine operand.
1286 /// to infer the correct register class base on the other operands.
1288 unsigned OpNo) const;
1289
1290 /// Return the size in bytes of the operand OpNo on the given
1291 // instruction opcode.
1292 unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const {
1293 const MCOperandInfo &OpInfo = get(Opcode).operands()[OpNo];
1294
1295 if (OpInfo.RegClass == -1) {
1296 // If this is an immediate operand, this must be a 32-bit literal.
1297 assert(OpInfo.OperandType == MCOI::OPERAND_IMMEDIATE);
1298 return 4;
1299 }
1300
1301 return RI.getRegSizeInBits(*RI.getRegClass(OpInfo.RegClass)) / 8;
1302 }
1303
1304 /// This form should usually be preferred since it handles operands
1305 /// with unknown register classes.
1306 unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const {
1307 const MachineOperand &MO = MI.getOperand(OpNo);
1308 if (MO.isReg()) {
1309 if (unsigned SubReg = MO.getSubReg()) {
1310 return RI.getSubRegIdxSize(SubReg) / 8;
1311 }
1312 }
1313 return RI.getRegSizeInBits(*getOpRegClass(MI, OpNo)) / 8;
1314 }
1315
1316 /// Legalize the \p OpIndex operand of this instruction by inserting
1317 /// a MOV. For example:
1318 /// ADD_I32_e32 VGPR0, 15
1319 /// to
1320 /// MOV VGPR1, 15
1321 /// ADD_I32_e32 VGPR0, VGPR1
1322 ///
1323 /// If the operand being legalized is a register, then a COPY will be used
1324 /// instead of MOV.
1325 void legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const;
1326
1327 /// Check if \p MO is a legal operand if it was the \p OpIdx Operand
1328 /// for \p MI.
1329 bool isOperandLegal(const MachineInstr &MI, unsigned OpIdx,
1330 const MachineOperand *MO = nullptr) const;
1331
1332 /// Check if \p MO would be a valid operand for the given operand
1333 /// definition \p OpInfo. Note this does not attempt to validate constant bus
1334 /// restrictions (e.g. literal constant usage).
1336 const MCOperandInfo &OpInfo,
1337 const MachineOperand &MO) const;
1338
1339 /// Check if \p MO (a register operand) is a legal register for the
1340 /// given operand description or operand index.
1341 /// The operand index version provide more legality checks
1343 const MCOperandInfo &OpInfo,
1344 const MachineOperand &MO) const;
1345 bool isLegalRegOperand(const MachineInstr &MI, unsigned OpIdx,
1346 const MachineOperand &MO) const;
1347
1348 /// Check if \p MO would be a legal operand for gfx12+ packed math FP32
1349 /// instructions. Packed math FP32 instructions typically accept SGPRs or
1350 /// VGPRs as source operands. On gfx12+, if a source operand uses SGPRs, the
1351 /// HW can only read the first SGPR and use it for both the low and high
1352 /// operations.
1353 /// \p SrcN can be 0, 1, or 2, representing src0, src1, and src2,
1354 /// respectively. If \p MO is nullptr, the operand corresponding to SrcN will
1355 /// be used.
1357 const MachineRegisterInfo &MRI, const MachineInstr &MI, unsigned SrcN,
1358 const MachineOperand *MO = nullptr) const;
1359
1360 /// Legalize operands in \p MI by either commuting it or inserting a
1361 /// copy of src1.
1363
1364 /// Fix operands in \p MI to satisfy constant bus requirements.
1366
1367 /// Copy a value from a VGPR (\p SrcReg) to SGPR. The desired register class
1368 /// for the dst register (\p DstRC) can be optionally supplied. This function
1369 /// can only be used when it is know that the value in SrcReg is same across
1370 /// all threads in the wave.
1371 /// \returns The SGPR register that \p SrcReg was copied to.
1374 const TargetRegisterClass *DstRC = nullptr) const;
1375
1378
1381 const TargetRegisterClass *DstRC,
1383 const DebugLoc &DL) const;
1384
1385 /// Legalize all operands in this instruction. This function may create new
1386 /// instructions and control-flow around \p MI. If present, \p MDT is
1387 /// updated.
1388 /// \returns A new basic block that contains \p MI if new blocks were created.
1390 legalizeOperands(MachineInstr &MI, MachineDominatorTree *MDT = nullptr) const;
1391
1392 /// Change SADDR form of a FLAT \p Inst to its VADDR form if saddr operand
1393 /// was moved to VGPR. \returns true if succeeded.
1394 bool moveFlatAddrToVGPR(MachineInstr &Inst) const;
1395
1396 /// Fix operands in Inst to fix 16bit SALU to VALU lowering.
1398 MachineRegisterInfo &MRI) const;
1399 void legalizeOperandsVALUt16(MachineInstr &Inst, unsigned OpIdx,
1400 MachineRegisterInfo &MRI) const;
1401
1402 /// Replace the instructions opcode with the equivalent VALU
1403 /// opcode. This function will also move the users of MachineInstruntions
1404 /// in the \p WorkList to the VALU if necessary. If present, \p MDT is
1405 /// updated.
1406 void moveToVALU(SIInstrWorklist &Worklist, MachineDominatorTree *MDT) const;
1407
1409 MachineInstr &Inst) const;
1410
1412 MachineBasicBlock::iterator MI) const override;
1413
1415 unsigned Quantity) const override;
1416
1417 void insertReturn(MachineBasicBlock &MBB) const;
1418
1419 /// Build instructions that simulate the behavior of a `s_trap 2` instructions
1420 /// for hardware (namely, gfx11) that runs in PRIV=1 mode. There, s_trap is
1421 /// interpreted as a nop.
1425 const DebugLoc &DL) const;
1426
1427 /// Return the number of wait states that result from executing this
1428 /// instruction.
1429 static unsigned getNumWaitStates(const MachineInstr &MI);
1430
1431 /// Returns the operand named \p Op. If \p MI does not have an
1432 /// operand named \c Op, this function returns nullptr.
1435 AMDGPU::OpName OperandName) const;
1436
1439 AMDGPU::OpName OperandName) const {
1440 return getNamedOperand(const_cast<MachineInstr &>(MI), OperandName);
1441 }
1442
1443 /// Get required immediate operand
1445 AMDGPU::OpName OperandName) const {
1446 int Idx = AMDGPU::getNamedOperandIdx(MI.getOpcode(), OperandName);
1447 return MI.getOperand(Idx).getImm();
1448 }
1449
1452
1453 bool isLowLatencyInstruction(const MachineInstr &MI) const;
1454 bool isHighLatencyDef(int Opc) const override;
1455
1456 /// Return the descriptor of the target-specific machine instruction
1457 /// that corresponds to the specified pseudo or native opcode.
1458 const MCInstrDesc &getMCOpcodeFromPseudo(unsigned Opcode) const {
1459 return get(pseudoToMCOpcode(Opcode));
1460 }
1461
1462 Register isStackAccess(const MachineInstr &MI, int &FrameIndex) const;
1463 Register isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex) const;
1464
1466 int &FrameIndex) const override;
1468 int &FrameIndex) const override;
1469
1470 unsigned getInstBundleSize(const MachineInstr &MI) const;
1471 unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
1472
1473 bool mayAccessFlatAddressSpace(const MachineInstr &MI) const;
1474
1475 std::pair<unsigned, unsigned>
1476 decomposeMachineOperandsTargetFlags(unsigned TF) const override;
1477
1479 getSerializableTargetIndices() const override;
1480
1483
1486
1489 const ScheduleDAG *DAG) const override;
1490
1492 CreateTargetPostRAHazardRecognizer(const MachineFunction &MF) const override;
1493
1496 const ScheduleDAGMI *DAG) const override;
1497
1499 const MachineFunction &MF) const override;
1500
1502 Register Reg = Register()) const override;
1503
1506 const DebugLoc &DL, Register Src,
1507 Register Dst) const override;
1508
1511 const DebugLoc &DL, Register Src,
1512 unsigned SrcSubReg,
1513 Register Dst) const override;
1514
1515 bool isWave32() const;
1516
1517 /// Return a partially built integer add instruction without carry.
1518 /// Caller must add source operands.
1519 /// For pre-GFX9 it will generate unused carry destination operand.
1520 /// TODO: After GFX9 it should return a no-carry operation.
1523 const DebugLoc &DL,
1524 Register DestReg) const;
1525
1528 const DebugLoc &DL,
1529 Register DestReg,
1530 RegScavenger &RS) const;
1531
1532 static bool isKillTerminator(unsigned Opcode);
1533 const MCInstrDesc &getKillTerminatorFromPseudo(unsigned Opcode) const;
1534
1535 bool isLegalMUBUFImmOffset(unsigned Imm) const;
1536
1537 static unsigned getMaxMUBUFImmOffset(const GCNSubtarget &ST);
1538
1539 bool splitMUBUFOffset(uint32_t Imm, uint32_t &SOffset, uint32_t &ImmOffset,
1540 Align Alignment = Align(4)) const;
1541
1542 /// Returns if \p Offset is legal for the subtarget as the offset to a FLAT
1543 /// encoded instruction with the given \p FlatVariant.
1544 bool isLegalFLATOffset(int64_t Offset, unsigned AddrSpace,
1545 uint64_t FlatVariant) const;
1546
1547 /// Split \p COffsetVal into {immediate offset field, remainder offset}
1548 /// values.
1549 std::pair<int64_t, int64_t> splitFlatOffset(int64_t COffsetVal,
1550 unsigned AddrSpace,
1551 uint64_t FlatVariant) const;
1552
1553 /// Returns true if negative offsets are allowed for the given \p FlatVariant.
1554 bool allowNegativeFlatOffset(uint64_t FlatVariant) const;
1555
1556 /// \brief Return a target-specific opcode if Opcode is a pseudo instruction.
1557 /// Return -1 if the target-specific opcode for the pseudo instruction does
1558 /// not exist. If Opcode is not a pseudo instruction, this is identity.
1559 int pseudoToMCOpcode(int Opcode) const;
1560
1561 /// \brief Check if this instruction should only be used by assembler.
1562 /// Return true if this opcode should not be used by codegen.
1563 bool isAsmOnlyOpcode(int MCOp) const;
1564
1565 const TargetRegisterClass *
1566 getRegClass(const MCInstrDesc &TID, unsigned OpNum,
1567 const TargetRegisterInfo *TRI) const override;
1568
1569 void fixImplicitOperands(MachineInstr &MI) const;
1570
1574 int FrameIndex,
1575 LiveIntervals *LIS = nullptr,
1576 VirtRegMap *VRM = nullptr) const override;
1577
1578 unsigned getInstrLatency(const InstrItineraryData *ItinData,
1579 const MachineInstr &MI,
1580 unsigned *PredCost = nullptr) const override;
1581
1583 getInstructionUniformity(const MachineInstr &MI) const override final;
1584
1587
1588 const MIRFormatter *getMIRFormatter() const override {
1589 if (!Formatter)
1590 Formatter = std::make_unique<AMDGPUMIRFormatter>();
1591 return Formatter.get();
1592 }
1593
1594 static unsigned getDSShaderTypeValue(const MachineFunction &MF);
1595
1596 const TargetSchedModel &getSchedModel() const { return SchedModel; }
1597
1598 // Enforce operand's \p OpName even alignment if required by target.
1599 // This is used if an operand is a 32 bit register but needs to be aligned
1600 // regardless.
1601 void enforceOperandRCAlignment(MachineInstr &MI, AMDGPU::OpName OpName) const;
1602};
1603
1604/// \brief Returns true if a reg:subreg pair P has a TRC class
1606 const TargetRegisterClass &TRC,
1608 auto *RC = MRI.getRegClass(P.Reg);
1609 if (!P.SubReg)
1610 return RC == &TRC;
1611 auto *TRI = MRI.getTargetRegisterInfo();
1612 return RC == TRI->getMatchingSuperRegClass(RC, &TRC, P.SubReg);
1613}
1614
1615/// \brief Create RegSubRegPair from a register MachineOperand
1616inline
1618 assert(O.isReg());
1619 return TargetInstrInfo::RegSubRegPair(O.getReg(), O.getSubReg());
1620}
1621
1622/// \brief Return the SubReg component from REG_SEQUENCE
1623TargetInstrInfo::RegSubRegPair getRegSequenceSubReg(MachineInstr &MI,
1624 unsigned SubReg);
1625
1626/// \brief Return the defining instruction for a given reg:subreg pair
1627/// skipping copy like instructions and subreg-manipulation pseudos.
1628/// Following another subreg of a reg:subreg isn't supported.
1629MachineInstr *getVRegSubRegDef(const TargetInstrInfo::RegSubRegPair &P,
1630 MachineRegisterInfo &MRI);
1631
1632/// \brief Return false if EXEC is not changed between the def of \p VReg at \p
1633/// DefMI and the use at \p UseMI. Should be run on SSA. Currently does not
1634/// attempt to track between blocks.
1635bool execMayBeModifiedBeforeUse(const MachineRegisterInfo &MRI,
1636 Register VReg,
1637 const MachineInstr &DefMI,
1638 const MachineInstr &UseMI);
1639
1640/// \brief Return false if EXEC is not changed between the def of \p VReg at \p
1641/// DefMI and all its uses. Should be run on SSA. Currently does not attempt to
1642/// track between blocks.
1643bool execMayBeModifiedBeforeAnyUse(const MachineRegisterInfo &MRI,
1644 Register VReg,
1645 const MachineInstr &DefMI);
1646
1647namespace AMDGPU {
1648
1650 int getVOPe64(uint16_t Opcode);
1651
1653 int getVOPe32(uint16_t Opcode);
1654
1656 int getSDWAOp(uint16_t Opcode);
1657
1660
1663
1666
1669
1672
1675
1676 /// Check if \p Opcode is an Addr64 opcode.
1677 ///
1678 /// \returns \p Opcode if it is an Addr64 opcode, otherwise -1.
1681
1683 int getSOPKOp(uint16_t Opcode);
1684
1685 /// \returns SADDR form of a FLAT Global instruction given an \p Opcode
1686 /// of a VADDR form.
1689
1690 /// \returns VADDR form of a FLAT Global instruction given an \p Opcode
1691 /// of a SADDR form.
1694
1697
1698 /// \returns ST form with only immediate offset of a FLAT Scratch instruction
1699 /// given an \p Opcode of an SS (SADDR) form.
1702
1703 /// \returns SV (VADDR) form of a FLAT Scratch instruction given an \p Opcode
1704 /// of an SVS (SADDR + VADDR) form.
1707
1708 /// \returns SS (SADDR) form of a FLAT Scratch instruction given an \p Opcode
1709 /// of an SV (VADDR) form.
1712
1713 /// \returns SV (VADDR) form of a FLAT Scratch instruction given an \p Opcode
1714 /// of an SS (SADDR) form.
1717
1718 /// \returns earlyclobber version of a MAC MFMA is exists.
1721
1722 /// \returns Version of an MFMA instruction which uses AGPRs for srcC and
1723 /// vdst, given an \p Opcode of an MFMA which uses VGPRs for srcC/vdst.
1726
1727 /// \returns v_cmpx version of a v_cmp instruction.
1730
1731 const uint64_t RSRC_DATA_FORMAT = 0xf00000000000LL;
1734 const uint64_t RSRC_TID_ENABLE = UINT64_C(1) << (32 + 23);
1735
1736} // end namespace AMDGPU
1737
1738namespace AMDGPU {
1740 // For sgpr to vgpr spill instructions
1742};
1743} // namespace AMDGPU
1744
1745namespace SI {
1747
1748/// Offsets in bytes from the start of the input buffer
1760
1761} // end namespace KernelInputOffsets
1762} // end namespace SI
1763
1764} // end namespace llvm
1765
1766#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
IRTranslator LLVM IR MI
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define I(x, y, z)
Definition MD5.cpp:58
Register Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
MachineInstr unsigned OpIdx
uint64_t IntrinsicInst * II
#define P(N)
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
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.
This holds information about one operand of a machine instruction, indicating the register class for ...
Definition MCInstrDesc.h:87
MIRFormater - Interface to format MIR operand based on target.
MachineInstrBundleIterator< MachineInstr > iterator
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.
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.
static bool isCBranchVCCZRead(const MachineInstr &MI)
bool isLegalMUBUFImmOffset(unsigned Imm) const
bool isFLATGlobal(uint16_t Opcode) const
bool isInlineConstant(const APInt &Imm) const
static bool isMAI(const MachineInstr &MI)
void legalizeOperandsVOP3(MachineRegisterInfo &MRI, MachineInstr &MI) const
Fix operands in MI to satisfy constant bus requirements.
static bool isDS(const MachineInstr &MI)
static bool isVMEM(const MachineInstr &MI)
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)
unsigned getLiveRangeSplitOpcode(Register Reg, const MachineFunction &MF) const override
bool isSMRD(uint16_t Opcode) const
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)
unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const
Return the size in bytes of the operand OpNo on the given.
bool isAtomic(uint16_t Opcode) const
bool isXDLWMMA(const MachineInstr &MI) const
bool isBasicBlockPrologue(const MachineInstr &MI, Register Reg=Register()) const override
bool isLDSDIR(uint16_t Opcode) const
bool isFLATScratch(uint16_t Opcode) const
uint64_t getDefaultRsrcDataFormat() const
static bool isSOPP(const MachineInstr &MI)
InstructionUniformity getGenericInstructionUniformity(const MachineInstr &MI) const
bool hasVGPRUses(const MachineInstr &MI) const
uint64_t getClampMask(const MachineInstr &MI) const
bool isIGLP(unsigned Opcode) const
static bool isFLATScratch(const MachineInstr &MI)
const MCInstrDesc & getIndirectRegWriteMovRelPseudo(unsigned VecSize, unsigned EltSize, bool IsSGPR) const
static bool isSpill(const MachineInstr &MI)
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)
void restoreExec(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, Register Reg, SlotIndexes *Indexes=nullptr) const
bool isVGPRSpill(uint16_t Opcode) const
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
static unsigned getFoldableCopySrcIdx(const MachineInstr &MI)
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
bool usesConstantBus(const MachineRegisterInfo &MRI, const MachineInstr &MI, int OpIdx) const
bool isVSAMPLE(uint16_t Opcode) const
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
static bool isMTBUF(const MachineInstr &MI)
const MCInstrDesc & getIndirectGPRIDXPseudo(unsigned VecSize, bool IsIndirectSrc) const
void insertReturn(MachineBasicBlock &MBB) const
static bool isDGEMM(unsigned Opcode)
static bool isEXP(const MachineInstr &MI)
static bool isSALU(const MachineInstr &MI)
bool isVIMAGE(uint16_t Opcode) const
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)
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
static bool isSDWA(const MachineInstr &MI)
bool isSOP1(uint16_t Opcode) const
const MCInstrDesc & getKillTerminatorFromPseudo(unsigned Opcode) const
static bool mayWriteLDSThroughDMA(const MachineInstr &MI)
void insertNoops(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned Quantity) const override
static bool isVINTRP(const MachineInstr &MI)
bool isIGLPMutationOnly(unsigned Opcode) const
bool isSWMMAC(uint16_t Opcode) const
bool isAtomicRet(uint16_t Opcode) const
static bool isGather4(const MachineInstr &MI)
MachineInstr * getWholeWaveFunctionSetup(MachineFunction &MF) const
static bool isMFMAorWMMA(const MachineInstr &MI)
static bool isWQM(const MachineInstr &MI)
static bool doesNotReadTiedSource(const MachineInstr &MI)
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
static bool isDOT(const MachineInstr &MI)
static bool usesFPDPRounding(const MachineInstr &MI)
bool isFixedSize(uint16_t Opcode) const
bool isImage(uint16_t Opcode) const
MachineInstr * createPHISourceCopy(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt, const DebugLoc &DL, Register Src, unsigned SrcSubReg, Register Dst) const override
bool isGWS(uint16_t Opcode) const
bool isInlineConstant(const MachineOperand &MO) const
bool hasModifiers(unsigned Opcode) const
Return true if this instruction has any modifiers.
bool isVOP3(uint16_t Opcode) const
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)
ScheduleHazardRecognizer * CreateTargetMIHazardRecognizer(const InstrItineraryData *II, const ScheduleDAGMI *DAG) const override
bool isDOT(uint16_t Opcode) const
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)
void removeModOperands(MachineInstr &MI) const
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx, int64_t ImmVal) const
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
bool isSpill(uint16_t Opcode) const
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
static bool isVIMAGE(const MachineInstr &MI)
static bool isLDSDIR(const MachineInstr &MI)
void enforceOperandRCAlignment(MachineInstr &MI, AMDGPU::OpName OpName) const
static bool isSOP2(const MachineInstr &MI)
LLVM_READONLY const MachineOperand * getNamedOperand(const MachineInstr &MI, AMDGPU::OpName OperandName) const
static bool isGWS(const MachineInstr &MI)
bool isLegalAV64PseudoImm(uint64_t Imm) const
Check if this immediate value can be used for AV_MOV_B64_IMM_PSEUDO.
bool isNeverCoissue(MachineInstr &MI) const
const TargetSchedModel & getSchedModel() const
bool isVOPC(uint16_t Opcode) const
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.
const MIRFormatter * getMIRFormatter() const override
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 isMAI(uint16_t Opcode) const
static bool isFLATGlobal(const MachineInstr &MI)
unsigned getMachineCSELookAheadLimit() const override
bool isGlobalMemoryObject(const MachineInstr *MI) const override
static bool isVSAMPLE(const MachineInstr &MI)
static bool isAtomicRet(const MachineInstr &MI)
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
bool isDS(uint16_t Opcode) const
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
bool hasVALU32BitEncoding(unsigned Opcode) const
Return true if this 64-bit VALU instruction has a 32-bit encoding.
static bool isDisableWQM(const MachineInstr &MI)
bool isAtomicNoRet(uint16_t Opcode) const
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)
static bool isImage(const MachineInstr &MI)
static bool isSOPK(const MachineInstr &MI)
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)
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx) const
returns true if the operand OpIdx in MI is a valid inline immediate.
static unsigned getDSShaderTypeValue(const MachineFunction &MF)
static bool isFoldableCopy(const MachineInstr &MI)
bool mayAccessLDSThroughFlat(const MachineInstr &MI) const
bool isIgnorableUse(const MachineOperand &MO) const override
static bool isVINTERP(const MachineInstr &MI)
static bool isMUBUF(const MachineInstr &MI)
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
const TargetRegisterClass * getRegClass(const MCInstrDesc &TID, unsigned OpNum, const TargetRegisterInfo *TRI) const override
bool isVOP2(uint16_t Opcode) const
static bool hasFPClamp(const MachineInstr &MI)
static bool isGFX12CacheInvOrWBInst(unsigned Opc)
InstructionUniformity getInstructionUniformity(const MachineInstr &MI) const override final
static bool isSegmentSpecificFLAT(const MachineInstr &MI)
static bool isWaitcnt(unsigned Opcode)
bool isReMaterializableImpl(const MachineInstr &MI) const override
static bool isVOP3(const MCInstrDesc &Desc)
bool isSDWA(uint16_t Opcode) const
unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const
This form should usually be preferred since it handles operands with unknown register classes.
bool physRegUsesConstantBus(const MachineOperand &Reg) const
bool isInlineConstant(const MachineOperand &MO, const MCOperandInfo &OpInfo) const
bool isSOPK(uint16_t Opcode) const
static bool isF16PseudoScalarTrans(unsigned Opcode)
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DstReg, ArrayRef< MachineOperand > Cond, Register TrueReg, Register FalseReg) const override
bool mayAccessVMEMThroughFlat(const MachineInstr &MI) const
static bool isChainCallOpcode(uint64_t Opcode)
static bool isDPP(const MachineInstr &MI)
bool analyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const
static bool isMFMA(const MachineInstr &MI)
bool isSGPRSpill(uint16_t Opcode) const
bool isLowLatencyInstruction(const MachineInstr &MI) const
bool isIGLP(const MachineInstr &MI) const
static bool isScalarStore(const MachineInstr &MI)
bool isTRANS(uint16_t Opcode) const
bool isLDSDMA(uint16_t Opcode)
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
bool isVALU(uint16_t Opcode) const
bool isVOP1(uint16_t Opcode) const
bool isAlwaysGDS(uint16_t Opcode) const
static bool isMAI(const MCInstrDesc &Desc)
bool isMUBUF(uint16_t Opcode) const
static bool isFPAtomic(const MachineInstr &MI)
static bool usesLGKM_CNT(const MachineInstr &MI)
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
bool isImmOperandLegal(const MCInstrDesc &InstDesc, unsigned OpNo, const MachineOperand &MO) const
static bool isPacked(const MachineInstr &MI)
bool canShrink(const MachineInstr &MI, const MachineRegisterInfo &MRI) const
static bool isBlockLoadStore(uint16_t Opcode)
bool isAsmOnlyOpcode(int MCOp) const
Check if this instruction should only be used by assembler.
bool isWMMA(uint16_t Opcode) const
bool isMTBUF(uint16_t Opcode) const
bool isDisableWQM(uint16_t Opcode) const
static bool isVGPRSpill(const MachineInstr &MI)
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
static bool isSBarrierSCCWrite(unsigned Opcode)
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)
unsigned getInstrLatency(const InstrItineraryData *ItinData, const MachineInstr &MI, unsigned *PredCost=nullptr) const override
bool isVMEM(uint16_t Opcode) const
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.
ArrayRef< std::pair< int, const char * > > getSerializableTargetIndices() const override
bool isVINTRP(uint16_t Opcode) const
bool isVGPRCopy(const MachineInstr &MI) const
bool isScalarStore(uint16_t Opcode) const
bool regUsesConstantBus(const MachineOperand &Reg, const MachineRegisterInfo &MRI) const
static bool isMIMG(const MachineInstr &MI)
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
static unsigned getNumWaitStates(const MachineInstr &MI)
Return the number of wait states that result from executing this instruction.
static bool isVOP3P(const MachineInstr &MI)
unsigned getVectorRegSpillSaveOpcode(Register Reg, const TargetRegisterClass *RC, unsigned Size, const SIMachineFunctionInfo &MFI) const
bool isWQM(uint16_t Opcode) const
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
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
bool swapSourceModifiers(MachineInstr &MI, MachineOperand &Src0, AMDGPU::OpName Src0OpName, MachineOperand &Src1, AMDGPU::OpName Src1OpName) const
bool isEXP(uint16_t Opcode) const
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)
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)
bool canInsertSelect(const MachineBasicBlock &MBB, ArrayRef< MachineOperand > Cond, Register DstReg, Register TrueReg, Register FalseReg, int &CondCycles, int &TrueCycles, int &FalseCycles) const override
bool isLiteralOperandLegal(const MCInstrDesc &InstDesc, const MCOperandInfo &OpInfo) const
static bool sopkIsZext(unsigned Opcode)
static bool isSGPRSpill(const MachineInstr &MI)
static bool isWMMA(const MachineInstr &MI)
ArrayRef< std::pair< MachineMemOperand::Flags, const char * > > getSerializableMachineMemOperandTargetFlags() const override
bool isVINTERP(uint16_t Opcode) const
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
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
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)
static bool isSOPC(const MachineInstr &MI)
static bool isFLAT(const MachineInstr &MI)
const SIRegisterInfo & getRegisterInfo() const
static bool isVALU(const MachineInstr &MI)
bool isBarrier(unsigned Opcode) const
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx0, unsigned OpIdx1) const override
static bool hasIntClamp(const MachineInstr &MI)
static bool isSpill(const MCInstrDesc &Desc)
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...
bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo, const MachineOperand &MO) const
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx, const MachineOperand &MO) const
static bool isScalarUnit(const MachineInstr &MI)
bool isSOPP(uint16_t Opcode) const
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
bool hasFPClamp(uint16_t Opcode) const
static bool usesVM_CNT(const MachineInstr &MI)
bool usesFPDPRounding(uint16_t Opcode) const
MachineInstr * createPHIDestinationCopy(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt, const DebugLoc &DL, Register Src, Register Dst) const override
static bool isFixedSize(const MachineInstr &MI)
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.
bool isBarrierStart(unsigned Opcode) const
static bool isLDSDMA(const MachineInstr &MI)
static bool isAtomicNoRet(const MachineInstr &MI)
static bool isVOP1(const MachineInstr &MI)
SIInstrInfo(const GCNSubtarget &ST)
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...
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.
A SetVector that performs no allocations if smaller than a certain size.
Definition SetVector.h:338
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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
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
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
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
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:62
Offsets
Offsets in bytes from the start of the input buffer.
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:477
TargetInstrInfo::RegSubRegPair getRegSubRegPair(const MachineOperand &O)
Create RegSubRegPair from a register MachineOperand.
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.
Op::Description Desc
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:1712
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...
static const MachineMemOperand::Flags MOCooperative
Mark the MMO of cooperative load/store atomics.
Definition SIInstrInfo.h:52
DWARFExpression::Operation Op
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.
InstructionUniformity
Enum describing how instructions behave with respect to uniformity and divergence,...
Definition Uniformity.h:18
GenericCycleInfo< MachineSSAContext > MachineCycleInfo
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
Utility to store machine instructions worklist.
Definition SIInstrInfo.h:56
MachineInstr * top() const
Definition SIInstrInfo.h:61
bool isDeferred(MachineInstr *MI)
SetVector< MachineInstr * > & getDeferredList()
Definition SIInstrInfo.h:80
void insert(MachineInstr *MI)
A pair composed of a register and a sub-register index.