brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 10b86b5 Raw
52 lines · cpp
1//===-------------------- IncrementalSourceMgr.cpp ------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// This file defines some implementations for IncrementalSourceMgr.11///12//===----------------------------------------------------------------------===//13 14#include "llvm/MCA/IncrementalSourceMgr.h"15#ifndef NDEBUG16#include "llvm/Support/Format.h"17#endif18 19using namespace llvm;20using namespace llvm::mca;21 22void IncrementalSourceMgr::clear() {23  Staging.clear();24  InstStorage.clear();25  TotalCounter = 0U;26  EOS = false;27}28 29void IncrementalSourceMgr::updateNext() {30  ++TotalCounter;31  Instruction *I = Staging.front();32  Staging.pop_front();33  I->reset();34 35  if (InstFreedCB)36    InstFreedCB(I);37}38 39#ifndef NDEBUG40void IncrementalSourceMgr::printStatistic(raw_ostream &OS) {41  unsigned MaxInstStorageSize = InstStorage.size();42  if (MaxInstStorageSize <= TotalCounter) {43    auto Ratio = double(MaxInstStorageSize) / double(TotalCounter);44    OS << "Cache ratio = " << MaxInstStorageSize << " / " << TotalCounter45       << llvm::format(" (%.2f%%)", (1.0 - Ratio) * 100.0) << "\n";46  } else {47    OS << "Error: Number of created instructions "48       << "are larger than the number of issued instructions\n";49  }50}51#endif52