diff options
author | Clement Courbet <courbet@google.com> | 2024-02-21 09:48:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-21 09:48:20 +0100 |
commit | 8b84de26dfc1ba742b427e45bc900bc233fd58e1 (patch) | |
tree | 70e495e4ee2751c6cdcff1ad99f9975860d0a7fd /llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp | |
parent | 02fad0565fe7f061bdaa79ff33b29f64b2c290eb (diff) | |
download | llvm-8b84de26dfc1ba742b427e45bc900bc233fd58e1.zip llvm-8b84de26dfc1ba742b427e45bc900bc233fd58e1.tar.gz llvm-8b84de26dfc1ba742b427e45bc900bc233fd58e1.tar.bz2 |
[llvm-exegesis][NFC] Refactor all `ValidationEvent` info in a single … (#82256)
…table.
All data is derived from a single table rather than being spread out
over an enum, a table and the main entry point.
This is intended as a replacement for #82092.
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp')
-rw-r--r-- | llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp | 49 |
1 files changed, 3 insertions, 46 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp index 189add6..f84ebd2 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -9,6 +9,7 @@ #include "BenchmarkResult.h" #include "BenchmarkRunner.h" #include "Error.h" +#include "ValidationEvent.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringRef.h" @@ -198,7 +199,7 @@ struct CustomMappingTraits<std::map<exegesis::ValidationEvent, int64_t>> { static void inputOne(IO &Io, StringRef KeyStr, std::map<exegesis::ValidationEvent, int64_t> &VI) { Expected<exegesis::ValidationEvent> Key = - exegesis::stringToValidationEvent(KeyStr); + exegesis::getValidationEventByName(KeyStr); if (!Key) { Io.setError("Key is not a valid validation event"); return; @@ -208,7 +209,7 @@ struct CustomMappingTraits<std::map<exegesis::ValidationEvent, int64_t>> { static void output(IO &Io, std::map<exegesis::ValidationEvent, int64_t> &VI) { for (auto &IndividualVI : VI) { - Io.mapRequired(exegesis::validationEventToString(IndividualVI.first), + Io.mapRequired(exegesis::getValidationEventName(IndividualVI.first), IndividualVI.second); } } @@ -441,49 +442,5 @@ bool operator==(const BenchmarkMeasure &A, const BenchmarkMeasure &B) { std::tie(B.Key, B.PerInstructionValue, B.PerSnippetValue); } -const char *validationEventToString(ValidationEvent VE) { - switch (VE) { - case exegesis::ValidationEvent::InstructionRetired: - return "instructions-retired"; - case exegesis::ValidationEvent::L1DCacheLoadMiss: - return "l1d-cache-load-misses"; - case exegesis::ValidationEvent::L1DCacheStoreMiss: - return "l1d-cache-store-misses"; - case exegesis::ValidationEvent::L1ICacheLoadMiss: - return "l1i-cache-load-misses"; - case exegesis::ValidationEvent::DataTLBLoadMiss: - return "data-tlb-load-misses"; - case exegesis::ValidationEvent::DataTLBStoreMiss: - return "data-tlb-store-misses"; - case exegesis::ValidationEvent::InstructionTLBLoadMiss: - return "instruction-tlb-load-misses"; - case exegesis::ValidationEvent::BranchPredictionMiss: - return "branch-prediction-misses"; - } - llvm_unreachable("Unhandled exegesis::ValidationEvent enum"); -} - -Expected<ValidationEvent> stringToValidationEvent(StringRef Input) { - if (Input == "instructions-retired") - return exegesis::ValidationEvent::InstructionRetired; - else if (Input == "l1d-cache-load-misses") - return exegesis::ValidationEvent::L1DCacheLoadMiss; - else if (Input == "l1d-cache-store-misses") - return exegesis::ValidationEvent::L1DCacheStoreMiss; - else if (Input == "l1i-cache-load-misses") - return exegesis::ValidationEvent::L1ICacheLoadMiss; - else if (Input == "data-tlb-load-misses") - return exegesis::ValidationEvent::DataTLBLoadMiss; - else if (Input == "data-tlb-store-misses") - return exegesis::ValidationEvent::DataTLBStoreMiss; - else if (Input == "instruction-tlb-load-misses") - return exegesis::ValidationEvent::InstructionTLBLoadMiss; - else if (Input == "branch-prediction-misses") - return exegesis::ValidationEvent::BranchPredictionMiss; - else - return make_error<StringError>("Invalid validation event string", - errc::invalid_argument); -} - } // namespace exegesis } // namespace llvm |