From 844f22d3c3806f372c1bec258a4bc559f974081d Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Tue, 13 Mar 2018 13:11:01 +0000 Subject: [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 --- llvm/tools/llvm-mca/TimelineView.cpp | 77 ++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 44 deletions(-) (limited to 'llvm/tools/llvm-mca/TimelineView.cpp') 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> & /* 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, -- cgit v1.2.3