1 //===--------------------- RetireControlUnitStatistics.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 RetireControlUnitStatistics interface. 12 /// 13 //===----------------------------------------------------------------------===// 14 15 #include "RetireControlUnitStatistics.h" 16 #include "llvm/Support/Format.h" 17 18 using namespace llvm; 19 20 namespace mca { 21 22 void RetireControlUnitStatistics::onEvent(const HWInstructionEvent &Event) { 23 if (Event.Type == HWInstructionEvent::Retired) 24 ++NumRetired; 25 } 26 27 void RetireControlUnitStatistics::printView(llvm::raw_ostream &OS) const { 28 std::string Buffer; 29 raw_string_ostream TempStream(Buffer); 30 TempStream << "\n\nRetire Control Unit - " 31 << "number of cycles where we saw N instructions retired:\n"; 32 TempStream << "[# retired], [# cycles]\n"; 33 34 for (const std::pair<unsigned, unsigned> &Entry : RetiredPerCycle) { 35 TempStream << " " << Entry.first; 36 if (Entry.first < 10) 37 TempStream << ", "; 38 else 39 TempStream << ", "; 40 TempStream << Entry.second << " (" 41 << format("%.1f", ((double)Entry.second / NumCycles) * 100.0) 42 << "%)\n"; 43 } 44 45 TempStream.flush(); 46 OS << Buffer; 47 } 48 49 } // namespace mca 50