summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/Views/TimelineView.cpp
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-10-24 15:06:27 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-10-24 15:06:27 +0000
commit7be45b0f85c81454ee65e19e5a9bc87260af39e7 (patch)
tree6627a4e5d756ae751ca5bf8c3dfef66f34b19db7 /llvm/tools/llvm-mca/Views/TimelineView.cpp
parent678f43f666675811a926811f5e63904aef4d4785 (diff)
downloadbcm5719-llvm-7be45b0f85c81454ee65e19e5a9bc87260af39e7.tar.gz
bcm5719-llvm-7be45b0f85c81454ee65e19e5a9bc87260af39e7.zip
[llvm-mca] Refactor class SourceMgr. NFCI
Added begin()/end() methods to allow the usage of SourceMgr in foreach loops. With this change, method getMCInstFromIndex() (as well as a couple of other methods) are now redundant, and can be removed from the public interface. llvm-svn: 345147
Diffstat (limited to 'llvm/tools/llvm-mca/Views/TimelineView.cpp')
-rw-r--r--llvm/tools/llvm-mca/Views/TimelineView.cpp51
1 files changed, 28 insertions, 23 deletions
diff --git a/llvm/tools/llvm-mca/Views/TimelineView.cpp b/llvm/tools/llvm-mca/Views/TimelineView.cpp
index 1ad7271b2a4..d802d42352d 100644
--- a/llvm/tools/llvm-mca/Views/TimelineView.cpp
+++ b/llvm/tools/llvm-mca/Views/TimelineView.cpp
@@ -177,11 +177,10 @@ void TimelineView::printAverageWaitTimes(raw_ostream &OS) const {
formatted_raw_ostream FOS(OS);
unsigned Executions = Timeline.size() / AsmSequence.size();
- for (unsigned I = 0, E = WaitTime.size(); I < E; ++I) {
- printWaitTimeEntry(FOS, WaitTime[I], I, Executions);
+ unsigned IID = 0;
+ for (const MCInst &Inst : AsmSequence) {
+ printWaitTimeEntry(FOS, WaitTime[IID], IID, Executions);
// Append the instruction info at the end of the line.
- const MCInst &Inst = AsmSequence.getMCInstFromIndex(I);
-
MCIP.printInst(&Inst, InstrStream, "", STI);
InstrStream.flush();
@@ -191,6 +190,8 @@ void TimelineView::printAverageWaitTimes(raw_ostream &OS) const {
FOS << " " << Str << '\n';
FOS.flush();
Instruction = "";
+
+ ++IID;
}
}
@@ -266,25 +267,29 @@ void TimelineView::printTimeline(raw_ostream &OS) const {
std::string Instruction;
raw_string_ostream InstrStream(Instruction);
- for (unsigned I = 0, E = Timeline.size(); I < E; ++I) {
- const TimelineViewEntry &Entry = Timeline[I];
- if (Entry.CycleRetired == 0)
- return;
-
- unsigned Iteration = I / AsmSequence.size();
- unsigned SourceIndex = I % AsmSequence.size();
- printTimelineViewEntry(FOS, Entry, Iteration, SourceIndex);
- // Append the instruction info at the end of the line.
- const MCInst &Inst = AsmSequence.getMCInstFromIndex(I);
- MCIP.printInst(&Inst, InstrStream, "", STI);
- InstrStream.flush();
-
- // Consume any tabs or spaces at the beginning of the string.
- StringRef Str(Instruction);
- Str = Str.ltrim();
- FOS << " " << Str << '\n';
- FOS.flush();
- Instruction = "";
+ unsigned IID = 0;
+ const unsigned Iterations = Timeline.size() / AsmSequence.size();
+ for (unsigned Iteration = 0; Iteration < Iterations; ++Iteration) {
+ for (const MCInst &Inst : AsmSequence) {
+ const TimelineViewEntry &Entry = Timeline[IID];
+ if (Entry.CycleRetired == 0)
+ return;
+
+ unsigned SourceIndex = IID % AsmSequence.size();
+ printTimelineViewEntry(FOS, Entry, Iteration, SourceIndex);
+ // Append the instruction info at the end of the line.
+ MCIP.printInst(&Inst, InstrStream, "", STI);
+ InstrStream.flush();
+
+ // Consume any tabs or spaces at the beginning of the string.
+ StringRef Str(Instruction);
+ Str = Str.ltrim();
+ FOS << " " << Str << '\n';
+ FOS.flush();
+ Instruction = "";
+
+ ++IID;
+ }
}
}
} // namespace mca
OpenPOWER on IntegriCloud