34 #include "debug/Indirect.hh" 37 const SimpleIndirectPredictorParams * params)
39 hashGHR(params->indirectHashGHR),
40 hashTargets(params->indirectHashTargets),
41 numSets(params->indirectSets),
42 numWays(params->indirectWays),
43 tagBits(params->indirectTagSize),
44 pathLength(params->indirectPathLength),
45 instShift(params->instShiftAmt),
46 ghrNumBits(params->indirectGHRBits),
47 ghrMask((1 << params->indirectGHRBits)-1)
50 panic(
"Indirect predictor requires power of 2 number of sets");
65 void* & indirect_history)
70 indirect_history =
new unsigned(
threadInfo[tid].ghr);
84 void * indirect_history,
bool actually_taken)
86 unsigned * previousGhr =
static_cast<unsigned *
>(indirect_history);
87 threadInfo[tid].ghr = ((*previousGhr) << 1) + actually_taken;
100 DPRINTF(Indirect,
"Looking up %x (set:%d)\n", br_addr, set_index);
102 for (
auto way = iset.begin(); way != iset.end(); ++way) {
103 if (way->tag == tag) {
104 DPRINTF(Indirect,
"Hit %x (target:%s)\n", br_addr, way->target);
105 target = way->target;
109 DPRINTF(Indirect,
"Miss %x\n", br_addr);
117 DPRINTF(Indirect,
"Recording %x seq:%d\n", br_addr, seq_num);
124 void * indirect_history)
126 DPRINTF(Indirect,
"Committing seq:%d\n", seq_num);
130 unsigned * previousGhr =
static_cast<unsigned *
>(indirect_history);
133 if (t_info.
pathHist.empty())
return;
148 DPRINTF(Indirect,
"Squashing seq:%d\n", seq_num);
150 auto squash_itr = t_info.
pathHist.begin();
151 while (squash_itr != t_info.
pathHist.end()) {
152 if (squash_itr->seqNum > seq_num) {
157 if (squash_itr != t_info.
pathHist.end()) {
158 DPRINTF(Indirect,
"Squashing series starting with sn:%d\n",
166 void * indirect_history)
168 unsigned * previousGhr =
static_cast<unsigned *
>(indirect_history);
181 unsigned * ghr =
static_cast<unsigned *
>(indirect_history);
184 auto hist_entry = *(t_info.
pathHist.rbegin());
189 hist_entry.targetAddr = target.instAddr();
190 t_info.
pathHist.push_back(hist_entry);
195 for (
auto way = iset.begin(); way != iset.end(); ++way) {
196 if (way->tag == tag) {
197 DPRINTF(Indirect,
"Updating Target (seq: %d br:%x set:%d target:" 198 "%s)\n", seq_num, hist_entry.pcAddr, set_index, target);
199 way->target = target;
204 DPRINTF(Indirect,
"Allocating Target (seq: %d br:%x set:%d target:%s)\n",
205 seq_num, hist_entry.pcAddr, set_index, target);
207 auto &way = iset[rand() %
numWays];
226 hash ^= (t_info.
pathHist[
i].targetAddr >>
227 (instShift +
p*hash_shift));
240 SimpleIndirectPredictorParams::create()
void changeDirectionPrediction(ThreadID tid, void *indirect_history, bool actually_taken)
#define panic(...)
This implements a cprintf based panic() function.
const unsigned ghrNumBits
std::vector< std::vector< IPredEntry > > targetCache
Addr getSetIndex(Addr br_addr, unsigned ghr, ThreadID tid)
std::vector< ThreadInfo > threadInfo
bool lookup(Addr br_addr, TheISA::PCState &br_target, ThreadID tid)
void commit(InstSeqNum seq_num, ThreadID tid, void *indirect_history)
void genIndirectInfo(ThreadID tid, void *&indirect_history)
bool isPowerOf2(const T &n)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::deque< HistoryEntry > pathHist
void deleteIndirectInfo(ThreadID tid, void *indirect_history)
int16_t ThreadID
Thread index/ID type.
int floorLog2(unsigned x)
void recordIndirect(Addr br_addr, Addr tgt_addr, InstSeqNum seq_num, ThreadID tid)
GenericISA::SimplePCState< MachInst > PCState
void squash(InstSeqNum seq_num, ThreadID tid)
void updateDirectionInfo(ThreadID tid, bool actually_taken)
const unsigned pathLength
void recordTarget(InstSeqNum seq_num, void *indirect_history, const TheISA::PCState &target, ThreadID tid)
Addr getTag(Addr br_addr)
SimpleIndirectPredictor(const SimpleIndirectPredictorParams *params)