-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-exegesis][NFC] Refactor all ValidationEvent
info in a single …
#82256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
#include "ValidationEvent.h" | ||
#include "llvm/ADT/StringRef.h" | ||
#include "llvm/Support/Errc.h" | ||
#include "llvm/Support/Error.h" | ||
|
||
namespace llvm { | ||
namespace exegesis { | ||
|
||
namespace { | ||
|
||
struct ValidationEventInfo { | ||
const char *const Name; | ||
const char *const Description; | ||
}; | ||
|
||
// Information about validation events, indexed by `ValidationEvent` enum | ||
// value. | ||
static constexpr ValidationEventInfo ValidationEventInfos[] = { | ||
{"instructions-retired", "Count retired instructions"}, | ||
{"l1d-cache-load-misses", "Count L1D load cache misses"}, | ||
{"l1d-cache-store-misses", "Count L1D store cache misses"}, | ||
{"l1i-cache-load-misses", "Count L1I load cache misses"}, | ||
{"data-tlb-load-misses", "Count DTLB load misses"}, | ||
{"data-tlb-store-misses", "Count DTLB store misses"}, | ||
{"instruction-tlb-load-misses", "Count ITLB load misses"}, | ||
{"branch-prediction-misses", "Branch prediction misses"}, | ||
}; | ||
|
||
static_assert(sizeof(ValidationEventInfos) == | ||
NumValidationEvents * sizeof(ValidationEventInfo), | ||
"please update ValidationEventInfos"); | ||
|
||
} // namespace | ||
|
||
const char *getValidationEventName(ValidationEvent VE) { | ||
return ValidationEventInfos[VE].Name; | ||
} | ||
const char *getValidationEventDescription(ValidationEvent VE) { | ||
return ValidationEventInfos[VE].Description; | ||
} | ||
|
||
Expected<ValidationEvent> getValidationEventByName(StringRef Name) { | ||
int VE = 0; | ||
for (const ValidationEventInfo &Info : ValidationEventInfos) { | ||
if (Name == Info.Name) | ||
return static_cast<ValidationEvent>(VE); | ||
++VE; | ||
} | ||
|
||
return make_error<StringError>("Invalid validation event string", | ||
errc::invalid_argument); | ||
} | ||
|
||
} // namespace exegesis | ||
} // namespace llvm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//===-- ValidationEvent.h ---------------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// \file | ||
/// Definitions and utilities for Validation Events. | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_TOOLS_LLVM_EXEGESIS_VALIDATIONEVENT_H | ||
#define LLVM_TOOLS_LLVM_EXEGESIS_VALIDATIONEVENT_H | ||
|
||
#include "llvm/ADT/StringRef.h" | ||
#include "llvm/Support/Error.h" | ||
|
||
namespace llvm { | ||
|
||
namespace exegesis { | ||
|
||
// The main list of supported validation events. The mapping between validation | ||
// events and pfm counters is defined in TableDef files for each target. | ||
enum ValidationEvent { | ||
InstructionRetired, | ||
L1DCacheLoadMiss, | ||
L1DCacheStoreMiss, | ||
L1ICacheLoadMiss, | ||
DataTLBLoadMiss, | ||
DataTLBStoreMiss, | ||
InstructionTLBLoadMiss, | ||
BranchPredictionMiss, | ||
// Number of events. | ||
NumValidationEvents, | ||
}; | ||
|
||
// Returns the name/description of the given event. | ||
const char *getValidationEventName(ValidationEvent VE); | ||
const char *getValidationEventDescription(ValidationEvent VE); | ||
|
||
// Returns the ValidationEvent with the given name. | ||
Expected<ValidationEvent> getValidationEventByName(StringRef Name); | ||
|
||
// Command-line options for validation events. | ||
struct ValidationEventOptions { | ||
template <class Opt> void apply(Opt &O) const { | ||
for (int I = 0; I < NumValidationEvents; ++I) { | ||
const auto VE = static_cast<ValidationEvent>(I); | ||
O.getParser().addLiteralOption(getValidationEventName(VE), VE, | ||
getValidationEventDescription(VE)); | ||
} | ||
} | ||
}; | ||
|
||
} // namespace exegesis | ||
} // namespace llvm | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe add a note here that the text mapping in
ValidationEvent.cpp
needs to be updated as well? Thestatic_assert
should take care of it, but having the info in the comment wouldn't hurt.