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