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