79 unsigned NextCascade = 1;
93 Info[
Reg].Stage = Stage;
111 Info[
Reg].Cascade = Cascade;
117 Cascade = NextCascade++;
126 Cascade = NextCascade;
130 template <
typename Iterator>
132 for (; Begin != End; ++Begin) {
136 Info[
Reg].Stage = NewStage;
152 return RegClassPriorityTrumpsGlobalness;
159 using PQueue = std::priority_queue<std::pair<unsigned, unsigned>>;
164 using RecoloringStack =
188 std::unique_ptr<Spiller> SpillerInstance;
190 std::unique_ptr<VirtRegAuxInfo> VRAI;
191 std::optional<ExtraRegInfo> ExtraInfo;
192 std::unique_ptr<RegAllocEvictionAdvisor> EvictAdvisor;
194 std::unique_ptr<RegAllocPriorityAdvisor> PriorityAdvisor;
210 uint8_t CutOffInfo = CutOffStage::CO_None;
213 static const char *
const StageName[];
217 std::unique_ptr<SplitAnalysis> SA;
218 std::unique_ptr<SplitEditor> SE;
221 InterferenceCache IntfCache;
224 SmallVector<SpillPlacement::BlockConstraint, 8> SplitConstraints;
227 struct GlobalSplitCandidate {
235 InterferenceCache::Cursor Intf;
238 BitVector LiveBundles;
239 SmallVector<unsigned, 8> ActiveBlocks;
241 void reset(InterferenceCache &Cache, MCRegister
Reg) {
244 Intf.setPhysReg(Cache,
Reg);
246 ActiveBlocks.clear();
250 unsigned getBundles(SmallVectorImpl<unsigned> &
B,
unsigned C) {
252 for (
unsigned I : LiveBundles.set_bits())
253 if (
B[
I] == NoCand) {
264 SmallVector<GlobalSplitCandidate, 32> GlobalCand;
266 enum :
unsigned {
NoCand = ~0
u };
270 SmallVector<unsigned, 32> BundleCand;
273 BlockFrequency CSRCost;
276 SmallSetVector<const LiveInterval *, 8> SetOfBrokenHints;
280 ArrayRef<uint8_t> RegCosts;
284 bool RegClassPriorityTrumpsGlobalness =
false;
286 bool ReverseLocalAssignment =
false;
289 RAGreedy(RequiredAnalyses &Analyses,
const RegAllocFilterFunc
F =
nullptr);
296 void aboutToRemoveInterval(
const LiveInterval &)
override;
301 void releaseMemory();
306 RecoloringStack &,
unsigned = 0);
308 bool LRE_CanEraseVirtReg(
Register)
override;
309 void LRE_WillShrinkVirtReg(
Register)
override;
314 bool hasVirtRegAlloc();
318 bool growRegion(GlobalSplitCandidate &Cand);
321 bool calcCompactRegion(GlobalSplitCandidate &);
326 bool mayRecolorAllInterferences(
MCRegister PhysReg,
328 SmallLISet &RecoloringCandidates,
339 unsigned calculateRegionSplitCostAroundReg(
MCPhysReg PhysReg,
345 unsigned calculateRegionSplitCost(
const LiveInterval &VirtReg,
348 unsigned &NumCands,
bool IgnoreCSR);
363 void initializeCSRCost();
379 void tryHintsRecoloring();
392 : Freq(Freq),
Reg(
Reg), PhysReg(PhysReg) {}
394 using HintsInfo = SmallVector<HintInfo, 4>;
396 BlockFrequency getBrokenHintFreq(
const HintsInfo &, MCRegister);
397 void collectHintInfo(
Register, HintsInfo &);
400 struct RAGreedyStats {
401 unsigned Reloads = 0;
402 unsigned FoldedReloads = 0;
403 unsigned ZeroCostFoldedReloads = 0;
405 unsigned FoldedSpills = 0;
407 float ReloadsCost = 0.0f;
408 float FoldedReloadsCost = 0.0f;
409 float SpillsCost = 0.0f;
410 float FoldedSpillsCost = 0.0f;
411 float CopiesCost = 0.0f;
414 return !(Reloads || FoldedReloads || Spills || FoldedSpills ||
415 ZeroCostFoldedReloads ||
Copies);
418 void add(
const RAGreedyStats &other) {
419 Reloads += other.Reloads;
420 FoldedReloads += other.FoldedReloads;
421 ZeroCostFoldedReloads += other.ZeroCostFoldedReloads;
422 Spills += other.Spills;
423 FoldedSpills += other.FoldedSpills;
425 ReloadsCost += other.ReloadsCost;
426 FoldedReloadsCost += other.FoldedReloadsCost;
427 SpillsCost += other.SpillsCost;
428 FoldedSpillsCost += other.FoldedSpillsCost;
429 CopiesCost += other.CopiesCost;
432 void report(MachineOptimizationRemarkMissed &R);
436 RAGreedyStats computeStats(MachineBasicBlock &
MBB);
439 RAGreedyStats reportStats(MachineLoop *L);