blob: f7d09006a499339c688c762e276d1f5074aea2ee [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"
Andrea Di Biagiodf5d9482018-03-23 19:40:04 +000017#include "llvm/Support/Format.h"
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000018
19namespace mca {
20
Andrea Di Biagiodf5d9482018-03-23 19:40:04 +000021#define DEBUG_TYPE "llvm-mca"
22
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000023using namespace llvm;
24
Andrea Di Biagiodf5d9482018-03-23 19:40:04 +000025void SummaryView::printView(raw_ostream &OS) const {
Andrea Di Biagiob5229752018-03-13 17:24:32 +000026 unsigned Iterations = Source.getNumIterations();
27 unsigned Instructions = Source.size();
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000028 unsigned TotalInstructions = Instructions * Iterations;
29 double IPC = (double)TotalInstructions / TotalCycles;
30
31 std::string Buffer;
32 raw_string_ostream TempStream(Buffer);
33 TempStream << "Iterations: " << Iterations;
34 TempStream << "\nInstructions: " << TotalInstructions;
35 TempStream << "\nTotal Cycles: " << TotalCycles;
36 TempStream << "\nDispatch Width: " << DispatchWidth;
37 TempStream << "\nIPC: " << format("%.2f", IPC) << '\n';
38 TempStream.flush();
39 OS << Buffer;
40}
41
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000042} // namespace mca.