blob: 7b1252ad0573afeea3d9bc02a5ca792af3e88399 [file] [log] [blame]
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +00001//===--------------------- SummaryView.cpp -------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9/// \file
10///
11/// This file implements the functionalities used by the SummaryView to print
12/// the report information.
13///
14//===----------------------------------------------------------------------===//
15
16#include "SummaryView.h"
17#include "llvm/CodeGen/TargetSchedule.h"
18
19namespace mca {
20
21using namespace llvm;
22
23void SummaryView::printSummary(raw_ostream &OS) const {
24 unsigned TotalInstructions = Instructions * Iterations;
25 double IPC = (double)TotalInstructions / TotalCycles;
26
27 std::string Buffer;
28 raw_string_ostream TempStream(Buffer);
29 TempStream << "Iterations: " << Iterations;
30 TempStream << "\nInstructions: " << TotalInstructions;
31 TempStream << "\nTotal Cycles: " << TotalCycles;
32 TempStream << "\nDispatch Width: " << DispatchWidth;
33 TempStream << "\nIPC: " << format("%.2f", IPC) << '\n';
34 TempStream.flush();
35 OS << Buffer;
36}
37
38void SummaryView::printInstructionInfo(raw_ostream &OS) const {
39 std::string Buffer;
40 raw_string_ostream TempStream(Buffer);
41
42 TempStream << "\n\nInstruction Info:\n";
43 TempStream << "[1]: #uOps\n[2]: Latency\n[3]: RThroughput\n"
44 << "[4]: MayLoad\n[5]: MayStore\n[6]: HasSideEffects\n\n";
45
46 TempStream << "[1] [2] [3] [4] [5] [6]\tInstructions:\n";
47 for (unsigned I = 0, E = Instructions; I < E; ++I) {
48 const MCInst &Inst = B.getMCInstFromIndex(I);
49 const InstrDesc &ID = B.getInstrDesc(Inst);
50 unsigned NumMicroOpcodes = ID.NumMicroOps;
51 unsigned Latency = ID.MaxLatency;
52 double RThroughput = B.getRThroughput(ID);
53 TempStream << ' ' << NumMicroOpcodes << " ";
54 if (NumMicroOpcodes < 10)
55 TempStream << " ";
56 else if (NumMicroOpcodes < 100)
57 TempStream << ' ';
58 TempStream << Latency << " ";
59 if (Latency < 10.0)
60 TempStream << " ";
61 else if (Latency < 100.0)
62 TempStream << ' ';
63 if (RThroughput) {
64 TempStream << format("%.2f", RThroughput) << ' ';
65 if (RThroughput < 10.0)
66 TempStream << " ";
67 else if (RThroughput < 100.0)
68 TempStream << ' ';
69 } else {
70 TempStream << " - ";
71 }
72 TempStream << (ID.MayLoad ? " * " : " ");
73 TempStream << (ID.MayStore ? " * " : " ");
74 TempStream << (ID.HasSideEffects ? " * " : " ");
75 MCIP.printInst(&Inst, TempStream, "", B.getSTI());
76 TempStream << '\n';
77 }
78
79 TempStream.flush();
80 OS << Buffer;
81}
82
83} // namespace mca.