49#include "debug/LTage.hh"
50#include "params/LoopPredictor.hh"
112 Addr pc = pc_in >> instShiftAmt;
130 unsigned instShiftAmt)
const
133 bi->loopPredValid =
false;
149 if (
ltable[idx].tag ==
bi->loopTag) {
153 uint16_t iter = speculative ?
ltable[idx].currentIterSpec
154 :
ltable[idx].currentIter;
156 if ((iter + 1) ==
ltable[idx].numIter) {
175 if (
bi->loopHit>=0) {
196 if (
bi->loopHit >= 0) {
198 if (
bi->loopPredValid) {
199 if (taken !=
bi->loopPred) {
203 ltable[idx].confidence = 0;
204 ltable[idx].currentIter = 0;
207 DPRINTF(LTage,
"Loop Prediction success:%lx\n",
pc);
215 ltable[idx].confidence = 0;
216 if (
ltable[idx].numIter != 0) {
227 DPRINTF(LTage,
"Loop End predicted successfully:%lx\n",
pc);
231 if (
ltable[idx].numIter < 3) {
236 ltable[idx].confidence = 0;
239 DPRINTF(LTage,
"Loop End predicted incorrectly:%lx\n",
pc);
240 if (
ltable[idx].numIter == 0) {
242 ltable[idx].confidence = 0;
251 ltable[idx].confidence = 0;
254 ltable[idx].currentIter = 0;
260 int nrand =
rng->random<
int>();
264 if (
ltable[idx].age == 0) {
266 "Allocating loop pred entry for branch %lx\n",
272 ltable[idx].confidence = 0;
289 BranchInfo*
bi,
bool prev_pred_taken,
unsigned instShiftAmt)
291 bool pred_taken = prev_pred_taken;
297 pred_taken =
bi->loopPred;
298 bi->loopPredUsed =
true;
312 if (
bi->loopHit >= 0) {
316 ltable[idx].currentIterSpec =
bi->currentIter;
323 if (
bi->loopHit >= 0) {
327 ltable[idx].currentIterSpec =
bi->currentIter;
334 if (
bi->loopPredUsed) {
336 if (taken ==
bi->loopPred) {
347 unsigned instShiftAmt)
354 bi->loopPred =
getLoop(branch_pc,
bi,
false, instShiftAmt);
357 if (
bi->loopPredValid) {
358 if (
bi->predTaken !=
bi->loopPred) {
360 (
bi->loopPred == taken),
372 "Number of times the loop predictor is the provider."),
374 "Number of times the loop predictor is the provider and the "
375 "prediction is correct"),
377 "Number of times the loop predictor is the provider and the "
378 "prediction is wrong")
virtual bool optionalAgeInc() const
size_t getSizeInBits() const
const unsigned loopTableAgeBits
virtual BranchInfo * makeBranchInfo()
LoopPredictor(const LoopPredictorParams &p)
void updateStats(bool taken, BranchInfo *bi)
Update the stats.
int finallindex(int lindex, int lowPcBits, int way) const
Computes the index used to access the ltable structures.
const unsigned initialLoopIter
static void unsignedCtrUpdate(uint8_t &ctr, bool up, unsigned nbits)
Updates an unsigned counter based on up/down parameter.
const uint16_t loopNumIterMask
static void signedCtrUpdate(int8_t &ctr, bool up, unsigned nbits)
const unsigned loopTableIterBits
const unsigned loopTableConfidenceBits
void specLoopUpdate(bool taken, BranchInfo *bi)
Speculatively updates the loop predictor iteration count (only for useSpeculation).
gem5::branch_prediction::LoopPredictor::LoopPredictorStats stats
const bool useDirectionBit
int lindex(Addr pc_in, unsigned instShiftAmt) const
Computes the index used to access the loop predictor.
const unsigned logLoopTableAssoc
void init() override
Initialize the loop predictor.
void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, bool tage_pred, BranchInfo *bi, unsigned instShiftAmt)
Update LTAGE for conditional branches.
const bool optionalAgeReset
const uint8_t confidenceThreshold
void squashLoop(BranchInfo *bi)
const bool restrictAllocation
virtual bool calcConf(int index) const
const unsigned logSizeLoopPred
bool getLoop(Addr pc, BranchInfo *bi, bool speculative, unsigned instShiftAmt) const
Get a branch prediction from the loop predictor.
bool loopPredict(ThreadID tid, Addr branch_pc, bool cond_branch, BranchInfo *bi, bool prev_pred_taken, unsigned instShiftAmt)
Get the loop prediction.
void loopUpdate(Addr pc, bool Taken, BranchInfo *bi, bool tage_pred)
Updates the loop predictor.
const unsigned loopTableTagBits
void squash(ThreadID tid, BranchInfo *bi)
const unsigned initialLoopAge
const bool useSpeculation
const uint16_t loopTagMask
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
SimObject(const Params &p)
Copyright (c) 2024 Arm Limited All rights reserved.
int16_t ThreadID
Thread index/ID type.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
LoopPredictorStats(statistics::Group *parent)
statistics::Scalar correct