diff --git a/llvm/include/llvm/CodeGen/MachineTraceMetrics.h b/llvm/include/llvm/CodeGen/MachineTraceMetrics.h --- a/llvm/include/llvm/CodeGen/MachineTraceMetrics.h +++ b/llvm/include/llvm/CodeGen/MachineTraceMetrics.h @@ -82,6 +82,12 @@ 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 @@ }; - /// 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 @@ SmallVector ProcResourceCycles; // One ensemble per strategy. - Ensemble* Ensembles[TS_NumStrategies]; + Ensemble + *Ensembles[static_cast(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 --- a/llvm/lib/CodeGen/EarlyIfConversion.cpp +++ b/llvm/lib/CodeGen/EarlyIfConversion.cpp @@ -874,7 +874,7 @@ 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 --- a/llvm/lib/CodeGen/MachineCombiner.cpp +++ b/llvm/lib/CodeGen/MachineCombiner.cpp @@ -595,7 +595,7 @@ // 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 RegUnits; RegUnits.setUniverse(TRI->getNumRegUnits()); diff --git a/llvm/lib/CodeGen/MachineTraceMetrics.cpp b/llvm/lib/CodeGen/MachineTraceMetrics.cpp --- a/llvm/lib/CodeGen/MachineTraceMetrics.cpp +++ b/llvm/lib/CodeGen/MachineTraceMetrics.cpp @@ -380,15 +380,17 @@ // 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(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 --- a/llvm/lib/Target/AArch64/AArch64ConditionalCompares.cpp +++ b/llvm/lib/Target/AArch64/AArch64ConditionalCompares.cpp @@ -855,7 +855,7 @@ 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 --- a/llvm/lib/Target/AArch64/AArch64StorePairSuppress.cpp +++ b/llvm/lib/Target/AArch64/AArch64StorePairSuppress.cpp @@ -75,7 +75,7 @@ /// 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();