summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/TimelineView.cpp
diff options
context:
space:
mode:
authorClement Courbet <courbet@google.com>2018-03-13 13:11:01 +0000
committerClement Courbet <courbet@google.com>2018-03-13 13:11:01 +0000
commit844f22d3c3806f372c1bec258a4bc559f974081d (patch)
treeba6ab90f820ffd1d69f46206e07e9e9f49322d76 /llvm/tools/llvm-mca/TimelineView.cpp
parent9d7e9032f1bd3a7cd83ed1883069bcced7b52b21 (diff)
downloadbcm5719-llvm-844f22d3c3806f372c1bec258a4bc559f974081d.tar.gz
bcm5719-llvm-844f22d3c3806f372c1bec258a4bc559f974081d.zip
[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
Diffstat (limited to 'llvm/tools/llvm-mca/TimelineView.cpp')
-rw-r--r--llvm/tools/llvm-mca/TimelineView.cpp77
1 files changed, 33 insertions, 44 deletions
diff --git a/llvm/tools/llvm-mca/TimelineView.cpp b/llvm/tools/llvm-mca/TimelineView.cpp
index dd44bccf28b..cb51e9e55cb 100644
--- a/llvm/tools/llvm-mca/TimelineView.cpp
+++ b/llvm/tools/llvm-mca/TimelineView.cpp
@@ -34,53 +34,42 @@ void TimelineView::initialize(unsigned MaxIterations) {
std::fill(WaitTime.begin(), WaitTime.end(), NullWTEntry);
}
-void TimelineView::onInstructionDispatched(unsigned Index) {
- if (CurrentCycle >= MaxCycle || Index >= Timeline.size())
+void TimelineView::onInstructionEvent(const HWInstructionEvent &Event) {
+ if (CurrentCycle >= MaxCycle || Event.Index >= Timeline.size())
return;
- Timeline[Index].CycleDispatched = CurrentCycle;
- LastCycle = std::max(LastCycle, CurrentCycle);
-}
-
-void TimelineView::onInstructionReady(unsigned Index) {
- if (CurrentCycle >= MaxCycle || Index >= Timeline.size())
- return;
- Timeline[Index].CycleReady = CurrentCycle;
- LastCycle = std::max(LastCycle, CurrentCycle);
-}
-
-void TimelineView::onInstructionIssued(
- unsigned Index,
- const ArrayRef<std::pair<ResourceRef, unsigned>> & /* Unused */) {
- if (CurrentCycle >= MaxCycle || Index >= Timeline.size())
- return;
- Timeline[Index].CycleIssued = CurrentCycle;
- LastCycle = std::max(LastCycle, CurrentCycle);
-}
-
-void TimelineView::onInstructionExecuted(unsigned Index) {
- if (CurrentCycle >= MaxCycle || Index >= Timeline.size())
- return;
- Timeline[Index].CycleExecuted = CurrentCycle;
- LastCycle = std::max(LastCycle, CurrentCycle);
-}
-
-void TimelineView::onInstructionRetired(unsigned Index) {
- if (CurrentCycle >= MaxCycle || Index >= Timeline.size())
+ switch (Event.Type) {
+ case HWInstructionEvent::Retired: {
+ TimelineViewEntry &TVEntry = Timeline[Event.Index];
+ TVEntry.CycleRetired = CurrentCycle;
+
+ // Update the WaitTime entry which corresponds to this Index.
+ WaitTimeEntry &WTEntry = WaitTime[Event.Index % AsmSequence.size()];
+ WTEntry.Executions++;
+ WTEntry.CyclesSpentInSchedulerQueue +=
+ TVEntry.CycleIssued - TVEntry.CycleDispatched;
+ assert(TVEntry.CycleDispatched <= TVEntry.CycleReady);
+ WTEntry.CyclesSpentInSQWhileReady +=
+ TVEntry.CycleIssued - TVEntry.CycleReady;
+ WTEntry.CyclesSpentAfterWBAndBeforeRetire +=
+ (TVEntry.CycleRetired - 1) - TVEntry.CycleExecuted;
+ break;
+ }
+ case HWInstructionEvent::Ready:
+ Timeline[Event.Index].CycleReady = CurrentCycle;
+ break;
+ case HWInstructionEvent::Issued:
+ Timeline[Event.Index].CycleIssued = CurrentCycle;
+ break;
+ case HWInstructionEvent::Executed:
+ Timeline[Event.Index].CycleExecuted = CurrentCycle;
+ break;
+ case HWInstructionEvent::Dispatched:
+ Timeline[Event.Index].CycleDispatched = CurrentCycle;
+ break;
+ default:
return;
- TimelineViewEntry &TVEntry = Timeline[Index];
- TVEntry.CycleRetired = CurrentCycle;
+ }
LastCycle = std::max(LastCycle, CurrentCycle);
-
- // Update the WaitTime entry which corresponds to this Index.
-
- WaitTimeEntry &WTEntry = WaitTime[Index % AsmSequence.size()];
- WTEntry.Executions++;
- WTEntry.CyclesSpentInSchedulerQueue +=
- TVEntry.CycleIssued - TVEntry.CycleDispatched;
- assert(TVEntry.CycleDispatched <= TVEntry.CycleReady);
- WTEntry.CyclesSpentInSQWhileReady += TVEntry.CycleIssued - TVEntry.CycleReady;
- WTEntry.CyclesSpentAfterWBAndBeforeRetire +=
- (TVEntry.CycleRetired - 1) - TVEntry.CycleExecuted;
}
void TimelineView::printWaitTimeEntry(raw_string_ostream &OS,
OpenPOWER on IntegriCloud