Skip to content

Commit 98f9b54

Browse files
authored
[CodeGen] Hide SparseSet<LiveRegUnit> behind a typedef (NFC) (llvm#167898)
So that changing the type of the container (planned in a future patch) is less intrusive.
1 parent e0aec1f commit 98f9b54

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

llvm/include/llvm/CodeGen/MachineTraceMetrics.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ struct LiveRegUnit {
8383
LiveRegUnit(unsigned RU) : RegUnit(RU) {}
8484
};
8585

86+
using LiveRegUnitSet = SparseSet<LiveRegUnit>;
87+
8688
/// Strategies for selecting traces.
8789
enum class MachineTraceStrategy {
8890
/// Select the trace through a block that has the fewest instructions.
@@ -380,16 +382,15 @@ class MachineTraceMetrics {
380382
Trace getTrace(const MachineBasicBlock *MBB);
381383

382384
/// Updates the depth of an machine instruction, given RegUnits.
383-
void updateDepth(TraceBlockInfo &TBI, const MachineInstr&,
384-
SparseSet<LiveRegUnit> &RegUnits);
385-
void updateDepth(const MachineBasicBlock *, const MachineInstr&,
386-
SparseSet<LiveRegUnit> &RegUnits);
385+
void updateDepth(TraceBlockInfo &TBI, const MachineInstr &,
386+
LiveRegUnitSet &RegUnits);
387+
void updateDepth(const MachineBasicBlock *, const MachineInstr &,
388+
LiveRegUnitSet &RegUnits);
387389

388390
/// Updates the depth of the instructions from Start to End.
389391
void updateDepths(MachineBasicBlock::iterator Start,
390392
MachineBasicBlock::iterator End,
391-
SparseSet<LiveRegUnit> &RegUnits);
392-
393+
LiveRegUnitSet &RegUnits);
393394
};
394395

395396
/// Get the trace ensemble representing the given trace selection strategy.

llvm/lib/CodeGen/MachineCombiner.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,8 @@ insertDeleteInstructions(MachineBasicBlock *MBB, MachineInstr &MI,
482482
SmallVectorImpl<MachineInstr *> &InsInstrs,
483483
SmallVectorImpl<MachineInstr *> &DelInstrs,
484484
MachineTraceMetrics::Ensemble *TraceEnsemble,
485-
SparseSet<LiveRegUnit> &RegUnits,
486-
const TargetInstrInfo *TII, unsigned Pattern,
487-
bool IncrementalUpdate) {
485+
LiveRegUnitSet &RegUnits, const TargetInstrInfo *TII,
486+
unsigned Pattern, bool IncrementalUpdate) {
488487
// If we want to fix up some placeholder for some target, do it now.
489488
// We need this because in genAlternativeCodeSequence, we have not decided the
490489
// better pattern InsInstrs or DelInstrs, so we don't want generate some
@@ -565,7 +564,7 @@ bool MachineCombiner::combineInstructions(MachineBasicBlock *MBB) {
565564
if (!TraceEnsemble)
566565
TraceEnsemble = Traces->getEnsemble(TII->getMachineCombinerTraceStrategy());
567566

568-
SparseSet<LiveRegUnit> RegUnits;
567+
LiveRegUnitSet RegUnits;
569568
RegUnits.setUniverse(TRI->getNumRegUnits());
570569

571570
bool OptForSize = llvm::shouldOptimizeForSize(MBB, PSI, MBFI);

llvm/lib/CodeGen/MachineTraceMetrics.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ static void getPHIDeps(const MachineInstr &UseMI,
737737
// tracking set when scanning instructions downwards.
738738
static void updatePhysDepsDownwards(const MachineInstr *UseMI,
739739
SmallVectorImpl<DataDep> &Deps,
740-
SparseSet<LiveRegUnit> &RegUnits,
740+
LiveRegUnitSet &RegUnits,
741741
const TargetRegisterInfo *TRI) {
742742
SmallVector<MCRegister, 8> Kills;
743743
SmallVector<unsigned, 8> LiveDefOps;
@@ -758,7 +758,7 @@ static void updatePhysDepsDownwards(const MachineInstr *UseMI,
758758
if (!MO.readsReg())
759759
continue;
760760
for (MCRegUnit Unit : TRI->regunits(Reg)) {
761-
SparseSet<LiveRegUnit>::iterator I = RegUnits.find(Unit);
761+
LiveRegUnitSet::iterator I = RegUnits.find(Unit);
762762
if (I == RegUnits.end())
763763
continue;
764764
Deps.push_back(DataDep(I->MI, I->Op, MO.getOperandNo()));
@@ -813,9 +813,9 @@ computeCrossBlockCriticalPath(const TraceBlockInfo &TBI) {
813813
return MaxLen;
814814
}
815815

816-
void MachineTraceMetrics::Ensemble::
817-
updateDepth(MachineTraceMetrics::TraceBlockInfo &TBI, const MachineInstr &UseMI,
818-
SparseSet<LiveRegUnit> &RegUnits) {
816+
void MachineTraceMetrics::Ensemble::updateDepth(TraceBlockInfo &TBI,
817+
const MachineInstr &UseMI,
818+
LiveRegUnitSet &RegUnits) {
819819
SmallVector<DataDep, 8> Deps;
820820
// Collect all data dependencies.
821821
if (UseMI.isPHI())
@@ -852,18 +852,17 @@ updateDepth(MachineTraceMetrics::TraceBlockInfo &TBI, const MachineInstr &UseMI,
852852
}
853853
}
854854

855-
void MachineTraceMetrics::Ensemble::
856-
updateDepth(const MachineBasicBlock *MBB, const MachineInstr &UseMI,
857-
SparseSet<LiveRegUnit> &RegUnits) {
855+
void MachineTraceMetrics::Ensemble::updateDepth(const MachineBasicBlock *MBB,
856+
const MachineInstr &UseMI,
857+
LiveRegUnitSet &RegUnits) {
858858
updateDepth(BlockInfo[MBB->getNumber()], UseMI, RegUnits);
859859
}
860860

861-
void MachineTraceMetrics::Ensemble::
862-
updateDepths(MachineBasicBlock::iterator Start,
863-
MachineBasicBlock::iterator End,
864-
SparseSet<LiveRegUnit> &RegUnits) {
865-
for (; Start != End; Start++)
866-
updateDepth(Start->getParent(), *Start, RegUnits);
861+
void MachineTraceMetrics::Ensemble::updateDepths(
862+
MachineBasicBlock::iterator Start, MachineBasicBlock::iterator End,
863+
LiveRegUnitSet &RegUnits) {
864+
for (; Start != End; Start++)
865+
updateDepth(Start->getParent(), *Start, RegUnits);
867866
}
868867

869868
/// Compute instruction depths for all instructions above or in MBB in its
@@ -887,7 +886,7 @@ computeInstrDepths(const MachineBasicBlock *MBB) {
887886
// in the trace. We should track any live-out physregs that were defined in
888887
// the trace. This is quite rare in SSA form, typically created by CSE
889888
// hoisting a compare.
890-
SparseSet<LiveRegUnit> RegUnits;
889+
LiveRegUnitSet RegUnits;
891890
RegUnits.setUniverse(MTM.TRI->getNumRegUnits());
892891

893892
// Go through trace blocks in top-down order, stopping after the center block.
@@ -925,7 +924,7 @@ computeInstrDepths(const MachineBasicBlock *MBB) {
925924
// Return the issue height of MI after considering any live regunits.
926925
// Height is the issue height computed from virtual register dependencies alone.
927926
static unsigned updatePhysDepsUpwards(const MachineInstr &MI, unsigned Height,
928-
SparseSet<LiveRegUnit> &RegUnits,
927+
LiveRegUnitSet &RegUnits,
929928
const TargetSchedModel &SchedModel,
930929
const TargetInstrInfo *TII,
931930
const TargetRegisterInfo *TRI) {
@@ -944,7 +943,7 @@ static unsigned updatePhysDepsUpwards(const MachineInstr &MI, unsigned Height,
944943
// This is a def of Reg. Remove corresponding entries from RegUnits, and
945944
// update MI Height to consider the physreg dependencies.
946945
for (MCRegUnit Unit : TRI->regunits(Reg.asMCReg())) {
947-
SparseSet<LiveRegUnit>::iterator I = RegUnits.find(Unit);
946+
LiveRegUnitSet::iterator I = RegUnits.find(Unit);
948947
if (I == RegUnits.end())
949948
continue;
950949
unsigned DepHeight = I->Cycle;
@@ -1048,7 +1047,7 @@ computeInstrHeights(const MachineBasicBlock *MBB) {
10481047

10491048
// For physregs, the def isn't known when we see the use.
10501049
// Instead, keep track of the highest use of each regunit.
1051-
SparseSet<LiveRegUnit> RegUnits;
1050+
LiveRegUnitSet RegUnits;
10521051
RegUnits.setUniverse(MTM.TRI->getNumRegUnits());
10531052

10541053
// If the bottom of the trace was already precomputed, initialize heights

0 commit comments

Comments
 (0)