38 #include "debug/LTage.hh" 39 #include "params/LoopPredictor.hh" 42 :
SimObject(p), logSizeLoopPred(p->logSizeLoopPred),
43 loopTableAgeBits(p->loopTableAgeBits),
44 loopTableConfidenceBits(p->loopTableConfidenceBits),
45 loopTableTagBits(p->loopTableTagBits),
46 loopTableIterBits(p->loopTableIterBits),
47 logLoopTableAssoc(p->logLoopTableAssoc),
48 confidenceThreshold((1 << loopTableConfidenceBits) - 1),
49 loopTagMask((1 << loopTableTagBits) - 1),
50 loopNumIterMask((1 << loopTableIterBits) - 1),
51 loopSetMask((1 << (logSizeLoopPred - logLoopTableAssoc)) - 1),
53 withLoopBits(p->withLoopBits),
54 useDirectionBit(p->useDirectionBit),
55 useSpeculation(p->useSpeculation),
56 useHashing(p->useHashing),
57 restrictAllocation(p->restrictAllocation),
58 initialLoopIter(p->initialLoopIter),
59 initialLoopAge(p->initialLoopAge),
60 optionalAgeReset(p->optionalAgeReset)
94 Addr pc = pc_in >> instShiftAmt;
112 unsigned instShiftAmt)
const 138 if ((iter + 1) ==
ltable[idx].numIter) {
159 if (taken !=
ltable[index].dir) {
189 DPRINTF(LTage,
"Loop Prediction success:%lx\n",pc);
198 if (
ltable[idx].numIter != 0) {
209 DPRINTF(LTage,
"Loop End predicted successfully:%lx\n", pc);
213 if (
ltable[idx].numIter < 3) {
221 DPRINTF(LTage,
"Loop End predicted incorrectly:%lx\n", pc);
222 if (
ltable[idx].numIter == 0) {
246 if (
ltable[idx].age == 0) {
248 "Allocating loop pred entry for branch %lx\n",
271 BranchInfo*
bi,
bool prev_pred_taken,
unsigned instShiftAmt)
273 bool pred_taken = prev_pred_taken;
326 unsigned instShiftAmt)
351 .
name(
name() +
".loopPredictorCorrect")
352 .
desc(
"Number of times the loop predictor is the provider and " 353 "the prediction is correct");
356 .
name(
name() +
".loopPredictorWrong")
357 .
desc(
"Number of times the loop predictor is the provider and " 358 "the prediction is wrong");
371 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