40 #include "debug/LTage.hh" 41 #include "params/LoopPredictor.hh" 44 :
SimObject(p), logSizeLoopPred(p->logSizeLoopPred),
45 loopTableAgeBits(p->loopTableAgeBits),
46 loopTableConfidenceBits(p->loopTableConfidenceBits),
47 loopTableTagBits(p->loopTableTagBits),
48 loopTableIterBits(p->loopTableIterBits),
49 logLoopTableAssoc(p->logLoopTableAssoc),
50 confidenceThreshold((1 << loopTableConfidenceBits) - 1),
51 loopTagMask((1 << loopTableTagBits) - 1),
52 loopNumIterMask((1 << loopTableIterBits) - 1),
53 loopSetMask((1 << (logSizeLoopPred - logLoopTableAssoc)) - 1),
55 withLoopBits(p->withLoopBits),
56 useDirectionBit(p->useDirectionBit),
57 useSpeculation(p->useSpeculation),
58 useHashing(p->useHashing),
59 restrictAllocation(p->restrictAllocation),
60 initialLoopIter(p->initialLoopIter),
61 initialLoopAge(p->initialLoopAge),
62 optionalAgeReset(p->optionalAgeReset)
96 Addr pc = pc_in >> instShiftAmt;
114 unsigned instShiftAmt)
const 140 if ((iter + 1) ==
ltable[idx].numIter) {
161 if (taken !=
ltable[index].dir) {
191 DPRINTF(LTage,
"Loop Prediction success:%lx\n",pc);
200 if (
ltable[idx].numIter != 0) {
211 DPRINTF(LTage,
"Loop End predicted successfully:%lx\n", pc);
215 if (
ltable[idx].numIter < 3) {
223 DPRINTF(LTage,
"Loop End predicted incorrectly:%lx\n", pc);
224 if (
ltable[idx].numIter == 0) {
248 if (
ltable[idx].age == 0) {
250 "Allocating loop pred entry for branch %lx\n",
273 BranchInfo*
bi,
bool prev_pred_taken,
unsigned instShiftAmt)
275 bool pred_taken = prev_pred_taken;
328 unsigned instShiftAmt)
353 .
name(
name() +
".loopPredictorCorrect")
354 .
desc(
"Number of times the loop predictor is the provider and " 355 "the prediction is correct");
358 .
name(
name() +
".loopPredictorWrong")
359 .
desc(
"Number of times the loop predictor is the provider and " 360 "the prediction is wrong");
373 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
virtual const std::string name() const
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.
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