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#include <array>
25
26namespace llvm {
27
29class raw_ostream;
30class SlotIndex;
31
34
35 static constexpr const char *getName(RegKind Kind) {
36 const char *Names[] = {"SGPR", "VGPR", "AGPR", "AVGPR"};
37 assert(Kind < TOTAL_KINDS);
38 return Names[Kind];
39 }
40
42 clear();
43 }
44
45 bool empty() const {
46 return !Value[SGPR] && !Value[VGPR] && !Value[AGPR] && !Value[AVGPR];
47 }
48
49 void clear() { Value.fill(0); }
50
51 unsigned getNumRegs(RegKind Kind) const {
52 assert(Kind < TOTAL_KINDS);
53 return Value[Kind];
54 }
55
56 /// \returns the SGPR32 pressure
57 unsigned getSGPRNum() const { return Value[SGPR]; }
58 /// \returns the aggregated ArchVGPR32, AccVGPR32, and Pseudo AVGPR pressure
59 /// dependent upon \p UnifiedVGPRFile
60 unsigned getVGPRNum(bool UnifiedVGPRFile) const {
61 if (UnifiedVGPRFile) {
62 return Value[AGPR]
63 ? getUnifiedVGPRNum(Value[VGPR], Value[AGPR], Value[AVGPR])
64 : Value[VGPR] + Value[AVGPR];
65 }
66 // AVGPR assignment priority is based on the width of the register. Account
67 // AVGPR pressure as VGPR.
68 return std::max(Value[VGPR] + Value[AVGPR], Value[AGPR]);
69 }
70
71 /// Returns the aggregated VGPR pressure, assuming \p NumArchVGPRs ArchVGPRs
72 /// \p NumAGPRs AGPRS, and \p NumAVGPRs AVGPRs for a target with a unified
73 /// VGPR file.
74 inline static unsigned getUnifiedVGPRNum(unsigned NumArchVGPRs,
75 unsigned NumAGPRs,
76 unsigned NumAVGPRs) {
77
78 // Assume AVGPRs will be assigned as VGPRs.
79 return alignTo(NumArchVGPRs + NumAVGPRs,
81 NumAGPRs;
82 }
83
84 /// \returns the ArchVGPR32 pressure, plus the AVGPRS which we assume will be
85 /// allocated as VGPR
86 unsigned getArchVGPRNum() const { return Value[VGPR] + Value[AVGPR]; }
87 /// \returns the AccVGPR32 pressure
88 unsigned getAGPRNum() const { return Value[AGPR]; }
89 /// \returns the AVGPR32 pressure
90 unsigned getAVGPRNum() const { return Value[AVGPR]; }
91
92 unsigned getVGPRTuplesWeight() const {
93 return std::max(Value[TOTAL_KINDS + VGPR] + Value[TOTAL_KINDS + AVGPR],
94 Value[TOTAL_KINDS + AGPR]);
95 }
96 unsigned getSGPRTuplesWeight() const { return Value[TOTAL_KINDS + SGPR]; }
97
98 unsigned getOccupancy(const GCNSubtarget &ST,
99 unsigned DynamicVGPRBlockSize) const {
100 return std::min(ST.getOccupancyWithNumSGPRs(getSGPRNum()),
101 ST.getOccupancyWithNumVGPRs(getVGPRNum(ST.hasGFX90AInsts()),
102 DynamicVGPRBlockSize));
103 }
104
105 void inc(unsigned Reg,
106 LaneBitmask PrevMask,
107 LaneBitmask NewMask,
108 const MachineRegisterInfo &MRI);
109
111 unsigned DynamicVGPRBlockSize) const {
112 return getOccupancy(ST, DynamicVGPRBlockSize) >
113 O.getOccupancy(ST, DynamicVGPRBlockSize);
114 }
115
116 /// Compares \p this GCNRegpressure to \p O, returning true if \p this is
117 /// less. Since GCNRegpressure contains different types of pressures, and due
118 /// to target-specific pecularities (e.g. we care about occupancy rather than
119 /// raw register usage), we determine if \p this GCNRegPressure is less than
120 /// \p O based on the following tiered comparisons (in order order of
121 /// precedence):
122 /// 1. Better occupancy
123 /// 2. Less spilling (first preference to VGPR spills, then to SGPR spills)
124 /// 3. Less tuple register pressure (first preference to VGPR tuples if we
125 /// determine that SGPR pressure is not important)
126 /// 4. Less raw register pressure (first preference to VGPR tuples if we
127 /// determine that SGPR pressure is not important)
128 bool less(const MachineFunction &MF, const GCNRegPressure &O,
129 unsigned MaxOccupancy = std::numeric_limits<unsigned>::max()) const;
130
131 bool operator==(const GCNRegPressure &O) const { return Value == O.Value; }
132
133 bool operator!=(const GCNRegPressure &O) const {
134 return !(*this == O);
135 }
136
138 for (unsigned I = 0; I < ValueArraySize; ++I)
139 Value[I] += RHS.Value[I];
140 return *this;
141 }
142
144 for (unsigned I = 0; I < ValueArraySize; ++I)
145 Value[I] -= RHS.Value[I];
146 return *this;
147 }
148
149 void dump() const;
150
151 static RegKind getRegKind(unsigned Reg, const MachineRegisterInfo &MRI) {
152 const TargetRegisterInfo *TRI = MRI.getTargetRegisterInfo();
153 const SIRegisterInfo *STI = static_cast<const SIRegisterInfo *>(TRI);
154 return (RegKind)getRegKind(MRI.getRegClass(Reg), STI);
155 }
156
157private:
158 static constexpr unsigned ValueArraySize = TOTAL_KINDS * 2;
159
160 /// Pressure for all register kinds (first all regular registers kinds, then
161 /// all tuple register kinds).
162 std::array<unsigned, ValueArraySize> Value;
163
164 static unsigned getRegKind(const TargetRegisterClass *RC,
165 const SIRegisterInfo *STI);
166
167 friend GCNRegPressure max(const GCNRegPressure &P1,
168 const GCNRegPressure &P2);
169
170 friend Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST,
171 unsigned DynamicVGPRBlockSize);
172};
173
174inline GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2) {
175 GCNRegPressure Res;
176 for (unsigned I = 0; I < GCNRegPressure::ValueArraySize; ++I)
177 Res.Value[I] = std::max(P1.Value[I], P2.Value[I]);
178 return Res;
179}
180
182 const GCNRegPressure &P2) {
183 GCNRegPressure Sum = P1;
184 Sum += P2;
185 return Sum;
186}
187
189 const GCNRegPressure &P2) {
190 GCNRegPressure Diff = P1;
191 Diff -= P2;
192 return Diff;
193}
194
195////////////////////////////////////////////////////////////////////////////////
196// GCNRPTarget
197
198/// Models a register pressure target, allowing to evaluate and track register
199/// savings against that target from a starting \ref GCNRegPressure.
201public:
202 /// Sets up the target such that the register pressure starting at \p RP does
203 /// not show register spilling on function \p MF (w.r.t. the function's
204 /// mininum target occupancy).
205 GCNRPTarget(const MachineFunction &MF, const GCNRegPressure &RP);
206
207 /// Sets up the target such that the register pressure starting at \p RP does
208 /// not use more than \p NumSGPRs SGPRs and \p NumVGPRs VGPRs on function \p
209 /// MF.
210 GCNRPTarget(unsigned NumSGPRs, unsigned NumVGPRs, const MachineFunction &MF,
211 const GCNRegPressure &RP);
212
213 /// Sets up the target such that the register pressure starting at \p RP does
214 /// not prevent achieving an occupancy of at least \p Occupancy on function
215 /// \p MF.
216 GCNRPTarget(unsigned Occupancy, const MachineFunction &MF,
217 const GCNRegPressure &RP);
218
219 /// Changes the target (same semantics as constructor).
220 void setTarget(unsigned NumSGPRs, unsigned NumVGPRs);
221
222 const GCNRegPressure &getCurrentRP() const { return RP; }
223
224 void setRP(const GCNRegPressure &NewRP) { RP = NewRP; }
225
226 /// Determines whether saving virtual register \p Reg will be beneficial
227 /// towards achieving the RP target.
228 bool isSaveBeneficial(Register Reg) const;
229
230 /// Saves virtual register \p Reg with lanemask \p Mask.
232 RP.inc(Reg, Mask, LaneBitmask::getNone(), MRI);
233 }
234
235 /// Whether the current RP is at or below the defined pressure target.
236 bool satisfied() const;
237
238#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
240 OS << "Actual/Target: " << Target.RP.getSGPRNum() << '/' << Target.MaxSGPRs
241 << " SGPRs, " << Target.RP.getArchVGPRNum() << '/' << Target.MaxVGPRs
242 << " ArchVGPRs, " << Target.RP.getAGPRNum() << '/' << Target.MaxVGPRs
243 << " AGPRs";
244
245 if (Target.MaxUnifiedVGPRs) {
246 OS << ", " << Target.RP.getVGPRNum(true) << '/' << Target.MaxUnifiedVGPRs
247 << " VGPRs (unified)";
248 }
249 return OS;
250 }
251#endif
252
253private:
254 const MachineFunction &MF;
255 const bool UnifiedRF;
256
257 /// Current register pressure.
259
260 /// Target number of SGPRs.
261 unsigned MaxSGPRs;
262 /// Target number of ArchVGPRs and AGPRs.
263 unsigned MaxVGPRs;
264 /// Target number of overall VGPRs for subtargets with unified RFs. Always 0
265 /// for subtargets with non-unified RFs.
266 unsigned MaxUnifiedVGPRs;
267
268 GCNRPTarget(const GCNRegPressure &RP, const MachineFunction &MF)
269 : MF(MF), UnifiedRF(MF.getSubtarget<GCNSubtarget>().hasGFX90AInsts()),
270 RP(RP) {}
271};
272
273///////////////////////////////////////////////////////////////////////////////
274// GCNRPTracker
275
277public:
279
280protected:
284 const MachineInstr *LastTrackedMI = nullptr;
285 mutable const MachineRegisterInfo *MRI = nullptr;
286
287 GCNRPTracker(const LiveIntervals &LIS_) : LIS(LIS_) {}
288
289 void reset(const MachineInstr &MI, const LiveRegSet *LiveRegsCopy,
290 bool After);
291
292 /// Mostly copy/paste from CodeGen/RegisterPressure.cpp
294
296
297public:
298 // reset tracker and set live register set to the specified value.
299 void reset(const MachineRegisterInfo &MRI_, const LiveRegSet &LiveRegs_);
300 // live regs for the current state
301 const decltype(LiveRegs) &getLiveRegs() const { return LiveRegs; }
302 const MachineInstr *getLastTrackedMI() const { return LastTrackedMI; }
303
304 void clearMaxPressure() { MaxPressure.clear(); }
305
307
308 decltype(LiveRegs) moveLiveRegs() {
309 return std::move(LiveRegs);
310 }
311};
312
314getLiveRegs(SlotIndex SI, const LiveIntervals &LIS,
315 const MachineRegisterInfo &MRI,
317
318////////////////////////////////////////////////////////////////////////////////
319// GCNUpwardRPTracker
320
322public:
324
326
327 /// reset tracker at the specified slot index \p SI.
331
332 /// reset tracker to the end of the \p MBB.
334 SlotIndex MBBLastSlot = LIS.getSlotIndexes()->getMBBLastIdx(&MBB);
335 reset(MBB.getParent()->getRegInfo(), MBBLastSlot);
336 }
337
338 /// reset tracker to the point just after \p MI (in program order).
339 void reset(const MachineInstr &MI) {
340 reset(MI.getMF()->getRegInfo(), LIS.getInstructionIndex(MI).getDeadSlot());
341 }
342
343 /// Move to the state of RP just before the \p MI . If \p UseInternalIterator
344 /// is set, also update the internal iterators. Setting \p UseInternalIterator
345 /// to false allows for an externally managed iterator / program order.
346 void recede(const MachineInstr &MI);
347
348 /// \p returns whether the tracker's state after receding MI corresponds
349 /// to reported by LIS.
350 bool isValid() const;
351
352 const GCNRegPressure &getMaxPressure() const { return MaxPressure; }
353
355
361};
362
363////////////////////////////////////////////////////////////////////////////////
364// GCNDownwardRPTracker
365
367 // Last position of reset or advanceBeforeNext
369
371
372public:
374
376
378
379 /// \p return MaxPressure and clear it.
381 auto Res = MaxPressure;
382 MaxPressure.clear();
383 return Res;
384 }
385
386 /// Reset tracker to the point before the \p MI
387 /// filling \p LiveRegs upon this point using LIS.
388 /// \p returns false if block is empty except debug values.
389 bool reset(const MachineInstr &MI, const LiveRegSet *LiveRegs = nullptr);
390
391 /// Move to the state right before the next MI or after the end of MBB.
392 /// \p returns false if reached end of the block.
393 /// If \p UseInternalIterator is true, then internal iterators are used and
394 /// set to process in program order. If \p UseInternalIterator is false, then
395 /// it is assumed that the tracker is using an externally managed iterator,
396 /// and advance* calls will not update the state of the iterator. In such
397 /// cases, the tracker will move to the state right before the provided \p MI
398 /// and use LIS for RP calculations.
399 bool advanceBeforeNext(MachineInstr *MI = nullptr,
400 bool UseInternalIterator = true);
401
402 /// Move to the state at the MI, advanceBeforeNext has to be called first.
403 /// If \p UseInternalIterator is true, then internal iterators are used and
404 /// set to process in program order. If \p UseInternalIterator is false, then
405 /// it is assumed that the tracker is using an externally managed iterator,
406 /// and advance* calls will not update the state of the iterator. In such
407 /// cases, the tracker will move to the state at the provided \p MI .
408 void advanceToNext(MachineInstr *MI = nullptr,
409 bool UseInternalIterator = true);
410
411 /// Move to the state at the next MI. \p returns false if reached end of
412 /// block. If \p UseInternalIterator is true, then internal iterators are used
413 /// and set to process in program order. If \p UseInternalIterator is false,
414 /// then it is assumed that the tracker is using an externally managed
415 /// iterator, and advance* calls will not update the state of the iterator. In
416 /// such cases, the tracker will move to the state right before the provided
417 /// \p MI and use LIS for RP calculations.
418 bool advance(MachineInstr *MI = nullptr, bool UseInternalIterator = true);
419
420 /// Advance instructions until before \p End.
422
423 /// Reset to \p Begin and advance to \p End.
426 const LiveRegSet *LiveRegsCopy = nullptr);
427
428 /// Mostly copy/paste from CodeGen/RegisterPressure.cpp
429 /// Calculate the impact \p MI will have on CurPressure and \return the
430 /// speculated pressure. In order to support RP Speculation, this does not
431 /// rely on the implicit program ordering in the LiveIntervals.
433 const SIRegisterInfo *TRI) const;
434};
435
436/// \returns the LaneMask of live lanes of \p Reg at position \p SI. Only the
437/// active lanes of \p LaneMaskFilter will be set in the return value. This is
438/// used, for example, to limit the live lanes to a specific subreg when
439/// calculating use masks.
440LaneBitmask getLiveLaneMask(unsigned Reg, SlotIndex SI,
441 const LiveIntervals &LIS,
442 const MachineRegisterInfo &MRI,
443 LaneBitmask LaneMaskFilter = LaneBitmask::getAll());
444
445LaneBitmask getLiveLaneMask(const LiveInterval &LI, SlotIndex SI,
446 const MachineRegisterInfo &MRI,
447 LaneBitmask LaneMaskFilter = LaneBitmask::getAll());
448
449/// creates a map MachineInstr -> LiveRegSet
450/// R - range of iterators on instructions
451/// After - upon entry or exit of every instruction
452/// Note: there is no entry in the map for instructions with empty live reg set
453/// Complexity = O(NumVirtRegs * averageLiveRangeSegmentsPerReg * lg(R))
454template <typename Range>
455DenseMap<MachineInstr*, GCNRPTracker::LiveRegSet>
456getLiveRegMap(Range &&R, bool After, LiveIntervals &LIS) {
457 std::vector<SlotIndex> Indexes;
458 Indexes.reserve(std::distance(R.begin(), R.end()));
459 auto &SII = *LIS.getSlotIndexes();
460 for (MachineInstr *I : R) {
461 auto SI = SII.getInstructionIndex(*I);
462 Indexes.push_back(After ? SI.getDeadSlot() : SI.getBaseIndex());
463 }
464 llvm::sort(Indexes);
465
466 auto &MRI = (*R.begin())->getParent()->getParent()->getRegInfo();
468 SmallVector<SlotIndex, 32> LiveIdxs, SRLiveIdxs;
469 for (unsigned I = 0, E = MRI.getNumVirtRegs(); I != E; ++I) {
471 if (!LIS.hasInterval(Reg))
472 continue;
473 auto &LI = LIS.getInterval(Reg);
474 LiveIdxs.clear();
475 if (!LI.findIndexesLiveAt(Indexes, std::back_inserter(LiveIdxs)))
476 continue;
477 if (!LI.hasSubRanges()) {
478 for (auto SI : LiveIdxs)
479 LiveRegMap[SII.getInstructionFromIndex(SI)][Reg] =
480 MRI.getMaxLaneMaskForVReg(Reg);
481 } else
482 for (const auto &S : LI.subranges()) {
483 // constrain search for subranges by indexes live at main range
484 SRLiveIdxs.clear();
485 S.findIndexesLiveAt(LiveIdxs, std::back_inserter(SRLiveIdxs));
486 for (auto SI : SRLiveIdxs)
487 LiveRegMap[SII.getInstructionFromIndex(SI)][Reg] |= S.LaneMask;
488 }
489 }
490 return LiveRegMap;
491}
492
494 const LiveIntervals &LIS) {
496 MI.getParent()->getParent()->getRegInfo());
497}
498
500 const LiveIntervals &LIS) {
502 MI.getParent()->getParent()->getRegInfo());
503}
504
505template <typename Range>
507 Range &&LiveRegs) {
508 GCNRegPressure Res;
509 for (const auto &RM : LiveRegs)
510 Res.inc(RM.first, LaneBitmask::getNone(), RM.second, MRI);
511 return Res;
512}
513
515 const GCNRPTracker::LiveRegSet &S2);
516
517Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST = nullptr,
518 unsigned DynamicVGPRBlockSize = 0);
519
521 const MachineRegisterInfo &MRI);
522
523Printable reportMismatch(const GCNRPTracker::LiveRegSet &LISLR,
524 const GCNRPTracker::LiveRegSet &TrackedL,
525 const TargetRegisterInfo *TRI, StringRef Pfx = " ");
526
528 static char ID;
529
530public:
532
533 bool runOnMachineFunction(MachineFunction &MF) override;
534
540};
541
542LLVM_ABI void dumpMaxRegPressure(MachineFunction &MF,
544 LiveIntervals &LIS,
545 const MachineLoopInfo *MLI);
546
547} // end namespace llvm
548
549#endif // LLVM_LIB_TARGET_AMDGPU_GCNREGPRESSURE_H
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
constexpr LLT S1
MachineBasicBlock & MBB
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h:213
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))
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
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.
GCNRPTarget(const MachineFunction &MF, const GCNRegPressure &RP)
Sets up the target such that the register pressure starting at RP does not show register spilling on ...
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).
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.
MachineInstrBundleIterator< const MachineInstr > const_iterator
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Representation of each machine instruction.
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.
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
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...
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.
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)
GCNRPTracker::LiveRegSet getLiveRegs(SlotIndex SI, const LiveIntervals &LIS, const MachineRegisterInfo &MRI, GCNRegPressure::RegKind RegKind=GCNRegPressure::TOTAL_KINDS)
GCNRegPressure getRegPressure(const MachineRegisterInfo &MRI, Range &&LiveRegs)
GCNRPTracker::LiveRegSet getLiveRegsAfter(const MachineInstr &MI, const LiveIntervals &LIS)
void sort(IteratorTy Start, IteratorTy End)
Definition STLExtras.h:1622
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition Alignment.h:144
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)
LLVM_ABI void dumpMaxRegPressure(MachineFunction &MF, GCNRegPressure::RegKind Kind, LiveIntervals &LIS, const MachineLoopInfo *MLI)
Printable reportMismatch(const GCNRPTracker::LiveRegSet &LISLR, const GCNRPTracker::LiveRegSet &TrackedL, const TargetRegisterInfo *TRI, StringRef Pfx=" ")
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
static RegKind getRegKind(unsigned Reg, const MachineRegisterInfo &MRI)
static constexpr const char * getName(RegKind Kind)
bool operator!=(const GCNRegPressure &O) const
GCNRegPressure & operator+=(const GCNRegPressure &RHS)
unsigned getNumRegs(RegKind Kind) const
unsigned getVGPRTuplesWeight() const
GCNRegPressure & operator-=(const GCNRegPressure &RHS)
unsigned getVGPRNum(bool UnifiedVGPRFile) const
friend Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST, unsigned DynamicVGPRBlockSize)
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