[llvm-mca] Refactor event listeners to make the backend agnostic to event types.
Summary: This is a first step towards making the pipeline configurable.
Subscribers: llvm-commits, andreadb
Differential Revision: https://reviews.llvm.org/D44309
llvm-svn: 327389
diff --git a/llvm/tools/llvm-mca/ResourcePressureView.cpp b/llvm/tools/llvm-mca/ResourcePressureView.cpp
index 1b9620f..18ef495 100644
--- a/llvm/tools/llvm-mca/ResourcePressureView.cpp
+++ b/llvm/tools/llvm-mca/ResourcePressureView.cpp
@@ -39,10 +39,13 @@
std::fill(ResourceUsage.begin(), ResourceUsage.end(), 0);
}
-void ResourcePressureView::onInstructionIssued(
- unsigned Index, const ArrayRef<std::pair<ResourceRef, unsigned>> &Used) {
- unsigned SourceIdx = Index % Source.size();
- for (const std::pair<ResourceRef, unsigned> &Use : Used) {
+void ResourcePressureView::onInstructionEvent(const HWInstructionEvent &Event) {
+ // We're only interested in Issue events.
+ if (Event.Type != HWInstructionEvent::Issued)
+ return;
+ const auto &IssueEvent = static_cast<const HWInstructionIssuedEvent &>(Event);
+ unsigned SourceIdx = Event.Index % Source.size();
+ for (const std::pair<ResourceRef, unsigned> &Use : IssueEvent.UsedResources) {
const ResourceRef &RR = Use.first;
assert(Resource2VecIndex.find(RR.first) != Resource2VecIndex.end());
unsigned R2VIndex = Resource2VecIndex[RR.first];