34 #include "debug/Indirect.hh"
37 unsigned num_sets,
unsigned num_ways,
38 unsigned tag_bits,
unsigned path_len,
unsigned inst_shift,
40 : hashGHR(hash_ghr), hashTargets(hash_targets),
41 numSets(num_sets), numWays(num_ways), tagBits(tag_bits),
42 pathLength(path_len), instShift(inst_shift)
45 panic(
"Indirect predictor requires power of 2 number of sets");
65 DPRINTF(Indirect,
"Looking up %x (set:%d)\n", br_addr, set_index);
67 for (
auto way = iset.begin(); way != iset.end(); ++way) {
68 if (way->tag == tag) {
69 DPRINTF(Indirect,
"Hit %x (target:%s)\n", br_addr, way->target);
74 DPRINTF(Indirect,
"Miss %x\n", br_addr);
82 DPRINTF(Indirect,
"Recording %x seq:%d\n", br_addr, seq_num);
90 DPRINTF(Indirect,
"Committing seq:%d\n", seq_num);
108 DPRINTF(Indirect,
"Squashing seq:%d\n", seq_num);
110 auto squash_itr = t_info.
pathHist.begin();
111 while (squash_itr != t_info.
pathHist.end()) {
112 if (squash_itr->seqNum > seq_num) {
117 if (squash_itr != t_info.
pathHist.end()) {
118 DPRINTF(Indirect,
"Squashing series starting with sn:%d\n",
132 auto hist_entry = *(t_info.
pathHist.rbegin());
137 hist_entry.targetAddr = target.instAddr();
138 t_info.
pathHist.push_back(hist_entry);
143 for (
auto way = iset.begin(); way != iset.end(); ++way) {
144 if (way->tag == tag) {
145 DPRINTF(Indirect,
"Updating Target (seq: %d br:%x set:%d target:"
146 "%s)\n", seq_num, hist_entry.pcAddr, set_index, target);
147 way->target = target;
152 DPRINTF(Indirect,
"Allocating Target (seq: %d br:%x set:%d target:%s)\n",
153 seq_num, hist_entry.pcAddr, set_index, target);
155 auto &way = iset[rand() %
numWays];
174 hash ^= (t_info.
pathHist[
i].targetAddr >>
175 (instShift +
p*hash_shift));
std::vector< ThreadInfo > threadInfo
const unsigned pathLength
std::vector< std::vector< IPredEntry > > targetCache
Addr getTag(Addr br_addr)
Addr getSetIndex(Addr br_addr, unsigned ghr, ThreadID tid)
void commit(InstSeqNum seq_num, ThreadID tid)
bool isPowerOf2(const T &n)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
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 recordTarget(InstSeqNum seq_num, unsigned ghr, const TheISA::PCState &target, ThreadID tid)
IndirectPredictor(bool hash_ghr, bool hash_targets, unsigned num_sets, unsigned num_ways, unsigned tag_bits, unsigned path_len, unsigned inst_shift, unsigned num_threads)
std::deque< HistoryEntry > pathHist
bool lookup(Addr br_addr, unsigned ghr, TheISA::PCState &br_target, ThreadID tid)
void squash(InstSeqNum seq_num, ThreadID tid)