32 #include "debug/Indirect.hh"
35 const SimpleIndirectPredictorParams * params)
37 hashGHR(params->indirectHashGHR),
38 hashTargets(params->indirectHashTargets),
39 numSets(params->indirectSets),
40 numWays(params->indirectWays),
41 tagBits(params->indirectTagSize),
42 pathLength(params->indirectPathLength),
43 instShift(params->instShiftAmt),
44 ghrNumBits(params->indirectGHRBits),
45 ghrMask((1 << params->indirectGHRBits)-1)
48 panic(
"Indirect predictor requires power of 2 number of sets");
63 void* & indirect_history)
68 indirect_history =
new unsigned(
threadInfo[tid].ghr);
82 void * indirect_history,
bool actually_taken)
84 unsigned * previousGhr =
static_cast<unsigned *
>(indirect_history);
85 threadInfo[tid].ghr = ((*previousGhr) << 1) + actually_taken;
98 DPRINTF(Indirect,
"Looking up %x (set:%d)\n", br_addr, set_index);
100 for (
auto way = iset.begin(); way != iset.end(); ++way) {
101 if (way->tag == tag) {
102 DPRINTF(Indirect,
"Hit %x (target:%s)\n", br_addr, way->target);
103 target = way->target;
107 DPRINTF(Indirect,
"Miss %x\n", br_addr);
115 DPRINTF(Indirect,
"Recording %x seq:%d\n", br_addr, seq_num);
122 void * indirect_history)
124 DPRINTF(Indirect,
"Committing seq:%d\n", seq_num);
128 unsigned * previousGhr =
static_cast<unsigned *
>(indirect_history);
131 if (t_info.
pathHist.empty())
return;
146 DPRINTF(Indirect,
"Squashing seq:%d\n", seq_num);
148 auto squash_itr = t_info.
pathHist.begin();
149 while (squash_itr != t_info.
pathHist.end()) {
150 if (squash_itr->seqNum > seq_num) {
155 if (squash_itr != t_info.
pathHist.end()) {
156 DPRINTF(Indirect,
"Squashing series starting with sn:%d\n",
164 void * indirect_history)
166 unsigned * previousGhr =
static_cast<unsigned *
>(indirect_history);
179 unsigned * ghr =
static_cast<unsigned *
>(indirect_history);
182 auto hist_entry = *(t_info.
pathHist.rbegin());
187 hist_entry.targetAddr = target.instAddr();
188 t_info.
pathHist.push_back(hist_entry);
193 for (
auto way = iset.begin(); way != iset.end(); ++way) {
194 if (way->tag == tag) {
195 DPRINTF(Indirect,
"Updating Target (seq: %d br:%x set:%d target:"
196 "%s)\n", seq_num, hist_entry.pcAddr, set_index, target);
197 way->target = target;
202 DPRINTF(Indirect,
"Allocating Target (seq: %d br:%x set:%d target:%s)\n",
203 seq_num, hist_entry.pcAddr, set_index, target);
205 auto &way = iset[rand() %
numWays];
224 hash ^= (t_info.
pathHist[
i].targetAddr >>
238 SimpleIndirectPredictorParams::create()