36 #include "debug/Fetch.hh"
40 localPredictorSize(params->localPredictorSize),
41 localCtrBits(params->localCtrBits)
44 fatal(
"Invalid local predictor size!\n");
50 fatal(
"Invalid number of local predictor sets! Check localCtrBits.\n");
64 DPRINTF(Fetch,
"local predictor size: %i\n",
69 DPRINTF(Fetch,
"instruction shift amount: %i\n",
96 DPRINTF(Fetch,
"Looking up index %#x\n",
99 counter_val =
localCtrs[local_predictor_idx].read();
101 DPRINTF(Fetch,
"prediction is %i.\n",
109 DPRINTF(Fetch,
"Branch updated as taken.\n");
110 localCtrs[local_predictor_idx].increment();
112 DPRINTF(Fetch,
"Branch updated as not taken.\n");
113 localCtrs[local_predictor_idx].decrement();
124 assert(bp_history == NULL);
125 unsigned local_predictor_idx;
136 DPRINTF(Fetch,
"Looking up index %#x\n", local_predictor_idx);
139 DPRINTF(Fetch,
"Branch updated as taken.\n");
140 localCtrs[local_predictor_idx].increment();
142 DPRINTF(Fetch,
"Branch updated as not taken.\n");
143 localCtrs[local_predictor_idx].decrement();
168 LocalBPParams::create()
Implements a local predictor that uses the PC to index into a table of counters.
unsigned localPredictorSize
Size of the local predictor.
void btbUpdate(ThreadID tid, Addr branch_addr, void *&bp_history)
Updates the branch predictor to Not Taken if a BTB entry is invalid or not found. ...
unsigned indexMask
Mask to get index bits.
virtual void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)
bool lookup(ThreadID tid, Addr branch_addr, void *&bp_history)
Looks up the given address in the branch predictor and returns a true/false value as to whether it is...
unsigned getLocalIndex(Addr &PC)
Calculates the local index based on the PC.
unsigned localPredictorSets
Number of sets.
LocalBP(const LocalBPParams *params)
Default branch predictor constructor.
bool isPowerOf2(const T &n)
std::vector< SatCounter > localCtrs
Array of counters that make up the local predictor.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Basically a wrapper class to hold both the branch predictor and the BTB.
int16_t ThreadID
Thread index/ID type.
unsigned localCtrBits
Number of bits of the local predictor's counters.
const unsigned instShiftAmt
Number of bits to shift instructions by for predictor addresses.
void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history, bool squashed)
Updates the branch predictor with the actual result of a branch.
bool getPrediction(uint8_t &count)
Returns the taken/not taken prediction given the value of the counter.