Allow SymbolUserOpInterface operators to be used in RemoveDeadValues Pass (#117405)
[llvm-project.git] / llvm / tools / llvm-exegesis / lib / ValidationEvent.cpp
blobc965b7ae55e10db53d92e6292e0a283cdb0e455f
2 #include "ValidationEvent.h"
3 #include "llvm/ADT/StringRef.h"
4 #include "llvm/Support/Errc.h"
5 #include "llvm/Support/Error.h"
7 namespace llvm {
8 namespace exegesis {
10 namespace {
12 struct ValidationEventInfo {
13 const char *const Name;
14 const char *const Description;
17 // Information about validation events, indexed by `ValidationEvent` enum
18 // value.
19 static constexpr ValidationEventInfo ValidationEventInfos[] = {
20 {"instructions-retired", "Count retired instructions"},
21 {"l1d-cache-load-misses", "Count L1D load cache misses"},
22 {"l1d-cache-store-misses", "Count L1D store cache misses"},
23 {"l1i-cache-load-misses", "Count L1I load cache misses"},
24 {"data-tlb-load-misses", "Count DTLB load misses"},
25 {"data-tlb-store-misses", "Count DTLB store misses"},
26 {"instruction-tlb-load-misses", "Count ITLB load misses"},
27 {"branch-prediction-misses", "Branch prediction misses"},
30 static_assert(sizeof(ValidationEventInfos) ==
31 NumValidationEvents * sizeof(ValidationEventInfo),
32 "please update ValidationEventInfos");
34 } // namespace
36 const char *getValidationEventName(ValidationEvent VE) {
37 return ValidationEventInfos[VE].Name;
39 const char *getValidationEventDescription(ValidationEvent VE) {
40 return ValidationEventInfos[VE].Description;
43 Expected<ValidationEvent> getValidationEventByName(StringRef Name) {
44 int VE = 0;
45 for (const ValidationEventInfo &Info : ValidationEventInfos) {
46 if (Name == Info.Name)
47 return static_cast<ValidationEvent>(VE);
48 ++VE;
51 return make_error<StringError>("Invalid validation event string",
52 errc::invalid_argument);
55 } // namespace exegesis
56 } // namespace llvm