37 #include "debug/LTage.hh" 38 #include "params/LoopPredictor.hh" 41 :
SimObject(p), logSizeLoopPred(p->logSizeLoopPred),
42 loopTableAgeBits(p->loopTableAgeBits),
43 loopTableConfidenceBits(p->loopTableConfidenceBits),
44 loopTableTagBits(p->loopTableTagBits),
45 loopTableIterBits(p->loopTableIterBits),
46 logLoopTableAssoc(p->logLoopTableAssoc),
47 confidenceThreshold((1 << loopTableConfidenceBits) - 1),
48 loopTagMask((1 << loopTableTagBits) - 1),
49 loopNumIterMask((1 << loopTableIterBits) - 1),
50 loopSetMask((1 << (logSizeLoopPred - logLoopTableAssoc)) - 1),
52 withLoopBits(p->withLoopBits),
53 useDirectionBit(p->useDirectionBit),
54 useSpeculation(p->useSpeculation),
55 useHashing(p->useHashing),
56 restrictAllocation(p->restrictAllocation),
57 initialLoopIter(p->initialLoopIter),
58 initialLoopAge(p->initialLoopAge),
59 optionalAgeReset(p->optionalAgeReset)
93 Addr pc = pc_in >> instShiftAmt;
111 unsigned instShiftAmt)
const 137 if ((iter + 1) ==
ltable[idx].numIter) {
158 if (taken !=
ltable[index].dir) {
188 DPRINTF(LTage,
"Loop Prediction success:%lx\n",pc);
197 if (
ltable[idx].numIter != 0) {
208 DPRINTF(LTage,
"Loop End predicted successfully:%lx\n", pc);
212 if (
ltable[idx].numIter < 3) {
220 DPRINTF(LTage,
"Loop End predicted incorrectly:%lx\n", pc);
221 if (
ltable[idx].numIter == 0) {
245 if (
ltable[idx].age == 0) {
247 "Allocating loop pred entry for branch %lx\n",
270 BranchInfo*
bi,
bool prev_pred_taken,
unsigned instShiftAmt)
272 bool pred_taken = prev_pred_taken;
325 unsigned instShiftAmt)
350 .
name(
name() +
".loopPredictorCorrect")
351 .
desc(
"Number of times the loop predictor is the provider and " 352 "the prediction is correct");
355 .
name(
name() +
".loopPredictorWrong")
356 .
desc(
"Number of times the loop predictor is the provider and " 357 "the prediction is wrong");
370 LoopPredictorParams::create()
bool getLoop(Addr pc, BranchInfo *bi, bool speculative, unsigned instShiftAmt) const
Get a branch prediction from the loop predictor.
void squashLoop(BranchInfo *bi)
const bool optionalAgeReset
void squash(ThreadID tid, BranchInfo *bi)
Stats::Scalar loopPredictorCorrect
void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, bool tage_pred, BranchInfo *bi, unsigned instShiftAmt)
Update LTAGE for conditional branches.
virtual BranchInfo * makeBranchInfo()
const unsigned loopTableAgeBits
const bool useDirectionBit
std::enable_if< std::is_integral< T >::value, T >::type random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
void init() override
Initialize the loop predictor.
Stats::Scalar loopPredictorWrong
const uint16_t loopNumIterMask
const unsigned loopTableConfidenceBits
const unsigned logLoopTableAssoc
static void unsignedCtrUpdate(uint8_t &ctr, bool up, unsigned nbits)
Updates an unsigned counter based on up/down parameter.
virtual bool calcConf(int index) const
int lindex(Addr pc_in, unsigned instShiftAmt) const
Computes the index used to access the loop predictor.
int finallindex(int lindex, int lowPcBits, int way) const
Computes the index used to access the ltable structures.
size_t getSizeInBits() const
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
#define ULL(N)
uint64_t constant
static void signedCtrUpdate(int8_t &ctr, bool up, unsigned nbits)
const unsigned loopTableIterBits
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
int16_t ThreadID
Thread index/ID type.
virtual const std::string name() const
const uint8_t confidenceThreshold
void specLoopUpdate(bool taken, BranchInfo *bi)
Speculatively updates the loop predictor iteration count (only for useSpeculation).
void regStats() override
Register stats for this object.
LoopPredictor(LoopPredictorParams *p)
const unsigned loopTableTagBits
const unsigned initialLoopAge
const uint16_t loopTagMask
const unsigned logSizeLoopPred
const unsigned initialLoopIter
const bool useSpeculation
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
bool loopPredict(ThreadID tid, Addr branch_pc, bool cond_branch, BranchInfo *bi, bool prev_pred_taken, unsigned instShiftAmt)
Get the loop prediction.
Abstract superclass for simulation objects.
void loopUpdate(Addr pc, bool Taken, BranchInfo *bi, bool tage_pred)
Updates the loop predictor.
const bool restrictAllocation
void updateStats(bool taken, BranchInfo *bi)
Update the stats.
virtual bool optionalAgeInc() const