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