LLVM 22.0.0git
SIMachineFunctionInfo.h
Go to the documentation of this file.
1//==- SIMachineFunctionInfo.h - SIMachineFunctionInfo 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//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H
14#define LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H
15
18#include "AMDGPUTargetMachine.h"
19#include "GCNSubtarget.h"
21#include "SIInstrInfo.h"
23#include "llvm/ADT/SetVector.h"
28#include <optional>
29
30namespace llvm {
31
32class MachineFrameInfo;
33class MachineFunction;
34class SIMachineFunctionInfo;
35class SIRegisterInfo;
36class TargetRegisterClass;
37
39public:
40 enum AMDGPUPSVKind : unsigned {
43 };
44
45protected:
47 : PseudoSourceValue(Kind, TM) {}
48
49public:
50 bool isConstant(const MachineFrameInfo *) const override {
51 // This should probably be true for most images, but we will start by being
52 // conservative.
53 return false;
54 }
55
56 bool isAliased(const MachineFrameInfo *) const override {
57 return true;
58 }
59
60 bool mayAlias(const MachineFrameInfo *) const override {
61 return true;
62 }
63};
64
66public:
69
70 static bool classof(const PseudoSourceValue *V) {
71 return V->kind() == GWSResource;
72 }
73
74 // These are inaccessible memory from IR.
75 bool isAliased(const MachineFrameInfo *) const override {
76 return false;
77 }
78
79 // These are inaccessible memory from IR.
80 bool mayAlias(const MachineFrameInfo *) const override {
81 return false;
82 }
83
84 void printCustom(raw_ostream &OS) const override {
85 OS << "GWSResource";
86 }
87};
88
89namespace yaml {
90
91struct SIArgument {
93 union {
95 unsigned StackOffset;
96 };
97 std::optional<unsigned> Mask;
98
99 // Default constructor, which creates a stack argument.
102 IsRegister = Other.IsRegister;
103 if (IsRegister)
104 new (&RegisterName) StringValue(Other.RegisterName);
105 else
106 StackOffset = Other.StackOffset;
107 Mask = Other.Mask;
108 }
110 // Default-construct or destruct the old RegisterName in case of switching
111 // union members
112 if (IsRegister != Other.IsRegister) {
113 if (Other.IsRegister)
114 new (&RegisterName) StringValue();
115 else
116 RegisterName.~StringValue();
117 }
118 IsRegister = Other.IsRegister;
119 if (IsRegister)
120 RegisterName = Other.RegisterName;
121 else
122 StackOffset = Other.StackOffset;
123 Mask = Other.Mask;
124 return *this;
125 }
127 if (IsRegister)
128 RegisterName.~StringValue();
129 }
130
131 // Helper to create a register or stack argument.
132 static inline SIArgument createArgument(bool IsReg) {
133 if (IsReg)
134 return SIArgument(IsReg);
135 return SIArgument();
136 }
137
138private:
139 // Construct a register argument.
141};
142
143template <> struct MappingTraits<SIArgument> {
144 static void mapping(IO &YamlIO, SIArgument &A) {
145 if (YamlIO.outputting()) {
146 if (A.IsRegister)
147 YamlIO.mapRequired("reg", A.RegisterName);
148 else
149 YamlIO.mapRequired("offset", A.StackOffset);
150 } else {
151 auto Keys = YamlIO.keys();
152 if (is_contained(Keys, "reg")) {
154 YamlIO.mapRequired("reg", A.RegisterName);
155 } else if (is_contained(Keys, "offset"))
156 YamlIO.mapRequired("offset", A.StackOffset);
157 else
158 YamlIO.setError("missing required key 'reg' or 'offset'");
159 }
160 YamlIO.mapOptional("mask", A.Mask);
161 }
162 static const bool flow = true;
163};
164
166 std::optional<SIArgument> PrivateSegmentBuffer;
167 std::optional<SIArgument> DispatchPtr;
168 std::optional<SIArgument> QueuePtr;
169 std::optional<SIArgument> KernargSegmentPtr;
170 std::optional<SIArgument> DispatchID;
171 std::optional<SIArgument> FlatScratchInit;
172 std::optional<SIArgument> PrivateSegmentSize;
173
174 std::optional<SIArgument> WorkGroupIDX;
175 std::optional<SIArgument> WorkGroupIDY;
176 std::optional<SIArgument> WorkGroupIDZ;
177 std::optional<SIArgument> WorkGroupInfo;
178 std::optional<SIArgument> LDSKernelId;
179 std::optional<SIArgument> PrivateSegmentWaveByteOffset;
180
181 std::optional<SIArgument> ImplicitArgPtr;
182 std::optional<SIArgument> ImplicitBufferPtr;
183
184 std::optional<SIArgument> WorkItemIDX;
185 std::optional<SIArgument> WorkItemIDY;
186 std::optional<SIArgument> WorkItemIDZ;
187};
188
189template <> struct MappingTraits<SIArgumentInfo> {
190 static void mapping(IO &YamlIO, SIArgumentInfo &AI) {
191 YamlIO.mapOptional("privateSegmentBuffer", AI.PrivateSegmentBuffer);
192 YamlIO.mapOptional("dispatchPtr", AI.DispatchPtr);
193 YamlIO.mapOptional("queuePtr", AI.QueuePtr);
194 YamlIO.mapOptional("kernargSegmentPtr", AI.KernargSegmentPtr);
195 YamlIO.mapOptional("dispatchID", AI.DispatchID);
196 YamlIO.mapOptional("flatScratchInit", AI.FlatScratchInit);
197 YamlIO.mapOptional("privateSegmentSize", AI.PrivateSegmentSize);
198
199 YamlIO.mapOptional("workGroupIDX", AI.WorkGroupIDX);
200 YamlIO.mapOptional("workGroupIDY", AI.WorkGroupIDY);
201 YamlIO.mapOptional("workGroupIDZ", AI.WorkGroupIDZ);
202 YamlIO.mapOptional("workGroupInfo", AI.WorkGroupInfo);
203 YamlIO.mapOptional("LDSKernelId", AI.LDSKernelId);
204 YamlIO.mapOptional("privateSegmentWaveByteOffset",
206
207 YamlIO.mapOptional("implicitArgPtr", AI.ImplicitArgPtr);
208 YamlIO.mapOptional("implicitBufferPtr", AI.ImplicitBufferPtr);
209
210 YamlIO.mapOptional("workItemIDX", AI.WorkItemIDX);
211 YamlIO.mapOptional("workItemIDY", AI.WorkItemIDY);
212 YamlIO.mapOptional("workItemIDZ", AI.WorkItemIDZ);
213 }
214};
215
216// Default to default mode for default calling convention.
217struct SIMode {
218 bool IEEE = true;
219 bool DX10Clamp = true;
224
225 SIMode() = default;
226
228 IEEE = Mode.IEEE;
229 DX10Clamp = Mode.DX10Clamp;
230 FP32InputDenormals = Mode.FP32Denormals.Input != DenormalMode::PreserveSign;
232 Mode.FP32Denormals.Output != DenormalMode::PreserveSign;
234 Mode.FP64FP16Denormals.Input != DenormalMode::PreserveSign;
236 Mode.FP64FP16Denormals.Output != DenormalMode::PreserveSign;
237 }
238
239 bool operator ==(const SIMode Other) const {
240 return IEEE == Other.IEEE &&
241 DX10Clamp == Other.DX10Clamp &&
242 FP32InputDenormals == Other.FP32InputDenormals &&
243 FP32OutputDenormals == Other.FP32OutputDenormals &&
244 FP64FP16InputDenormals == Other.FP64FP16InputDenormals &&
245 FP64FP16OutputDenormals == Other.FP64FP16OutputDenormals;
246 }
247};
248
249template <> struct MappingTraits<SIMode> {
250 static void mapping(IO &YamlIO, SIMode &Mode) {
251 YamlIO.mapOptional("ieee", Mode.IEEE, true);
252 YamlIO.mapOptional("dx10-clamp", Mode.DX10Clamp, true);
253 YamlIO.mapOptional("fp32-input-denormals", Mode.FP32InputDenormals, true);
254 YamlIO.mapOptional("fp32-output-denormals", Mode.FP32OutputDenormals, true);
255 YamlIO.mapOptional("fp64-fp16-input-denormals", Mode.FP64FP16InputDenormals, true);
256 YamlIO.mapOptional("fp64-fp16-output-denormals", Mode.FP64FP16OutputDenormals, true);
257 }
258};
259
266 bool IsEntryFunction = false;
267 bool IsChainFunction = false;
269 bool MemoryBound = false;
270 bool WaveLimiter = false;
271 bool HasSpilledSGPRs = false;
272 bool HasSpilledVGPRs = false;
276
277 // TODO: 10 may be a better default since it's the maximum.
278 unsigned Occupancy = 0;
279
282
283 StringValue ScratchRSrcReg = "$private_rsrc_reg";
286
288 bool ReturnsVoid = true;
289
290 std::optional<SIArgumentInfo> ArgInfo;
291
292 unsigned PSInputAddr = 0;
293 unsigned PSInputEnable = 0;
295
297 std::optional<FrameIndex> ScavengeFI;
301
302 bool HasInitWholeWave = false;
304
307
310 const TargetRegisterInfo &TRI,
311 const llvm::MachineFunction &MF);
312
313 void mappingImpl(yaml::IO &YamlIO) override;
315};
316
318 static void mapping(IO &YamlIO, SIMachineFunctionInfo &MFI) {
319 YamlIO.mapOptional("explicitKernArgSize", MFI.ExplicitKernArgSize,
320 UINT64_C(0));
321 YamlIO.mapOptional("maxKernArgAlign", MFI.MaxKernArgAlign);
322 YamlIO.mapOptional("ldsSize", MFI.LDSSize, 0u);
323 YamlIO.mapOptional("gdsSize", MFI.GDSSize, 0u);
324 YamlIO.mapOptional("dynLDSAlign", MFI.DynLDSAlign, Align());
325 YamlIO.mapOptional("isEntryFunction", MFI.IsEntryFunction, false);
326 YamlIO.mapOptional("isChainFunction", MFI.IsChainFunction, false);
327 YamlIO.mapOptional("noSignedZerosFPMath", MFI.NoSignedZerosFPMath, false);
328 YamlIO.mapOptional("memoryBound", MFI.MemoryBound, false);
329 YamlIO.mapOptional("waveLimiter", MFI.WaveLimiter, false);
330 YamlIO.mapOptional("hasSpilledSGPRs", MFI.HasSpilledSGPRs, false);
331 YamlIO.mapOptional("hasSpilledVGPRs", MFI.HasSpilledVGPRs, false);
332 YamlIO.mapOptional("numWaveDispatchSGPRs", MFI.NumWaveDispatchSGPRs, false);
333 YamlIO.mapOptional("numWaveDispatchVGPRs", MFI.NumWaveDispatchVGPRs, false);
334 YamlIO.mapOptional("scratchRSrcReg", MFI.ScratchRSrcReg,
335 StringValue("$private_rsrc_reg"));
336 YamlIO.mapOptional("frameOffsetReg", MFI.FrameOffsetReg,
337 StringValue("$fp_reg"));
338 YamlIO.mapOptional("stackPtrOffsetReg", MFI.StackPtrOffsetReg,
339 StringValue("$sp_reg"));
340 YamlIO.mapOptional("bytesInStackArgArea", MFI.BytesInStackArgArea, 0u);
341 YamlIO.mapOptional("returnsVoid", MFI.ReturnsVoid, true);
342 YamlIO.mapOptional("argumentInfo", MFI.ArgInfo);
343 YamlIO.mapOptional("psInputAddr", MFI.PSInputAddr, 0u);
344 YamlIO.mapOptional("psInputEnable", MFI.PSInputEnable, 0u);
345 YamlIO.mapOptional("maxMemoryClusterDWords", MFI.MaxMemoryClusterDWords,
347 YamlIO.mapOptional("mode", MFI.Mode, SIMode());
348 YamlIO.mapOptional("highBitsOf32BitAddress",
349 MFI.HighBitsOf32BitAddress, 0u);
350 YamlIO.mapOptional("occupancy", MFI.Occupancy, 0);
351 YamlIO.mapOptional("spillPhysVGPRs", MFI.SpillPhysVGPRS);
352 YamlIO.mapOptional("wwmReservedRegs", MFI.WWMReservedRegs);
353 YamlIO.mapOptional("scavengeFI", MFI.ScavengeFI);
354 YamlIO.mapOptional("vgprForAGPRCopy", MFI.VGPRForAGPRCopy,
355 StringValue()); // Don't print out when it's empty.
356 YamlIO.mapOptional("sgprForEXECCopy", MFI.SGPRForEXECCopy,
357 StringValue()); // Don't print out when it's empty.
358 YamlIO.mapOptional("longBranchReservedReg", MFI.LongBranchReservedReg,
359 StringValue());
360 YamlIO.mapOptional("hasInitWholeWave", MFI.HasInitWholeWave, false);
361 YamlIO.mapOptional("dynamicVGPRBlockSize", MFI.DynamicVGPRBlockSize, false);
362 YamlIO.mapOptional("scratchReservedForDynamicVGPRs",
364 YamlIO.mapOptional("isWholeWaveFunction", MFI.IsWholeWaveFunction, false);
365 }
366};
367
368} // end namespace yaml
369
370// A CSR SGPR value can be preserved inside a callee using one of the following
371// methods.
372// 1. Copy to an unused scratch SGPR.
373// 2. Spill to a VGPR lane.
374// 3. Spill to memory via. a scratch VGPR.
375// class PrologEpilogSGPRSaveRestoreInfo represents the save/restore method used
376// for an SGPR at function prolog/epilog.
377enum class SGPRSaveKind : uint8_t {
381};
382
384 SGPRSaveKind Kind;
385 union {
386 int Index;
388 };
389
390public:
393 : Kind(K), Reg(R) {}
394 Register getReg() const { return Reg; }
395 int getIndex() const { return Index; }
396 SGPRSaveKind getKind() const { return Kind; }
397};
398
401 unsigned operator()(Register Reg) const {
402 assert(AMDGPU::VReg_1024RegClass.contains(Reg) && "Expecting a VGPR block");
403
404 const MCRegister FirstVGPRBlock = AMDGPU::VReg_1024RegClass.getRegister(0);
405 return Reg - FirstVGPRBlock;
406 }
407};
408
409/// This class keeps track of the SPI_SP_INPUT_ADDR config register, which
410/// tells the hardware which interpolation parameters to load.
413 friend class GCNTargetMachine;
414
415 // State of MODE register, assumed FP mode.
417
418 // Registers that may be reserved for spilling purposes. These may be the same
419 // as the input registers.
420 Register ScratchRSrcReg = AMDGPU::PRIVATE_RSRC_REG;
421
422 // This is the unswizzled offset from the current dispatch's scratch wave
423 // base to the beginning of the current function's frame.
424 Register FrameOffsetReg = AMDGPU::FP_REG;
425
426 // This is an ABI register used in the non-entry calling convention to
427 // communicate the unswizzled offset from the current dispatch's scratch wave
428 // base to the beginning of the new function's frame.
429 Register StackPtrOffsetReg = AMDGPU::SP_REG;
430
431 // Registers that may be reserved when RA doesn't allocate enough
432 // registers to plan for the case where an indirect branch ends up
433 // being needed during branch relaxation.
434 Register LongBranchReservedReg;
435
437
438 // Graphics info.
439 unsigned PSInputAddr = 0;
440 unsigned PSInputEnable = 0;
441
442 /// Number of bytes of arguments this function has on the stack. If the callee
443 /// is expected to restore the argument stack this should be a multiple of 16,
444 /// all usable during a tail call.
445 ///
446 /// The alternative would forbid tail call optimisation in some cases: if we
447 /// want to transfer control from a function with 8-bytes of stack-argument
448 /// space to a function with 16-bytes then misalignment of this value would
449 /// make a stack adjustment necessary, which could not be undone by the
450 /// callee.
451 unsigned BytesInStackArgArea = 0;
452
453 bool ReturnsVoid = true;
454
455 // A pair of default/requested minimum/maximum flat work group sizes.
456 // Minimum - first, maximum - second.
457 std::pair<unsigned, unsigned> FlatWorkGroupSizes = {0, 0};
458
459 // A pair of default/requested minimum/maximum number of waves per execution
460 // unit. Minimum - first, maximum - second.
461 std::pair<unsigned, unsigned> WavesPerEU = {0, 0};
462
463 const AMDGPUGWSResourcePseudoSourceValue GWSResourcePSV;
464
465 // Default/requested number of work groups for the function.
466 SmallVector<unsigned> MaxNumWorkGroups = {0, 0, 0};
467
468private:
469 unsigned NumUserSGPRs = 0;
470 unsigned NumSystemSGPRs = 0;
471
472 unsigned NumWaveDispatchSGPRs = 0;
473 unsigned NumWaveDispatchVGPRs = 0;
474
475 bool HasSpilledSGPRs = false;
476 bool HasSpilledVGPRs = false;
477 bool HasNonSpillStackObjects = false;
478 bool IsStackRealigned = false;
479
480 unsigned NumSpilledSGPRs = 0;
481 unsigned NumSpilledVGPRs = 0;
482
483 unsigned DynamicVGPRBlockSize = 0;
484
485 // The size in bytes of the scratch space reserved for the CWSR trap handler
486 // to spill some of the dynamic VGPRs.
487 unsigned ScratchReservedForDynamicVGPRs = 0;
488
489 // Tracks information about user SGPRs that will be setup by hardware which
490 // will apply to all wavefronts of the grid.
491 GCNUserSGPRUsageInfo UserSGPRInfo;
492
493 // Feature bits required for inputs passed in system SGPRs.
494 bool WorkGroupIDX : 1; // Always initialized.
495 bool WorkGroupIDY : 1;
496 bool WorkGroupIDZ : 1;
497 bool WorkGroupInfo : 1;
498 bool LDSKernelId : 1;
499 bool PrivateSegmentWaveByteOffset : 1;
500
501 bool WorkItemIDX : 1; // Always initialized.
502 bool WorkItemIDY : 1;
503 bool WorkItemIDZ : 1;
504
505 // Pointer to where the ABI inserts special kernel arguments separate from the
506 // user arguments. This is an offset from the KernargSegmentPtr.
507 bool ImplicitArgPtr : 1;
508
509 bool MayNeedAGPRs : 1;
510
511 // The hard-wired high half of the address of the global information table
512 // for AMDPAL OS type. 0xffffffff represents no hard-wired high half, since
513 // current hardware only allows a 16 bit value.
514 unsigned GITPtrHigh;
515
516 unsigned HighBitsOf32BitAddress;
517
518 // Flags associated with the virtual registers.
519 IndexedMap<uint8_t, VirtReg2IndexFunctor> VRegFlags;
520
521 // Current recorded maximum possible occupancy.
522 unsigned Occupancy;
523
524 // Maximum number of dwords that can be clusterred during instruction
525 // scheduler stage.
526 unsigned MaxMemoryClusterDWords = DefaultMemoryClusterDWordsLimit;
527
528 MCPhysReg getNextUserSGPR() const;
529
530 MCPhysReg getNextSystemSGPR() const;
531
532 // MachineRegisterInfo callback functions to notify events.
533 void MRI_NoteNewVirtualRegister(Register Reg) override;
534 void MRI_NoteCloneVirtualRegister(Register NewReg, Register SrcReg) override;
535
536public:
539 bool FullyAllocated = false;
540 bool IsDead = false;
541 };
542
543private:
544 // To track virtual VGPR + lane index for each subregister of the SGPR spilled
545 // to frameindex key during SILowerSGPRSpills pass.
547 SGPRSpillsToVirtualVGPRLanes;
548 // To track physical VGPR + lane index for CSR SGPR spills and special SGPRs
549 // like Frame Pointer identified during PrologEpilogInserter.
551 SGPRSpillsToPhysicalVGPRLanes;
552 unsigned NumVirtualVGPRSpillLanes = 0;
553 unsigned NumPhysicalVGPRSpillLanes = 0;
554 SmallVector<Register, 2> SpillVGPRs;
555 SmallVector<Register, 2> SpillPhysVGPRs;
557 // To track the registers used in instructions that can potentially modify the
558 // inactive lanes. The WWM instructions and the writelane instructions for
559 // spilling SGPRs to VGPRs fall under such category of operations. The VGPRs
560 // modified by them should be spilled/restored at function prolog/epilog to
561 // avoid any undesired outcome. Each entry in this map holds a pair of values,
562 // the VGPR and its stack slot index.
563 WWMSpillsMap WWMSpills;
564
565 // Before allocation, the VGPR registers are partitioned into two distinct
566 // sets, the first one for WWM-values and the second set for non-WWM values.
567 // The latter set should be reserved during WWM-regalloc.
568 BitVector NonWWMRegMask;
569
571 // To track the VGPRs reserved for WWM instructions. They get stack slots
572 // later during PrologEpilogInserter and get added into the superset WWMSpills
573 // for actual spilling. A separate set makes the register reserved part and
574 // the serialization easier.
575 ReservedRegSet WWMReservedRegs;
576
577 bool IsWholeWaveFunction = false;
578
579 using PrologEpilogSGPRSpill =
580 std::pair<Register, PrologEpilogSGPRSaveRestoreInfo>;
581 // To track the SGPR spill method used for a CSR SGPR register during
582 // frame lowering. Even though the SGPR spills are handled during
583 // SILowerSGPRSpills pass, some special handling needed later during the
584 // PrologEpilogInserter.
585 SmallVector<PrologEpilogSGPRSpill, 3> PrologEpilogSGPRSpills;
586
587 // To save/restore EXEC MASK around WWM spills and copies.
588 Register SGPRForEXECCopy;
589
590 DenseMap<int, VGPRSpillToAGPR> VGPRToAGPRSpills;
591
592 // AGPRs used for VGPR spills.
594
595 // VGPRs used for AGPR spills.
597
598 // Emergency stack slot. Sometimes, we create this before finalizing the stack
599 // frame, so save it here and add it to the RegScavenger later.
600 std::optional<int> ScavengeFI;
601
602 // Map each VGPR CSR to the mask needed to save and restore it using block
603 // load/store instructions. Only used if the subtarget feature for VGPR block
604 // load/store is enabled.
606
607private:
608 Register VGPRForAGPRCopy;
609
610 bool allocateVirtualVGPRForSGPRSpills(MachineFunction &MF, int FI,
611 unsigned LaneIndex);
612 bool allocatePhysicalVGPRForSGPRSpills(MachineFunction &MF, int FI,
613 unsigned LaneIndex,
614 bool IsPrologEpilog);
615
616public:
618 return VGPRForAGPRCopy;
619 }
620
621 void setVGPRForAGPRCopy(Register NewVGPRForAGPRCopy) {
622 VGPRForAGPRCopy = NewVGPRForAGPRCopy;
623 }
624
625 bool isCalleeSavedReg(const MCPhysReg *CSRegs, MCPhysReg Reg) const;
626
627 void setMaskForVGPRBlockOps(Register RegisterBlock, uint32_t Mask) {
628 MaskForVGPRBlockOps.grow(RegisterBlock);
629 MaskForVGPRBlockOps[RegisterBlock] = Mask;
630 }
631
633 return MaskForVGPRBlockOps[RegisterBlock];
634 }
635
636 bool hasMaskForVGPRBlockOps(Register RegisterBlock) const {
637 return MaskForVGPRBlockOps.inBounds(RegisterBlock);
638 }
639
640public:
642 SIMachineFunctionInfo(const Function &F, const GCNSubtarget *STI);
643
647 const override;
648
650 const MachineFunction &MF,
652 SMDiagnostic &Error, SMRange &SourceRange);
653
654 void reserveWWMRegister(Register Reg) { WWMReservedRegs.insert(Reg); }
655 bool isWWMReg(Register Reg) const {
656 return Reg.isVirtual() ? checkFlag(Reg, AMDGPU::VirtRegFlag::WWM_REG)
657 : WWMReservedRegs.contains(Reg);
658 }
659
660 void updateNonWWMRegMask(BitVector &RegMask) { NonWWMRegMask = RegMask; }
661 BitVector getNonWWMRegMask() const { return NonWWMRegMask; }
662 void clearNonWWMRegAllocMask() { NonWWMRegMask.clear(); }
663
664 SIModeRegisterDefaults getMode() const { return Mode; }
665
667 getSGPRSpillToVirtualVGPRLanes(int FrameIndex) const {
668 auto I = SGPRSpillsToVirtualVGPRLanes.find(FrameIndex);
669 return (I == SGPRSpillsToVirtualVGPRLanes.end())
671 : ArrayRef(I->second);
672 }
673
674 ArrayRef<Register> getSGPRSpillVGPRs() const { return SpillVGPRs; }
675 ArrayRef<Register> getSGPRSpillPhysVGPRs() const { return SpillPhysVGPRs; }
676
677 const WWMSpillsMap &getWWMSpills() const { return WWMSpills; }
678 const ReservedRegSet &getWWMReservedRegs() const { return WWMReservedRegs; }
679
681 return WWMReservedRegs.contains(Reg);
682 }
683
684 bool isWholeWaveFunction() const { return IsWholeWaveFunction; }
685
687 assert(is_sorted(PrologEpilogSGPRSpills, llvm::less_first()));
688 return PrologEpilogSGPRSpills;
689 }
690
691 GCNUserSGPRUsageInfo &getUserSGPRInfo() { return UserSGPRInfo; }
692
693 const GCNUserSGPRUsageInfo &getUserSGPRInfo() const { return UserSGPRInfo; }
694
698
699 // Insert a new entry in the right place to keep the vector in sorted order.
700 // This should be cheap since the vector is expected to be very short.
701 PrologEpilogSGPRSpills.insert(
703 PrologEpilogSGPRSpills, Reg,
704 [](const auto &LHS, const auto &RHS) { return LHS < RHS.first; }),
705 std::make_pair(Reg, SI));
706 }
707
708 // Check if an entry created for \p Reg in PrologEpilogSGPRSpills. Return true
709 // on success and false otherwise.
711 const auto *I = find_if(PrologEpilogSGPRSpills, [&Reg](const auto &Spill) {
712 return Spill.first == Reg;
713 });
714 return I != PrologEpilogSGPRSpills.end();
715 }
716
717 // Get the scratch SGPR if allocated to save/restore \p Reg.
719 const auto *I = find_if(PrologEpilogSGPRSpills, [&Reg](const auto &Spill) {
720 return Spill.first == Reg;
721 });
722 if (I != PrologEpilogSGPRSpills.end() &&
723 I->second.getKind() == SGPRSaveKind::COPY_TO_SCRATCH_SGPR)
724 return I->second.getReg();
725
726 return AMDGPU::NoRegister;
727 }
728
729 // Get all scratch SGPRs allocated to copy/restore the SGPR spills.
731 for (const auto &SI : PrologEpilogSGPRSpills) {
732 if (SI.second.getKind() == SGPRSaveKind::COPY_TO_SCRATCH_SGPR)
733 Regs.push_back(SI.second.getReg());
734 }
735 }
736
737 // Check if \p FI is allocated for any SGPR spill to a VGPR lane during PEI.
739 return find_if(PrologEpilogSGPRSpills,
740 [FI](const std::pair<Register,
742 return SI.second.getKind() ==
744 SI.second.getIndex() == FI;
745 }) != PrologEpilogSGPRSpills.end();
746 }
747
750 const auto *I = find_if(PrologEpilogSGPRSpills, [&Reg](const auto &Spill) {
751 return Spill.first == Reg;
752 });
753 assert(I != PrologEpilogSGPRSpills.end());
754
755 return I->second;
756 }
757
759 getSGPRSpillToPhysicalVGPRLanes(int FrameIndex) const {
760 auto I = SGPRSpillsToPhysicalVGPRLanes.find(FrameIndex);
761 return (I == SGPRSpillsToPhysicalVGPRLanes.end())
763 : ArrayRef(I->second);
764 }
765
767 assert(Reg.isVirtual());
768 if (VRegFlags.inBounds(Reg))
769 VRegFlags[Reg] |= Flag;
770 }
771
772 bool checkFlag(Register Reg, uint8_t Flag) const {
773 if (Reg.isPhysical())
774 return false;
775
776 return VRegFlags.inBounds(Reg) && VRegFlags[Reg] & Flag;
777 }
778
779 bool hasVRegFlags() { return VRegFlags.size(); }
780
782 Align Alignment = Align(4));
783
785 MachineFunction &MF,
786 SmallVectorImpl<std::pair<Register, int>> &CalleeSavedRegs,
787 SmallVectorImpl<std::pair<Register, int>> &ScratchRegs) const;
788
790 return SpillAGPR;
791 }
792
793 Register getSGPRForEXECCopy() const { return SGPRForEXECCopy; }
794
795 void setSGPRForEXECCopy(Register Reg) { SGPRForEXECCopy = Reg; }
796
798 return SpillVGPR;
799 }
800
801 MCPhysReg getVGPRToAGPRSpill(int FrameIndex, unsigned Lane) const {
802 auto I = VGPRToAGPRSpills.find(FrameIndex);
803 return (I == VGPRToAGPRSpills.end()) ? (MCPhysReg)AMDGPU::NoRegister
804 : I->second.Lanes[Lane];
805 }
806
807 void setVGPRToAGPRSpillDead(int FrameIndex) {
808 auto I = VGPRToAGPRSpills.find(FrameIndex);
809 if (I != VGPRToAGPRSpills.end())
810 I->second.IsDead = true;
811 }
812
813 // To bring the allocated WWM registers in \p WWMVGPRs to the lowest available
814 // range.
817 BitVector &SavedVGPRs);
818
820 bool SpillToPhysVGPRLane = false,
821 bool IsPrologEpilog = false);
822 bool allocateVGPRSpillToAGPR(MachineFunction &MF, int FI, bool isAGPRtoVGPR);
823
824 /// If \p ResetSGPRSpillStackIDs is true, reset the stack ID from sgpr-spill
825 /// to the default stack.
827 bool ResetSGPRSpillStackIDs);
828
830 std::optional<int> getOptionalScavengeFI() const { return ScavengeFI; }
831
832 unsigned getBytesInStackArgArea() const {
833 return BytesInStackArgArea;
834 }
835
836 void setBytesInStackArgArea(unsigned Bytes) {
837 BytesInStackArgArea = Bytes;
838 }
839
840 bool isDynamicVGPREnabled() const { return DynamicVGPRBlockSize != 0; }
841 unsigned getDynamicVGPRBlockSize() const { return DynamicVGPRBlockSize; }
842
843 // This is only used if we need to save any dynamic VGPRs in scratch.
845 return ScratchReservedForDynamicVGPRs;
846 }
847
848 void setScratchReservedForDynamicVGPRs(unsigned SizeInBytes) {
849 ScratchReservedForDynamicVGPRs = SizeInBytes;
850 }
851
852 // Add user SGPRs.
864 unsigned AllocSizeDWord, int KernArgIdx,
865 int PaddingSGPRs);
866
867 /// Increment user SGPRs used for padding the argument list only.
869 Register Next = getNextUserSGPR();
870 ++NumUserSGPRs;
871 return Next;
872 }
873
874 // Add system SGPRs.
876 ArgInfo.WorkGroupIDX = ArgDescriptor::createRegister(getNextSystemSGPR());
877 NumSystemSGPRs += 1;
878 return ArgInfo.WorkGroupIDX.getRegister();
879 }
880
882 ArgInfo.WorkGroupIDY = ArgDescriptor::createRegister(getNextSystemSGPR());
883 NumSystemSGPRs += 1;
884 return ArgInfo.WorkGroupIDY.getRegister();
885 }
886
888 ArgInfo.WorkGroupIDZ = ArgDescriptor::createRegister(getNextSystemSGPR());
889 NumSystemSGPRs += 1;
890 return ArgInfo.WorkGroupIDZ.getRegister();
891 }
892
894 ArgInfo.WorkGroupInfo = ArgDescriptor::createRegister(getNextSystemSGPR());
895 NumSystemSGPRs += 1;
896 return ArgInfo.WorkGroupInfo.getRegister();
897 }
898
899 bool hasLDSKernelId() const { return LDSKernelId; }
900
901 // Add special VGPR inputs
903 ArgInfo.WorkItemIDX = Arg;
904 }
905
907 ArgInfo.WorkItemIDY = Arg;
908 }
909
911 ArgInfo.WorkItemIDZ = Arg;
912 }
913
915 ArgInfo.PrivateSegmentWaveByteOffset
916 = ArgDescriptor::createRegister(getNextSystemSGPR());
917 NumSystemSGPRs += 1;
918 return ArgInfo.PrivateSegmentWaveByteOffset.getRegister();
919 }
920
922 ArgInfo.PrivateSegmentWaveByteOffset = ArgDescriptor::createRegister(Reg);
923 }
924
925 bool hasWorkGroupIDX() const {
926 return WorkGroupIDX;
927 }
928
929 bool hasWorkGroupIDY() const {
930 return WorkGroupIDY;
931 }
932
933 bool hasWorkGroupIDZ() const {
934 return WorkGroupIDZ;
935 }
936
937 bool hasWorkGroupInfo() const {
938 return WorkGroupInfo;
939 }
940
942 return PrivateSegmentWaveByteOffset;
943 }
944
945 bool hasWorkItemIDX() const {
946 return WorkItemIDX;
947 }
948
949 bool hasWorkItemIDY() const {
950 return WorkItemIDY;
951 }
952
953 bool hasWorkItemIDZ() const {
954 return WorkItemIDZ;
955 }
956
957 bool hasImplicitArgPtr() const {
958 return ImplicitArgPtr;
959 }
960
962 return ArgInfo;
963 }
964
966 return ArgInfo;
967 }
968
969 std::tuple<const ArgDescriptor *, const TargetRegisterClass *, LLT>
971 return ArgInfo.getPreloadedValue(Value);
972 }
973
975 const auto *Arg = std::get<0>(ArgInfo.getPreloadedValue(Value));
976 return Arg ? Arg->getRegister() : MCRegister();
977 }
978
979 unsigned getGITPtrHigh() const {
980 return GITPtrHigh;
981 }
982
983 Register getGITPtrLoReg(const MachineFunction &MF) const;
984
986 return HighBitsOf32BitAddress;
987 }
988
989 unsigned getNumUserSGPRs() const {
990 return NumUserSGPRs;
991 }
992
993 unsigned getNumPreloadedSGPRs() const {
994 return NumUserSGPRs + NumSystemSGPRs;
995 }
996
998 return UserSGPRInfo.getNumKernargPreloadSGPRs();
999 }
1000
1001 unsigned getNumWaveDispatchSGPRs() const { return NumWaveDispatchSGPRs; }
1002
1003 void setNumWaveDispatchSGPRs(unsigned Count) { NumWaveDispatchSGPRs = Count; }
1004
1005 unsigned getNumWaveDispatchVGPRs() const { return NumWaveDispatchVGPRs; }
1006
1007 void setNumWaveDispatchVGPRs(unsigned Count) { NumWaveDispatchVGPRs = Count; }
1008
1010 return ArgInfo.PrivateSegmentWaveByteOffset.getRegister();
1011 }
1012
1013 /// Returns the physical register reserved for use as the resource
1014 /// descriptor for scratch accesses.
1016 return ScratchRSrcReg;
1017 }
1018
1020 assert(Reg != 0 && "Should never be unset");
1021 ScratchRSrcReg = Reg;
1022 }
1023
1025 return FrameOffsetReg;
1026 }
1027
1029 assert(Reg != 0 && "Should never be unset");
1030 FrameOffsetReg = Reg;
1031 }
1032
1034 assert(Reg != 0 && "Should never be unset");
1035 StackPtrOffsetReg = Reg;
1036 }
1037
1038 void setLongBranchReservedReg(Register Reg) { LongBranchReservedReg = Reg; }
1039
1040 // Note the unset value for this is AMDGPU::SP_REG rather than
1041 // NoRegister. This is mostly a workaround for MIR tests where state that
1042 // can't be directly computed from the function is not preserved in serialized
1043 // MIR.
1045 return StackPtrOffsetReg;
1046 }
1047
1048 Register getLongBranchReservedReg() const { return LongBranchReservedReg; }
1049
1051 return ArgInfo.QueuePtr.getRegister();
1052 }
1053
1055 return ArgInfo.ImplicitBufferPtr.getRegister();
1056 }
1057
1058 bool hasSpilledSGPRs() const {
1059 return HasSpilledSGPRs;
1060 }
1061
1062 void setHasSpilledSGPRs(bool Spill = true) {
1063 HasSpilledSGPRs = Spill;
1064 }
1065
1066 bool hasSpilledVGPRs() const {
1067 return HasSpilledVGPRs;
1068 }
1069
1070 void setHasSpilledVGPRs(bool Spill = true) {
1071 HasSpilledVGPRs = Spill;
1072 }
1073
1075 return HasNonSpillStackObjects;
1076 }
1077
1078 void setHasNonSpillStackObjects(bool StackObject = true) {
1079 HasNonSpillStackObjects = StackObject;
1080 }
1081
1082 bool isStackRealigned() const {
1083 return IsStackRealigned;
1084 }
1085
1086 void setIsStackRealigned(bool Realigned = true) {
1087 IsStackRealigned = Realigned;
1088 }
1089
1090 unsigned getNumSpilledSGPRs() const {
1091 return NumSpilledSGPRs;
1092 }
1093
1094 unsigned getNumSpilledVGPRs() const {
1095 return NumSpilledVGPRs;
1096 }
1097
1098 void addToSpilledSGPRs(unsigned num) {
1099 NumSpilledSGPRs += num;
1100 }
1101
1102 void addToSpilledVGPRs(unsigned num) {
1103 NumSpilledVGPRs += num;
1104 }
1105
1106 unsigned getPSInputAddr() const {
1107 return PSInputAddr;
1108 }
1109
1110 unsigned getPSInputEnable() const {
1111 return PSInputEnable;
1112 }
1113
1114 bool isPSInputAllocated(unsigned Index) const {
1115 return PSInputAddr & (1 << Index);
1116 }
1117
1119 PSInputAddr |= 1 << Index;
1120 }
1121
1122 void markPSInputEnabled(unsigned Index) {
1123 PSInputEnable |= 1 << Index;
1124 }
1125
1126 bool returnsVoid() const {
1127 return ReturnsVoid;
1128 }
1129
1131 ReturnsVoid = Value;
1132 }
1133
1134 /// \returns A pair of default/requested minimum/maximum flat work group sizes
1135 /// for this function.
1136 std::pair<unsigned, unsigned> getFlatWorkGroupSizes() const {
1137 return FlatWorkGroupSizes;
1138 }
1139
1140 /// \returns Default/requested minimum flat work group size for this function.
1141 unsigned getMinFlatWorkGroupSize() const {
1142 return FlatWorkGroupSizes.first;
1143 }
1144
1145 /// \returns Default/requested maximum flat work group size for this function.
1146 unsigned getMaxFlatWorkGroupSize() const {
1147 return FlatWorkGroupSizes.second;
1148 }
1149
1150 /// \returns A pair of default/requested minimum/maximum number of waves per
1151 /// execution unit.
1152 std::pair<unsigned, unsigned> getWavesPerEU() const {
1153 return WavesPerEU;
1154 }
1155
1156 /// \returns Default/requested minimum number of waves per execution unit.
1157 unsigned getMinWavesPerEU() const {
1158 return WavesPerEU.first;
1159 }
1160
1161 /// \returns Default/requested maximum number of waves per execution unit.
1162 unsigned getMaxWavesPerEU() const {
1163 return WavesPerEU.second;
1164 }
1165
1168 return &GWSResourcePSV;
1169 }
1170
1171 unsigned getOccupancy() const {
1172 return Occupancy;
1173 }
1174
1175 unsigned getMinAllowedOccupancy() const {
1176 if (!isMemoryBound() && !needsWaveLimiter())
1177 return Occupancy;
1178 return (Occupancy < 4) ? Occupancy : 4;
1179 }
1180
1181 void limitOccupancy(const MachineFunction &MF);
1182
1183 void limitOccupancy(unsigned Limit) {
1184 if (Occupancy > Limit)
1185 Occupancy = Limit;
1186 }
1187
1188 void increaseOccupancy(const MachineFunction &MF, unsigned Limit) {
1189 if (Occupancy < Limit)
1190 Occupancy = Limit;
1191 limitOccupancy(MF);
1192 }
1193
1194 unsigned getMaxMemoryClusterDWords() const { return MaxMemoryClusterDWords; }
1195
1196 bool mayNeedAGPRs() const {
1197 return MayNeedAGPRs;
1198 }
1199
1200 // \returns true if a function has a use of AGPRs via inline asm or
1201 // has a call which may use it.
1202 bool mayUseAGPRs(const Function &F) const;
1203
1204 /// \returns Default/requested number of work groups for this function.
1205 SmallVector<unsigned> getMaxNumWorkGroups() const { return MaxNumWorkGroups; }
1206
1207 unsigned getMaxNumWorkGroupsX() const { return MaxNumWorkGroups[0]; }
1208 unsigned getMaxNumWorkGroupsY() const { return MaxNumWorkGroups[1]; }
1209 unsigned getMaxNumWorkGroupsZ() const { return MaxNumWorkGroups[2]; }
1210};
1211
1212} // end namespace llvm
1213
1214#endif // LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Provides AMDGPU specific target descriptions.
The AMDGPU TargetMachine interface definition for hw codegen targets.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
uint32_t Index
uint64_t Size
IO & YamlIO
Definition: ELFYAML.cpp:1327
AMD GCN specific subclass of TargetSubtarget.
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
Register Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition: Mem2Reg.cpp:110
Basic Register Allocator
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
Interface definition for SIInstrInfo.
raw_pwrite_stream & OS
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition: Value.cpp:480
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallVector class.
Value * RHS
Value * LHS
void printCustom(raw_ostream &OS) const override
Implement printing for PseudoSourceValue.
static bool classof(const PseudoSourceValue *V)
AMDGPUGWSResourcePseudoSourceValue(const AMDGPUTargetMachine &TM)
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
bool isAliased(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
bool isConstant(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
AMDGPUPseudoSourceValue(unsigned Kind, const AMDGPUTargetMachine &TM)
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
bool isAliased(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
void clear()
clear - Removes all bits from the bitvector.
Definition: BitVector.h:335
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:177
iterator end()
Definition: DenseMap.h:87
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
void grow(IndexT n)
Definition: IndexedMap.h:69
bool inBounds(IndexT n) const
Definition: IndexedMap.h:75
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
PrologEpilogSGPRSaveRestoreInfo(SGPRSaveKind K, Register R)
PrologEpilogSGPRSaveRestoreInfo(SGPRSaveKind K, int I)
Special value supplied for machine level alias analysis.
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
ArrayRef< PrologEpilogSGPRSpill > getPrologEpilogSGPRSpills() const
const WWMSpillsMap & getWWMSpills() const
bool isPSInputAllocated(unsigned Index) const
void getAllScratchSGPRCopyDstRegs(SmallVectorImpl< Register > &Regs) const
ArrayRef< MCPhysReg > getAGPRSpillVGPRs() const
bool initializeBaseYamlFields(const yaml::SIMachineFunctionInfo &YamlMFI, const MachineFunction &MF, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange)
void shiftWwmVGPRsToLowestRange(MachineFunction &MF, SmallVectorImpl< Register > &WWMVGPRs, BitVector &SavedVGPRs)
void setWorkItemIDY(ArgDescriptor Arg)
void increaseOccupancy(const MachineFunction &MF, unsigned Limit)
Register addPrivateSegmentSize(const SIRegisterInfo &TRI)
void setWorkItemIDZ(ArgDescriptor Arg)
std::pair< unsigned, unsigned > getWavesPerEU() const
void setMaskForVGPRBlockOps(Register RegisterBlock, uint32_t Mask)
MCPhysReg getVGPRToAGPRSpill(int FrameIndex, unsigned Lane) const
GCNUserSGPRUsageInfo & getUserSGPRInfo()
void allocateWWMSpill(MachineFunction &MF, Register VGPR, uint64_t Size=4, Align Alignment=Align(4))
Register addDispatchPtr(const SIRegisterInfo &TRI)
void setFlag(Register Reg, uint8_t Flag)
void setVGPRToAGPRSpillDead(int FrameIndex)
std::pair< unsigned, unsigned > getFlatWorkGroupSizes() const
Register addFlatScratchInit(const SIRegisterInfo &TRI)
Register getScratchRSrcReg() const
Returns the physical register reserved for use as the resource descriptor for scratch accesses.
Register addReservedUserSGPR()
Increment user SGPRs used for padding the argument list only.
ArrayRef< MCPhysReg > getVGPRSpillAGPRs() const
ArrayRef< Register > getSGPRSpillPhysVGPRs() const
int getScavengeFI(MachineFrameInfo &MFI, const SIRegisterInfo &TRI)
Register addQueuePtr(const SIRegisterInfo &TRI)
ArrayRef< SIRegisterInfo::SpilledReg > getSGPRSpillToVirtualVGPRLanes(int FrameIndex) const
uint32_t getMaskForVGPRBlockOps(Register RegisterBlock) const
SIMachineFunctionInfo(const SIMachineFunctionInfo &MFI)=default
bool hasMaskForVGPRBlockOps(Register RegisterBlock) const
SmallVector< unsigned > getMaxNumWorkGroups() const
bool hasPrologEpilogSGPRSpillEntry(Register Reg) const
Register getGITPtrLoReg(const MachineFunction &MF) const
void setVGPRForAGPRCopy(Register NewVGPRForAGPRCopy)
bool allocateVGPRSpillToAGPR(MachineFunction &MF, int FI, bool isAGPRtoVGPR)
Reserve AGPRs or VGPRs to support spilling for FrameIndex FI.
void splitWWMSpillRegisters(MachineFunction &MF, SmallVectorImpl< std::pair< Register, int > > &CalleeSavedRegs, SmallVectorImpl< std::pair< Register, int > > &ScratchRegs) const
void setBytesInStackArgArea(unsigned Bytes)
void setNumWaveDispatchSGPRs(unsigned Count)
SIModeRegisterDefaults getMode() const
bool isWWMReservedRegister(Register Reg) const
ArrayRef< SIRegisterInfo::SpilledReg > getSGPRSpillToPhysicalVGPRLanes(int FrameIndex) const
std::tuple< const ArgDescriptor *, const TargetRegisterClass *, LLT > getPreloadedValue(AMDGPUFunctionArgInfo::PreloadedValue Value) const
bool mayUseAGPRs(const Function &F) const
bool isCalleeSavedReg(const MCPhysReg *CSRegs, MCPhysReg Reg) const
const GCNUserSGPRUsageInfo & getUserSGPRInfo() const
bool allocateSGPRSpillToVGPRLane(MachineFunction &MF, int FI, bool SpillToPhysVGPRLane=false, bool IsPrologEpilog=false)
void setPrivateSegmentWaveByteOffset(Register Reg)
void setLongBranchReservedReg(Register Reg)
const AMDGPUFunctionArgInfo & getArgInfo() const
Register addKernargSegmentPtr(const SIRegisterInfo &TRI)
Register addDispatchID(const SIRegisterInfo &TRI)
void setHasSpilledVGPRs(bool Spill=true)
bool removeDeadFrameIndices(MachineFrameInfo &MFI, bool ResetSGPRSpillStackIDs)
If ResetSGPRSpillStackIDs is true, reset the stack ID from sgpr-spill to the default stack.
void setScratchReservedForDynamicVGPRs(unsigned SizeInBytes)
void markPSInputAllocated(unsigned Index)
void setWorkItemIDX(ArgDescriptor Arg)
bool isWWMReg(Register Reg) const
MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB) const override
Make a functionally equivalent copy of this MachineFunctionInfo in MF.
bool checkFlag(Register Reg, uint8_t Flag) const
void setNumWaveDispatchVGPRs(unsigned Count)
void markPSInputEnabled(unsigned Index)
MCRegister getPreloadedReg(AMDGPUFunctionArgInfo::PreloadedValue Value) const
void setHasSpilledSGPRs(bool Spill=true)
bool checkIndexInPrologEpilogSGPRSpills(int FI) const
void updateNonWWMRegMask(BitVector &RegMask)
unsigned getNumKernargPreloadedSGPRs() const
Register addPrivateSegmentBuffer(const SIRegisterInfo &TRI)
unsigned getScratchReservedForDynamicVGPRs() const
const ReservedRegSet & getWWMReservedRegs() const
Register getImplicitBufferPtrUserSGPR() const
std::optional< int > getOptionalScavengeFI() const
Register addImplicitBufferPtr(const SIRegisterInfo &TRI)
AMDGPUFunctionArgInfo & getArgInfo()
const PrologEpilogSGPRSaveRestoreInfo & getPrologEpilogSGPRSaveRestoreInfo(Register Reg) const
void setHasNonSpillStackObjects(bool StackObject=true)
void setIsStackRealigned(bool Realigned=true)
void limitOccupancy(const MachineFunction &MF)
ArrayRef< Register > getSGPRSpillVGPRs() const
SmallVectorImpl< MCRegister > * addPreloadedKernArg(const SIRegisterInfo &TRI, const TargetRegisterClass *RC, unsigned AllocSizeDWord, int KernArgIdx, int PaddingSGPRs)
void addToPrologEpilogSGPRSpills(Register Reg, PrologEpilogSGPRSaveRestoreInfo SI)
Register getScratchSGPRCopyDstReg(Register Reg) const
Register getPrivateSegmentWaveByteOffsetSystemSGPR() const
const AMDGPUGWSResourcePseudoSourceValue * getGWSPSV(const AMDGPUTargetMachine &TM)
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:282
Represents a range in source code.
Definition: SMLoc.h:48
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition: SetVector.h:168
bool contains(const key_type &key) const
Check if the SetVector contains the given key.
Definition: SetVector.h:269
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
iterator insert(iterator I, T &&Elt)
Definition: SmallVector.h:806
void push_back(const T &Elt)
Definition: SmallVector.h:414
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StackOffset holds a fixed and a scalable offset in bytes.
Definition: TypeSize.h:34
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LLVM Value Representation.
Definition: Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition: MCRegister.h:21
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:2026
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
Definition: STLExtras.h:1939
@ Other
Any other memory.
constexpr unsigned DefaultMemoryClusterDWordsLimit
Definition: SIInstrInfo.h:40
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1777
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition: STLExtras.h:1916
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
static ArgDescriptor createRegister(Register Reg, unsigned Mask=~0u)
Helper struct shared between Function Specialization and SCCP Solver.
Definition: SCCPSolver.h:42
@ PreserveSign
The sign of a flushed-to-zero number is preserved in the sign of 0.
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
unsigned operator()(Register Reg) const
Function object to check whether the first component of a container supported by std::get (like std::...
Definition: STLExtras.h:1472
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
static void mapping(IO &YamlIO, SIArgumentInfo &AI)
static void mapping(IO &YamlIO, SIArgument &A)
static void mapping(IO &YamlIO, SIMachineFunctionInfo &MFI)
static void mapping(IO &YamlIO, SIMode &Mode)
std::optional< SIArgument > PrivateSegmentWaveByteOffset
std::optional< SIArgument > WorkGroupIDY
std::optional< SIArgument > FlatScratchInit
std::optional< SIArgument > DispatchPtr
std::optional< SIArgument > DispatchID
std::optional< SIArgument > WorkItemIDY
std::optional< SIArgument > WorkGroupIDX
std::optional< SIArgument > ImplicitArgPtr
std::optional< SIArgument > QueuePtr
std::optional< SIArgument > WorkGroupInfo
std::optional< SIArgument > LDSKernelId
std::optional< SIArgument > ImplicitBufferPtr
std::optional< SIArgument > WorkItemIDX
std::optional< SIArgument > KernargSegmentPtr
std::optional< SIArgument > WorkItemIDZ
std::optional< SIArgument > PrivateSegmentSize
std::optional< SIArgument > PrivateSegmentBuffer
std::optional< SIArgument > WorkGroupIDZ
std::optional< unsigned > Mask
SIArgument(const SIArgument &Other)
SIArgument & operator=(const SIArgument &Other)
static SIArgument createArgument(bool IsReg)
SmallVector< StringValue > WWMReservedRegs
void mappingImpl(yaml::IO &YamlIO) override
std::optional< SIArgumentInfo > ArgInfo
SmallVector< StringValue, 2 > SpillPhysVGPRS
std::optional< FrameIndex > ScavengeFI
SIMode(const SIModeRegisterDefaults &Mode)
A wrapper around std::string which contains a source range that's being set during parsing.