80 unsigned NextCascade = 1;
94 Info[
Reg].Stage = Stage;
112 Info[
Reg].Cascade = Cascade;
118 Cascade = NextCascade++;
127 Cascade = NextCascade;
131 template <
typename Iterator>
133 for (; Begin != End; ++Begin) {
137 Info[
Reg].Stage = NewStage;
153 return RegClassPriorityTrumpsGlobalness;
160 using PQueue = std::priority_queue<std::pair<unsigned, unsigned>>;
165 using RecoloringStack =
189 std::unique_ptr<Spiller> SpillerInstance;
191 std::unique_ptr<VirtRegAuxInfo> VRAI;
192 std::optional<ExtraRegInfo> ExtraInfo;
193 std::unique_ptr<RegAllocEvictionAdvisor> EvictAdvisor;
195 std::unique_ptr<RegAllocPriorityAdvisor> PriorityAdvisor;
211 uint8_t CutOffInfo = CutOffStage::CO_None;
214 static const char *
const StageName[];
218 std::unique_ptr<SplitAnalysis> SA;
219 std::unique_ptr<SplitEditor> SE;
222 InterferenceCache IntfCache;
225 SmallVector<SpillPlacement::BlockConstraint, 8> SplitConstraints;
228 struct GlobalSplitCandidate {
236 InterferenceCache::Cursor Intf;
239 BitVector LiveBundles;
240 SmallVector<unsigned, 8> ActiveBlocks;
242 void reset(InterferenceCache &Cache, MCRegister
Reg) {
245 Intf.setPhysReg(Cache,
Reg);
247 ActiveBlocks.clear();
251 unsigned getBundles(SmallVectorImpl<unsigned> &
B,
unsigned C) {
253 for (
unsigned I : LiveBundles.set_bits())
254 if (
B[
I] == NoCand) {
265 SmallVector<GlobalSplitCandidate, 32> GlobalCand;
267 enum :
unsigned {
NoCand = ~0
u };
271 SmallVector<unsigned, 32> BundleCand;
274 BlockFrequency CSRCost;
277 SmallSetVector<const LiveInterval *, 8> SetOfBrokenHints;
281 ArrayRef<uint8_t> RegCosts;
285 bool RegClassPriorityTrumpsGlobalness =
false;
287 bool ReverseLocalAssignment =
false;
290 RAGreedy(RequiredAnalyses &Analyses,
const RegAllocFilterFunc
F =
nullptr);
297 void aboutToRemoveInterval(
const LiveInterval &)
override;
302 void releaseMemory();
307 RecoloringStack &,
unsigned = 0);
309 bool LRE_CanEraseVirtReg(
Register)
override;
310 void LRE_WillShrinkVirtReg(
Register)
override;
315 bool hasVirtRegAlloc();
319 bool growRegion(GlobalSplitCandidate &Cand);
322 bool calcCompactRegion(GlobalSplitCandidate &);
327 bool mayRecolorAllInterferences(
MCRegister PhysReg,
329 SmallLISet &RecoloringCandidates,
340 unsigned calculateRegionSplitCostAroundReg(
MCPhysReg PhysReg,
346 unsigned calculateRegionSplitCost(
const LiveInterval &VirtReg,
349 unsigned &NumCands,
bool IgnoreCSR);
364 void initializeCSRCost();
380 void tryHintsRecoloring();
393 : Freq(Freq),
Reg(
Reg), PhysReg(PhysReg) {}
395 using HintsInfo = SmallVector<HintInfo, 4>;
397 BlockFrequency getBrokenHintFreq(
const HintsInfo &, MCRegister);
398 void collectHintInfo(
Register, HintsInfo &);
401 struct RAGreedyStats {
402 unsigned Reloads = 0;
403 unsigned FoldedReloads = 0;
404 unsigned ZeroCostFoldedReloads = 0;
406 unsigned FoldedSpills = 0;
408 float ReloadsCost = 0.0f;
409 float FoldedReloadsCost = 0.0f;
410 float SpillsCost = 0.0f;
411 float FoldedSpillsCost = 0.0f;
412 float CopiesCost = 0.0f;
415 return !(Reloads || FoldedReloads || Spills || FoldedSpills ||
416 ZeroCostFoldedReloads ||
Copies);
419 void add(
const RAGreedyStats &other) {
420 Reloads += other.Reloads;
421 FoldedReloads += other.FoldedReloads;
422 ZeroCostFoldedReloads += other.ZeroCostFoldedReloads;
423 Spills += other.Spills;
424 FoldedSpills += other.FoldedSpills;
426 ReloadsCost += other.ReloadsCost;
427 FoldedReloadsCost += other.FoldedReloadsCost;
428 SpillsCost += other.SpillsCost;
429 FoldedSpillsCost += other.FoldedSpillsCost;
430 CopiesCost += other.CopiesCost;
433 void report(MachineOptimizationRemarkMissed &R);
437 RAGreedyStats computeStats(MachineBasicBlock &
MBB);
440 RAGreedyStats reportStats(MachineLoop *L);