@@ -30,91 +30,74 @@ class BTBITTAGE : public TimedBaseBTBPredictor
3030{
3131 using defer = std::shared_ptr<void >;
3232 using bitset = boost::dynamic_bitset<>;
33-
3433 public:
3534 typedef BTBITTAGEParams Params;
3635
3736 struct TageEntry
3837 {
39- public:
40- bool valid;
41- Addr tag;
42- Addr target;
43- short counter;
44- bool useful;
45- Addr pc; // TODO: should use lowest bits only
46-
47- TageEntry () : valid(false ), tag(0 ), target(0 ), counter(0 ), useful(false ), pc(0 ) {}
48-
49- TageEntry (Addr tag, Addr target, short counter, Addr pc)
50- : valid(true ), tag(tag), target(target), counter(counter), useful(false ), pc(pc)
51- {
52- }
53- bool taken () { return counter >= 2 ; }
38+ public:
39+ bool valid;
40+ Addr tag;
41+ Addr target;
42+ short counter;
43+ bool useful;
44+ Addr pc; // TODO: should use lowest bits only
45+
46+ TageEntry () : valid(false ), tag(0 ), target(0 ), counter(0 ), useful(false ), pc(0 ) {}
47+
48+ TageEntry (Addr tag, Addr target, short counter, Addr pc) :
49+ valid (true ), tag(tag), target(target), counter(counter), useful(false ), pc(pc) {}
50+ bool taken () {
51+ return counter >= 2 ;
52+ }
5453 };
5554
5655 struct TageTableInfo
5756 {
58- public:
59- bool found;
60- TageEntry entry;
61- unsigned table;
62- Addr index;
63- Addr tag;
64- TageTableInfo () : found(false ), table(0 ), index(0 ), tag(0 ) {}
65- TageTableInfo (bool found, TageEntry entry, unsigned table, Addr index, Addr tag)
66- : found(found), entry(entry), table(table), index(index), tag(tag)
67- {
68- }
69- bool taken () { return entry.taken (); }
57+ public:
58+ bool found;
59+ TageEntry entry;
60+ unsigned table;
61+ Addr index;
62+ Addr tag;
63+ TageTableInfo () : found(false ), table(0 ), index(0 ), tag(0 ) {}
64+ TageTableInfo (bool found, TageEntry entry, unsigned table, Addr index, Addr tag) :
65+ found (found), entry(entry), table(table), index(index), tag(tag) {}
66+ bool taken () { return entry.taken (); }
7067 };
7168
7269 struct TagePrediction
7370 {
74- public:
75- Addr btb_pc;
76- TageTableInfo mainInfo;
77- TageTableInfo altInfo;
71+ public:
72+ Addr btb_pc;
73+ TageTableInfo mainInfo;
74+ TageTableInfo altInfo;
7875
79- bool useAlt;
80- // bitset usefulMask;
81- // bool taken;
82- Addr target;
76+ bool useAlt;
77+ // bitset usefulMask;
78+ // bool taken;
79+ Addr target;
8380
84- TagePrediction () : btb_pc(0 ), useAlt(false ), target(0 ) {}
81+ TagePrediction () : btb_pc(0 ), useAlt(false ), target(0 ) {}
82+
83+ TagePrediction (Addr btb_pc, TageTableInfo mainInfo, TageTableInfo altInfo,
84+ bool useAlt, Addr target) :
85+ btb_pc (btb_pc), mainInfo(mainInfo), altInfo(altInfo),
86+ useAlt (useAlt), target(target) {}
8587
86- TagePrediction (Addr btb_pc, TageTableInfo mainInfo, TageTableInfo altInfo, bool useAlt, Addr target)
87- : btb_pc(btb_pc), mainInfo(mainInfo), altInfo(altInfo), useAlt(useAlt), target(target)
88- {
89- }
9088 };
9189
9290 public:
93- BTBITTAGE (const Params & p);
91+ BTBITTAGE (const Params& p);
9492
9593 void tickStart () override ;
9694
9795 void tick () override ;
9896 void dryRunCycle (Addr startAddr) override ;
9997 // make predictions, record in stage preds
100- void putPCHistory (Addr startAddr, const boost::dynamic_bitset<> &history,
98+ void putPCHistory (Addr startAddr,
99+ const boost::dynamic_bitset<> &history,
101100 std::vector<FullBTBPrediction> &stagePreds) override ;
102- void putPCHistoryForBlock1 (Addr startAddr, const boost::dynamic_bitset<> &history,
103- const boost::dynamic_bitset<> &phistory, const boost::dynamic_bitset<> &bwhistory,
104- const std::vector<boost::dynamic_bitset<>> &lhistory,
105- std::vector<FullBTBPrediction> &stagePreds, const FullBTBPrediction &lowerPred) override
106- {
107- (void )phistory;
108- (void )bwhistory;
109- (void )lhistory;
110- if (!participatesInBlock1 ()) {
111- for (int s = getDelay (); s < stagePreds.size (); s++) {
112- stagePreds[s].indirectTargets = lowerPred.indirectTargets ;
113- }
114- return ;
115- }
116- putPCHistory (startAddr, history, stagePreds);
117- }
118101
119102 std::shared_ptr<void > getPredictionMeta () override ;
120103
@@ -124,8 +107,8 @@ class BTBITTAGE : public TimedBaseBTBPredictor
124107
125108 // Recover 3 folded history after a misprediction, then update 3 folded history according to history and pred.taken
126109 // the other recoverHist methods are left blank
127- void recoverPHist (const boost::dynamic_bitset<> &history, const FetchTarget &entry, int shamt,
128- bool cond_taken) override ;
110+ void recoverPHist (const boost::dynamic_bitset<> &history,
111+ const FetchTarget &entry, int shamt, bool cond_taken) override ;
129112
130113 void update (const FetchTarget &entry) override ;
131114
@@ -135,8 +118,9 @@ class BTBITTAGE : public TimedBaseBTBPredictor
135118 void checkFoldedHist (const bitset &history, const char *when);
136119
137120 private:
121+
138122 // return provided
139- void lookupHelper (Addr stream_start, const std::vector<BTBEntry> &btbEntries, IndirectTargets & results);
123+ void lookupHelper (Addr stream_start, const std::vector<BTBEntry> &btbEntries, IndirectTargets& results);
140124
141125 // use blockPC
142126 Addr getTageIndex (Addr pc, int table);
@@ -150,7 +134,9 @@ class BTBITTAGE : public TimedBaseBTBPredictor
150134 // use blockPC (uint64_t version for performance)
151135 Addr getTageTag (Addr pc, int table, uint64_t foldedHist, uint64_t altFoldedHist);
152136
153- Addr getOffset (Addr pc) { return (pc & (blockSize - 1 )) >> 1 ; }
137+ Addr getOffset (Addr pc) {
138+ return (pc & (blockSize - 1 )) >> 1 ;
139+ }
154140
155141 // Update branch history
156142 void doUpdateHist (const bitset &history, bool taken, Addr pc, Addr target);
@@ -188,7 +174,7 @@ class BTBITTAGE : public TimedBaseBTBPredictor
188174
189175 unsigned numBr;
190176
191- unsigned instShiftAmt{1 };
177+ unsigned instShiftAmt {1 };
192178
193179 void updateCounter (bool taken, unsigned width, short &counter);
194180
@@ -229,7 +215,7 @@ class BTBITTAGE : public TimedBaseBTBPredictor
229215 statistics::Distribution updateTableHits;
230216
231217 int numPredictors;
232- IttageStats (statistics::Group * parent, int numPredictors);
218+ IttageStats (statistics::Group* parent, int numPredictors);
233219#endif
234220 Scalar commitHits;
235221 Scalar callHits;
@@ -277,12 +263,13 @@ class BTBITTAGE : public TimedBaseBTBPredictor
277263
278264 std::shared_ptr<TageMeta> meta;
279265
280- public:
266+ public:
267+
281268 Addr debugPC = 0 ;
282269 Addr debugPC2 = 0 ;
283270 bool debugFlag = false ;
284271
285- void recoverFoldedHist (const bitset & history);
272+ void recoverFoldedHist (const bitset& history);
286273 bool tageHit ();
287274
288275 // void checkFoldedHist(const bitset& history);
0 commit comments