[llvm] 77bd15a - [MachineTraceMetrics][NFC] Move Strategy enum out of the class
Anton Sidorenko via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 14 05:42:12 PST 2023
Author: Anton Sidorenko
Date: 2023-02-14T16:38:47+03:00
New Revision: 77bd15ae2fa381e5c017543853d72a3f0cc7ced7
URL: https://github.com/llvm/llvm-project/commit/77bd15ae2fa381e5c017543853d72a3f0cc7ced7
DIFF: https://github.com/llvm/llvm-project/commit/77bd15ae2fa381e5c017543853d72a3f0cc7ced7.diff
LOG: [MachineTraceMetrics][NFC] Move Strategy enum out of the class
Make forward declaration possible to reduce amount of dependencies and reduce
re-compilation burden caused by further patches.
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D140539
Added:
Modified:
llvm/include/llvm/CodeGen/MachineTraceMetrics.h
llvm/lib/CodeGen/EarlyIfConversion.cpp
llvm/lib/CodeGen/MachineCombiner.cpp
llvm/lib/CodeGen/MachineTraceMetrics.cpp
llvm/lib/Target/AArch64/AArch64ConditionalCompares.cpp
llvm/lib/Target/AArch64/AArch64StorePairSuppress.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/MachineTraceMetrics.h b/llvm/include/llvm/CodeGen/MachineTraceMetrics.h
index 89c9c94455d96..66e37ab37ee2e 100644
--- a/llvm/include/llvm/CodeGen/MachineTraceMetrics.h
+++ b/llvm/include/llvm/CodeGen/MachineTraceMetrics.h
@@ -82,6 +82,12 @@ struct LiveRegUnit {
LiveRegUnit(unsigned RU) : RegUnit(RU) {}
};
+/// Strategies for selecting traces.
+enum class MachineTraceStrategy {
+ /// Select the trace through a block that has the fewest instructions.
+ TS_MinInstrCount,
+ TS_NumStrategies
+};
class MachineTraceMetrics : public MachineFunctionPass {
const MachineFunction *MF = nullptr;
@@ -372,18 +378,10 @@ class MachineTraceMetrics : public MachineFunctionPass {
};
- /// Strategies for selecting traces.
- enum Strategy {
- /// Select the trace through a block that has the fewest instructions.
- TS_MinInstrCount,
-
- TS_NumStrategies
- };
-
/// Get the trace ensemble representing the given trace selection strategy.
/// The returned Ensemble object is owned by the MachineTraceMetrics analysis,
/// and valid for the lifetime of the analysis pass.
- Ensemble *getEnsemble(Strategy);
+ Ensemble *getEnsemble(MachineTraceStrategy);
/// Invalidate cached information about MBB. This must be called *before* MBB
/// is erased, or the CFG is otherwise changed.
@@ -407,7 +405,8 @@ class MachineTraceMetrics : public MachineFunctionPass {
SmallVector<unsigned, 0> ProcResourceCycles;
// One ensemble per strategy.
- Ensemble* Ensembles[TS_NumStrategies];
+ Ensemble
+ *Ensembles[static_cast<size_t>(MachineTraceStrategy::TS_NumStrategies)];
// Convert scaled resource usage to a cycle count that can be compared with
// latencies.
diff --git a/llvm/lib/CodeGen/EarlyIfConversion.cpp b/llvm/lib/CodeGen/EarlyIfConversion.cpp
index 00626604d81c4..4226a97c06fd1 100644
--- a/llvm/lib/CodeGen/EarlyIfConversion.cpp
+++ b/llvm/lib/CodeGen/EarlyIfConversion.cpp
@@ -874,7 +874,7 @@ bool EarlyIfConverter::shouldConvertIf() {
return true;
if (!MinInstr)
- MinInstr = Traces->getEnsemble(MachineTraceMetrics::TS_MinInstrCount);
+ MinInstr = Traces->getEnsemble(MachineTraceStrategy::TS_MinInstrCount);
MachineTraceMetrics::Trace TBBTrace = MinInstr->getTrace(IfConv.getTPred());
MachineTraceMetrics::Trace FBBTrace = MinInstr->getTrace(IfConv.getFPred());
diff --git a/llvm/lib/CodeGen/MachineCombiner.cpp b/llvm/lib/CodeGen/MachineCombiner.cpp
index 974d570ece51f..485ec66d5dc27 100644
--- a/llvm/lib/CodeGen/MachineCombiner.cpp
+++ b/llvm/lib/CodeGen/MachineCombiner.cpp
@@ -575,7 +575,7 @@ bool MachineCombiner::combineInstructions(MachineBasicBlock *MBB) {
// Check if the block is in a loop.
const MachineLoop *ML = MLI->getLoopFor(MBB);
if (!MinInstr)
- MinInstr = Traces->getEnsemble(MachineTraceMetrics::TS_MinInstrCount);
+ MinInstr = Traces->getEnsemble(MachineTraceStrategy::TS_MinInstrCount);
SparseSet<LiveRegUnit> RegUnits;
RegUnits.setUniverse(TRI->getNumRegUnits());
diff --git a/llvm/lib/CodeGen/MachineTraceMetrics.cpp b/llvm/lib/CodeGen/MachineTraceMetrics.cpp
index 8f793a00ca472..a3ea657c95317 100644
--- a/llvm/lib/CodeGen/MachineTraceMetrics.cpp
+++ b/llvm/lib/CodeGen/MachineTraceMetrics.cpp
@@ -380,15 +380,17 @@ MinInstrCountEnsemble::pickTraceSucc(const MachineBasicBlock *MBB) {
// Get an Ensemble sub-class for the requested trace strategy.
MachineTraceMetrics::Ensemble *
-MachineTraceMetrics::getEnsemble(MachineTraceMetrics::Strategy strategy) {
- assert(strategy < TS_NumStrategies && "Invalid trace strategy enum");
- Ensemble *&E = Ensembles[strategy];
+MachineTraceMetrics::getEnsemble(MachineTraceStrategy strategy) {
+ assert(strategy < MachineTraceStrategy::TS_NumStrategies &&
+ "Invalid trace strategy enum");
+ Ensemble *&E = Ensembles[static_cast<size_t>(strategy)];
if (E)
return E;
// Allocate new Ensemble on demand.
switch (strategy) {
- case TS_MinInstrCount: return (E = new MinInstrCountEnsemble(this));
+ case MachineTraceStrategy::TS_MinInstrCount:
+ return (E = new MinInstrCountEnsemble(this));
default: llvm_unreachable("Invalid trace strategy enum");
}
}
diff --git a/llvm/lib/Target/AArch64/AArch64ConditionalCompares.cpp b/llvm/lib/Target/AArch64/AArch64ConditionalCompares.cpp
index b3e816df0f46d..4c8c03a4c693f 100644
--- a/llvm/lib/Target/AArch64/AArch64ConditionalCompares.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ConditionalCompares.cpp
@@ -855,7 +855,7 @@ bool AArch64ConditionalCompares::shouldConvert() {
if (Stress)
return true;
if (!MinInstr)
- MinInstr = Traces->getEnsemble(MachineTraceMetrics::TS_MinInstrCount);
+ MinInstr = Traces->getEnsemble(MachineTraceStrategy::TS_MinInstrCount);
// Head dominates CmpBB, so it is always included in its trace.
MachineTraceMetrics::Trace Trace = MinInstr->getTrace(CmpConv.CmpBB);
diff --git a/llvm/lib/Target/AArch64/AArch64StorePairSuppress.cpp b/llvm/lib/Target/AArch64/AArch64StorePairSuppress.cpp
index 3ee0d5190ea34..93bd35b9c1219 100644
--- a/llvm/lib/Target/AArch64/AArch64StorePairSuppress.cpp
+++ b/llvm/lib/Target/AArch64/AArch64StorePairSuppress.cpp
@@ -75,7 +75,7 @@ FunctionPass *llvm::createAArch64StorePairSuppressPass() {
/// oversaturate the vector units.
bool AArch64StorePairSuppress::shouldAddSTPToBlock(const MachineBasicBlock *BB) {
if (!MinInstr)
- MinInstr = Traces->getEnsemble(MachineTraceMetrics::TS_MinInstrCount);
+ MinInstr = Traces->getEnsemble(MachineTraceStrategy::TS_MinInstrCount);
MachineTraceMetrics::Trace BBTrace = MinInstr->getTrace(BB);
unsigned ResLength = BBTrace.getResourceLength();
More information about the llvm-commits
mailing list