LLVM 23.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
33class MachineFunction;
35class SIRegisterInfo;
37
39public:
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 std::optional<SIArgument> FirstKernArgPreloadReg;
174
175 std::optional<SIArgument> WorkGroupIDX;
176 std::optional<SIArgument> WorkGroupIDY;
177 std::optional<SIArgument> WorkGroupIDZ;
178 std::optional<SIArgument> WorkGroupInfo;
179 std::optional<SIArgument> LDSKernelId;
180 std::optional<SIArgument> PrivateSegmentWaveByteOffset;
181
182 std::optional<SIArgument> ImplicitArgPtr;
183 std::optional<SIArgument> ImplicitBufferPtr;
184
185 std::optional<SIArgument> WorkItemIDX;
186 std::optional<SIArgument> WorkItemIDY;
187 std::optional<SIArgument> WorkItemIDZ;
188};
189
190template <> struct MappingTraits<SIArgumentInfo> {
191 static void mapping(IO &YamlIO, SIArgumentInfo &AI) {
192 YamlIO.mapOptional("privateSegmentBuffer", AI.PrivateSegmentBuffer);
193 YamlIO.mapOptional("dispatchPtr", AI.DispatchPtr);
194 YamlIO.mapOptional("queuePtr", AI.QueuePtr);
195 YamlIO.mapOptional("kernargSegmentPtr", AI.KernargSegmentPtr);
196 YamlIO.mapOptional("dispatchID", AI.DispatchID);
197 YamlIO.mapOptional("flatScratchInit", AI.FlatScratchInit);
198 YamlIO.mapOptional("privateSegmentSize", AI.PrivateSegmentSize);
199 YamlIO.mapOptional("firstKernArgPreloadReg", AI.FirstKernArgPreloadReg);
200
201 YamlIO.mapOptional("workGroupIDX", AI.WorkGroupIDX);
202 YamlIO.mapOptional("workGroupIDY", AI.WorkGroupIDY);
203 YamlIO.mapOptional("workGroupIDZ", AI.WorkGroupIDZ);
204 YamlIO.mapOptional("workGroupInfo", AI.WorkGroupInfo);
205 YamlIO.mapOptional("LDSKernelId", AI.LDSKernelId);
206 YamlIO.mapOptional("privateSegmentWaveByteOffset",
208
209 YamlIO.mapOptional("implicitArgPtr", AI.ImplicitArgPtr);
210 YamlIO.mapOptional("implicitBufferPtr", AI.ImplicitBufferPtr);
211
212 YamlIO.mapOptional("workItemIDX", AI.WorkItemIDX);
213 YamlIO.mapOptional("workItemIDY", AI.WorkItemIDY);
214 YamlIO.mapOptional("workItemIDZ", AI.WorkItemIDZ);
215 }
216};
217
218// Default to default mode for default calling convention.
219struct SIMode {
220 bool IEEE = true;
221 bool DX10Clamp = true;
226
227 SIMode() = default;
228
230 IEEE = Mode.IEEE;
231 DX10Clamp = Mode.DX10Clamp;
232 FP32InputDenormals = Mode.FP32Denormals.Input != DenormalMode::PreserveSign;
234 Mode.FP32Denormals.Output != DenormalMode::PreserveSign;
236 Mode.FP64FP16Denormals.Input != DenormalMode::PreserveSign;
238 Mode.FP64FP16Denormals.Output != DenormalMode::PreserveSign;
239 }
240
241 bool operator ==(const SIMode Other) const {
242 return IEEE == Other.IEEE &&
243 DX10Clamp == Other.DX10Clamp &&
244 FP32InputDenormals == Other.FP32InputDenormals &&
245 FP32OutputDenormals == Other.FP32OutputDenormals &&
246 FP64FP16InputDenormals == Other.FP64FP16InputDenormals &&
247 FP64FP16OutputDenormals == Other.FP64FP16OutputDenormals;
248 }
249};
250
251template <> struct MappingTraits<SIMode> {
252 static void mapping(IO &YamlIO, SIMode &Mode) {
253 YamlIO.mapOptional("ieee", Mode.IEEE, true);
254 YamlIO.mapOptional("dx10-clamp", Mode.DX10Clamp, true);
255 YamlIO.mapOptional("fp32-input-denormals", Mode.FP32InputDenormals, true);
256 YamlIO.mapOptional("fp32-output-denormals", Mode.FP32OutputDenormals, true);
257 YamlIO.mapOptional("fp64-fp16-input-denormals", Mode.FP64FP16InputDenormals, true);
258 YamlIO.mapOptional("fp64-fp16-output-denormals", Mode.FP64FP16OutputDenormals, true);
259 }
260};
261
268 bool IsEntryFunction = false;
269 bool IsChainFunction = false;
270 bool MemoryBound = false;
271 bool WaveLimiter = false;
272 bool HasSpilledSGPRs = false;
273 bool HasSpilledVGPRs = false;
277
278 // TODO: 10 may be a better default since it's the maximum.
279 unsigned Occupancy = 0;
280
283
284 StringValue ScratchRSrcReg = "$private_rsrc_reg";
287
289 bool ReturnsVoid = true;
290
291 std::optional<SIArgumentInfo> ArgInfo;
292
293 unsigned PSInputAddr = 0;
294 unsigned PSInputEnable = 0;
296
298 std::optional<FrameIndex> ScavengeFI;
302
303 bool HasInitWholeWave = false;
305
308
310
313 const TargetRegisterInfo &TRI,
314 const llvm::MachineFunction &MF);
315
316 void mappingImpl(yaml::IO &YamlIO) override;
317 ~SIMachineFunctionInfo() override = default;
318};
319
321 static void mapping(IO &YamlIO, SIMachineFunctionInfo &MFI) {
322 YamlIO.mapOptional("explicitKernArgSize", MFI.ExplicitKernArgSize,
323 UINT64_C(0));
324 YamlIO.mapOptional("maxKernArgAlign", MFI.MaxKernArgAlign);
325 YamlIO.mapOptional("ldsSize", MFI.LDSSize, 0u);
326 YamlIO.mapOptional("gdsSize", MFI.GDSSize, 0u);
327 YamlIO.mapOptional("dynLDSAlign", MFI.DynLDSAlign, Align());
328 YamlIO.mapOptional("isEntryFunction", MFI.IsEntryFunction, false);
329 YamlIO.mapOptional("isChainFunction", MFI.IsChainFunction, false);
330 YamlIO.mapOptional("memoryBound", MFI.MemoryBound, false);
331 YamlIO.mapOptional("waveLimiter", MFI.WaveLimiter, false);
332 YamlIO.mapOptional("hasSpilledSGPRs", MFI.HasSpilledSGPRs, false);
333 YamlIO.mapOptional("hasSpilledVGPRs", MFI.HasSpilledVGPRs, false);
334 YamlIO.mapOptional("numWaveDispatchSGPRs", MFI.NumWaveDispatchSGPRs, false);
335 YamlIO.mapOptional("numWaveDispatchVGPRs", MFI.NumWaveDispatchVGPRs, false);
336 YamlIO.mapOptional("scratchRSrcReg", MFI.ScratchRSrcReg,
337 StringValue("$private_rsrc_reg"));
338 YamlIO.mapOptional("frameOffsetReg", MFI.FrameOffsetReg,
339 StringValue("$fp_reg"));
340 YamlIO.mapOptional("stackPtrOffsetReg", MFI.StackPtrOffsetReg,
341 StringValue("$sp_reg"));
342 YamlIO.mapOptional("bytesInStackArgArea", MFI.BytesInStackArgArea, 0u);
343 YamlIO.mapOptional("returnsVoid", MFI.ReturnsVoid, true);
344 YamlIO.mapOptional("argumentInfo", MFI.ArgInfo);
345 YamlIO.mapOptional("psInputAddr", MFI.PSInputAddr, 0u);
346 YamlIO.mapOptional("psInputEnable", MFI.PSInputEnable, 0u);
347 YamlIO.mapOptional("maxMemoryClusterDWords", MFI.MaxMemoryClusterDWords,
349 YamlIO.mapOptional("mode", MFI.Mode, SIMode());
350 YamlIO.mapOptional("highBitsOf32BitAddress",
351 MFI.HighBitsOf32BitAddress, 0u);
352 YamlIO.mapOptional("occupancy", MFI.Occupancy, 0);
353 YamlIO.mapOptional("spillPhysVGPRs", MFI.SpillPhysVGPRS);
354 YamlIO.mapOptional("wwmReservedRegs", MFI.WWMReservedRegs);
355 YamlIO.mapOptional("scavengeFI", MFI.ScavengeFI);
356 YamlIO.mapOptional("vgprForAGPRCopy", MFI.VGPRForAGPRCopy,
357 StringValue()); // Don't print out when it's empty.
358 YamlIO.mapOptional("sgprForEXECCopy", MFI.SGPRForEXECCopy,
359 StringValue()); // Don't print out when it's empty.
360 YamlIO.mapOptional("longBranchReservedReg", MFI.LongBranchReservedReg,
361 StringValue());
362 YamlIO.mapOptional("hasInitWholeWave", MFI.HasInitWholeWave, false);
363 YamlIO.mapOptional("dynamicVGPRBlockSize", MFI.DynamicVGPRBlockSize, false);
364 YamlIO.mapOptional("scratchReservedForDynamicVGPRs",
366 YamlIO.mapOptional("numKernargPreloadSGPRs", MFI.NumKernargPreloadSGPRs, 0);
367 YamlIO.mapOptional("isWholeWaveFunction", MFI.IsWholeWaveFunction, false);
368 }
369};
370
371} // end namespace yaml
372
373// A CSR SGPR value can be preserved inside a callee using one of the following
374// methods.
375// 1. Copy to an unused scratch SGPR.
376// 2. Spill to a VGPR lane.
377// 3. Spill to memory via. a scratch VGPR.
378// class PrologEpilogSGPRSaveRestoreInfo represents the save/restore method used
379// for an SGPR at function prolog/epilog.
385
387 SGPRSaveKind Kind;
388 union {
389 int Index;
391 };
392
393public:
397 Register getReg() const { return Reg; }
398 int getIndex() const { return Index; }
399 SGPRSaveKind getKind() const { return Kind; }
400};
401
404 unsigned operator()(Register Reg) const {
405 assert(AMDGPU::VReg_1024RegClass.contains(Reg) && "Expecting a VGPR block");
406
407 const MCRegister FirstVGPRBlock = AMDGPU::VReg_1024RegClass.getRegister(0);
408 return Reg - FirstVGPRBlock;
409 }
410};
411
412/// This class keeps track of the SPI_SP_INPUT_ADDR config register, which
413/// tells the hardware which interpolation parameters to load.
416 friend class GCNTargetMachine;
417
418 // State of MODE register, assumed FP mode.
420
421 // Registers that may be reserved for spilling purposes. These may be the same
422 // as the input registers.
423 Register ScratchRSrcReg = AMDGPU::PRIVATE_RSRC_REG;
424
425 // This is the unswizzled offset from the current dispatch's scratch wave
426 // base to the beginning of the current function's frame.
427 Register FrameOffsetReg = AMDGPU::FP_REG;
428
429 // This is an ABI register used in the non-entry calling convention to
430 // communicate the unswizzled offset from the current dispatch's scratch wave
431 // base to the beginning of the new function's frame.
432 Register StackPtrOffsetReg = AMDGPU::SP_REG;
433
434 // Registers that may be reserved when RA doesn't allocate enough
435 // registers to plan for the case where an indirect branch ends up
436 // being needed during branch relaxation.
437 Register LongBranchReservedReg;
438
439 AMDGPUFunctionArgInfo ArgInfo;
440
441 // Graphics info.
442 unsigned PSInputAddr = 0;
443 unsigned PSInputEnable = 0;
444
445 /// Number of bytes of arguments this function has on the stack. If the callee
446 /// is expected to restore the argument stack this should be a multiple of 16,
447 /// all usable during a tail call.
448 ///
449 /// The alternative would forbid tail call optimisation in some cases: if we
450 /// want to transfer control from a function with 8-bytes of stack-argument
451 /// space to a function with 16-bytes then misalignment of this value would
452 /// make a stack adjustment necessary, which could not be undone by the
453 /// callee.
454 unsigned BytesInStackArgArea = 0;
455
456 bool ReturnsVoid = true;
457
458 // A pair of default/requested minimum/maximum flat work group sizes.
459 // Minimum - first, maximum - second.
460 std::pair<unsigned, unsigned> FlatWorkGroupSizes = {0, 0};
461
462 // A pair of default/requested minimum/maximum number of waves per execution
463 // unit. Minimum - first, maximum - second.
464 std::pair<unsigned, unsigned> WavesPerEU = {0, 0};
465
466 const AMDGPUGWSResourcePseudoSourceValue GWSResourcePSV;
467
468 // Default/requested number of work groups for the function.
469 SmallVector<unsigned> MaxNumWorkGroups = {0, 0, 0};
470
471 // Requested cluster dimensions.
472 AMDGPU::ClusterDimsAttr ClusterDims;
473
474private:
475 unsigned NumUserSGPRs = 0;
476 unsigned NumSystemSGPRs = 0;
477
478 unsigned NumWaveDispatchSGPRs = 0;
479 unsigned NumWaveDispatchVGPRs = 0;
480
481 bool HasSpilledSGPRs = false;
482 bool HasSpilledVGPRs = false;
483 bool HasNonSpillStackObjects = false;
484 bool IsStackRealigned = false;
485
486 unsigned NumSpilledSGPRs = 0;
487 unsigned NumSpilledVGPRs = 0;
488
489 unsigned DynamicVGPRBlockSize = 0;
490
491 // The size in bytes of the scratch space reserved for the CWSR trap handler
492 // to spill some of the dynamic VGPRs.
493 unsigned ScratchReservedForDynamicVGPRs = 0;
494
495 // Tracks information about user SGPRs that will be setup by hardware which
496 // will apply to all wavefronts of the grid.
497 GCNUserSGPRUsageInfo UserSGPRInfo;
498
499 // Feature bits required for inputs passed in system SGPRs.
500 bool WorkGroupIDX : 1; // Always initialized.
501 bool WorkGroupIDY : 1;
502 bool WorkGroupIDZ : 1;
503 bool WorkGroupInfo : 1;
504 bool LDSKernelId : 1;
505 bool PrivateSegmentWaveByteOffset : 1;
506
507 bool WorkItemIDX : 1; // Always initialized.
508 bool WorkItemIDY : 1;
509 bool WorkItemIDZ : 1;
510
511 // Pointer to where the ABI inserts special kernel arguments separate from the
512 // user arguments. This is an offset from the KernargSegmentPtr.
513 bool ImplicitArgPtr : 1;
514
515 /// Minimum number of AGPRs required to allocate in the function. Only
516 /// relevant for gfx90a-gfx950. For gfx908, this should be infinite.
517 unsigned MinNumAGPRs = ~0u;
518
519 // The hard-wired high half of the address of the global information table
520 // for AMDPAL OS type. 0xffffffff represents no hard-wired high half, since
521 // current hardware only allows a 16 bit value.
522 unsigned GITPtrHigh;
523
524 unsigned HighBitsOf32BitAddress;
525
526 // Flags associated with the virtual registers.
527 IndexedMap<uint8_t, VirtReg2IndexFunctor> VRegFlags;
528
529 // Current recorded maximum possible occupancy.
530 unsigned Occupancy;
531
532 // Maximum number of dwords that can be clusterred during instruction
533 // scheduler stage.
534 unsigned MaxMemoryClusterDWords = DefaultMemoryClusterDWordsLimit;
535
536 MCPhysReg getNextUserSGPR() const;
537
538 MCPhysReg getNextSystemSGPR() const;
539
540 // MachineRegisterInfo callback functions to notify events.
541 void MRI_NoteNewVirtualRegister(Register Reg) override;
542 void MRI_NoteCloneVirtualRegister(Register NewReg, Register SrcReg) override;
543
544public:
545 static bool MFMAVGPRForm;
546
552
553private:
554 // To track virtual VGPR + lane index for each subregister of the SGPR spilled
555 // to frameindex key during SILowerSGPRSpills pass.
557 SGPRSpillsToVirtualVGPRLanes;
558 // To track physical VGPR + lane index for CSR SGPR spills and special SGPRs
559 // like Frame Pointer identified during PrologEpilogInserter.
561 SGPRSpillsToPhysicalVGPRLanes;
562 unsigned NumVirtualVGPRSpillLanes = 0;
563 unsigned NumPhysicalVGPRSpillLanes = 0;
564 SmallVector<Register, 2> SpillVGPRs;
565 SmallVector<Register, 2> SpillPhysVGPRs;
566 using WWMSpillsMap = MapVector<Register, int>;
567 // To track the registers used in instructions that can potentially modify the
568 // inactive lanes. The WWM instructions and the writelane instructions for
569 // spilling SGPRs to VGPRs fall under such category of operations. The VGPRs
570 // modified by them should be spilled/restored at function prolog/epilog to
571 // avoid any undesired outcome. Each entry in this map holds a pair of values,
572 // the VGPR and its stack slot index.
573 WWMSpillsMap WWMSpills;
574
575 // Before allocation, the VGPR registers are partitioned into two distinct
576 // sets, the first one for WWM-values and the second set for non-WWM values.
577 // The latter set should be reserved during WWM-regalloc.
578 BitVector NonWWMRegMask;
579
580 using ReservedRegSet = SmallSetVector<Register, 8>;
581 // To track the VGPRs reserved for WWM instructions. They get stack slots
582 // later during PrologEpilogInserter and get added into the superset WWMSpills
583 // for actual spilling. A separate set makes the register reserved part and
584 // the serialization easier.
585 ReservedRegSet WWMReservedRegs;
586
587 bool IsWholeWaveFunction = false;
588
589 using PrologEpilogSGPRSpill =
590 std::pair<Register, PrologEpilogSGPRSaveRestoreInfo>;
591 // To track the SGPR spill method used for a CSR SGPR register during
592 // frame lowering. Even though the SGPR spills are handled during
593 // SILowerSGPRSpills pass, some special handling needed later during the
594 // PrologEpilogInserter.
595 SmallVector<PrologEpilogSGPRSpill, 3> PrologEpilogSGPRSpills;
596
597 // To save/restore EXEC MASK around WWM spills and copies.
598 Register SGPRForEXECCopy;
599
600 DenseMap<int, VGPRSpillToAGPR> VGPRToAGPRSpills;
601
602 // AGPRs used for VGPR spills.
604
605 // VGPRs used for AGPR spills.
607
608 // Emergency stack slot. Sometimes, we create this before finalizing the stack
609 // frame, so save it here and add it to the RegScavenger later.
610 std::optional<int> ScavengeFI;
611
612 // Map each VGPR CSR to the mask needed to save and restore it using block
613 // load/store instructions. Only used if the subtarget feature for VGPR block
614 // load/store is enabled.
616
617private:
618 Register VGPRForAGPRCopy;
619
620 bool allocateVirtualVGPRForSGPRSpills(MachineFunction &MF, int FI,
621 unsigned LaneIndex);
622 bool allocatePhysicalVGPRForSGPRSpills(MachineFunction &MF, int FI,
623 unsigned LaneIndex,
624 bool IsPrologEpilog);
625
626public:
628 return VGPRForAGPRCopy;
629 }
630
631 void setVGPRForAGPRCopy(Register NewVGPRForAGPRCopy) {
632 VGPRForAGPRCopy = NewVGPRForAGPRCopy;
633 }
634
635 bool isCalleeSavedReg(const MCPhysReg *CSRegs, MCPhysReg Reg) const;
636
637 void setMaskForVGPRBlockOps(Register RegisterBlock, uint32_t Mask) {
638 MaskForVGPRBlockOps.grow(RegisterBlock);
639 MaskForVGPRBlockOps[RegisterBlock] = Mask;
640 }
641
643 return MaskForVGPRBlockOps[RegisterBlock];
644 }
645
646 bool hasMaskForVGPRBlockOps(Register RegisterBlock) const {
647 return MaskForVGPRBlockOps.inBounds(RegisterBlock);
648 }
649
650public:
652 SIMachineFunctionInfo(const Function &F, const GCNSubtarget *STI);
653
657 const override;
658
660 const MachineFunction &MF,
662 SMDiagnostic &Error, SMRange &SourceRange);
663
664 void reserveWWMRegister(Register Reg) { WWMReservedRegs.insert(Reg); }
665 bool isWWMReg(Register Reg) const {
666 return Reg.isVirtual() ? checkFlag(Reg, AMDGPU::VirtRegFlag::WWM_REG)
667 : WWMReservedRegs.contains(Reg);
668 }
669
670 void updateNonWWMRegMask(BitVector &RegMask) { NonWWMRegMask = RegMask; }
671 BitVector getNonWWMRegMask() const { return NonWWMRegMask; }
672 void clearNonWWMRegAllocMask() { NonWWMRegMask.clear(); }
673
674 SIModeRegisterDefaults getMode() const { return Mode; }
675
677 getSGPRSpillToVirtualVGPRLanes(int FrameIndex) const {
678 auto I = SGPRSpillsToVirtualVGPRLanes.find(FrameIndex);
679 return (I == SGPRSpillsToVirtualVGPRLanes.end())
681 : ArrayRef(I->second);
682 }
683
684 ArrayRef<Register> getSGPRSpillVGPRs() const { return SpillVGPRs; }
685 ArrayRef<Register> getSGPRSpillPhysVGPRs() const { return SpillPhysVGPRs; }
686
687 const WWMSpillsMap &getWWMSpills() const { return WWMSpills; }
688 const ReservedRegSet &getWWMReservedRegs() const { return WWMReservedRegs; }
689
691 return WWMReservedRegs.contains(Reg);
692 }
693
694 bool isWholeWaveFunction() const { return IsWholeWaveFunction; }
695
697 assert(is_sorted(PrologEpilogSGPRSpills, llvm::less_first()));
698 return PrologEpilogSGPRSpills;
699 }
700
701 GCNUserSGPRUsageInfo &getUserSGPRInfo() { return UserSGPRInfo; }
702
703 const GCNUserSGPRUsageInfo &getUserSGPRInfo() const { return UserSGPRInfo; }
704
708
709 // Insert a new entry in the right place to keep the vector in sorted order.
710 // This should be cheap since the vector is expected to be very short.
711 PrologEpilogSGPRSpills.insert(
713 PrologEpilogSGPRSpills, Reg,
714 [](const auto &LHS, const auto &RHS) { return LHS < RHS.first; }),
715 std::make_pair(Reg, SI));
716 }
717
718 // Check if an entry created for \p Reg in PrologEpilogSGPRSpills. Return true
719 // on success and false otherwise.
721 const auto *I = find_if(PrologEpilogSGPRSpills, [&Reg](const auto &Spill) {
722 return Spill.first == Reg;
723 });
724 return I != PrologEpilogSGPRSpills.end();
725 }
726
727 // Get the scratch SGPR if allocated to save/restore \p Reg.
729 const auto *I = find_if(PrologEpilogSGPRSpills, [&Reg](const auto &Spill) {
730 return Spill.first == Reg;
731 });
732 if (I != PrologEpilogSGPRSpills.end() &&
733 I->second.getKind() == SGPRSaveKind::COPY_TO_SCRATCH_SGPR)
734 return I->second.getReg();
735
736 return AMDGPU::NoRegister;
737 }
738
739 // Get all scratch SGPRs allocated to copy/restore the SGPR spills.
741 for (const auto &SI : PrologEpilogSGPRSpills) {
742 if (SI.second.getKind() == SGPRSaveKind::COPY_TO_SCRATCH_SGPR)
743 Regs.push_back(SI.second.getReg());
744 }
745 }
746
747 // Check if \p FI is allocated for any SGPR spill to a VGPR lane during PEI.
749 return find_if(PrologEpilogSGPRSpills,
750 [FI](const std::pair<Register,
752 return SI.second.getKind() ==
754 SI.second.getIndex() == FI;
755 }) != PrologEpilogSGPRSpills.end();
756 }
757
760 const auto *I = find_if(PrologEpilogSGPRSpills, [&Reg](const auto &Spill) {
761 return Spill.first == Reg;
762 });
763 assert(I != PrologEpilogSGPRSpills.end());
764
765 return I->second;
766 }
767
769 getSGPRSpillToPhysicalVGPRLanes(int FrameIndex) const {
770 auto I = SGPRSpillsToPhysicalVGPRLanes.find(FrameIndex);
771 return (I == SGPRSpillsToPhysicalVGPRLanes.end())
773 : ArrayRef(I->second);
774 }
775
777 assert(Reg.isVirtual());
778 if (VRegFlags.inBounds(Reg))
779 VRegFlags[Reg] |= Flag;
780 }
781
782 bool checkFlag(Register Reg, uint8_t Flag) const {
783 if (Reg.isPhysical())
784 return false;
785
786 return VRegFlags.inBounds(Reg) && VRegFlags[Reg] & Flag;
787 }
788
789 bool hasVRegFlags() { return VRegFlags.size(); }
790
792 Align Alignment = Align(4));
793
795 MachineFunction &MF,
796 SmallVectorImpl<std::pair<Register, int>> &CalleeSavedRegs,
797 SmallVectorImpl<std::pair<Register, int>> &ScratchRegs) const;
798
800 return SpillAGPR;
801 }
802
803 Register getSGPRForEXECCopy() const { return SGPRForEXECCopy; }
804
805 void setSGPRForEXECCopy(Register Reg) { SGPRForEXECCopy = Reg; }
806
808 return SpillVGPR;
809 }
810
811 MCPhysReg getVGPRToAGPRSpill(int FrameIndex, unsigned Lane) const {
812 auto I = VGPRToAGPRSpills.find(FrameIndex);
813 return (I == VGPRToAGPRSpills.end()) ? (MCPhysReg)AMDGPU::NoRegister
814 : I->second.Lanes[Lane];
815 }
816
817 void setVGPRToAGPRSpillDead(int FrameIndex) {
818 auto I = VGPRToAGPRSpills.find(FrameIndex);
819 if (I != VGPRToAGPRSpills.end())
820 I->second.IsDead = true;
821 }
822
823 // To bring the allocated WWM registers in \p WWMVGPRs to the lowest available
824 // range.
827 BitVector &SavedVGPRs);
828
830 bool SpillToPhysVGPRLane = false,
831 bool IsPrologEpilog = false);
832 bool allocateVGPRSpillToAGPR(MachineFunction &MF, int FI, bool isAGPRtoVGPR);
833
834 /// If \p ResetSGPRSpillStackIDs is true, reset the stack ID from sgpr-spill
835 /// to the default stack.
837 bool ResetSGPRSpillStackIDs);
838
840 std::optional<int> getOptionalScavengeFI() const { return ScavengeFI; }
841
842 unsigned getBytesInStackArgArea() const {
843 return BytesInStackArgArea;
844 }
845
846 void setBytesInStackArgArea(unsigned Bytes) {
847 BytesInStackArgArea = Bytes;
848 }
849
850 bool isDynamicVGPREnabled() const { return DynamicVGPRBlockSize != 0; }
851 unsigned getDynamicVGPRBlockSize() const { return DynamicVGPRBlockSize; }
852
853 // This is only used if we need to save any dynamic VGPRs in scratch.
855 return ScratchReservedForDynamicVGPRs;
856 }
857
858 void setScratchReservedForDynamicVGPRs(unsigned SizeInBytes) {
859 ScratchReservedForDynamicVGPRs = SizeInBytes;
860 }
861
862 // Add user SGPRs.
874 unsigned AllocSizeDWord, int KernArgIdx,
875 int PaddingSGPRs);
876
877 /// Increment user SGPRs used for padding the argument list only.
879 Register Next = getNextUserSGPR();
880 ++NumUserSGPRs;
881 return Next;
882 }
883
884 // Add system SGPRs.
886 ArgInfo.WorkGroupIDX = ArgDescriptor::createRegister(getNextSystemSGPR());
887 NumSystemSGPRs += 1;
888 return ArgInfo.WorkGroupIDX.getRegister();
889 }
890
892 ArgInfo.WorkGroupIDY = ArgDescriptor::createRegister(getNextSystemSGPR());
893 NumSystemSGPRs += 1;
894 return ArgInfo.WorkGroupIDY.getRegister();
895 }
896
898 ArgInfo.WorkGroupIDZ = ArgDescriptor::createRegister(getNextSystemSGPR());
899 NumSystemSGPRs += 1;
900 return ArgInfo.WorkGroupIDZ.getRegister();
901 }
902
904 ArgInfo.WorkGroupInfo = ArgDescriptor::createRegister(getNextSystemSGPR());
905 NumSystemSGPRs += 1;
906 return ArgInfo.WorkGroupInfo.getRegister();
907 }
908
909 bool hasLDSKernelId() const { return LDSKernelId; }
910
911 // Add special VGPR inputs
913 ArgInfo.WorkItemIDX = Arg;
914 }
915
917 ArgInfo.WorkItemIDY = Arg;
918 }
919
921 ArgInfo.WorkItemIDZ = Arg;
922 }
923
925 ArgInfo.PrivateSegmentWaveByteOffset
926 = ArgDescriptor::createRegister(getNextSystemSGPR());
927 NumSystemSGPRs += 1;
928 return ArgInfo.PrivateSegmentWaveByteOffset.getRegister();
929 }
930
932 ArgInfo.PrivateSegmentWaveByteOffset = ArgDescriptor::createRegister(Reg);
933 }
934
935 bool hasWorkGroupIDX() const {
936 return WorkGroupIDX;
937 }
938
939 bool hasWorkGroupIDY() const {
940 return WorkGroupIDY;
941 }
942
943 bool hasWorkGroupIDZ() const {
944 return WorkGroupIDZ;
945 }
946
947 bool hasWorkGroupInfo() const {
948 return WorkGroupInfo;
949 }
950
952 return PrivateSegmentWaveByteOffset;
953 }
954
955 bool hasWorkItemIDX() const {
956 return WorkItemIDX;
957 }
958
959 bool hasWorkItemIDY() const {
960 return WorkItemIDY;
961 }
962
963 bool hasWorkItemIDZ() const {
964 return WorkItemIDZ;
965 }
966
967 bool hasImplicitArgPtr() const {
968 return ImplicitArgPtr;
969 }
970
972 return ArgInfo;
973 }
974
976 return ArgInfo;
977 }
978
979 std::tuple<const ArgDescriptor *, const TargetRegisterClass *, LLT>
981 return ArgInfo.getPreloadedValue(Value);
982 }
983
985 const auto *Arg = std::get<0>(ArgInfo.getPreloadedValue(Value));
986 return Arg ? Arg->getRegister() : MCRegister();
987 }
988
989 unsigned getGITPtrHigh() const {
990 return GITPtrHigh;
991 }
992
993 Register getGITPtrLoReg(const MachineFunction &MF) const;
994
996 return HighBitsOf32BitAddress;
997 }
998
999 unsigned getNumUserSGPRs() const {
1000 return NumUserSGPRs;
1001 }
1002
1003 unsigned getNumPreloadedSGPRs() const {
1004 return NumUserSGPRs + NumSystemSGPRs;
1005 }
1006
1008 return UserSGPRInfo.getNumKernargPreloadSGPRs();
1009 }
1010
1011 unsigned getNumWaveDispatchSGPRs() const { return NumWaveDispatchSGPRs; }
1012
1013 void setNumWaveDispatchSGPRs(unsigned Count) { NumWaveDispatchSGPRs = Count; }
1014
1015 unsigned getNumWaveDispatchVGPRs() const { return NumWaveDispatchVGPRs; }
1016
1017 void setNumWaveDispatchVGPRs(unsigned Count) { NumWaveDispatchVGPRs = Count; }
1018
1020 if (ArgInfo.PrivateSegmentWaveByteOffset)
1021 return ArgInfo.PrivateSegmentWaveByteOffset.getRegister();
1022 return MCRegister();
1023 }
1024
1025 /// Returns the physical register reserved for use as the resource
1026 /// descriptor for scratch accesses.
1028 return ScratchRSrcReg;
1029 }
1030
1032 assert(Reg != 0 && "Should never be unset");
1033 ScratchRSrcReg = Reg;
1034 }
1035
1037 return FrameOffsetReg;
1038 }
1039
1041 assert(Reg != 0 && "Should never be unset");
1042 FrameOffsetReg = Reg;
1043 }
1044
1046 assert(Reg != 0 && "Should never be unset");
1047 StackPtrOffsetReg = Reg;
1048 }
1049
1050 void setLongBranchReservedReg(Register Reg) { LongBranchReservedReg = Reg; }
1051
1052 // Note the unset value for this is AMDGPU::SP_REG rather than
1053 // NoRegister. This is mostly a workaround for MIR tests where state that
1054 // can't be directly computed from the function is not preserved in serialized
1055 // MIR.
1057 return StackPtrOffsetReg;
1058 }
1059
1060 Register getLongBranchReservedReg() const { return LongBranchReservedReg; }
1061
1063 return ArgInfo.QueuePtr.getRegister();
1064 }
1065
1067 return ArgInfo.ImplicitBufferPtr.getRegister();
1068 }
1069
1070 bool hasSpilledSGPRs() const {
1071 return HasSpilledSGPRs;
1072 }
1073
1074 void setHasSpilledSGPRs(bool Spill = true) {
1075 HasSpilledSGPRs = Spill;
1076 }
1077
1078 bool hasSpilledVGPRs() const {
1079 return HasSpilledVGPRs;
1080 }
1081
1082 void setHasSpilledVGPRs(bool Spill = true) {
1083 HasSpilledVGPRs = Spill;
1084 }
1085
1087 return HasNonSpillStackObjects;
1088 }
1089
1090 void setHasNonSpillStackObjects(bool StackObject = true) {
1091 HasNonSpillStackObjects = StackObject;
1092 }
1093
1094 bool isStackRealigned() const {
1095 return IsStackRealigned;
1096 }
1097
1098 void setIsStackRealigned(bool Realigned = true) {
1099 IsStackRealigned = Realigned;
1100 }
1101
1102 unsigned getNumSpilledSGPRs() const {
1103 return NumSpilledSGPRs;
1104 }
1105
1106 unsigned getNumSpilledVGPRs() const {
1107 return NumSpilledVGPRs;
1108 }
1109
1110 void addToSpilledSGPRs(unsigned num) {
1111 NumSpilledSGPRs += num;
1112 }
1113
1114 void addToSpilledVGPRs(unsigned num) {
1115 NumSpilledVGPRs += num;
1116 }
1117
1118 unsigned getPSInputAddr() const {
1119 return PSInputAddr;
1120 }
1121
1122 unsigned getPSInputEnable() const {
1123 return PSInputEnable;
1124 }
1125
1126 bool isPSInputAllocated(unsigned Index) const {
1127 return PSInputAddr & (1 << Index);
1128 }
1129
1130 void markPSInputAllocated(unsigned Index) {
1131 PSInputAddr |= 1 << Index;
1132 }
1133
1134 void markPSInputEnabled(unsigned Index) {
1135 PSInputEnable |= 1 << Index;
1136 }
1137
1138 bool returnsVoid() const {
1139 return ReturnsVoid;
1140 }
1141
1143 ReturnsVoid = Value;
1144 }
1145
1146 /// \returns A pair of default/requested minimum/maximum flat work group sizes
1147 /// for this function.
1148 std::pair<unsigned, unsigned> getFlatWorkGroupSizes() const {
1149 return FlatWorkGroupSizes;
1150 }
1151
1152 /// \returns Default/requested minimum flat work group size for this function.
1153 unsigned getMinFlatWorkGroupSize() const {
1154 return FlatWorkGroupSizes.first;
1155 }
1156
1157 /// \returns Default/requested maximum flat work group size for this function.
1158 unsigned getMaxFlatWorkGroupSize() const {
1159 return FlatWorkGroupSizes.second;
1160 }
1161
1162 /// \returns A pair of default/requested minimum/maximum number of waves per
1163 /// execution unit.
1164 std::pair<unsigned, unsigned> getWavesPerEU() const {
1165 return WavesPerEU;
1166 }
1167
1168 /// \returns Default/requested minimum number of waves per execution unit.
1169 unsigned getMinWavesPerEU() const {
1170 return WavesPerEU.first;
1171 }
1172
1173 /// \returns Default/requested maximum number of waves per execution unit.
1174 unsigned getMaxWavesPerEU() const {
1175 return WavesPerEU.second;
1176 }
1177
1180 return &GWSResourcePSV;
1181 }
1182
1183 unsigned getOccupancy() const {
1184 return Occupancy;
1185 }
1186
1187 unsigned getMinAllowedOccupancy() const {
1188 if (!isMemoryBound() && !needsWaveLimiter())
1189 return Occupancy;
1190 return (Occupancy < 4) ? Occupancy : 4;
1191 }
1192
1193 void limitOccupancy(const MachineFunction &MF);
1194
1195 void limitOccupancy(unsigned Limit) {
1196 if (Occupancy > Limit)
1197 Occupancy = Limit;
1198 }
1199
1200 void increaseOccupancy(const MachineFunction &MF, unsigned Limit) {
1201 if (Occupancy < Limit)
1202 Occupancy = Limit;
1203 limitOccupancy(MF);
1204 }
1205
1206 unsigned getMaxMemoryClusterDWords() const { return MaxMemoryClusterDWords; }
1207
1208 unsigned getMinNumAGPRs() const { return MinNumAGPRs; }
1209
1210 /// Return true if an MFMA that requires at least \p NumRegs should select to
1211 /// the AGPR form, instead of the VGPR form.
1212 bool selectAGPRFormMFMA(unsigned NumRegs) const {
1213 return !MFMAVGPRForm && getMinNumAGPRs() >= NumRegs;
1214 }
1215
1216 // \returns true if a function has a use of AGPRs via inline asm or
1217 // has a call which may use it.
1218 bool mayUseAGPRs(const Function &F) const;
1219
1220 /// \returns Default/requested number of work groups for this function.
1221 SmallVector<unsigned> getMaxNumWorkGroups() const { return MaxNumWorkGroups; }
1222
1223 unsigned getMaxNumWorkGroupsX() const { return MaxNumWorkGroups[0]; }
1224 unsigned getMaxNumWorkGroupsY() const { return MaxNumWorkGroups[1]; }
1225 unsigned getMaxNumWorkGroupsZ() const { return MaxNumWorkGroups[2]; }
1226
1227 AMDGPU::ClusterDimsAttr getClusterDims() const { return ClusterDims; }
1228};
1229
1230} // end namespace llvm
1231
1232#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")
AMD GCN specific subclass of TargetSubtarget.
static bool IsRegister(const MCParsedAsmOperand &op)
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
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.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition Value.cpp:487
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...
AMDGPUMachineFunction(const Function &F, const AMDGPUSubtarget &ST)
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:40
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
This class implements a map that also provides access to all stored values in a deterministic order.
Definition MapVector.h:36
PrologEpilogSGPRSaveRestoreInfo(SGPRSaveKind K, Register R)
PrologEpilogSGPRSaveRestoreInfo(SGPRSaveKind K, int I)
Special value supplied for machine level alias analysis.
PseudoSourceValue(unsigned Kind, const TargetMachine &TM)
Wrapper class representing virtual and physical registers.
Definition Register.h:20
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
AMDGPU::ClusterDimsAttr getClusterDims() 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)
bool selectAGPRFormMFMA(unsigned NumRegs) const
Return true if an MFMA that requires at least NumRegs should select to the AGPR form,...
Register addPrivateSegmentBuffer(const SIRegisterInfo &TRI)
unsigned getScratchReservedForDynamicVGPRs() const
const ReservedRegSet & getWWMReservedRegs() 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:297
Represents a range in source code.
Definition SMLoc.h:47
A SetVector that performs no allocations if smaller than a certain size.
Definition SetVector.h:339
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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
virtual bool outputting() const =0
void mapOptional(StringRef Key, T &Val)
Definition YAMLTraits.h:799
virtual void setError(const Twine &)=0
void mapRequired(StringRef Key, T &Val)
Definition YAMLTraits.h:789
virtual std::vector< StringRef > keys()=0
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
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:2055
FunctionAddr VTableAddr Count
Definition InstrProf.h:139
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:1968
@ Other
Any other memory.
Definition ModRef.h:68
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition MCRegister.h:21
FunctionAddr VTableAddr Next
Definition InstrProf.h:141
ArrayRef(const T &OneElt) -> ArrayRef< T >
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:1770
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1945
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383
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)
@ 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:1437
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)
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
Definition YAMLTraits.h:62
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 > FirstKernArgPreloadReg
std::optional< SIArgument > WorkGroupIDZ
std::optional< unsigned > Mask
SIArgument(const SIArgument &Other)
SIArgument & operator=(const SIArgument &Other)
static SIArgument createArgument(bool IsReg)
~SIMachineFunctionInfo() override=default
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)
bool operator==(const SIMode Other) const
A wrapper around std::string which contains a source range that's being set during parsing.