Path: blob/main/contrib/llvm-project/llvm/lib/MCA/IncrementalSourceMgr.cpp
35259 views
//===-------------------- IncrementalSourceMgr.cpp ------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7///8/// \file9/// This file defines some implementations for IncrementalSourceMgr.10///11//===----------------------------------------------------------------------===//1213#include "llvm/MCA/IncrementalSourceMgr.h"14#ifndef NDEBUG15#include "llvm/Support/Format.h"16#endif1718using namespace llvm;19using namespace llvm::mca;2021void IncrementalSourceMgr::clear() {22Staging.clear();23InstStorage.clear();24TotalCounter = 0U;25EOS = false;26}2728void IncrementalSourceMgr::updateNext() {29++TotalCounter;30Instruction *I = Staging.front();31Staging.pop_front();32I->reset();3334if (InstFreedCB)35InstFreedCB(I);36}3738#ifndef NDEBUG39void IncrementalSourceMgr::printStatistic(raw_ostream &OS) {40unsigned MaxInstStorageSize = InstStorage.size();41if (MaxInstStorageSize <= TotalCounter) {42auto Ratio = double(MaxInstStorageSize) / double(TotalCounter);43OS << "Cache ratio = " << MaxInstStorageSize << " / " << TotalCounter44<< llvm::format(" (%.2f%%)", (1.0 - Ratio) * 100.0) << "\n";45} else {46OS << "Error: Number of created instructions "47<< "are larger than the number of issued instructions\n";48}49}50#endif515253