mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-20 04:15:53 +00:00

Also, get rid of a redundant include in FetchStage.h and FetchStage.cpp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332468 91177308-0d34-0410-b5e6-96231b3b80d8
44 lines
1.4 KiB
C++
44 lines
1.4 KiB
C++
//===---------------------- FetchStage.cpp ----------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
/// \file
|
|
///
|
|
/// This file defines the Fetch stage of an instruction pipeline. Its sole
|
|
/// purpose in life is to produce instructions for the rest of the pipeline.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "FetchStage.h"
|
|
|
|
namespace mca {
|
|
|
|
bool FetchStage::isReady() const { return SM.hasNext(); }
|
|
|
|
bool FetchStage::execute(InstRef &IR) {
|
|
if (!SM.hasNext())
|
|
return false;
|
|
const SourceRef SR = SM.peekNext();
|
|
std::unique_ptr<Instruction> I = IB.createInstruction(*SR.second);
|
|
IR = InstRef(SR.first, I.get());
|
|
Instructions[IR.getSourceIndex()] = std::move(I);
|
|
return true;
|
|
}
|
|
|
|
void FetchStage::postExecute(const InstRef &IR) {
|
|
// Find the first instruction which hasn't been retired.
|
|
const InstMap::iterator It =
|
|
llvm::find_if(Instructions, [](const InstMap::value_type &KeyValuePair) {
|
|
return !KeyValuePair.second->isRetired();
|
|
});
|
|
if (It != Instructions.begin())
|
|
Instructions.erase(Instructions.begin(), It);
|
|
SM.updateNext();
|
|
}
|
|
|
|
} // namespace mca
|