LLVM 22.0.0git
GCNRegPressure.h
Go to the documentation of this file.
1//===- GCNRegPressure.h -----------------------------------------*- 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/// This file defines the GCNRegPressure class, which tracks registry pressure
11/// by bookkeeping number of SGPR/VGPRs used, weights for large SGPR/VGPRs. It
12/// also implements a compare function, which compares different register
13/// pressures, and declares one with max occupancy as winner.
14///
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_LIB_TARGET_AMDGPU_GCNREGPRESSURE_H
18#define LLVM_LIB_TARGET_AMDGPU_GCNREGPRESSURE_H
19
20#include "GCNSubtarget.h"
23#include <algorithm>
24
25namespace llvm {
26
27class MachineRegisterInfo;
28class raw_ostream;
29class SlotIndex;
30
33
35 clear();
36 }
37
38 bool empty() const {
39 return !Value[SGPR] && !Value[VGPR] && !Value[AGPR] && !Value[AVGPR];
40 }
41
42 void clear() { std::fill(&Value[0], &Value[ValueArraySize], 0); }
43
44 /// \returns the SGPR32 pressure
45 unsigned getSGPRNum() const { return Value[SGPR]; }
46 /// \returns the aggregated ArchVGPR32, AccVGPR32, and Pseudo AVGPR pressure
47 /// dependent upon \p UnifiedVGPRFile
48 unsigned getVGPRNum(bool UnifiedVGPRFile) const {
49 if (UnifiedVGPRFile) {
50 return Value[AGPR]
52 : Value[VGPR] + Value[AVGPR];
53 }
54 // AVGPR assignment priority is based on the width of the register. Account
55 // AVGPR pressure as VGPR.
56 return std::max(Value[VGPR] + Value[AVGPR], Value[AGPR]);
57 }
58
59 /// Returns the aggregated VGPR pressure, assuming \p NumArchVGPRs ArchVGPRs
60 /// \p NumAGPRs AGPRS, and \p NumAVGPRs AVGPRs for a target with a unified
61 /// VGPR file.
62 inline static unsigned getUnifiedVGPRNum(unsigned NumArchVGPRs,
63 unsigned NumAGPRs,
64 unsigned NumAVGPRs) {
65
66 // Assume AVGPRs will be assigned as VGPRs.
67 return alignTo(NumArchVGPRs + NumAVGPRs,
69 NumAGPRs;
70 }
71
72 /// \returns the ArchVGPR32 pressure, plus the AVGPRS which we assume will be
73 /// allocated as VGPR
74 unsigned getArchVGPRNum() const { return Value[VGPR] + Value[AVGPR]; }
75 /// \returns the AccVGPR32 pressure
76 unsigned getAGPRNum() const { return Value[AGPR]; }
77 /// \returns the AVGPR32 pressure
78 unsigned getAVGPRNum() const { return Value[AVGPR]; }
79
80 unsigned getVGPRTuplesWeight() const {
81 return std::max(Value[TOTAL_KINDS + VGPR] + Value[TOTAL_KINDS + AVGPR],
83 }
84 unsigned getSGPRTuplesWeight() const { return Value[TOTAL_KINDS + SGPR]; }
85
86 unsigned getOccupancy(const GCNSubtarget &ST,
87 unsigned DynamicVGPRBlockSize) const {
88 return std::min(ST.getOccupancyWithNumSGPRs(getSGPRNum()),
89 ST.getOccupancyWithNumVGPRs(getVGPRNum(ST.hasGFX90AInsts()),
90 DynamicVGPRBlockSize));
91 }
92
93 void inc(unsigned Reg,
94 LaneBitmask PrevMask,
95 LaneBitmask NewMask,
97
99 unsigned DynamicVGPRBlockSize) const {
100 return getOccupancy(ST, DynamicVGPRBlockSize) >
101 O.getOccupancy(ST, DynamicVGPRBlockSize);
102 }
103
104 /// Compares \p this GCNRegpressure to \p O, returning true if \p this is
105 /// less. Since GCNRegpressure contains different types of pressures, and due
106 /// to target-specific pecularities (e.g. we care about occupancy rather than
107 /// raw register usage), we determine if \p this GCNRegPressure is less than
108 /// \p O based on the following tiered comparisons (in order order of
109 /// precedence):
110 /// 1. Better occupancy
111 /// 2. Less spilling (first preference to VGPR spills, then to SGPR spills)
112 /// 3. Less tuple register pressure (first preference to VGPR tuples if we
113 /// determine that SGPR pressure is not important)
114 /// 4. Less raw register pressure (first preference to VGPR tuples if we
115 /// determine that SGPR pressure is not important)
116 bool less(const MachineFunction &MF, const GCNRegPressure &O,
117 unsigned MaxOccupancy = std::numeric_limits<unsigned>::max()) const;
118
119 bool operator==(const GCNRegPressure &O) const {
120 return std::equal(&Value[0], &Value[ValueArraySize], O.Value);
121 }
122
123 bool operator!=(const GCNRegPressure &O) const {
124 return !(*this == O);
125 }
126
128 for (unsigned I = 0; I < ValueArraySize; ++I)
129 Value[I] += RHS.Value[I];
130 return *this;
131 }
132
134 for (unsigned I = 0; I < ValueArraySize; ++I)
135 Value[I] -= RHS.Value[I];
136 return *this;
137 }
138
139 void dump() const;
140
141private:
142 static constexpr unsigned ValueArraySize = TOTAL_KINDS * 2;
143
144 /// Pressure for all register kinds (first all regular registers kinds, then
145 /// all tuple register kinds).
146 unsigned Value[ValueArraySize];
147
148 static unsigned getRegKind(const TargetRegisterClass *RC,
149 const SIRegisterInfo *STI);
150
151 friend GCNRegPressure max(const GCNRegPressure &P1,
152 const GCNRegPressure &P2);
153
154 friend Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST,
155 unsigned DynamicVGPRBlockSize);
156};
157
158inline GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2) {
159 GCNRegPressure Res;
160 for (unsigned I = 0; I < GCNRegPressure::ValueArraySize; ++I)
161 Res.Value[I] = std::max(P1.Value[I], P2.Value[I]);
162 return Res;
163}
164
166 const GCNRegPressure &P2) {
167 GCNRegPressure Sum = P1;
168 Sum += P2;
169 return Sum;
170}
171
173 const GCNRegPressure &P2) {
174 GCNRegPressure Diff = P1;
175 Diff -= P2;
176 return Diff;
177}
178
179////////////////////////////////////////////////////////////////////////////////
180// GCNRPTarget
181
182/// Models a register pressure target, allowing to evaluate and track register
183/// savings against that target from a starting \ref GCNRegPressure.
185public:
186 /// Sets up the target such that the register pressure starting at \p RP does
187 /// not show register spilling on function \p MF (w.r.t. the function's
188 /// mininum target occupancy).
189 GCNRPTarget(const MachineFunction &MF, const GCNRegPressure &RP);
190
191 /// Sets up the target such that the register pressure starting at \p RP does
192 /// not use more than \p NumSGPRs SGPRs and \p NumVGPRs VGPRs on function \p
193 /// MF.
194 GCNRPTarget(unsigned NumSGPRs, unsigned NumVGPRs, const MachineFunction &MF,
195 const GCNRegPressure &RP);
196
197 /// Sets up the target such that the register pressure starting at \p RP does
198 /// not prevent achieving an occupancy of at least \p Occupancy on function
199 /// \p MF.
200 GCNRPTarget(unsigned Occupancy, const MachineFunction &MF,
201 const GCNRegPressure &RP);
202
203 /// Changes the target (same semantics as constructor).
204 void setTarget(unsigned NumSGPRs, unsigned NumVGPRs);
205
206 const GCNRegPressure &getCurrentRP() const { return RP; }
207
208 void setRP(const GCNRegPressure &NewRP) { RP = NewRP; }
209
210 /// Determines whether saving virtual register \p Reg will be beneficial
211 /// towards achieving the RP target.
212 bool isSaveBeneficial(Register Reg) const;
213
214 /// Saves virtual register \p Reg with lanemask \p Mask.
216 RP.inc(Reg, Mask, LaneBitmask::getNone(), MRI);
217 }
218
219 /// Whether the current RP is at or below the defined pressure target.
220 bool satisfied() const;
221
222#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
224 OS << "Actual/Target: " << Target.RP.getSGPRNum() << '/' << Target.MaxSGPRs
225 << " SGPRs, " << Target.RP.getArchVGPRNum() << '/' << Target.MaxVGPRs
226 << " ArchVGPRs, " << Target.RP.getAGPRNum() << '/' << Target.MaxVGPRs
227 << " AGPRs";
228
229 if (Target.MaxUnifiedVGPRs) {
230 OS << ", " << Target.RP.getVGPRNum(true) << '/' << Target.MaxUnifiedVGPRs
231 << " VGPRs (unified)";
232 }
233 return OS;
234 }
235#endif
236
237private:
238 const MachineFunction &MF;
239 const bool UnifiedRF;
240
241 /// Current register pressure.
243
244 /// Target number of SGPRs.
245 unsigned MaxSGPRs;
246 /// Target number of ArchVGPRs and AGPRs.
247 unsigned MaxVGPRs;
248 /// Target number of overall VGPRs for subtargets with unified RFs. Always 0
249 /// for subtargets with non-unified RFs.
250 unsigned MaxUnifiedVGPRs;
251
252 GCNRPTarget(const GCNRegPressure &RP, const MachineFunction &MF)
253 : MF(MF), UnifiedRF(MF.getSubtarget<GCNSubtarget>().hasGFX90AInsts()),
254 RP(RP) {}
255};
256
257///////////////////////////////////////////////////////////////////////////////
258// GCNRPTracker
259
261public:
263
264protected:
268 const MachineInstr *LastTrackedMI = nullptr;
269 mutable const MachineRegisterInfo *MRI = nullptr;
270
271 GCNRPTracker(const LiveIntervals &LIS_) : LIS(LIS_) {}
272
273 void reset(const MachineInstr &MI, const LiveRegSet *LiveRegsCopy,
274 bool After);
275
276 /// Mostly copy/paste from CodeGen/RegisterPressure.cpp
278
280
281public:
282 // reset tracker and set live register set to the specified value.
283 void reset(const MachineRegisterInfo &MRI_, const LiveRegSet &LiveRegs_);
284 // live regs for the current state
285 const decltype(LiveRegs) &getLiveRegs() const { return LiveRegs; }
286 const MachineInstr *getLastTrackedMI() const { return LastTrackedMI; }
287
289
291
292 decltype(LiveRegs) moveLiveRegs() {
293 return std::move(LiveRegs);
294 }
295};
296
297GCNRPTracker::LiveRegSet getLiveRegs(SlotIndex SI, const LiveIntervals &LIS,
298 const MachineRegisterInfo &MRI);
299
300////////////////////////////////////////////////////////////////////////////////
301// GCNUpwardRPTracker
302
304public:
306
308
309 /// reset tracker at the specified slot index \p SI.
312 }
313
314 /// reset tracker to the end of the \p MBB.
316 reset(MBB.getParent()->getRegInfo(),
318 }
319
320 /// reset tracker to the point just after \p MI (in program order).
321 void reset(const MachineInstr &MI) {
322 reset(MI.getMF()->getRegInfo(), LIS.getInstructionIndex(MI).getDeadSlot());
323 }
324
325 /// Move to the state of RP just before the \p MI . If \p UseInternalIterator
326 /// is set, also update the internal iterators. Setting \p UseInternalIterator
327 /// to false allows for an externally managed iterator / program order.
328 void recede(const MachineInstr &MI);
329
330 /// \p returns whether the tracker's state after receding MI corresponds
331 /// to reported by LIS.
332 bool isValid() const;
333
334 const GCNRegPressure &getMaxPressure() const { return MaxPressure; }
335
337
341 return RP;
342 }
343};
344
345////////////////////////////////////////////////////////////////////////////////
346// GCNDownwardRPTracker
347
349 // Last position of reset or advanceBeforeNext
351
353
354public:
356
358
360
361 /// \p return MaxPressure and clear it.
363 auto Res = MaxPressure;
365 return Res;
366 }
367
368 /// Reset tracker to the point before the \p MI
369 /// filling \p LiveRegs upon this point using LIS.
370 /// \p returns false if block is empty except debug values.
371 bool reset(const MachineInstr &MI, const LiveRegSet *LiveRegs = nullptr);
372
373 /// Move to the state right before the next MI or after the end of MBB.
374 /// \p returns false if reached end of the block.
375 /// If \p UseInternalIterator is true, then internal iterators are used and
376 /// set to process in program order. If \p UseInternalIterator is false, then
377 /// it is assumed that the tracker is using an externally managed iterator,
378 /// and advance* calls will not update the state of the iterator. In such
379 /// cases, the tracker will move to the state right before the provided \p MI
380 /// and use LIS for RP calculations.
381 bool advanceBeforeNext(MachineInstr *MI = nullptr,
382 bool UseInternalIterator = true);
383
384 /// Move to the state at the MI, advanceBeforeNext has to be called first.
385 /// If \p UseInternalIterator is true, then internal iterators are used and
386 /// set to process in program order. If \p UseInternalIterator is false, then
387 /// it is assumed that the tracker is using an externally managed iterator,
388 /// and advance* calls will not update the state of the iterator. In such
389 /// cases, the tracker will move to the state at the provided \p MI .
390 void advanceToNext(MachineInstr *MI = nullptr,
391 bool UseInternalIterator = true);
392
393 /// Move to the state at the next MI. \p returns false if reached end of
394 /// block. If \p UseInternalIterator is true, then internal iterators are used
395 /// and set to process in program order. If \p UseInternalIterator is false,
396 /// then it is assumed that the tracker is using an externally managed
397 /// iterator, and advance* calls will not update the state of the iterator. In
398 /// such cases, the tracker will move to the state right before the provided
399 /// \p MI and use LIS for RP calculations.
400 bool advance(MachineInstr *MI = nullptr, bool UseInternalIterator = true);
401
402 /// Advance instructions until before \p End.
404
405 /// Reset to \p Begin and advance to \p End.
408 const LiveRegSet *LiveRegsCopy = nullptr);
409
410 /// Mostly copy/paste from CodeGen/RegisterPressure.cpp
411 /// Calculate the impact \p MI will have on CurPressure and \return the
412 /// speculated pressure. In order to support RP Speculation, this does not
413 /// rely on the implicit program ordering in the LiveIntervals.
415 const SIRegisterInfo *TRI) const;
416};
417
418/// \returns the LaneMask of live lanes of \p Reg at position \p SI. Only the
419/// active lanes of \p LaneMaskFilter will be set in the return value. This is
420/// used, for example, to limit the live lanes to a specific subreg when
421/// calculating use masks.
422LaneBitmask getLiveLaneMask(unsigned Reg, SlotIndex SI,
423 const LiveIntervals &LIS,
424 const MachineRegisterInfo &MRI,
425 LaneBitmask LaneMaskFilter = LaneBitmask::getAll());
426
427LaneBitmask getLiveLaneMask(const LiveInterval &LI, SlotIndex SI,
428 const MachineRegisterInfo &MRI,
429 LaneBitmask LaneMaskFilter = LaneBitmask::getAll());
430
431GCNRPTracker::LiveRegSet getLiveRegs(SlotIndex SI, const LiveIntervals &LIS,
432 const MachineRegisterInfo &MRI);
433
434/// creates a map MachineInstr -> LiveRegSet
435/// R - range of iterators on instructions
436/// After - upon entry or exit of every instruction
437/// Note: there is no entry in the map for instructions with empty live reg set
438/// Complexity = O(NumVirtRegs * averageLiveRangeSegmentsPerReg * lg(R))
439template <typename Range>
440DenseMap<MachineInstr*, GCNRPTracker::LiveRegSet>
441getLiveRegMap(Range &&R, bool After, LiveIntervals &LIS) {
442 std::vector<SlotIndex> Indexes;
443 Indexes.reserve(std::distance(R.begin(), R.end()));
444 auto &SII = *LIS.getSlotIndexes();
445 for (MachineInstr *I : R) {
446 auto SI = SII.getInstructionIndex(*I);
447 Indexes.push_back(After ? SI.getDeadSlot() : SI.getBaseIndex());
448 }
449 llvm::sort(Indexes);
450
451 auto &MRI = (*R.begin())->getParent()->getParent()->getRegInfo();
453 SmallVector<SlotIndex, 32> LiveIdxs, SRLiveIdxs;
454 for (unsigned I = 0, E = MRI.getNumVirtRegs(); I != E; ++I) {
456 if (!LIS.hasInterval(Reg))
457 continue;
458 auto &LI = LIS.getInterval(Reg);
459 LiveIdxs.clear();
460 if (!LI.findIndexesLiveAt(Indexes, std::back_inserter(LiveIdxs)))
461 continue;
462 if (!LI.hasSubRanges()) {
463 for (auto SI : LiveIdxs)
464 LiveRegMap[SII.getInstructionFromIndex(SI)][Reg] =
465 MRI.getMaxLaneMaskForVReg(Reg);
466 } else
467 for (const auto &S : LI.subranges()) {
468 // constrain search for subranges by indexes live at main range
469 SRLiveIdxs.clear();
470 S.findIndexesLiveAt(LiveIdxs, std::back_inserter(SRLiveIdxs));
471 for (auto SI : SRLiveIdxs)
472 LiveRegMap[SII.getInstructionFromIndex(SI)][Reg] |= S.LaneMask;
473 }
474 }
475 return LiveRegMap;
476}
477
479 const LiveIntervals &LIS) {
481 MI.getParent()->getParent()->getRegInfo());
482}
483
485 const LiveIntervals &LIS) {
487 MI.getParent()->getParent()->getRegInfo());
488}
489
490template <typename Range>
492 Range &&LiveRegs) {
493 GCNRegPressure Res;
494 for (const auto &RM : LiveRegs)
495 Res.inc(RM.first, LaneBitmask::getNone(), RM.second, MRI);
496 return Res;
497}
498
500 const GCNRPTracker::LiveRegSet &S2);
501
502Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST = nullptr,
503 unsigned DynamicVGPRBlockSize = 0);
504
505Printable print(const GCNRPTracker::LiveRegSet &LiveRegs,
506 const MachineRegisterInfo &MRI);
507
508Printable reportMismatch(const GCNRPTracker::LiveRegSet &LISLR,
509 const GCNRPTracker::LiveRegSet &TrackedL,
510 const TargetRegisterInfo *TRI, StringRef Pfx = " ");
511
513 static char ID;
514
515public:
517
518 bool runOnMachineFunction(MachineFunction &MF) override;
519
520 void getAnalysisUsage(AnalysisUsage &AU) const override {
522 AU.setPreservesAll();
524 }
525};
526
527} // end namespace llvm
528
529#endif // LLVM_LIB_TARGET_AMDGPU_GCNREGPRESSURE_H
unsigned const MachineRegisterInfo * MRI
constexpr LLT S1
MachineBasicBlock & MBB
static const Function * getParent(const Value *V)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool End
Definition: ELF_riscv.cpp:480
AMD GCN specific subclass of TargetSubtarget.
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition: MD5.cpp:58
Register Reg
Register const TargetRegisterInfo * TRI
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
raw_pwrite_stream & OS
Value * RHS
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
GCNRegPressure moveMaxPressure()
return MaxPressure and clear it.
bool advanceBeforeNext(MachineInstr *MI=nullptr, bool UseInternalIterator=true)
Move to the state right before the next MI or after the end of MBB.
bool advance(MachineInstr *MI=nullptr, bool UseInternalIterator=true)
Move to the state at the next MI.
GCNRegPressure bumpDownwardPressure(const MachineInstr *MI, const SIRegisterInfo *TRI) const
Mostly copy/paste from CodeGen/RegisterPressure.cpp Calculate the impact MI will have on CurPressure ...
MachineBasicBlock::const_iterator getNext() const
GCNDownwardRPTracker(const LiveIntervals &LIS_)
bool reset(const MachineInstr &MI, const LiveRegSet *LiveRegs=nullptr)
Reset tracker to the point before the MI filling LiveRegs upon this point using LIS.
void advanceToNext(MachineInstr *MI=nullptr, bool UseInternalIterator=true)
Move to the state at the MI, advanceBeforeNext has to be called first.
Models a register pressure target, allowing to evaluate and track register savings against that targe...
bool isSaveBeneficial(Register Reg) const
Determines whether saving virtual register Reg will be beneficial towards achieving the RP target.
void saveReg(Register Reg, LaneBitmask Mask, const MachineRegisterInfo &MRI)
Saves virtual register Reg with lanemask Mask.
bool satisfied() const
Whether the current RP is at or below the defined pressure target.
void setRP(const GCNRegPressure &NewRP)
const GCNRegPressure & getCurrentRP() const
void setTarget(unsigned NumSGPRs, unsigned NumVGPRs)
Changes the target (same semantics as constructor).
friend raw_ostream & operator<<(raw_ostream &OS, const GCNRPTarget &Target)
GCNRegPressure getPressure() const
const decltype(LiveRegs) & getLiveRegs() const
const MachineInstr * LastTrackedMI
decltype(LiveRegs) moveLiveRegs()
GCNRegPressure CurPressure
DenseMap< unsigned, LaneBitmask > LiveRegSet
GCNRPTracker(const LiveIntervals &LIS_)
GCNRegPressure MaxPressure
void reset(const MachineInstr &MI, const LiveRegSet *LiveRegsCopy, bool After)
LaneBitmask getLastUsedLanes(Register RegUnit, SlotIndex Pos) const
Mostly copy/paste from CodeGen/RegisterPressure.cpp.
void bumpDeadDefs(ArrayRef< VRegMaskOrUnit > DeadDefs)
Mostly copy/paste from CodeGen/RegisterPressure.cpp.
const MachineInstr * getLastTrackedMI() const
const MachineRegisterInfo * MRI
const LiveIntervals & LIS
GCNUpwardRPTracker(const LiveIntervals &LIS_)
GCNRegPressure getMaxPressureAndReset()
void reset(const MachineRegisterInfo &MRI, SlotIndex SI)
reset tracker at the specified slot index SI.
void recede(const MachineInstr &MI)
Move to the state of RP just before the MI .
const GCNRegPressure & getMaxPressure() const
void reset(const MachineBasicBlock &MBB)
reset tracker to the end of the MBB.
bool isValid() const
returns whether the tracker's state after receding MI corresponds to reported by LIS.
void reset(const MachineInstr &MI)
reset tracker to the point just after MI (in program order).
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:663
bool hasInterval(Register Reg) const
SlotIndexes * getSlotIndexes() const
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
LiveInterval & getInterval(Register Reg)
A set of live virtual registers and physical register units.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Representation of each machine instruction.
Definition: MachineInstr.h:72
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Simple wrapper around std::function<void(raw_ostream&)>.
Definition: Printable.h:38
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
Definition: Register.h:67
SlotIndex - An opaque wrapper around machine indexes.
Definition: SlotIndexes.h:66
SlotIndex getDeadSlot() const
Returns the dead def kill slot for the current instruction.
Definition: SlotIndexes.h:243
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
Definition: SlotIndexes.h:225
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
Definition: SlotIndexes.h:471
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
Target - Wrapper for Target specific information.
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
unsigned getArchVGPRAllocGranule()
For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage, returns the allocation granule...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
LaneBitmask getLiveLaneMask(unsigned Reg, SlotIndex SI, const LiveIntervals &LIS, const MachineRegisterInfo &MRI, LaneBitmask LaneMaskFilter=LaneBitmask::getAll())
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
GCNRegPressure getRegPressure(const MachineRegisterInfo &MRI, Range &&LiveRegs)
GCNRPTracker::LiveRegSet getLiveRegs(SlotIndex SI, const LiveIntervals &LIS, const MachineRegisterInfo &MRI)
GCNRPTracker::LiveRegSet getLiveRegsAfter(const MachineInstr &MI, const LiveIntervals &LIS)
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1669
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:155
APInt operator-(APInt)
Definition: APInt.h:2188
DenseMap< MachineInstr *, GCNRPTracker::LiveRegSet > getLiveRegMap(Range &&R, bool After, LiveIntervals &LIS)
creates a map MachineInstr -> LiveRegSet R - range of iterators on instructions After - upon entry or...
APInt operator+(APInt a, const APInt &b)
Definition: APInt.h:2193
GCNRPTracker::LiveRegSet getLiveRegsBefore(const MachineInstr &MI, const LiveIntervals &LIS)
Printable reportMismatch(const GCNRPTracker::LiveRegSet &LISLR, const GCNRPTracker::LiveRegSet &TrackedL, const TargetRegisterInfo *TRI, StringRef Pfx=" ")
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
bool operator!=(const GCNRegPressure &O) const
friend Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST, unsigned DynamicVGPRBlockSize)
GCNRegPressure & operator+=(const GCNRegPressure &RHS)
unsigned getVGPRTuplesWeight() const
GCNRegPressure & operator-=(const GCNRegPressure &RHS)
unsigned getVGPRNum(bool UnifiedVGPRFile) const
unsigned getOccupancy(const GCNSubtarget &ST, unsigned DynamicVGPRBlockSize) const
friend GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
void inc(unsigned Reg, LaneBitmask PrevMask, LaneBitmask NewMask, const MachineRegisterInfo &MRI)
bool higherOccupancy(const GCNSubtarget &ST, const GCNRegPressure &O, unsigned DynamicVGPRBlockSize) const
unsigned getArchVGPRNum() const
unsigned getAGPRNum() const
unsigned getSGPRNum() const
unsigned getSGPRTuplesWeight() const
bool operator==(const GCNRegPressure &O) const
static unsigned getUnifiedVGPRNum(unsigned NumArchVGPRs, unsigned NumAGPRs, unsigned NumAVGPRs)
Returns the aggregated VGPR pressure, assuming NumArchVGPRs ArchVGPRs NumAGPRs AGPRS,...
unsigned getAVGPRNum() const
bool less(const MachineFunction &MF, const GCNRegPressure &O, unsigned MaxOccupancy=std::numeric_limits< unsigned >::max()) const
Compares this GCNRegpressure to O, returning true if this is less.
static constexpr LaneBitmask getAll()
Definition: LaneBitmask.h:82
static constexpr LaneBitmask getNone()
Definition: LaneBitmask.h:81