LLVM 24.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"
25
26#define GET_INSTRINFO_HEADER
27#include "AMDGPUGenInstrInfo.inc"
28
29namespace llvm {
30
31class APInt;
32class GCNSubtarget;
33class MachineDominatorTree;
34class MachineRegisterInfo;
35class RegScavenger;
36class SIMachineFunctionInfo;
37class MCRegisterClass;
38using TargetRegisterClass = MCRegisterClass;
39class ScheduleHazardRecognizer;
40
41namespace AMDGPU {
42enum class AsyncStages : uint32_t;
43} // namespace AMDGPU
44
45constexpr unsigned DefaultMemoryClusterDWordsLimit = 8;
46
47/// Mark the MMO of a uniform load if there are no potentially clobbering stores
48/// on any path from the start of an entry function to this load.
51
52/// Mark the MMO of a load as the last use.
55
56/// Mark the MMO of cooperative load/store atomics.
59
61 // Operands that need to replaced by waterfall
63 // Target physical registers replacing the MOs
65};
66/// Mark the MMO of accesses to memory locations that are
67/// never written to by other threads.
70
71/// Use two MMO flags to encode the 2-bit cache fill size field for GFX13+
74
77
78/// Utility to store machine instructions worklist.
80 SIInstrWorklist() = default;
81
82 void insert(MachineInstr *MI);
83
84 MachineInstr *top() const { return InstrList[Front]; }
85
86 void erase_top() {
87 InSet.erase(InstrList[Front]);
88 ++Front;
89 }
90
91 bool empty() const { return Front == InstrList.size(); }
92
93 void clear() {
94 InstrList.clear();
95 Front = 0;
96 InSet.clear();
97 DeferredList.clear();
98 }
99
101
102 SetVector<MachineInstr *> &getDeferredList() { return DeferredList; }
103
104private:
105 /// InstrList contains the MachineInstrs.
108 unsigned Front = 0;
109 /// Deferred instructions are specific MachineInstr
110 /// that will be added by insert method.
111 SetVector<MachineInstr *> DeferredList;
112};
113
114// In namespace llvm so ADL finds it when SIInstrFlags predicates are
115// instantiated with MachineInstr (MachineInstr is in namespace llvm).
117 return MI.getDesc().TSFlags;
118}
119
120class SIInstrInfo final : public AMDGPUGenInstrInfo {
121 struct ThreeAddressUpdates;
122
123private:
124 const SIRegisterInfo RI;
125 const GCNSubtarget &ST;
126 TargetSchedModel SchedModel;
127 mutable std::unique_ptr<AMDGPUMIRFormatter> Formatter;
128
129 // The inverse predicate should have the negative value.
130 enum BranchPredicate {
131 INVALID_BR = 0,
132 SCC_TRUE = 1,
133 SCC_FALSE = -1,
134 VCCNZ = 2,
135 VCCZ = -2,
136 EXECNZ = -3,
137 EXECZ = 3
138 };
139
140 using SetVectorType = SmallSetVector<MachineInstr *, 32>;
141
142 static unsigned getBranchOpcode(BranchPredicate Cond);
143 static BranchPredicate getBranchPredicate(unsigned Opcode);
144
145public:
148 const MachineOperand &SuperReg,
149 const TargetRegisterClass *SuperRC,
150 unsigned SubIdx,
151 const TargetRegisterClass *SubRC) const;
154 const MachineOperand &SuperReg, const TargetRegisterClass *SuperRC,
155 unsigned SubIdx, const TargetRegisterClass *SubRC) const;
156
157private:
158 bool optimizeSCC(MachineInstr *SCCValid, MachineInstr *SCCRedefine,
159 bool NeedInversion) const;
160
161 bool invertSCCUse(MachineInstr *SCCDef) const;
162
163 void swapOperands(MachineInstr &Inst) const;
164
165 std::pair<bool, MachineBasicBlock *>
166 moveScalarAddSub(SIInstrWorklist &Worklist, MachineInstr &Inst,
167 MachineDominatorTree *MDT = nullptr) const;
168
169 void lowerSelect(SIInstrWorklist &Worklist, MachineInstr &Inst,
170 MachineDominatorTree *MDT = nullptr) const;
171
172 void lowerScalarAbs(SIInstrWorklist &Worklist, MachineInstr &Inst) const;
173
174 void lowerScalarAbsDiff(SIInstrWorklist &Worklist, MachineInstr &Inst) const;
175
176 void lowerScalarXnor(SIInstrWorklist &Worklist, MachineInstr &Inst) const;
177
178 void splitScalarNotBinop(SIInstrWorklist &Worklist, MachineInstr &Inst,
179 unsigned Opcode) const;
180
181 void splitScalarBinOpN2(SIInstrWorklist &Worklist, MachineInstr &Inst,
182 unsigned Opcode) const;
183
184 void splitScalar64BitUnaryOp(SIInstrWorklist &Worklist, MachineInstr &Inst,
185 unsigned Opcode, bool Swap = false) const;
186
187 void splitScalar64BitBinaryOp(SIInstrWorklist &Worklist, MachineInstr &Inst,
188 unsigned Opcode,
189 MachineDominatorTree *MDT = nullptr) const;
190
191 void splitScalarSMulU64(SIInstrWorklist &Worklist, MachineInstr &Inst,
192 MachineDominatorTree *MDT) const;
193
194 void splitScalarSMulPseudo(SIInstrWorklist &Worklist, MachineInstr &Inst,
195 MachineDominatorTree *MDT) const;
196
197 void splitScalar64BitXnor(SIInstrWorklist &Worklist, MachineInstr &Inst,
198 MachineDominatorTree *MDT = nullptr) const;
199
200 void splitScalar64BitBCNT(SIInstrWorklist &Worklist,
201 MachineInstr &Inst) const;
202 void splitScalar64BitBFE(SIInstrWorklist &Worklist, MachineInstr &Inst) const;
203 void splitScalar64BitCountOp(SIInstrWorklist &Worklist, MachineInstr &Inst,
204 unsigned Opcode,
205 MachineDominatorTree *MDT = nullptr) const;
206 void movePackToVALU(SIInstrWorklist &Worklist, MachineRegisterInfo &MRI,
207 MachineInstr &Inst) const;
208
209 void addUsersToMoveToVALUWorklist(Register Reg, MachineRegisterInfo &MRI,
210 SIInstrWorklist &Worklist) const;
211
212 void addSCCDefUsersToVALUWorklist(const MachineOperand &Op,
213 MachineInstr &SCCDefInst,
214 SIInstrWorklist &Worklist,
215 Register NewCond = Register()) const;
216 void addSCCDefsToVALUWorklist(MachineInstr *SCCUseInst,
217 SIInstrWorklist &Worklist) const;
218
219 const TargetRegisterClass *
220 getDestEquivalentVGPRClass(const MachineInstr &Inst) const;
221
222 bool checkInstOffsetsDoNotOverlap(const MachineInstr &MIa,
223 const MachineInstr &MIb) const;
224
225 Register findUsedSGPR(const MachineInstr &MI, int OpIndices[3]) const;
226
227 bool verifyCopy(const MachineInstr &MI, const MachineRegisterInfo &MRI,
228 StringRef &ErrInfo) const;
229
230 bool resultDependsOnExec(const MachineInstr &MI) const;
231
232 MachineInstr *convertToThreeAddressImpl(MachineInstr &MI,
233 ThreeAddressUpdates &Updates) const;
234
235protected:
236 /// If the specific machine instruction is a instruction that moves/copies
237 /// value from one register to another register return destination and source
238 /// registers as machine operands.
239 std::optional<DestSourcePair>
240 isCopyInstrImpl(const MachineInstr &MI) const override;
241
243 AMDGPU::OpName Src0OpName, MachineOperand &Src1,
244 AMDGPU::OpName Src1OpName) const;
245 bool isNonCommutableDPP(const MachineInstr &MI) const;
247 unsigned OpIdx0,
248 unsigned OpIdx1) const override;
249
250public:
251 bool isLegalToSwap(const MachineInstr &MI, unsigned fromIdx,
252 unsigned toIdx) const;
254 MO_MASK = 0xf,
255
257 // MO_GOTPCREL -> symbol@GOTPCREL -> R_AMDGPU_GOTPCREL.
259 // MO_GOTPCREL32_LO -> symbol@gotpcrel32@lo -> R_AMDGPU_GOTPCREL32_LO.
262 // MO_GOTPCREL32_HI -> symbol@gotpcrel32@hi -> R_AMDGPU_GOTPCREL32_HI.
264 // MO_GOTPCREL64 -> symbol@GOTPCREL -> R_AMDGPU_GOTPCREL.
266 // MO_REL32_LO -> symbol@rel32@lo -> R_AMDGPU_REL32_LO.
269 // MO_REL32_HI -> symbol@rel32@hi -> R_AMDGPU_REL32_HI.
272
274
278 };
279
280 explicit SIInstrInfo(const GCNSubtarget &ST);
281
283 return RI;
284 }
285
286 // FIXME: This is inaccurate and needs to account for use context. Normal asm
287 // constraints should use 64-bit pointers.
289 InlineAsm::ConstraintCode C) const override {
290 switch (C) {
293 // flat_load/flat_store require a 64-bit VGPR pair for the address.
294 return &AMDGPU::VReg_64RegClass;
295 default:
296 return &AMDGPU::VGPR_32RegClass;
297 }
298 }
299
300 const GCNSubtarget &getSubtarget() const {
301 return ST;
302 }
303
304 bool isReMaterializableImpl(const MachineInstr &MI) const override;
305
306 bool isIgnorableUse(const MachineInstr &MI, unsigned OpIdx) const override;
307
308 bool isSafeToSink(MachineInstr &MI, MachineBasicBlock *SuccToSinkTo,
309 MachineCycleInfo *CI) const override;
310
311 bool areLoadsFromSameBasePtr(SDNode *Load0, SDNode *Load1, int64_t &Offset0,
312 int64_t &Offset1) const override;
313
314 bool isGlobalMemoryObject(const MachineInstr *MI) const override;
315
317 const MachineInstr &LdSt,
319 bool &OffsetIsScalable, LocationSize &Width) const final;
320
322 int64_t Offset1, bool OffsetIsScalable1,
324 int64_t Offset2, bool OffsetIsScalable2,
325 unsigned ClusterSize,
326 unsigned NumBytes) const override;
327
328 /// Return true if the memory operations described by \p BaseOps1 and
329 /// \p BaseOps2 (as returned by getMemOperandsWithOffsetWidth) address the
330 /// same base. Unlike shouldClusterMemOps, this does not apply the
331 /// MaxMemoryClusterDWords budget, which only bounds pre-RA register pressure.
332 /// Only the first base operand is compared, unlike
333 /// memOpsHaveSameBaseOperands which requires all of them to match.
335 ArrayRef<const MachineOperand *> BaseOps2) const;
336
337 bool shouldScheduleLoadsNear(SDNode *Load0, SDNode *Load1, int64_t Offset0,
338 int64_t Offset1, unsigned NumLoads) const override;
339
341 const DebugLoc &DL, Register DestReg, Register SrcReg,
342 bool KillSrc, bool RenamableDest = false,
343 bool RenamableSrc = false) const override;
344
345private:
346 /// Return the sign extended register bits \p Imm reads as for \p OpType.
347 int64_t getImmOperandBits(uint8_t OpType, int64_t Imm) const;
348
349 void storeRegToStackSlotImpl(MachineBasicBlock &MBB,
351 bool isKill, int FrameIndex,
352 const TargetRegisterClass *RC, Register VReg,
353 MachineInstr::MIFlag Flags, bool NeedsCFI) const;
354
355public:
358 bool isKill, int FrameIndex,
359 const TargetRegisterClass *RC) const;
360
362 int64_t &ImmVal) const override;
363
364 std::optional<int64_t>
366 const MachineOperand &Op,
367 MachineInstr **DefMI = nullptr) const;
368 std::optional<int64_t>
370 MachineInstr **DefMI = nullptr) const;
371
373 const TargetRegisterClass *RC,
374 unsigned Size,
375 const SIMachineFunctionInfo &MFI,
376 bool NeedsCFI) const;
377 unsigned
379 unsigned Size,
380 const SIMachineFunctionInfo &MFI) const;
381
384 bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg,
385 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
386
389 int FrameIndex, const TargetRegisterClass *RC, Register VReg,
390 unsigned SubReg = 0,
391 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
392
393 bool expandPostRAPseudo(MachineInstr &MI) const override;
394
395 void
397 Register DestReg, unsigned SubIdx, const MachineInstr &Orig,
398 LaneBitmask UsedLanes = LaneBitmask::getAll()) const override;
399
400 // Splits a V_MOV_B64_DPP_PSEUDO opcode into a pair of v_mov_b32_dpp
401 // instructions. Returns a pair of generated instructions.
402 // Can split either post-RA with physical registers or pre-RA with
403 // virtual registers. In latter case IR needs to be in SSA form and
404 // and a REG_SEQUENCE is produced to define original register.
405 std::pair<MachineInstr*, MachineInstr*>
407
408 // Returns an opcode that can be used to move a value to a \p DstRC
409 // register. If there is no hardware instruction that can store to \p
410 // DstRC, then AMDGPU::COPY is returned.
411 unsigned getMovOpcode(const TargetRegisterClass *DstRC) const;
412
413 const MCInstrDesc &getIndirectRegWriteMovRelPseudo(unsigned VecSize,
414 unsigned EltSize,
415 bool IsSGPR) const;
416
417 const MCInstrDesc &getIndirectGPRIDXPseudo(unsigned VecSize,
418 bool IsIndirectSrc) const;
420 int commuteOpcode(unsigned Opc) const;
421
423 inline int commuteOpcode(const MachineInstr &MI) const {
424 return commuteOpcode(MI.getOpcode());
425 }
426
427 bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx0,
428 unsigned &SrcOpIdx1) const override;
429
430 bool findCommutedOpIndices(const MCInstrDesc &Desc, unsigned &SrcOpIdx0,
431 unsigned &SrcOpIdx1) const;
432
433 bool isBranchOffsetInRange(unsigned BranchOpc,
434 int64_t BrOffset) const override;
435
436 MachineBasicBlock *getBranchDestBlock(const MachineInstr &MI) const override;
437
438 /// Return whether the block terminate with divergent branch.
439 /// Note this only work before lowering the pseudo control flow instructions.
440 bool hasDivergentBranch(const MachineBasicBlock *MBB) const;
441
443 MachineBasicBlock &NewDestBB,
444 MachineBasicBlock &RestoreBB, const DebugLoc &DL,
445 int64_t BrOffset, RegScavenger *RS) const override;
446
450 MachineBasicBlock *&FBB,
452 bool AllowModify) const;
453
455 MachineBasicBlock *&FBB,
457 bool AllowModify = false) const override;
458
460 int *BytesRemoved = nullptr) const override;
461
464 const DebugLoc &DL,
465 int *BytesAdded = nullptr) const override;
466
468 SmallVectorImpl<MachineOperand> &Cond) const override;
469
470 std::unique_ptr<PipelinerLoopInfo>
471 analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const override;
472
475 Register TrueReg, Register FalseReg,
476 SelectExpansion &Exp) const override;
477
481 Register TrueReg, Register FalseReg) const override;
482
483 bool analyzeCompare(const MachineInstr &MI, Register &SrcReg,
484 Register &SrcReg2, int64_t &CmpMask,
485 int64_t &CmpValue) const override;
486
487 bool optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg,
488 Register SrcReg2, int64_t CmpMask, int64_t CmpValue,
489 const MachineRegisterInfo *MRI) const override;
490
491 bool
493 const MachineInstr &MIb) const override;
494
495 static bool isFoldableCopy(const MachineInstr &MI);
496 static unsigned getFoldableCopySrcIdx(const MachineInstr &MI);
497
498 void removeModOperands(MachineInstr &MI) const;
499
501 const MCInstrDesc &NewDesc) const;
502
503 /// Return the extracted immediate value in a subregister use from a constant
504 /// materialized in a super register.
505 ///
506 /// e.g. %imm = S_MOV_B64 K[0:63]
507 /// USE %imm.sub1
508 /// This will return K[32:63]
509 static std::optional<int64_t> extractSubregFromImm(int64_t ImmVal,
510 unsigned SubRegIndex);
511
512 /// Return how many op_sel bits select a half of source operand \p OpIdx.
513 unsigned getNumOpSelBits(const MachineInstr &MI, unsigned OpIdx) const;
514
515 /// Return true if \p Imm reads the same as a register holding \p Imm.
516 bool isImmEquivalentToReg(const MachineInstr &MI, unsigned OpIdx,
517 int64_t Imm) const;
518
519 /// Return the sign extended value operand \p OpIdx reads from \p Bits.
520 int64_t getSrcOperandValue(const MachineInstr &MI, unsigned OpIdx,
521 int64_t Bits, unsigned Mods) const;
522
523 int64_t getSrcOperandValue(const MachineInstr &MI, unsigned OpIdx,
524 int64_t Bits) const;
525
526 /// Return \p Mods with op_sel chosen so that \p Imm reads \p Value.
527 std::optional<unsigned> getImmOpSelForValue(const MachineInstr &MI,
528 unsigned OpIdx, int64_t Imm,
529 int64_t Value,
530 unsigned Mods) const;
531
532 /// Return the target flags for a global address operand reading subregister
533 /// \p SubRegIndex of a 64-bit global address with \p TargetFlags.
534 /// e.g. %addr = S_MOV_B64 target-flags(amdgpu-abs64) @gv
535 /// USE %addr.sub1
536 /// This will return amdgpu-abs32-hi
537 static std::optional<unsigned>
538 extractSubregFromGlobalAddressFlags(unsigned TargetFlags,
539 unsigned SubRegIndex);
540
542 MachineRegisterInfo *MRI) const final;
543
544 unsigned getMachineCSELookAheadLimit() const override { return 500; }
545
547 LiveIntervals *LIS) const override;
548
550 const MachineBasicBlock *MBB,
551 const MachineFunction &MF) const override;
552
553 static bool isSALU(const MachineInstr &MI) {
554 return SIInstrFlags::isSALU(MI);
555 }
556
557 bool isSALU(uint32_t Opcode) const {
558 return SIInstrFlags::isSALU(get(Opcode));
559 }
560
561 static bool isVALU(const MachineInstr &MI, bool AllowLDSDMA) {
562 if (!AllowLDSDMA && isLDSDMA(MI))
563 return false;
564
565 return SIInstrFlags::isVALU(MI);
566 }
567
568 /// LDSDMA instructions act as both VALU and memory instructions, thus
569 /// we also tag them as VALU. However, in many places, we do not actually want
570 /// to include LDSDMA instructions in this query. By setting \p AllowLDSDMA to
571 /// false, this will return false for LDSDMA instructions.
572 bool isVALU(uint32_t Opcode, bool AllowLDSDMA) const {
573 if (!AllowLDSDMA && isLDSDMA(Opcode))
574 return false;
575
576 return SIInstrFlags::isVALU(get(Opcode));
577 }
578
579 static bool isImage(const MachineInstr &MI) {
581 }
582
583 bool isImage(uint32_t Opcode) const {
584 return SIInstrFlags::isImage(get(Opcode));
585 }
586
587 static bool isVMEM(const MachineInstr &MI) {
588 return SIInstrFlags::isVMEM(MI);
589 }
590
591 bool isVMEM(uint32_t Opcode) const {
592 return SIInstrFlags::isVMEM(get(Opcode));
593 }
594
595 /// True if MI implicitly drains XCNT.
596 static bool isXcntDrain(const MachineInstr &MI);
597
598 static bool isSOP1(const MachineInstr &MI) {
599 return SIInstrFlags::isSOP1(MI);
600 }
601
602 bool isSOP1(uint32_t Opcode) const {
603 return SIInstrFlags::isSOP1(get(Opcode));
604 }
605
606 static bool isSOP2(const MachineInstr &MI) {
607 return SIInstrFlags::isSOP2(MI);
608 }
609
610 bool isSOP2(uint32_t Opcode) const {
611 return SIInstrFlags::isSOP2(get(Opcode));
612 }
613
614 static bool isSOPC(const MachineInstr &MI) {
615 return SIInstrFlags::isSOPC(MI);
616 }
617
618 bool isSOPC(uint32_t Opcode) const {
619 return SIInstrFlags::isSOPC(get(Opcode));
620 }
621
622 static bool isSOPK(const MachineInstr &MI) {
623 return SIInstrFlags::isSOPK(MI);
624 }
625
626 bool isSOPK(uint32_t Opcode) const {
627 return SIInstrFlags::isSOPK(get(Opcode));
628 }
629
630 static bool isSOPP(const MachineInstr &MI) {
631 return SIInstrFlags::isSOPP(MI);
632 }
633
634 bool isSOPP(uint32_t Opcode) const {
635 return SIInstrFlags::isSOPP(get(Opcode));
636 }
637
638 static bool isPacked(const MachineInstr &MI) {
640 }
641
642 bool isPacked(uint32_t Opcode) const {
643 return SIInstrFlags::isPacked(get(Opcode));
644 }
645
646 static bool isVOP1(const MachineInstr &MI) {
647 return SIInstrFlags::isVOP1(MI);
648 }
649
650 bool isVOP1(uint32_t Opcode) const {
651 return SIInstrFlags::isVOP1(get(Opcode));
652 }
653
654 static bool isVOP2(const MachineInstr &MI) {
655 return SIInstrFlags::isVOP2(MI);
656 }
657
658 bool isVOP2(uint32_t Opcode) const {
659 return SIInstrFlags::isVOP2(get(Opcode));
660 }
661
662 static bool isVOP3(const MCInstrDesc &Desc) {
664 }
665
666 static bool isVOP3(const MachineInstr &MI) { return isVOP3(MI.getDesc()); }
667
668 bool isVOP3(uint32_t Opcode) const { return isVOP3(get(Opcode)); }
669
670 static bool isSDWA(const MachineInstr &MI) {
671 return SIInstrFlags::isSDWA(MI);
672 }
673
674 bool isSDWA(uint32_t Opcode) const {
675 return SIInstrFlags::isSDWA(get(Opcode));
676 }
677
678 static bool isVOPC(const MachineInstr &MI) {
679 return SIInstrFlags::isVOPC(MI);
680 }
681
682 bool isVOPC(uint32_t Opcode) const {
683 return SIInstrFlags::isVOPC(get(Opcode));
684 }
685
686 static bool isMUBUF(const MachineInstr &MI) {
688 }
689
690 bool isMUBUF(uint32_t Opcode) const {
691 return SIInstrFlags::isMUBUF(get(Opcode));
692 }
693
694 static bool isMTBUF(const MachineInstr &MI) {
696 }
697
698 bool isMTBUF(uint32_t Opcode) const {
699 return SIInstrFlags::isMTBUF(get(Opcode));
700 }
701
702 static bool isBUF(const MachineInstr &MI) {
703 return isMUBUF(MI) || isMTBUF(MI);
704 }
705
706 static bool isSMRD(const MachineInstr &MI) {
707 return SIInstrFlags::isSMRD(MI);
708 }
709
710 bool isSMRD(uint32_t Opcode) const {
711 return SIInstrFlags::isSMRD(get(Opcode));
712 }
713
714 bool isBufferSMRD(const MachineInstr &MI) const;
715
716 static bool isDS(const MachineInstr &MI) { return SIInstrFlags::isDS(MI); }
717
718 bool isDS(uint32_t Opcode) const { return SIInstrFlags::isDS(get(Opcode)); }
719
720 static bool isLDSDMA(const MachineInstr &MI) {
721 return (SIInstrFlags::isVALU(MI) && (isMUBUF(MI) || isFLAT(MI))) ||
723 }
724
725 bool isLDSDMA(uint32_t Opcode) const {
726 return (SIInstrFlags::isVALU(get(Opcode)) &&
727 (isMUBUF(Opcode) || isFLAT(Opcode))) ||
729 }
730
731 static bool isGWS(const MachineInstr &MI) { return SIInstrFlags::isGWS(MI); }
732
733 bool isGWS(uint32_t Opcode) const { return SIInstrFlags::isGWS(get(Opcode)); }
734
735 bool isAlwaysGDS(uint32_t Opcode) const;
736
737 static bool isMIMG(const MachineInstr &MI) {
738 return SIInstrFlags::isMIMG(MI);
739 }
740
741 bool isMIMG(uint32_t Opcode) const {
742 return SIInstrFlags::isMIMG(get(Opcode));
743 }
744
745 static bool isVIMAGE(const MachineInstr &MI) {
747 }
748
749 bool isVIMAGE(uint32_t Opcode) const {
750 return SIInstrFlags::isVIMAGE(get(Opcode));
751 }
752
753 static bool isVSAMPLE(const MachineInstr &MI) {
755 }
756
757 bool isVSAMPLE(uint32_t Opcode) const {
758 return SIInstrFlags::isVSAMPLE(get(Opcode));
759 }
760
761 static bool isGather4(const MachineInstr &MI) {
763 }
764
765 bool isGather4(uint32_t Opcode) const {
766 return SIInstrFlags::isGather4(get(Opcode));
767 }
768
769 static bool isFLAT(const MachineInstr &MI) {
770 return SIInstrFlags::isFLAT(MI);
771 }
772
773 // Is a FLAT encoded instruction which accesses a specific segment,
774 // i.e. global_* or scratch_*.
778
779 bool isSegmentSpecificFLAT(uint32_t Opcode) const {
781 }
782
783 static bool isFLATGlobal(const MachineInstr &MI) {
785 }
786
787 bool isFLATGlobal(uint32_t Opcode) const {
788 return SIInstrFlags::isFlatGlobal(get(Opcode));
789 }
790
791 static bool isFLATScratch(const MachineInstr &MI) {
793 }
794
795 bool isFLATScratch(uint32_t Opcode) const {
796 return SIInstrFlags::isFlatScratch(get(Opcode));
797 }
798
799 // Any FLAT encoded instruction, including global_* and scratch_*.
800 bool isFLAT(uint32_t Opcode) const {
801 return SIInstrFlags::isFLAT(get(Opcode));
802 }
803
804 /// \returns true for SCRATCH_ instructions, or FLAT/BUF instructions unless
805 /// the MMOs do not include scratch.
806 /// Conservatively correct; will return true if \p MI cannot be proven
807 /// to not hit scratch.
808 bool mayAccessScratch(const MachineInstr &MI) const;
809
810 /// \returns true for FLAT instructions that can access VMEM.
811 bool mayAccessVMEMThroughFlat(const MachineInstr &MI) const;
812
813 /// \returns true for FLAT instructions that can access LDS.
814 bool mayAccessLDSThroughFlat(const MachineInstr &MI, bool TgSplit) const;
815
816 static bool isBlockLoadStore(uint32_t Opcode) {
817 switch (Opcode) {
818 case AMDGPU::SI_BLOCK_SPILL_V1024_SAVE:
819 case AMDGPU::SI_BLOCK_SPILL_V1024_CFI_SAVE:
820 case AMDGPU::SI_BLOCK_SPILL_V1024_RESTORE:
821 case AMDGPU::SCRATCH_STORE_BLOCK_SADDR:
822 case AMDGPU::SCRATCH_LOAD_BLOCK_SADDR:
823 case AMDGPU::SCRATCH_STORE_BLOCK_SVS:
824 case AMDGPU::SCRATCH_LOAD_BLOCK_SVS:
825 return true;
826 default:
827 return false;
828 }
829 }
830
832 switch (MI.getOpcode()) {
833 case AMDGPU::S_ABSDIFF_I32:
834 case AMDGPU::S_ABS_I32:
835 case AMDGPU::S_AND_B32:
836 case AMDGPU::S_AND_B64:
837 case AMDGPU::S_ANDN2_B32:
838 case AMDGPU::S_ANDN2_B64:
839 case AMDGPU::S_ASHR_I32:
840 case AMDGPU::S_ASHR_I64:
841 case AMDGPU::S_BCNT0_I32_B32:
842 case AMDGPU::S_BCNT0_I32_B64:
843 case AMDGPU::S_BCNT1_I32_B32:
844 case AMDGPU::S_BCNT1_I32_B64:
845 case AMDGPU::S_BFE_I32:
846 case AMDGPU::S_BFE_I64:
847 case AMDGPU::S_BFE_U32:
848 case AMDGPU::S_BFE_U64:
849 case AMDGPU::S_LSHL_B32:
850 case AMDGPU::S_LSHL_B64:
851 case AMDGPU::S_LSHR_B32:
852 case AMDGPU::S_LSHR_B64:
853 case AMDGPU::S_NAND_B32:
854 case AMDGPU::S_NAND_B64:
855 case AMDGPU::S_NOR_B32:
856 case AMDGPU::S_NOR_B64:
857 case AMDGPU::S_NOT_B32:
858 case AMDGPU::S_NOT_B64:
859 case AMDGPU::S_OR_B32:
860 case AMDGPU::S_OR_B64:
861 case AMDGPU::S_ORN2_B32:
862 case AMDGPU::S_ORN2_B64:
863 case AMDGPU::S_QUADMASK_B32:
864 case AMDGPU::S_QUADMASK_B64:
865 case AMDGPU::S_WQM_B32:
866 case AMDGPU::S_WQM_B64:
867 case AMDGPU::S_XNOR_B32:
868 case AMDGPU::S_XNOR_B64:
869 case AMDGPU::S_XOR_B32:
870 case AMDGPU::S_XOR_B64:
871 return true;
872 default:
873 return false;
874 }
875 }
876
877 static bool isEXP(const MachineInstr &MI) { return SIInstrFlags::isEXP(MI); }
878
880 if (!isEXP(MI))
881 return false;
882 unsigned Target = MI.getOperand(0).getImm();
885 }
886
887 bool isEXP(uint32_t Opcode) const { return SIInstrFlags::isEXP(get(Opcode)); }
888
889 static bool isAtomicNoRet(const MachineInstr &MI) {
891 }
892
893 bool isAtomicNoRet(uint32_t Opcode) const {
894 return SIInstrFlags::isAtomicNoRet(get(Opcode));
895 }
896
897 static bool isAtomicRet(const MachineInstr &MI) {
899 }
900
901 bool isAtomicRet(uint32_t Opcode) const {
902 return SIInstrFlags::isAtomicRet(get(Opcode));
903 }
904
905 static bool isAtomic(const MachineInstr &MI) {
907 }
908
909 bool isAtomic(uint32_t Opcode) const {
910 return SIInstrFlags::isAtomic(get(Opcode));
911 }
912
914 unsigned Opc = MI.getOpcode();
915 // Exclude instructions that read FROM LDS (not write to it)
916 return isLDSDMA(MI) && Opc != AMDGPU::BUFFER_STORE_LDS_DWORD &&
917 Opc != AMDGPU::TENSOR_STORE_FROM_LDS_d2 &&
918 Opc != AMDGPU::TENSOR_STORE_FROM_LDS_d4;
919 }
920
922 return mayWriteLDSThroughDMA(MI) && !isAsync(MI);
923 }
924
925 /// \returns true if \p MI creates an async operation.
926 bool isAsync(const MachineInstr &MI) const {
927 if (!isLDSDMA(MI))
928 return false;
930 return true;
931 const MachineOperand *Async = getNamedOperand(MI, AMDGPU::OpName::IsAsync);
932 return Async && (Async->getImm());
933 }
934
935 /// \returns the asyncmark stage that the async operation initiated by \p MI
936 /// belongs to, or no stage if \p MI does not initiate an async operation.
938
939 static bool isSBarrierSCCWrite(unsigned Opcode) {
940 return Opcode == AMDGPU::S_BARRIER_LEAVE ||
941 Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_IMM ||
942 Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_M0;
943 }
944
945 static bool isCBranchVCCZRead(const MachineInstr &MI) {
946 unsigned Opc = MI.getOpcode();
947 return (Opc == AMDGPU::S_CBRANCH_VCCNZ || Opc == AMDGPU::S_CBRANCH_VCCZ) &&
948 !MI.getOperand(1).isUndef();
949 }
950
951 static bool isWQM(const MachineInstr &MI) { return SIInstrFlags::isWQM(MI); }
952
953 bool isWQM(uint32_t Opcode) const { return SIInstrFlags::isWQM(get(Opcode)); }
954
955 static bool isDisableWQM(const MachineInstr &MI) {
957 }
958
959 bool isDisableWQM(uint32_t Opcode) const {
960 return SIInstrFlags::isDisableWQM(get(Opcode));
961 }
962
963 // SI_SPILL_S32_TO_VGPR and SI_RESTORE_S32_FROM_VGPR form a special case of
964 // SGPRs spilling to VGPRs which are SGPR spills but from VALU instructions
965 // therefore we need an explicit check for them since just checking if the
966 // Spill bit is set and what instruction type it came from misclassifies
967 // them.
968 static bool isVGPRSpill(const MachineInstr &MI) {
969 return MI.getOpcode() != AMDGPU::SI_SPILL_S32_TO_VGPR &&
970 MI.getOpcode() != AMDGPU::SI_RESTORE_S32_FROM_VGPR &&
971 (isSpill(MI) && isVALU(MI, /*AllowLDSDMA=*/false));
972 }
973
974 bool isVGPRSpill(uint32_t Opcode) const {
975 return Opcode != AMDGPU::SI_SPILL_S32_TO_VGPR &&
976 Opcode != AMDGPU::SI_RESTORE_S32_FROM_VGPR &&
977 (isSpill(Opcode) && isVALU(Opcode, /*AllowLDSDMA=*/false));
978 }
979
980 static bool isSGPRSpill(const MachineInstr &MI) {
981 return MI.getOpcode() == AMDGPU::SI_SPILL_S32_TO_VGPR ||
982 MI.getOpcode() == AMDGPU::SI_RESTORE_S32_FROM_VGPR ||
983 (isSpill(MI) && isSALU(MI));
984 }
985
986 bool isSGPRSpill(uint32_t Opcode) const {
987 return Opcode == AMDGPU::SI_SPILL_S32_TO_VGPR ||
988 Opcode == AMDGPU::SI_RESTORE_S32_FROM_VGPR ||
989 (isSpill(Opcode) && isSALU(Opcode));
990 }
991
992 bool isSpill(uint32_t Opcode) const {
993 return SIInstrFlags::isSpill(get(Opcode));
994 }
995
996 static bool isSpill(const MCInstrDesc &Desc) {
998 }
999
1000 static bool isSpill(const MachineInstr &MI) { return isSpill(MI.getDesc()); }
1001
1002 static bool isWWMRegSpillOpcode(uint32_t Opcode) {
1003 return Opcode == AMDGPU::SI_SPILL_WWM_V32_SAVE ||
1004 Opcode == AMDGPU::SI_SPILL_WWM_AV32_SAVE ||
1005 Opcode == AMDGPU::SI_SPILL_WWM_V32_RESTORE ||
1006 Opcode == AMDGPU::SI_SPILL_WWM_AV32_RESTORE;
1007 }
1008
1009 static bool isChainCallOpcode(uint64_t Opcode) {
1010 return Opcode == AMDGPU::SI_CS_CHAIN_TC_W32 ||
1011 Opcode == AMDGPU::SI_CS_CHAIN_TC_W64;
1012 }
1013
1014 static bool isDPP(const MachineInstr &MI) { return SIInstrFlags::isDPP(MI); }
1015
1016 bool isDPP(uint32_t Opcode) const { return SIInstrFlags::isDPP(get(Opcode)); }
1017
1018 // Some opcodes use Src1 for DPP instead of Src0, because the sequencer
1019 // transforms them and reverse the order of their operands at runtime.
1020 //
1021 // Documentation is incomplete on which instructions are effected, so
1022 // the implementation is derived from experimentation.
1023 //
1024 // Listed as target-independent pseudos; the per-subtarget MC opcodes
1025 // (V_SUBREV_NC_U32_e32_gfx11 and friends) are all reached through these.
1026 // Defined out of line because GCNSubtarget is incomplete here.
1027 static bool isSrc1DPPRevOpcode(const GCNSubtarget &ST, uint32_t Opcode);
1028
1029 static bool isTRANS(const MachineInstr &MI) {
1030 return SIInstrFlags::isTRANS(MI);
1031 }
1032
1033 bool isTRANS(uint32_t Opcode) const {
1034 return SIInstrFlags::isTRANS(get(Opcode));
1035 }
1036
1037 static bool isVOP3P(const MachineInstr &MI) {
1038 return SIInstrFlags::isVOP3P(MI);
1039 }
1040
1041 bool isVOP3P(uint32_t Opcode) const {
1042 return SIInstrFlags::isVOP3P(get(Opcode));
1043 }
1044
1045 bool isVOP3PMix(const MachineInstr &MI) const {
1046 return isVOP3PMix(MI.getOpcode());
1047 }
1048
1049 bool isVOP3PMix(uint16_t Opcode) const {
1050 switch (Opcode) {
1051 case AMDGPU::V_FMA_MIXHI_F16:
1052 case AMDGPU::V_FMA_MIXLO_F16:
1053 case AMDGPU::V_FMA_MIX_F32:
1054 case AMDGPU::V_MAD_MIXHI_F16:
1055 case AMDGPU::V_MAD_MIXLO_F16:
1056 case AMDGPU::V_MAD_MIX_F32:
1057 return true;
1058 default:
1059 return false;
1060 }
1061 }
1062
1063 static bool isVINTRP(const MachineInstr &MI) {
1064 return SIInstrFlags::isVINTRP(MI);
1065 }
1066
1067 bool isVINTRP(uint32_t Opcode) const {
1068 return SIInstrFlags::isVINTRP(get(Opcode));
1069 }
1070
1071 static bool isMAI(const MCInstrDesc &Desc) {
1072 return SIInstrFlags::isMAI(Desc);
1073 }
1074
1075 static bool isMAI(const MachineInstr &MI) { return isMAI(MI.getDesc()); }
1076
1077 bool isMAI(uint32_t Opcode) const { return isMAI(get(Opcode)); }
1078
1079 static bool isMFMA(const MachineInstr &MI) {
1080 return isMAI(MI) && MI.getOpcode() != AMDGPU::V_ACCVGPR_WRITE_B32_e64 &&
1081 MI.getOpcode() != AMDGPU::V_ACCVGPR_READ_B32_e64 &&
1082 MI.getOpcode() != AMDGPU::V_ACCVGPR_WRITE_B32_vi &&
1083 MI.getOpcode() != AMDGPU::V_ACCVGPR_READ_B32_vi;
1084 }
1085
1086 bool isMFMA(uint32_t Opcode) const {
1087 return isMAI(Opcode) && Opcode != AMDGPU::V_ACCVGPR_WRITE_B32_e64 &&
1088 Opcode != AMDGPU::V_ACCVGPR_READ_B32_e64 &&
1089 Opcode != AMDGPU::V_ACCVGPR_WRITE_B32_vi &&
1090 Opcode != AMDGPU::V_ACCVGPR_READ_B32_vi;
1091 }
1092
1093 static bool isDOT(const MachineInstr &MI) { return SIInstrFlags::isDOT(MI); }
1094
1095 static bool isWMMA(const MachineInstr &MI) {
1096 return SIInstrFlags::isWMMA(MI);
1097 }
1098
1099 bool isWMMA(uint32_t Opcode) const {
1100 return SIInstrFlags::isWMMA(get(Opcode));
1101 }
1102
1103 static bool isMFMAorWMMA(const MachineInstr &MI) {
1104 return isMFMA(MI) || isWMMA(MI) || isSWMMAC(MI);
1105 }
1106
1107 bool isMFMAorWMMA(uint32_t Opcode) const {
1108 return isMFMA(Opcode) || isWMMA(Opcode) || isSWMMAC(Opcode);
1109 }
1110
1111 static bool isSWMMAC(const MachineInstr &MI) {
1112 return SIInstrFlags::isSWMMAC(MI);
1113 }
1114
1115 bool isSWMMAC(uint32_t Opcode) const {
1116 return SIInstrFlags::isSWMMAC(get(Opcode));
1117 }
1118
1119 bool isDOT(uint32_t Opcode) const { return SIInstrFlags::isDOT(get(Opcode)); }
1120
1121 bool isXDLWMMA(const MachineInstr &MI) const;
1122
1123 bool isXDL(const MachineInstr &MI) const;
1124
1125 /// On gfx1250, an XDL instruction whose destination spans at least eight
1126 /// VGPRs decrements VA_VDST only after every earlier-issued VALU instruction,
1127 /// of any type, has decremented it. Nothing is implied about the order
1128 /// relative to instructions issued after it.
1129 bool isVAVDSTOrderedXDL(const MachineInstr &MI) const;
1130
1131 static bool isDGEMM(unsigned Opcode) { return AMDGPU::getMAIIsDGEMM(Opcode); }
1132
1133 static bool isLDSDIR(const MachineInstr &MI) {
1134 return SIInstrFlags::isLDSDIR(MI);
1135 }
1136
1137 bool isLDSDIR(uint32_t Opcode) const {
1138 return SIInstrFlags::isLDSDIR(get(Opcode));
1139 }
1140
1141 static bool isVINTERP(const MachineInstr &MI) {
1143 }
1144
1145 bool isVINTERP(uint32_t Opcode) const {
1146 return SIInstrFlags::isVINTERP(get(Opcode));
1147 }
1148
1149 static bool usesVM_CNT(const MachineInstr &MI) {
1151 }
1152
1153 static bool usesLGKM_CNT(const MachineInstr &MI) {
1155 }
1156
1157 static bool usesASYNC_CNT(const MachineInstr &MI) {
1159 }
1160
1161 bool usesASYNC_CNT(uint32_t Opcode) const {
1162 return SIInstrFlags::usesASYNC_CNT(get(Opcode));
1163 }
1164
1165 static bool usesTENSOR_CNT(const MachineInstr &MI) {
1167 }
1168
1169 bool usesTENSOR_CNT(uint32_t Opcode) const {
1170 return SIInstrFlags::usesTENSOR_CNT(get(Opcode));
1171 }
1172
1173 // Most sopk treat the immediate as a signed 16-bit, however some
1174 // use it as unsigned.
1175 static bool sopkIsZext(unsigned Opcode) {
1176 return Opcode == AMDGPU::S_CMPK_EQ_U32 || Opcode == AMDGPU::S_CMPK_LG_U32 ||
1177 Opcode == AMDGPU::S_CMPK_GT_U32 || Opcode == AMDGPU::S_CMPK_GE_U32 ||
1178 Opcode == AMDGPU::S_CMPK_LT_U32 || Opcode == AMDGPU::S_CMPK_LE_U32 ||
1179 Opcode == AMDGPU::S_GETREG_B32 ||
1180 Opcode == AMDGPU::S_GETREG_B32_const;
1181 }
1182
1183 /// \returns true if this is an s_store_dword* instruction. This is more
1184 /// specific than isSMEM && mayStore.
1185 static bool isScalarStore(const MachineInstr &MI) {
1187 }
1188
1189 bool isScalarStore(uint32_t Opcode) const {
1190 return SIInstrFlags::isScalarStore(get(Opcode));
1191 }
1192
1193 static bool isFixedSize(const MachineInstr &MI) {
1195 }
1196
1197 bool isFixedSize(uint32_t Opcode) const {
1198 return SIInstrFlags::isFixedSize(get(Opcode));
1199 }
1200
1201 static bool hasFPClamp(const MachineInstr &MI) {
1203 }
1204
1205 bool hasFPClamp(uint32_t Opcode) const {
1206 return SIInstrFlags::hasFPClamp(get(Opcode));
1207 }
1208
1209 static bool hasIntClamp(const MachineInstr &MI) {
1211 }
1212
1213 static bool hasSameClamp(const MachineInstr &A, const MachineInstr &B) {
1214 const MCInstrDesc &DA = A.getDesc(), &DB = B.getDesc();
1219 }
1220
1221 static bool usesFPDPRounding(const MachineInstr &MI) {
1223 }
1224
1225 bool usesFPDPRounding(uint32_t Opcode) const {
1226 return SIInstrFlags::usesFPDPRounding(get(Opcode));
1227 }
1228
1229 static bool isFPAtomic(const MachineInstr &MI) {
1231 }
1232
1233 bool isFPAtomic(uint32_t Opcode) const {
1234 return SIInstrFlags::isFPAtomic(get(Opcode));
1235 }
1236
1237 static bool isNeverUniform(const MachineInstr &MI) {
1239 }
1240
1241 // Check to see if opcode is for a barrier start. Pre gfx12 this is just the
1242 // S_BARRIER, but after support for S_BARRIER_SIGNAL* / S_BARRIER_WAIT we want
1243 // to check for the barrier start (S_BARRIER_SIGNAL*)
1244 bool isBarrierStart(unsigned Opcode) const {
1245 return Opcode == AMDGPU::S_BARRIER ||
1246 Opcode == AMDGPU::S_BARRIER_SIGNAL_M0 ||
1247 Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_M0 ||
1248 Opcode == AMDGPU::S_BARRIER_SIGNAL_IMM ||
1249 Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_IMM;
1250 }
1251
1252 bool isBarrier(unsigned Opcode) const {
1253 return isBarrierStart(Opcode) || Opcode == AMDGPU::S_BARRIER_WAIT ||
1254 Opcode == AMDGPU::S_BARRIER_INIT_M0 ||
1255 Opcode == AMDGPU::S_BARRIER_INIT_IMM ||
1256 Opcode == AMDGPU::S_BARRIER_JOIN_IMM ||
1257 Opcode == AMDGPU::S_BARRIER_LEAVE || Opcode == AMDGPU::DS_GWS_INIT ||
1258 Opcode == AMDGPU::DS_GWS_BARRIER;
1259 }
1260
1261 static bool isLoadMonitor(unsigned Opc) {
1262 switch (Opc) {
1263 case AMDGPU::GLOBAL_LOAD_MONITOR_B32:
1264 case AMDGPU::GLOBAL_LOAD_MONITOR_B32_SADDR:
1265 case AMDGPU::GLOBAL_LOAD_MONITOR_B64:
1266 case AMDGPU::GLOBAL_LOAD_MONITOR_B64_SADDR:
1267 case AMDGPU::GLOBAL_LOAD_MONITOR_B128:
1268 case AMDGPU::GLOBAL_LOAD_MONITOR_B128_SADDR:
1269 case AMDGPU::FLAT_LOAD_MONITOR_B32:
1270 case AMDGPU::FLAT_LOAD_MONITOR_B64:
1271 case AMDGPU::FLAT_LOAD_MONITOR_B128:
1272 return true;
1273 default:
1274 return false;
1275 }
1276 }
1277
1278 static bool isGFX12CacheInvOrWBInst(unsigned Opc) {
1279 return Opc == AMDGPU::GLOBAL_INV || Opc == AMDGPU::GLOBAL_WB ||
1280 Opc == AMDGPU::GLOBAL_WBINV;
1281 }
1282
1283 static bool isF16PseudoScalarTrans(unsigned Opcode) {
1284 return Opcode == AMDGPU::V_S_EXP_F16_e64 ||
1285 Opcode == AMDGPU::V_S_LOG_F16_e64 ||
1286 Opcode == AMDGPU::V_S_RCP_F16_e64 ||
1287 Opcode == AMDGPU::V_S_RSQ_F16_e64 ||
1288 Opcode == AMDGPU::V_S_SQRT_F16_e64;
1289 }
1290
1291 static bool isPseudoScalarTrans(unsigned Opcode) {
1292 return isF16PseudoScalarTrans(Opcode) ||
1293 Opcode == AMDGPU::V_S_EXP_F32_e64 ||
1294 Opcode == AMDGPU::V_S_LOG_F32_e64 ||
1295 Opcode == AMDGPU::V_S_RCP_F32_e64 ||
1296 Opcode == AMDGPU::V_S_RSQ_F32_e64 ||
1297 Opcode == AMDGPU::V_S_SQRT_F32_e64;
1298 }
1299
1300 static bool isVPermPk16(unsigned Opcode) {
1301 return Opcode == AMDGPU::V_PERM_PK16_B4_U4_e64 ||
1302 Opcode == AMDGPU::V_PERM_PK16_B6_U4_e64 ||
1303 Opcode == AMDGPU::V_PERM_PK16_B8_U4_e64;
1304 }
1305
1306 // \returns true if \p MI clears the V_PERM_PK16 hazard when it immediately
1307 // follows a V_PERM_PK16 (i.e. \p MI is a "safe" instruction).
1309 unsigned Opc = MI.getOpcode();
1310
1311 // Only VALU ops issue on the pipe that clears the V_PERM_PK16 hazard.
1312 if (!isVALU(MI, /*AllowLDSDMA=*/false))
1313 return false;
1314 // OP_XDL: matrix (WMMA/SWMMAC/DOT) ops clear the hazard.
1315 if (isXDL(MI))
1316 return true;
1317 // Pseudo-scalar transcendentals (OP32_SCL_T) do NOT clear the hazard.
1319 return false;
1320
1321 // Use the table lookup, not getBlockingCycles(): occupancy is gated off on
1322 // gfx1251 but the hazard applies to both gfx1250 and gfx1251. Gfx1250 table
1323 // is valid enough for gfx1251 w.r.t. v_perm_pk16 safety check here.
1324 // OP_32_T is in the table at 2 and is safe; other table entries (>= 2) are
1325 // not.
1326 unsigned Cycles = getGFX1250BlockingCyclesTable(MI);
1327 return Cycles < 2 || (Cycles == 2 && isTRANS(MI));
1328 }
1329
1333
1334 bool doesNotReadTiedSource(uint32_t Opcode) const {
1335 return SIInstrFlags::isTiedSourceNotRead(get(Opcode));
1336 }
1337
1338 bool isIGLP(unsigned Opcode) const {
1339 return Opcode == AMDGPU::SCHED_BARRIER ||
1340 Opcode == AMDGPU::SCHED_GROUP_BARRIER || Opcode == AMDGPU::IGLP_OPT;
1341 }
1342
1343 bool isIGLP(const MachineInstr &MI) const { return isIGLP(MI.getOpcode()); }
1344
1345 // Return true if the instruction is mutually exclusive with all non-IGLP DAG
1346 // mutations, requiring all other mutations to be disabled.
1347 bool isIGLPMutationOnly(unsigned Opcode) const {
1348 return Opcode == AMDGPU::SCHED_GROUP_BARRIER || Opcode == AMDGPU::IGLP_OPT;
1349 }
1350
1351 static unsigned getNonSoftWaitcntOpcode(unsigned Opcode) {
1352 switch (Opcode) {
1353 case AMDGPU::S_WAITCNT_soft:
1354 return AMDGPU::S_WAITCNT;
1355 case AMDGPU::S_WAITCNT_VSCNT_soft:
1356 return AMDGPU::S_WAITCNT_VSCNT;
1357 case AMDGPU::S_WAIT_LOADCNT_soft:
1358 return AMDGPU::S_WAIT_LOADCNT;
1359 case AMDGPU::S_WAIT_STORECNT_soft:
1360 return AMDGPU::S_WAIT_STORECNT;
1361 case AMDGPU::S_WAIT_SAMPLECNT_soft:
1362 return AMDGPU::S_WAIT_SAMPLECNT;
1363 case AMDGPU::S_WAIT_BVHCNT_soft:
1364 return AMDGPU::S_WAIT_BVHCNT;
1365 case AMDGPU::S_WAIT_DSCNT_soft:
1366 return AMDGPU::S_WAIT_DSCNT;
1367 case AMDGPU::S_WAIT_KMCNT_soft:
1368 return AMDGPU::S_WAIT_KMCNT;
1369 case AMDGPU::S_WAIT_XCNT_soft:
1370 return AMDGPU::S_WAIT_XCNT;
1371 default:
1372 return Opcode;
1373 }
1374 }
1375
1376 static bool isWaitcnt(unsigned Opcode) {
1377 switch (getNonSoftWaitcntOpcode(Opcode)) {
1378 case AMDGPU::S_WAITCNT:
1379 case AMDGPU::S_WAITCNT_VSCNT:
1380 case AMDGPU::S_WAITCNT_VMCNT:
1381 case AMDGPU::S_WAITCNT_EXPCNT:
1382 case AMDGPU::S_WAITCNT_LGKMCNT:
1383 case AMDGPU::S_WAIT_LOADCNT:
1384 case AMDGPU::S_WAIT_LOADCNT_DSCNT:
1385 case AMDGPU::S_WAIT_STORECNT:
1386 case AMDGPU::S_WAIT_STORECNT_DSCNT:
1387 case AMDGPU::S_WAIT_SAMPLECNT:
1388 case AMDGPU::S_WAIT_BVHCNT:
1389 case AMDGPU::S_WAIT_EXPCNT:
1390 case AMDGPU::S_WAIT_DSCNT:
1391 case AMDGPU::S_WAIT_KMCNT:
1392 case AMDGPU::S_WAIT_XCNT:
1393 case AMDGPU::S_WAIT_ASYNCCNT:
1394 case AMDGPU::S_WAIT_TENSORCNT:
1395 case AMDGPU::S_WAIT_IDLE:
1396 return true;
1397 default:
1398 return false;
1399 }
1400 }
1401
1402 bool isVGPRCopy(const MachineInstr &MI) const {
1403 assert(isCopyInstr(MI));
1404 Register Dest = MI.getOperand(0).getReg();
1405 const MachineFunction &MF = *MI.getMF();
1406 const MachineRegisterInfo &MRI = MF.getRegInfo();
1407 return !RI.isSGPRReg(MRI, Dest);
1408 }
1409
1410 bool hasVGPRUses(const MachineInstr &MI) const {
1411 const MachineFunction &MF = *MI.getMF();
1412 const MachineRegisterInfo &MRI = MF.getRegInfo();
1413 return llvm::any_of(MI.explicit_uses(),
1414 [&MRI, this](const MachineOperand &MO) {
1415 return MO.isReg() && RI.isVGPR(MRI, MO.getReg());});
1416 }
1417
1418 /// Return true if the instruction modifies the mode register.q
1419 static bool modifiesModeRegister(const MachineInstr &MI);
1420
1421 /// This function is used to determine if an instruction can be safely
1422 /// executed under EXEC = 0 without hardware error, indeterminate results,
1423 /// and/or visible effects on future vector execution or outside the shader.
1424 /// Note: as of 2024 the only use of this is SIPreEmitPeephole where it is
1425 /// used in removing branches over short EXEC = 0 sequences.
1426 /// As such it embeds certain assumptions which may not apply to every case
1427 /// of EXEC = 0 execution.
1429
1430 /// Returns true if the instruction could potentially depend on the value of
1431 /// exec. If false, exec dependencies may safely be ignored.
1432 bool mayReadEXEC(const MachineRegisterInfo &MRI, const MachineInstr &MI) const;
1433
1434 bool isInlineConstant(const APInt &Imm) const;
1435
1436 bool isInlineConstant(const APFloat &Imm) const;
1437
1438 // Returns true if this non-register operand definitely does not need to be
1439 // encoded as a 32-bit literal. Note that this function handles all kinds of
1440 // operands, not just immediates.
1441 //
1442 // Some operands like FrameIndexes could resolve to an inline immediate value
1443 // that will not require an additional 4-bytes; this function assumes that it
1444 // will.
1445 bool isInlineConstant(const MachineOperand &MO, uint8_t OperandType) const {
1446 if (!MO.isImm())
1447 return false;
1448 return isInlineConstant(MO.getImm(), OperandType);
1449 }
1450 bool isInlineConstant(int64_t ImmVal, uint8_t OperandType) const;
1451
1453 const MCOperandInfo &OpInfo) const {
1454 return isInlineConstant(MO, OpInfo.OperandType);
1455 }
1456
1457 /// \p returns true if \p UseMO is substituted with \p DefMO in \p MI it would
1458 /// be an inline immediate.
1460 const MachineOperand &UseMO,
1461 const MachineOperand &DefMO) const {
1462 assert(UseMO.getParent() == &MI);
1463 int OpIdx = UseMO.getOperandNo();
1464 if (OpIdx >= MI.getDesc().NumOperands)
1465 return false;
1466
1467 return isInlineConstant(DefMO, MI.getDesc().operands()[OpIdx]);
1468 }
1469
1470 /// \p returns true if the operand \p OpIdx in \p MI is a valid inline
1471 /// immediate.
1472 bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx) const {
1473 const MachineOperand &MO = MI.getOperand(OpIdx);
1474 return isInlineConstant(MO, MI.getDesc().operands()[OpIdx].OperandType);
1475 }
1476
1477 bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx,
1478 int64_t ImmVal) const {
1479 if (OpIdx >= MI.getDesc().NumOperands)
1480 return false;
1481
1482 if (isCopyInstr(MI)) {
1483 unsigned Size = getOpSize(MI, OpIdx);
1484 assert(Size == 8 || Size == 4);
1485
1486 uint8_t OpType = (Size == 8) ?
1488 return isInlineConstant(ImmVal, OpType);
1489 }
1490
1491 return isInlineConstant(ImmVal, MI.getDesc().operands()[OpIdx].OperandType);
1492 }
1493
1494 bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx,
1495 const MachineOperand &MO) const {
1496 return isInlineConstant(MI, OpIdx, MO.getImm());
1497 }
1498
1499 bool isInlineConstant(const MachineOperand &MO) const {
1500 return isInlineConstant(*MO.getParent(), MO.getOperandNo());
1501 }
1502
1503 bool isImmOperandLegal(const MCInstrDesc &InstDesc, unsigned OpNo,
1504 const MachineOperand &MO) const;
1505
1506 bool isLiteralOperandLegal(const MCInstrDesc &InstDesc,
1507 const MCOperandInfo &OpInfo) const;
1508
1509 bool isImmOperandLegal(const MCInstrDesc &InstDesc, unsigned OpNo,
1510 int64_t ImmVal) const;
1511
1512 bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo,
1513 const MachineOperand &MO) const {
1514 return isImmOperandLegal(MI.getDesc(), OpNo, MO);
1515 }
1516
1517 /// Return true if \p ImmVal is legal for \p OpNo with modifiers \p Mods.
1518 bool isImmOperandLegalWithMods(const MachineInstr &MI, unsigned OpNo,
1519 int64_t ImmVal, unsigned Mods) const;
1520
1521 bool isNeverCoissue(MachineInstr &MI) const;
1522
1523 /// Check if this immediate value can be used for AV_MOV_B64_IMM_PSEUDO.
1524 bool isLegalAV64PseudoImm(uint64_t Imm) const;
1525
1526 /// Return true if this 64-bit VALU instruction has a 32-bit encoding.
1527 /// This function will return false if you pass it a 32-bit instruction.
1528 bool hasVALU32BitEncoding(unsigned Opcode) const;
1529
1530 /// Return true if \p Reg is a lane mask that already has 0 in every bit
1531 /// corresponding to a lane that is inactive in EXEC where \p Use executes,
1532 /// so that ANDing it with EXEC there would be a no-op. Requires SSA form.
1534 const MachineRegisterInfo &MRI, unsigned Depth = 0) const;
1535
1536 bool physRegUsesConstantBus(const MachineOperand &Reg) const;
1538 const MachineRegisterInfo &MRI) const;
1539
1540 /// Returns true if this operand uses the constant bus.
1542 const MachineOperand &MO,
1543 const MCOperandInfo &OpInfo) const;
1544
1546 int OpIdx) const {
1547 return usesConstantBus(MRI, MI.getOperand(OpIdx),
1548 MI.getDesc().operands()[OpIdx]);
1549 }
1550
1551 /// Return true if this instruction has any modifiers.
1552 /// e.g. src[012]_mod, omod, clamp.
1553 bool hasModifiers(unsigned Opcode) const;
1554
1555 bool hasModifiersSet(const MachineInstr &MI, AMDGPU::OpName OpName) const;
1556 bool hasAnyModifiersSet(const MachineInstr &MI) const;
1557
1558 bool canShrink(const MachineInstr &MI,
1559 const MachineRegisterInfo &MRI) const;
1560
1562 unsigned NewOpcode) const;
1563
1564 bool verifyInstruction(const MachineInstr &MI,
1565 StringRef &ErrInfo) const override;
1566
1567 unsigned getVALUOp(const MachineInstr &MI) const;
1568 unsigned getVALUOp(unsigned Opc) const;
1569
1572 const DebugLoc &DL, Register Reg, bool IsSCCLive,
1573 SlotIndexes *Indexes = nullptr) const;
1574
1577 Register Reg, SlotIndexes *Indexes = nullptr) const;
1578
1580
1581 /// Return the correct register class for \p OpNo. For target-specific
1582 /// instructions, this will return the register class that has been defined
1583 /// in tablegen. For generic instructions, like REG_SEQUENCE it will return
1584 /// the register class of its machine operand.
1585 /// to infer the correct register class base on the other operands.
1587 unsigned OpNo) const;
1588
1589 /// Return the size in bytes of the operand OpNo on the given
1590 // instruction opcode.
1591 unsigned getOpSize(uint32_t Opcode, unsigned OpNo) const {
1592 const MCOperandInfo &OpInfo = get(Opcode).operands()[OpNo];
1593
1594 if (OpInfo.RegClass == -1) {
1595 // If this is an immediate operand, this must be a 32-bit literal.
1596 assert(OpInfo.OperandType == MCOI::OPERAND_IMMEDIATE);
1597 return 4;
1598 }
1599
1600 return RI.getRegSizeInBits(*RI.getRegClass(getOpRegClassID(OpInfo))) / 8;
1601 }
1602
1603 /// This form should usually be preferred since it handles operands
1604 /// with unknown register classes.
1605 unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const {
1606 const MachineOperand &MO = MI.getOperand(OpNo);
1607 if (MO.isReg()) {
1608 if (unsigned SubReg = MO.getSubReg()) {
1609 return RI.getSubRegIdxSize(SubReg) / 8;
1610 }
1611 }
1612 return RI.getRegSizeInBits(*getOpRegClass(MI, OpNo)) / 8;
1613 }
1614
1615 /// Legalize the \p OpIndex operand of this instruction by inserting
1616 /// a MOV. For example:
1617 /// ADD_I32_e32 VGPR0, 15
1618 /// to
1619 /// MOV VGPR1, 15
1620 /// ADD_I32_e32 VGPR0, VGPR1
1621 ///
1622 /// If the operand being legalized is a register, then a COPY will be used
1623 /// instead of MOV.
1624 void legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const;
1625
1626 /// Check if \p MO is a legal operand if it was the \p OpIdx Operand
1627 /// for \p MI.
1628 bool isOperandLegal(const MachineInstr &MI, unsigned OpIdx,
1629 const MachineOperand *MO = nullptr) const;
1630
1631 /// Check if \p MO (a register operand) is a legal register for the
1632 /// given operand description or operand index.
1633 /// The operand index version provide more legality checks
1635 const MCOperandInfo &OpInfo,
1636 const MachineOperand &MO) const;
1637 bool isLegalRegOperand(const MachineInstr &MI, unsigned OpIdx,
1638 const MachineOperand &MO) const;
1639
1640 /// Check if \p MO would be a legal operand for a single-SGPR-read
1641 /// instruction.
1642 ///
1643 /// Single-SGPR-read instructions typically accept VGPRs, SGPRs, or immediates
1644 /// as source operands. On gfx12+, if a source operand uses SGPRs, the HW can
1645 /// only read the first SGPR and replicate the value across all lanes. \p SrcN
1646 /// can be 0, 1, or 2, representing src0, src1, and src2, respectively. If \p
1647 /// MO is nullptr, the operand corresponding to \p SrcN will be used. Non-SGPR
1648 /// operands are always considered legal.
1649 bool
1651 const MachineInstr &MI, unsigned SrcN,
1652 const MachineOperand *MO = nullptr) const;
1653
1654 /// Legalize operands in \p MI by either commuting it or inserting a
1655 /// copy of src1.
1657
1658 /// Fix operands in \p MI to satisfy constant bus requirements.
1660
1661 /// Copy a value from a VGPR (\p SrcReg) to SGPR. The desired register class
1662 /// for the dst register (\p DstRC) can be optionally supplied. This function
1663 /// can only be used when it is know that the value in SrcReg is same across
1664 /// all threads in the wave.
1665 /// \returns The SGPR register that \p SrcReg was copied to.
1668 const TargetRegisterClass *DstRC = nullptr) const;
1669
1672
1675 const TargetRegisterClass *DstRC,
1677 const DebugLoc &DL) const;
1678
1679 /// Legalize all operands in this instruction. This function may create new
1680 /// instructions and control-flow around \p MI. If present, \p MDT is
1681 /// updated.
1682 /// \returns A new basic block that contains \p MI if new blocks were created.
1684 legalizeOperands(MachineInstr &MI, MachineDominatorTree *MDT = nullptr) const;
1685
1686 /// Change SADDR form of a FLAT \p Inst to its VADDR form if saddr operand
1687 /// was moved to VGPR. \returns true if succeeded.
1688 bool moveFlatAddrToVGPR(MachineInstr &Inst) const;
1689
1690 /// Fix operands in Inst to fix 16bit SALU to VALU lowering.
1692 MachineRegisterInfo &MRI) const;
1693 void legalizeOperandsVALUt16(MachineInstr &Inst, unsigned OpIdx,
1694 MachineRegisterInfo &MRI) const;
1695
1696 /// Build a 32-bit VGPR whose low half is the 16-bit value \p Src.SrcSubReg
1697 /// and whose high half is undefined. The instructions are inserted before
1698 /// \p I. \returns the new register.
1701 const DebugLoc &DL, Register Src,
1702 unsigned SrcSubReg) const;
1703
1704 /// Replace the instructions opcode with the equivalent VALU
1705 /// opcode. This function will also move the users of MachineInstruntions
1706 /// in the \p WorkList to the VALU if necessary. If present, \p MDT is
1707 /// updated.
1708 void moveToVALU(SIInstrWorklist &Worklist, MachineDominatorTree *MDT) const;
1709
1710 void
1712 MachineInstr &Inst,
1714 DenseMap<MachineInstr *, bool> &V2SPhyCopiesToErase) const;
1715 /// Wrapper function for generating waterfall for instruction \p MI
1716 /// This function take into consideration of related pre & succ instructions
1717 /// (e.g. calling process) into consideratioin
1720 ArrayRef<Register> PhySGPRs = {}) const;
1721
1722 void insertNoop(MachineBasicBlock &MBB,
1723 MachineBasicBlock::iterator MI) const override;
1724
1725 void insertNoops(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
1726 unsigned Quantity) const override;
1727
1728 /// Build instructions that simulate the behavior of a `s_trap 2` instructions
1729 /// for hardware (namely, gfx11) that runs in PRIV=1 mode. There, s_trap is
1730 /// interpreted as a nop.
1731 MachineBasicBlock *insertSimulatedTrap(MachineRegisterInfo &MRI,
1732 MachineBasicBlock &MBB,
1733 MachineInstr &MI,
1734 const DebugLoc &DL) const;
1735
1736 /// Return the number of wait states that result from executing this
1737 /// instruction.
1738 static unsigned getNumWaitStates(const MachineInstr &MI);
1739
1740 /// Returns the operand named \p Op. If \p MI does not have an
1741 /// operand named \c Op, this function returns nullptr.
1743 MachineOperand *getNamedOperand(MachineInstr &MI,
1744 AMDGPU::OpName OperandName) const;
1745
1748 AMDGPU::OpName OperandName) const {
1749 return getNamedOperand(const_cast<MachineInstr &>(MI), OperandName);
1750 }
1751
1752 /// Get required immediate operand
1754 AMDGPU::OpName OperandName) const {
1755 int Idx = AMDGPU::getNamedOperandIdx(MI.getOpcode(), OperandName);
1756 return MI.getOperand(Idx).getImm();
1757 }
1758
1761
1762 bool isLowLatencyInstruction(const MachineInstr &MI) const;
1763 bool isHighLatencyDef(int Opc) const override;
1764
1765 /// Return the descriptor of the target-specific machine instruction
1766 /// that corresponds to the specified pseudo or native opcode.
1767 const MCInstrDesc &getMCOpcodeFromPseudo(unsigned Opcode) const {
1768 return get(pseudoToMCOpcode(Opcode));
1769 }
1770
1771 Register isStackAccess(const MachineInstr &MI, int &FrameIndex,
1772 TypeSize &MemBytes) const;
1773 Register isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex,
1774 TypeSize &MemBytes) const;
1775
1777 int &FrameIndex) const override {
1778 TypeSize MemBytes = TypeSize::getZero();
1779 return isLoadFromStackSlot(MI, FrameIndex, MemBytes);
1780 }
1781
1782 Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex,
1783 TypeSize &MemBytes) const override;
1784
1786 int &FrameIndex) const override {
1787 TypeSize MemBytes = TypeSize::getZero();
1788 return isStoreToStackSlot(MI, FrameIndex, MemBytes);
1789 }
1790
1791 Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex,
1792 TypeSize &MemBytes) const override;
1793
1794 unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
1795
1796 InstSizeVerifyMode
1797 getInstSizeVerifyMode(const MachineInstr &MI) const override;
1798
1799 std::pair<unsigned, unsigned>
1800 decomposeMachineOperandsTargetFlags(unsigned TF) const override;
1801
1803 getSerializableTargetIndices() const override;
1804
1807
1810
1813 const ScheduleDAG *DAG) const override;
1814
1817 MachineLoopInfo *MLI) const override;
1818
1821 const ScheduleDAGMI *DAG) const override;
1822
1824 const MachineFunction &MF) const override;
1825
1827 Register Reg = Register()) const override;
1828
1829 bool canAddToBBProlog(const MachineInstr &MI) const;
1830
1833 const DebugLoc &DL, Register Src,
1834 Register Dst) const override;
1835
1838 const DebugLoc &DL, Register Src,
1839 unsigned SrcSubReg,
1840 Register Dst) const override;
1841
1842 bool isWave32() const;
1843
1844 bool isVOPDAntidependencyAllowed(const MachineInstr &MI) const;
1845
1846 bool hasRAWDependency(const MachineInstr &FirstMI,
1847 const MachineInstr &SecondMI) const;
1848
1849 /// Return a partially built integer add instruction without carry.
1850 /// Caller must add source operands.
1851 /// For pre-GFX9 it will generate unused carry destination operand.
1852 /// TODO: After GFX9 it should return a no-carry operation.
1855 const DebugLoc &DL,
1856 Register DestReg) const;
1857
1860 const DebugLoc &DL,
1861 Register DestReg,
1862 RegScavenger &RS) const;
1863
1864 static bool isKillTerminator(unsigned Opcode);
1865 const MCInstrDesc &getKillTerminatorFromPseudo(unsigned Opcode) const;
1866
1867 bool isLegalMUBUFImmOffset(unsigned Imm) const;
1868
1869 static unsigned getMaxMUBUFImmOffset(const GCNSubtarget &ST);
1870
1871 bool splitMUBUFOffset(uint32_t Imm, uint32_t &SOffset, uint32_t &ImmOffset,
1872 Align Alignment = Align(4)) const;
1873
1874 /// Returns if \p Offset is legal for the subtarget as the offset to a FLAT
1875 /// encoded instruction with the given \p FlatVariant.
1876 bool isLegalFLATOffset(int64_t Offset, unsigned AddrSpace,
1877 AMDGPU::FlatAddrSpace FlatVariant) const;
1878
1879 /// Split \p COffsetVal into {immediate offset field, remainder offset}
1880 /// values.
1881 std::pair<int64_t, int64_t>
1882 splitFlatOffset(int64_t COffsetVal, unsigned AddrSpace,
1883 AMDGPU::FlatAddrSpace FlatVariant) const;
1884
1885 /// Returns true if negative offsets are allowed for the given \p FlatVariant.
1886 bool allowNegativeFlatOffset(AMDGPU::FlatAddrSpace FlatVariant) const;
1887
1888 /// \brief Return a target-specific opcode if Opcode is a pseudo instruction.
1889 /// Return -1 if the target-specific opcode for the pseudo instruction does
1890 /// not exist. If Opcode is not a pseudo instruction, this is identity.
1891 int pseudoToMCOpcode(int Opcode) const;
1892
1893 /// \brief Check if this instruction should only be used by assembler.
1894 /// Return true if this opcode should not be used by codegen.
1895 bool isAsmOnlyOpcode(int MCOp) const;
1896
1897 void fixImplicitOperands(MachineInstr &MI) const;
1898
1900 ArrayRef<unsigned> Ops, int FrameIndex,
1901 MachineInstr *&CopyMI,
1902 LiveIntervals *LIS = nullptr,
1903 VirtRegMap *VRM = nullptr) const override;
1904
1905 unsigned getInstrLatency(const InstrItineraryData *ItinData,
1906 const MachineInstr &MI,
1907 unsigned *PredCost = nullptr) const override;
1908
1909 unsigned getBlockingCycles(const MachineInstr &MI) const;
1910
1911 /// GFX1250 blocking-cycles table lookup with no occupancy subtarget gate.
1912 /// Returns 0 if \p MI is not in the table. Used as a multi-pass VALU denylist
1913 /// (e.g. V_PERM_PK16 hazard) on both gfx1250 and gfx1251.
1914 unsigned getGFX1250BlockingCyclesTable(const MachineInstr &MI) const;
1915
1916 const MachineOperand &getCalleeOperand(const MachineInstr &MI) const override;
1917
1919
1921
1922 const MIRFormatter *getMIRFormatter() const override;
1923
1924 static unsigned getDSShaderTypeValue(const MachineFunction &MF);
1925
1926 const TargetSchedModel &getSchedModel() const { return SchedModel; }
1927
1929 Register DstReg,
1930 MachineInstr &Inst) const;
1931
1933 SIInstrWorklist &Worklist, Register DstReg, MachineInstr &Inst,
1936 DenseMap<MachineInstr *, bool> &V2SPhyCopiesToErase) const;
1937
1938 // FIXME: This should be removed
1939 // Enforce operand's \p OpName even alignment if required by target.
1940 // This is used if an operand is a 32 bit register but needs to be aligned
1941 // regardless.
1942 void enforceOperandRCAlignment(MachineInstr &MI, AMDGPU::OpName OpName) const;
1943};
1944
1945/// \brief Returns true if a reg:subreg pair P has a TRC class
1947 const TargetRegisterClass &TRC,
1949 auto *RC = MRI.getRegClass(P.Reg);
1950 if (!P.SubReg)
1951 return RC == &TRC;
1952 auto *TRI = MRI.getTargetRegisterInfo();
1953 return RC == TRI->getMatchingSuperRegClass(RC, &TRC, P.SubReg);
1954}
1955
1956/// \brief Create RegSubRegPair from a register MachineOperand
1957inline
1959 assert(O.isReg());
1960 return TargetInstrInfo::RegSubRegPair(O.getReg(), O.getSubReg());
1961}
1962
1963/// \brief Return the SubReg component from REG_SEQUENCE
1964TargetInstrInfo::RegSubRegPair getRegSequenceSubReg(MachineInstr &MI,
1965 unsigned SubReg);
1966
1967/// \brief Return the defining instruction for a given reg:subreg pair
1968/// skipping copy like instructions and subreg-manipulation pseudos.
1969/// Following another subreg of a reg:subreg isn't supported.
1970MachineInstr *getVRegSubRegDef(const TargetInstrInfo::RegSubRegPair &P,
1971 const MachineRegisterInfo &MRI);
1972
1973/// \brief Return false if EXEC is not changed between the def of \p VReg at \p
1974/// DefMI and the use at \p UseMI. Should be run on SSA. Currently does not
1975/// attempt to track between blocks.
1976bool execMayBeModifiedBeforeUse(const MachineRegisterInfo &MRI,
1977 Register VReg,
1978 const MachineInstr &DefMI,
1979 const MachineInstr &UseMI);
1980
1981/// \brief Return false if EXEC is not changed between the def of \p VReg at \p
1982/// DefMI and all its uses. Should be run on SSA. Currently does not attempt to
1983/// track between blocks.
1984bool execMayBeModifiedBeforeAnyUse(const MachineRegisterInfo &MRI,
1985 Register VReg,
1986 const MachineInstr &DefMI);
1987
1988namespace AMDGPU {
1989
1991 int32_t getVOPe64(uint32_t Opcode);
1992
1994 int32_t getVOPe32(uint32_t Opcode);
1995
1997 int32_t getSDWAOp(uint32_t Opcode);
1998
2000 int32_t getDPPOp32(uint32_t Opcode);
2001
2003 int32_t getDPPOp64(uint32_t Opcode);
2004
2007
2009 int32_t getCommuteRev(uint32_t Opcode);
2010
2012 int32_t getCommuteOrig(uint32_t Opcode);
2013
2015 int32_t getAddr64Inst(uint32_t Opcode);
2016
2017 /// Check if \p Opcode is an Addr64 opcode.
2018 ///
2019 /// \returns \p Opcode if it is an Addr64 opcode, otherwise -1.
2021 int32_t getIfAddr64Inst(uint32_t Opcode);
2022
2024 int32_t getSOPKOp(uint32_t Opcode);
2025
2026 /// \returns SADDR form of a FLAT Global instruction given an \p Opcode
2027 /// of a VADDR form.
2030
2031 /// \returns VADDR form of a FLAT Global instruction given an \p Opcode
2032 /// of a SADDR form.
2035
2036 /// \returns ST form with only immediate offset of a FLAT Scratch instruction
2037 /// given an \p Opcode of an SS (SADDR) form.
2040
2041 /// \returns SV (VADDR) form of a FLAT Scratch instruction given an \p Opcode
2042 /// of an SVS (SADDR + VADDR) form.
2045
2046 /// \returns SS (SADDR) form of a FLAT Scratch instruction given an \p Opcode
2047 /// of an SV (VADDR) form.
2050
2051 /// \returns SV (VADDR) form of a FLAT Scratch instruction given an \p Opcode
2052 /// of an SS (SADDR) form.
2055
2056 /// \returns earlyclobber version of a MAC MFMA is exists.
2059
2060 /// \returns Version of an instruction which uses AGPRs for coupled operands
2061 /// given an \p Opcode which uses VGPRs for coupled operands.
2063 int32_t getAGPRFormOp(uint32_t Opcode);
2064
2065 /// \returns v_cmpx version of a v_cmp instruction.
2068
2069 const uint64_t RSRC_DATA_FORMAT = 0xf00000000000LL;
2072 const uint64_t RSRC_TID_ENABLE = UINT64_C(1) << (32 + 23);
2073
2074} // end namespace AMDGPU
2075
2076namespace AMDGPU {
2078 // For sgpr to vgpr spill instructions
2080};
2081} // namespace AMDGPU
2082
2083namespace SI {
2085
2086/// Offsets in bytes from the start of the input buffer
2098
2099} // end namespace KernelInputOffsets
2100} // end namespace SI
2101
2102} // end namespace llvm
2103
2104#endif // LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
uint64_t Imm
Provides AMDGPU specific target descriptions.
AMDGPU specific overrides of MIRFormatter.
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_READONLY
Definition Compiler.h:334
IRTranslator LLVM IR MI
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
SmallVector< MachineOperand, 4 > Cond
unsigned Opc
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
uint64_t IntrinsicInst * II
#define P(N)
MachineRegisterInfo & MRI
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
Interface definition for SIRegisterInfo.
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
static unsigned getBranchOpcode(ISD::CondCode Cond)
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A debug info location.
Definition DebugLoc.h:126
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:88
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:20
Represents one node in the SelectionDAG.
bool usesFPDPRounding(uint32_t Opcode) const
static bool isCBranchVCCZRead(const MachineInstr &MI)
bool isLegalMUBUFImmOffset(unsigned Imm) 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.
bool canAddToBBProlog(const MachineInstr &MI) const
static std::optional< unsigned > extractSubregFromGlobalAddressFlags(unsigned TargetFlags, unsigned SubRegIndex)
Return the target flags for a global address operand reading subregister SubRegIndex of a 64-bit glob...
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
bool isWQM(uint32_t Opcode) const
static bool isVOP3(const MachineInstr &MI)
bool isMTBUF(uint32_t Opcode) const
unsigned getLiveRangeSplitOpcode(Register Reg, const MachineFunction &MF) const override
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
static bool isNeverUniform(const MachineInstr &MI)
bool isXDLWMMA(const MachineInstr &MI) const
void handleCopyToPhysHelper(SIInstrWorklist &Worklist, Register DstReg, MachineInstr &Inst, MachineRegisterInfo &MRI, MachineDominatorTree *MDT, DenseMap< MachineInstr *, V2PhysSCopyInfo > &WaterFalls, DenseMap< MachineInstr *, bool > &V2SPhyCopiesToErase) const
bool isBasicBlockPrologue(const MachineInstr &MI, Register Reg=Register()) const override
bool isSpill(uint32_t Opcode) const
bool isMUBUF(uint32_t Opcode) const
uint64_t getDefaultRsrcDataFormat() const
static bool isSOPP(const MachineInstr &MI)
bool hasVGPRUses(const MachineInstr &MI) const
bool mayAccessScratch(const MachineInstr &MI) const
bool isIGLP(unsigned Opcode) const
static bool isFLATScratch(const MachineInstr &MI)
Register buildVGPR32FromLo16(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register Src, unsigned SrcSubReg) const
Build a 32-bit VGPR whose low half is the 16-bit value Src.SrcSubReg and whose high half is undefined...
bool isLegalFLATOffset(int64_t Offset, unsigned AddrSpace, AMDGPU::FlatAddrSpace FlatVariant) const
Returns if Offset is legal for the subtarget as the offset to a FLAT encoded instruction with the giv...
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 isVOP3PMix(uint16_t Opcode) 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
bool isIgnorableUse(const MachineInstr &MI, unsigned OpIdx) const override
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.
bool isDisableWQM(uint32_t Opcode) const
static bool isSMRD(const MachineInstr &MI)
unsigned getGFX1250BlockingCyclesTable(const MachineInstr &MI) const
GFX1250 blocking-cycles table lookup with no occupancy subtarget gate.
void restoreExec(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, Register Reg, SlotIndexes *Indexes=nullptr) const
void storeRegToStackSlotCFI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC) 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)
bool doesNotReadTiedSource(uint32_t Opcode) const
bool isSOPK(uint32_t Opcode) const
static unsigned getFoldableCopySrcIdx(const MachineInstr &MI)
unsigned getOpSize(uint32_t Opcode, unsigned OpNo) const
Return the size in bytes of the operand OpNo on the given.
bool isLDSDMA(uint32_t Opcode) const
static bool hasSameClamp(const MachineInstr &A, const MachineInstr &B)
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 getMemOperandsWithOffsetWidth(const MachineInstr &LdSt, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, LocationSize &Width) const final
bool usesConstantBus(const MachineRegisterInfo &MRI, const MachineInstr &MI, int OpIdx) const
const TargetRegisterClass * getInlineAsmMemoryOperandRegClass(InlineAsm::ConstraintCode C) const override
bool isAtomicRet(uint32_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 isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool isVINTRP(uint32_t Opcode) const
bool isSOP1(uint32_t Opcode) const
static bool isMTBUF(const MachineInstr &MI)
const MCInstrDesc & getIndirectGPRIDXPseudo(unsigned VecSize, bool IsIndirectSrc) const
static bool isDGEMM(unsigned Opcode)
static bool isEXP(const MachineInstr &MI)
static bool isSALU(const MachineInstr &MI)
static bool setsSCCIfResultIsNonZero(const MachineInstr &MI)
const MIRFormatter * getMIRFormatter() const override
bool isSGPRSpill(uint32_t Opcode) const
static bool isXcntDrain(const MachineInstr &MI)
True if MI implicitly drains XCNT.
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
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)
const MCInstrDesc & getKillTerminatorFromPseudo(unsigned Opcode) const
static bool mayWriteLDSThroughDMA(const MachineInstr &MI)
void insertNoops(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned Quantity) const override
bool isDOT(uint32_t Opcode) const
static bool isVINTRP(const MachineInstr &MI)
bool isIGLPMutationOnly(unsigned Opcode) const
static bool isGather4(const MachineInstr &MI)
bool isDS(uint32_t Opcode) const
MachineInstr * getWholeWaveFunctionSetup(MachineFunction &MF) const
static bool isMFMAorWMMA(const MachineInstr &MI)
static bool isWQM(const MachineInstr &MI)
static bool doesNotReadTiedSource(const MachineInstr &MI)
static bool isDOT(const MachineInstr &MI)
std::unique_ptr< PipelinerLoopInfo > analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const override
InstSizeVerifyMode getInstSizeVerifyMode(const MachineInstr &MI) const override
bool isGather4(uint32_t Opcode) const
static bool usesFPDPRounding(const MachineInstr &MI)
bool isVIMAGE(uint32_t Opcode) const
MachineInstr * createPHISourceCopy(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt, const DebugLoc &DL, Register Src, unsigned SrcSubReg, Register Dst) const override
bool isImage(uint32_t Opcode) const
static bool usesTENSOR_CNT(const MachineInstr &MI)
bool isInlineConstant(const MachineOperand &MO) const
bool hasModifiers(unsigned Opcode) const
Return true if this instruction has any modifiers.
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 isDPP(uint32_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 hasFPClamp(uint32_t Opcode) const
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx, int64_t ImmVal) const
bool isImmEquivalentToReg(const MachineInstr &MI, unsigned OpIdx, int64_t Imm) const
Return true if Imm reads the same as a register holding Imm.
bool isGWS(uint32_t Opcode) const
unsigned getVectorRegSpillRestoreOpcode(Register Reg, const TargetRegisterClass *RC, unsigned Size, const SIMachineFunctionInfo &MFI) const
bool isLegalSingleSGPRReadInstOperand(const MachineRegisterInfo &MRI, const MachineInstr &MI, unsigned SrcN, const MachineOperand *MO=nullptr) const
Check if MO would be a legal operand for a single-SGPR-read instruction.
bool isXDL(const MachineInstr &MI) const
Register isStackAccess(const MachineInstr &MI, int &FrameIndex, TypeSize &MemBytes) 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 hasRAWDependency(const MachineInstr &FirstMI, const MachineInstr &SecondMI) const
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
static bool isBUF(const MachineInstr &MI)
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.
bool isSOPC(uint32_t Opcode) const
bool isMAI(uint32_t Opcode) const
bool isNonCommutableDPP(const MachineInstr &MI) const
bool hasModifiersSet(const MachineInstr &MI, AMDGPU::OpName OpName) const
bool isLegalToSwap(const MachineInstr &MI, unsigned fromIdx, unsigned toIdx) const
bool isFixedSize(uint32_t Opcode) const
static bool isFLATGlobal(const MachineInstr &MI)
unsigned getMachineCSELookAheadLimit() const override
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, int FrameIndex, MachineInstr *&CopyMI, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
bool isGlobalMemoryObject(const MachineInstr *MI) const override
bool canInsertSelect(const MachineBasicBlock &MBB, ArrayRef< MachineOperand > Cond, Register DstReg, Register TrueReg, Register FalseReg, SelectExpansion &Exp) 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 isVOPDAntidependencyAllowed(const MachineInstr &MI) const
If OpX is multicycle, anti-dependencies are not allowed.
bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx0, unsigned &SrcOpIdx1) const override
const GCNSubtarget & getSubtarget() const
void insertScratchExecCopy(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, Register Reg, bool IsSCCLive, SlotIndexes *Indexes=nullptr) 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)
unsigned getBlockingCycles(const MachineInstr &MI) const
bool isVOP3PMix(const MachineInstr &MI) const
unsigned getMovOpcode(const TargetRegisterClass *DstRC) const
Register isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex, TypeSize &MemBytes) const
bool isMFMAorWMMA(uint32_t Opcode) const
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.
static bool isVPermPk16(unsigned Opcode)
bool isFLATGlobal(uint32_t Opcode) const
static bool isVALU(const MachineInstr &MI, bool AllowLDSDMA)
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,...
std::optional< unsigned > getImmOpSelForValue(const MachineInstr &MI, unsigned OpIdx, int64_t Imm, int64_t Value, unsigned Mods) const
Return Mods with op_sel chosen so that Imm reads Value.
bool isMIMG(uint32_t Opcode) const
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.
bool isVGPRSpill(uint32_t Opcode) const
static unsigned getDSShaderTypeValue(const MachineFunction &MF)
static bool isFoldableCopy(const MachineInstr &MI)
bool isAtomic(uint32_t Opcode) const
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
void createWaterFallForSiCall(MachineInstr *MI, MachineDominatorTree *MDT, ArrayRef< MachineOperand * > ScalarOps, ArrayRef< Register > PhySGPRs={}) const
Wrapper function for generating waterfall for instruction MI This function take into consideration of...
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
static bool hasFPClamp(const MachineInstr &MI)
bool isVOP2(uint32_t Opcode) const
AMDGPU::AsyncStages getAsyncStage(const MachineInstr &MI) const
static bool isGFX12CacheInvOrWBInst(unsigned Opc)
static bool isSegmentSpecificFLAT(const MachineInstr &MI)
static bool isWaitcnt(unsigned Opcode)
bool isReMaterializableImpl(const MachineInstr &MI) const override
bool isFLATScratch(uint32_t Opcode) const
static bool isVOP3(const MCInstrDesc &Desc)
int64_t getSrcOperandValue(const MachineInstr &MI, unsigned OpIdx, int64_t Bits, unsigned Mods) const
Return the sign extended value operand OpIdx reads from Bits.
unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const
This form should usually be preferred since it handles operands with unknown register classes.
bool isSegmentSpecificFLAT(uint32_t Opcode) const
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool physRegUsesConstantBus(const MachineOperand &Reg) const
bool isInlineConstant(const MachineOperand &MO, const MCOperandInfo &OpInfo) 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)
bool isVOPC(uint32_t Opcode) const
static bool isDPP(const MachineInstr &MI)
bool analyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const
bool isPacked(uint32_t Opcode) const
static bool isMFMA(const MachineInstr &MI)
bool isLowLatencyInstruction(const MachineInstr &MI) const
bool isIGLP(const MachineInstr &MI) const
static bool isScalarStore(const MachineInstr &MI)
bool isFLAT(uint32_t Opcode) const
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 isVALU(uint32_t Opcode, bool AllowLDSDMA) const
LDSDMA instructions act as both VALU and memory instructions, thus we also tag them as VALU.
void mutateAndCleanupImplicit(MachineInstr &MI, const MCInstrDesc &NewDesc) const
ValueUniformity getGenericValueUniformity(const MachineInstr &MI) const
static bool isMAI(const MCInstrDesc &Desc)
static bool isSrc1DPPRevOpcode(const GCNSubtarget &ST, uint32_t Opcode)
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, unsigned SubIdx, const MachineInstr &Orig, LaneBitmask UsedLanes=LaneBitmask::getAll()) const override
static bool isFPAtomic(const MachineInstr &MI)
static bool usesLGKM_CNT(const MachineInstr &MI)
bool isFPAtomic(uint32_t Opcode) const
void legalizeOperandsVALUt16(MachineInstr &Inst, MachineRegisterInfo &MRI) const
Fix operands in Inst to fix 16bit SALU to VALU lowering.
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
const MachineOperand & getCalleeOperand(const MachineInstr &MI) const override
bool isVPermPk16SafeInstr(const MachineInstr &MI) const
bool isAsmOnlyOpcode(int MCOp) const
Check if this instruction should only be used by assembler.
bool isAlwaysGDS(uint32_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)
unsigned getInstrLatency(const InstrItineraryData *ItinData, const MachineInstr &MI, unsigned *PredCost=nullptr) const override
unsigned getVectorRegSpillSaveOpcode(Register Reg, const TargetRegisterClass *RC, unsigned Size, const SIMachineFunctionInfo &MFI, bool NeedsCFI) const
int64_t getNamedImmOperand(const MachineInstr &MI, AMDGPU::OpName OperandName) const
Get required immediate operand.
bool isSOP2(uint32_t Opcode) const
ArrayRef< std::pair< int, const char * > > getSerializableTargetIndices() const override
bool isVGPRCopy(const MachineInstr &MI) const
bool isVOP1(uint32_t Opcode) const
bool isVINTERP(uint32_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
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...
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)
bool isVAVDSTOrderedXDL(const MachineInstr &MI) const
On gfx1250, an XDL instruction whose destination spans at least eight VGPRs decrements VA_VDST only a...
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
std::pair< int64_t, int64_t > splitFlatOffset(int64_t COffsetVal, unsigned AddrSpace, AMDGPU::FlatAddrSpace FlatVariant) const
Split COffsetVal into {immediate offset field, remainder offset} values.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool isVOP3P(uint32_t Opcode) const
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.
bool isSWMMAC(uint32_t Opcode) const
static bool usesASYNC_CNT(const MachineInstr &MI)
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 isMaskedByExec(Register Reg, const MachineInstr &Use, const MachineRegisterInfo &MRI, unsigned Depth=0) const
Return true if Reg is a lane mask that already has 0 in every bit corresponding to a lane that is ina...
void createReadFirstLaneFromCopyToPhysReg(MachineRegisterInfo &MRI, Register DstReg, MachineInstr &Inst) const
bool swapSourceModifiers(MachineInstr &MI, MachineOperand &Src0, AMDGPU::OpName Src0OpName, MachineOperand &Src1, AMDGPU::OpName Src1OpName) const
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
static bool isDualSourceBlendEXP(const MachineInstr &MI)
bool isAsync(const MachineInstr &MI) const
bool memOpsHaveSameBase(ArrayRef< const MachineOperand * > BaseOps1, ArrayRef< const MachineOperand * > BaseOps2) const
Return true if the memory operations described by BaseOps1 and BaseOps2 (as returned by getMemOperand...
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 isLiteralOperandLegal(const MCInstrDesc &InstDesc, const MCOperandInfo &OpInfo) const
static bool isWWMRegSpillOpcode(uint32_t Opcode)
static bool sopkIsZext(unsigned Opcode)
static bool isSGPRSpill(const MachineInstr &MI)
static bool isWMMA(const MachineInstr &MI)
bool isMFMA(uint32_t Opcode) const
ArrayRef< std::pair< MachineMemOperand::Flags, const char * > > getSerializableMachineMemOperandTargetFlags() const override
bool mayReadEXEC(const MachineRegisterInfo &MRI, const MachineInstr &MI) const
Returns true if the instruction could potentially depend on the value of exec.
bool isSALU(uint32_t Opcode) const
bool isSMRD(uint32_t Opcode) const
bool isWMMA(uint32_t Opcode) const
void legalizeOperandsSMRD(MachineRegisterInfo &MRI, MachineInstr &MI) const
bool isVSAMPLE(uint32_t Opcode) const
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
std::pair< MachineInstr *, MachineInstr * > expandMovDPP64(MachineInstr &MI) const
static bool isLoadMonitor(unsigned Opc)
static bool isSOP1(const MachineInstr &MI)
static bool isSOPC(const MachineInstr &MI)
bool isSOPP(uint32_t Opcode) const
static bool isFLAT(const MachineInstr &MI)
const SIRegisterInfo & getRegisterInfo() const
bool isLDSDIR(uint32_t Opcode) const
bool isBarrier(unsigned Opcode) const
bool isAtomicNoRet(uint32_t Opcode) const
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx0, unsigned OpIdx1) const override
bool isVOP3(uint32_t Opcode) const
bool mayAccessLDSThroughFlat(const MachineInstr &MI, bool TgSplit) const
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 isEXP(uint32_t Opcode) const
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx, const MachineOperand &MO) const
bool isImmOperandLegalWithMods(const MachineInstr &MI, unsigned OpNo, int64_t ImmVal, unsigned Mods) const
Return true if ImmVal is legal for OpNo with modifiers Mods.
static bool usesVM_CNT(const MachineInstr &MI)
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
static bool isPseudoScalarTrans(unsigned Opcode)
bool usesTENSOR_CNT(uint32_t Opcode) const
LLVM_READONLY int commuteOpcode(unsigned Opc) const
bool isScalarStore(uint32_t Opcode) const
unsigned getNumOpSelBits(const MachineInstr &MI, unsigned OpIdx) const
Return how many op_sel bits select a half of source operand OpIdx.
static bool isBlockLoadStore(uint32_t Opcode)
ValueUniformity getValueUniformity(const MachineInstr &MI) const final
uint64_t getScratchRsrcWords23() const
bool usesASYNC_CNT(uint32_t Opcode) const
LLVM_READONLY MachineOperand * getNamedOperand(MachineInstr &MI, AMDGPU::OpName OperandName) const
Returns the operand named Op.
MachineInstr * convertToThreeAddress(MachineInstr &MI, LiveIntervals *LIS) const override
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
bool isVMEM(uint32_t Opcode) const
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.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
bool allowNegativeFlatOffset(AMDGPU::FlatAddrSpace FlatVariant) const
Returns true if negative offsets are allowed for the given FlatVariant.
bool isBarrierStart(unsigned Opcode) const
void moveToVALUImpl(SIInstrWorklist &Worklist, MachineDominatorTree *MDT, MachineInstr &Inst, DenseMap< MachineInstr *, V2PhysSCopyInfo > &WaterFalls, DenseMap< MachineInstr *, bool > &V2SPhyCopiesToErase) const
static bool isLDSDMA(const MachineInstr &MI)
static bool isAtomicNoRet(const MachineInstr &MI)
static bool isVOP1(const MachineInstr &MI)
SIInstrInfo(const GCNSubtarget &ST)
bool isNonAsyncLdsDmaWrite(const MachineInstr &MI) const
std::optional< int64_t > getImmOrMaterializedImm(const MachineRegisterInfo &MRI, const MachineOperand &Op, MachineInstr **DefMI=nullptr) const
void insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, MachineBasicBlock &RestoreBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS) const override
bool isTRANS(uint32_t Opcode) const
bool isSDWA(uint32_t Opcode) const
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:57
SlotIndexes pass.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
Definition SetVector.h:346
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Provide an instruction scheduling machine model to CodeGen passes.
Target - Wrapper for Target specific information.
static constexpr TypeSize getZero()
Definition TypeSize.h:358
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
LLVM Value Representation.
Definition Value.h:75
const uint64_t RSRC_DATA_FORMAT
LLVM_READONLY int32_t getSOPKOp(uint32_t Opcode)
LLVM_READONLY int32_t getCommuteRev(uint32_t Opcode)
LLVM_READONLY int32_t getCommuteOrig(uint32_t Opcode)
LLVM_READONLY int32_t getDPPOp32(uint32_t Opcode)
AsyncStages
Bit mask of the async stages tracked by the asyncmark / wait_asyncmark intrinsics.
LLVM_READONLY int32_t getGlobalVaddrOp(uint32_t Opcode)
LLVM_READONLY int32_t getMFMAEarlyClobberOp(uint32_t Opcode)
const uint64_t RSRC_ELEMENT_SIZE_SHIFT
LLVM_READONLY int32_t getIfAddr64Inst(uint32_t Opcode)
Check if Opcode is an Addr64 opcode.
const uint64_t RSRC_TID_ENABLE
LLVM_READONLY int32_t getVOPe32(uint32_t Opcode)
LLVM_READONLY int32_t getSDWAOp(uint32_t Opcode)
LLVM_READONLY int32_t getVCMPXOpFromVCMP(uint32_t Opcode)
LLVM_READONLY int32_t getAGPRFormOp(uint32_t Opcode)
LLVM_READONLY int32_t getGlobalSaddrOp(uint32_t Opcode)
LLVM_READONLY int32_t getAddr64Inst(uint32_t Opcode)
LLVM_READONLY int32_t getVOPe64(uint32_t Opcode)
LLVM_READONLY int32_t getDPPOp64(uint32_t Opcode)
@ OPERAND_REG_IMM_INT64
Definition SIDefines.h:432
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
Definition SIDefines.h:431
LLVM_READONLY int32_t getBasicFromSDWAOp(uint32_t Opcode)
LLVM_READONLY int32_t getFlatScratchInstSSfromSV(uint32_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 int32_t getFlatScratchInstSVfromSVS(uint32_t Opcode)
LLVM_READONLY int32_t getFlatScratchInstSVfromSS(uint32_t Opcode)
LLVM_READONLY int32_t getFlatScratchInstSTfromSS(uint32_t Opcode)
@ OPERAND_IMMEDIATE
Definition MCInstrDesc.h:61
constexpr bool isAtomicRet(const T &...O)
Definition SIDefines.h:367
constexpr bool isVOPC(const T &...O)
Definition SIDefines.h:236
constexpr bool isVOP3(const T &...O)
Definition SIDefines.h:239
constexpr bool isScalarStore(const T &...O)
Definition SIDefines.h:313
constexpr bool isVOP1(const T &...O)
Definition SIDefines.h:230
constexpr bool isFPAtomic(const T &...O)
Definition SIDefines.h:352
constexpr bool usesVM_CNT(const T &...O)
Definition SIDefines.h:388
constexpr bool usesTENSOR_CNT(const T &...O)
Definition SIDefines.h:310
constexpr bool isMAI(const T &...O)
Definition SIDefines.h:355
constexpr bool isVOP2(const T &...O)
Definition SIDefines.h:233
constexpr bool isSWMMAC(const T &...O)
Definition SIDefines.h:382
constexpr bool isTRANS(const T &...O)
Definition SIDefines.h:258
constexpr bool isSOP2(const T &...O)
Definition SIDefines.h:218
constexpr bool isFLAT(const T &...O)
Definition SIDefines.h:286
constexpr bool isVOP3P(const T &...O)
Definition SIDefines.h:242
constexpr bool usesFPDPRounding(const T &...O)
Definition SIDefines.h:349
constexpr bool isDisableWQM(const T &...O)
Definition SIDefines.h:304
constexpr bool hasIntClamp(const T &...O)
Definition SIDefines.h:334
constexpr bool isAtomicNoRet(const T &...O)
Definition SIDefines.h:364
constexpr bool isMTBUF(const T &...O)
Definition SIDefines.h:264
constexpr bool isVIMAGE(const T &...O)
Definition SIDefines.h:277
constexpr bool isSMRD(const T &...O)
Definition SIDefines.h:271
constexpr bool isFlatScratch(const T &...O)
Definition SIDefines.h:361
constexpr bool isSpill(const T &...O)
Definition SIDefines.h:292
constexpr bool isMIMG(const T &...O)
Definition SIDefines.h:274
constexpr bool isVMEM(const T &...O)
Definition SIDefines.h:407
constexpr bool hasFPClamp(const T &...O)
Definition SIDefines.h:331
constexpr bool isNeverUniform(const T &...O)
Definition SIDefines.h:376
constexpr bool isImage(const T &...O)
Definition SIDefines.h:403
constexpr bool isWMMA(const T &...O)
Definition SIDefines.h:370
constexpr bool isVALU(const T &...O)
Definition SIDefines.h:212
constexpr bool isWQM(const T &...O)
Definition SIDefines.h:301
constexpr bool hasClampLo(const T &...O)
Definition SIDefines.h:337
constexpr bool isGWS(const T &...O)
Definition SIDefines.h:379
constexpr bool isFlatGlobal(const T &...O)
Definition SIDefines.h:346
constexpr bool usesASYNC_CNT(const T &...O)
Definition SIDefines.h:319
constexpr bool isMUBUF(const T &...O)
Definition SIDefines.h:261
constexpr bool isSDWA(const T &...O)
Definition SIDefines.h:252
constexpr bool isTiedSourceNotRead(const T &...O)
Definition SIDefines.h:373
constexpr bool isEXP(const T &...O)
Definition SIDefines.h:283
constexpr bool usesLGKM_CNT(const T &...O)
Definition SIDefines.h:391
constexpr bool isSOPK(const T &...O)
Definition SIDefines.h:224
constexpr bool isSOPC(const T &...O)
Definition SIDefines.h:221
constexpr bool isSOPP(const T &...O)
Definition SIDefines.h:227
constexpr bool isDOT(const T &...O)
Definition SIDefines.h:358
constexpr bool isVINTRP(const T &...O)
Definition SIDefines.h:249
constexpr bool isVINTERP(const T &...O)
Definition SIDefines.h:298
constexpr bool isVSAMPLE(const T &...O)
Definition SIDefines.h:280
constexpr bool isDS(const T &...O)
Definition SIDefines.h:289
constexpr bool isAtomic(const T &...O)
Definition SIDefines.h:396
constexpr bool isLDSDIR(const T &...O)
Definition SIDefines.h:295
constexpr bool isSALU(const T &...O)
Definition SIDefines.h:209
constexpr bool isGather4(const T &...O)
Definition SIDefines.h:307
constexpr bool isPacked(const T &...O)
Definition SIDefines.h:343
constexpr bool hasClampHi(const T &...O)
Definition SIDefines.h:340
constexpr bool isDPP(const T &...O)
Definition SIDefines.h:255
constexpr bool isSOP1(const T &...O)
Definition SIDefines.h:215
constexpr bool isSegmentSpecificFLAT(const T &...O)
Definition SIDefines.h:399
constexpr bool isFixedSize(const T &...O)
Definition SIDefines.h:316
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:577
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.
static const MachineMemOperand::Flags MOCFSB1
Definition SIInstrInfo.h:75
uint64_t getTSFlags(const MachineInstr &MI)
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:49
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:1762
@ Async
"Asynchronous" unwind tables (instr precise)
Definition CodeGen.h:365
MachineInstr * getVRegSubRegDef(const TargetInstrInfo::RegSubRegPair &P, const MachineRegisterInfo &MRI)
Return the defining instruction for a given reg:subreg pair skipping copy like instructions and subre...
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
static const MachineMemOperand::Flags MOCooperative
Mark the MMO of cooperative load/store atomics.
Definition SIInstrInfo.h:57
DWARFExpression::Operation Op
constexpr unsigned DefaultMemoryClusterDWordsLimit
Definition SIInstrInfo.h:45
static const MachineMemOperand::Flags MOLastUse
Mark the MMO of a load as the last use.
Definition SIInstrInfo.h:53
static const MachineMemOperand::Flags MOCFSB0
Use two MMO flags to encode the 2-bit cache fill size field for GFX13+.
Definition SIInstrInfo.h:72
bool isOfRegClass(const TargetInstrInfo::RegSubRegPair &P, const TargetRegisterClass &TRC, MachineRegisterInfo &MRI)
Returns true if a reg:subreg pair P has a TRC class.
ValueUniformity
Enum describing how values behave with respect to uniformity and divergence, to answer the question: ...
Definition Uniformity.h:18
static const MachineMemOperand::Flags MOThreadPrivate
Mark the MMO of accesses to memory locations that are never written to by other threads.
Definition SIInstrInfo.h:68
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.
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
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
static constexpr LaneBitmask getAll()
Definition LaneBitmask.h:82
Utility to store machine instructions worklist.
Definition SIInstrInfo.h:79
MachineInstr * top() const
Definition SIInstrInfo.h:84
bool isDeferred(MachineInstr *MI)
SetVector< MachineInstr * > & getDeferredList()
void insert(MachineInstr *MI)
A pair composed of a register and a sub-register index.
SmallVector< MachineOperand * > MOs
Definition SIInstrInfo.h:62
SmallVector< Register > SGPRs
Definition SIInstrInfo.h:64