Index: llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp +++ llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp @@ -319,8 +319,9 @@ std::vector SchedClassPoint(NumMeasurements); // Latency case. assert(!Clustering.getPoints().empty()); - const std::string &Mode = Clustering.getPoints()[0].Key.Mode; - if (Mode == "latency") { // FIXME: use an enum. + const InstructionBenchmarkKey::ModeE Mode = + Clustering.getPoints()[0].Key.Mode; + if (Mode == InstructionBenchmarkKey::Latency) { if (NumMeasurements != 1) { llvm::errs() << "invalid number of measurements in latency mode: expected 1, got " @@ -336,7 +337,7 @@ std::max(SchedClassPoint[0].Value, WLE->Cycles); } ClusterCenterPoint[0].Value = Representative[0].avg(); - } else if (Mode == "uops") { + } else if (Mode == InstructionBenchmarkKey::Uops) { for (int I = 0, E = Representative.size(); I < E; ++I) { // Find the pressure on ProcResIdx `Key`. uint16_t ProcResIdx = 0; @@ -358,8 +359,8 @@ ClusterCenterPoint[I].Value = Representative[I].avg(); } } else { - llvm::errs() << "unimplemented measurement matching for mode ''" << Mode - << "''\n"; + llvm::errs() << "unimplemented measurement matching for mode " << Mode + << "\n"; return false; } return Clustering.isNeighbour(ClusterCenterPoint, SchedClassPoint); Index: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h +++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h @@ -27,8 +27,8 @@ struct InstructionBenchmarkKey { // The LLVM opcode name. std::string OpcodeName; - // The benchmark mode. - std::string Mode; + enum ModeE { Unknown, Latency, Uops }; + ModeE Mode; // An opaque configuration, that can be used to separate several benchmarks of // the same instruction under different configurations. std::string Config; Index: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -34,6 +34,16 @@ static const bool flow = true; }; +template <> +struct ScalarEnumerationTraits { + static void enumeration(IO &Io, + exegesis::InstructionBenchmarkKey::ModeE &Value) { + Io.enumCase(Value, "", exegesis::InstructionBenchmarkKey::Unknown); + Io.enumCase(Value, "latency", exegesis::InstructionBenchmarkKey::Latency); + Io.enumCase(Value, "uops", exegesis::InstructionBenchmarkKey::Uops); + } +}; + template <> struct MappingTraits { static void mapping(IO &Io, exegesis::InstructionBenchmarkKey &Obj) { Io.mapRequired("opcode_name", Obj.OpcodeName); Index: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.h =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.h +++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.h @@ -54,7 +54,7 @@ const llvm::MCRegisterInfo &MCRegisterInfo; private: - virtual const char *getDisplayName() const = 0; + virtual InstructionBenchmarkKey::ModeE getMode() const = 0; virtual llvm::Expected> createSnippet(RegisterAliasingTrackerCache &RATC, unsigned Opcode, Index: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp +++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp @@ -37,7 +37,7 @@ InstructionBenchmark InstrBenchmark; InstrBenchmark.Key.OpcodeName = State.getInstrInfo().getName(Opcode); - InstrBenchmark.Key.Mode = getDisplayName(); + InstrBenchmark.Key.Mode = getMode(); InstrBenchmark.CpuName = State.getCpuName(); InstrBenchmark.LLVMTriple = State.getTriple(); InstrBenchmark.NumRepetitions = NumRepetitions; Index: llvm/trunk/tools/llvm-exegesis/lib/Latency.h =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/Latency.h +++ llvm/trunk/tools/llvm-exegesis/lib/Latency.h @@ -25,7 +25,7 @@ ~LatencyBenchmarkRunner() override; private: - const char *getDisplayName() const override; + InstructionBenchmarkKey::ModeE getMode() const override; llvm::Expected> createSnippet(RegisterAliasingTrackerCache &RATC, unsigned OpcodeIndex, Index: llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp +++ llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp @@ -52,7 +52,9 @@ LatencyBenchmarkRunner::~LatencyBenchmarkRunner() = default; -const char *LatencyBenchmarkRunner::getDisplayName() const { return "latency"; } +InstructionBenchmarkKey::ModeE LatencyBenchmarkRunner::getMode() const { + return InstructionBenchmarkKey::Latency; +} llvm::Expected> LatencyBenchmarkRunner::createSnippet(RegisterAliasingTrackerCache &RATC, Index: llvm/trunk/tools/llvm-exegesis/lib/Uops.h =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/Uops.h +++ llvm/trunk/tools/llvm-exegesis/lib/Uops.h @@ -25,7 +25,7 @@ ~UopsBenchmarkRunner() override; private: - const char *getDisplayName() const override; + InstructionBenchmarkKey::ModeE getMode() const override; llvm::Expected> createSnippet(RegisterAliasingTrackerCache &RATC, unsigned Opcode, Index: llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp +++ llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp @@ -141,7 +141,9 @@ UopsBenchmarkRunner::~UopsBenchmarkRunner() = default; -const char *UopsBenchmarkRunner::getDisplayName() const { return "uops"; } +InstructionBenchmarkKey::ModeE UopsBenchmarkRunner::getMode() const { + return InstructionBenchmarkKey::Uops; +} llvm::Expected> UopsBenchmarkRunner::createSnippet(RegisterAliasingTrackerCache &RATC, Index: llvm/trunk/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp =================================================================== --- llvm/trunk/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp +++ llvm/trunk/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp @@ -28,7 +28,7 @@ InstructionBenchmark ToDisk; ToDisk.Key.OpcodeName = "name"; - ToDisk.Key.Mode = "mode"; + ToDisk.Key.Mode = InstructionBenchmarkKey::Latency; ToDisk.Key.Config = "config"; ToDisk.CpuName = "cpu_name"; ToDisk.LLVMTriple = "llvm_triple";