tournament.hh (11433:72b075cdc336) tournament.hh (11434:b5aed9d2d54e)
1/*
2 * Copyright (c) 2011, 2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 63 unchanged lines hidden (view full) ---

72 /**
73 * Looks up the given address in the branch predictor and returns
74 * a true/false value as to whether it is taken. Also creates a
75 * BPHistory object to store any state it will need on squash/update.
76 * @param branch_addr The address of the branch to look up.
77 * @param bp_history Pointer that will be set to the BPHistory object.
78 * @return Whether or not the branch is taken.
79 */
1/*
2 * Copyright (c) 2011, 2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 63 unchanged lines hidden (view full) ---

72 /**
73 * Looks up the given address in the branch predictor and returns
74 * a true/false value as to whether it is taken. Also creates a
75 * BPHistory object to store any state it will need on squash/update.
76 * @param branch_addr The address of the branch to look up.
77 * @param bp_history Pointer that will be set to the BPHistory object.
78 * @return Whether or not the branch is taken.
79 */
80 bool lookup(Addr branch_addr, void * &bp_history);
80 bool lookup(ThreadID tid, Addr branch_addr, void * &bp_history);
81
82 /**
83 * Records that there was an unconditional branch, and modifies
84 * the bp history to point to an object that has the previous
85 * global history stored in it.
86 * @param bp_history Pointer that will be set to the BPHistory object.
87 */
81
82 /**
83 * Records that there was an unconditional branch, and modifies
84 * the bp history to point to an object that has the previous
85 * global history stored in it.
86 * @param bp_history Pointer that will be set to the BPHistory object.
87 */
88 void uncondBranch(Addr pc, void * &bp_history);
88 void uncondBranch(ThreadID tid, Addr pc, void * &bp_history);
89 /**
90 * Updates the branch predictor to Not Taken if a BTB entry is
91 * invalid or not found.
92 * @param branch_addr The address of the branch to look up.
93 * @param bp_history Pointer to any bp history state.
94 * @return Whether or not the branch is taken.
95 */
89 /**
90 * Updates the branch predictor to Not Taken if a BTB entry is
91 * invalid or not found.
92 * @param branch_addr The address of the branch to look up.
93 * @param bp_history Pointer to any bp history state.
94 * @return Whether or not the branch is taken.
95 */
96 void btbUpdate(Addr branch_addr, void * &bp_history);
96 void btbUpdate(ThreadID tid, Addr branch_addr, void * &bp_history);
97 /**
98 * Updates the branch predictor with the actual result of a branch.
99 * @param branch_addr The address of the branch to update.
100 * @param taken Whether or not the branch was taken.
101 * @param bp_history Pointer to the BPHistory object that was created
102 * when the branch was predicted.
103 * @param squashed is set when this function is called during a squash
104 * operation.
105 */
97 /**
98 * Updates the branch predictor with the actual result of a branch.
99 * @param branch_addr The address of the branch to update.
100 * @param taken Whether or not the branch was taken.
101 * @param bp_history Pointer to the BPHistory object that was created
102 * when the branch was predicted.
103 * @param squashed is set when this function is called during a squash
104 * operation.
105 */
106 void update(Addr branch_addr, bool taken, void *bp_history, bool squashed);
106 void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history,
107 bool squashed);
107
108
108 void retireSquashed(void *bp_history);
109 void retireSquashed(ThreadID tid, void *bp_history);
109
110 /**
111 * Restores the global branch history on a squash.
112 * @param bp_history Pointer to the BPHistory object that has the
113 * previous global branch history in it.
114 */
110
111 /**
112 * Restores the global branch history on a squash.
113 * @param bp_history Pointer to the BPHistory object that has the
114 * previous global branch history in it.
115 */
115 void squash(void *bp_history);
116 void squash(ThreadID tid, void *bp_history);
116
117
117 unsigned getGHR(void *bp_history) const;
118 unsigned getGHR(ThreadID tid, void *bp_history) const;
118
119
119 /** Returns the global history. */
120 inline unsigned readGlobalHist() { return globalHistory; }
121
122 private:
123 /**
124 * Returns if the branch should be taken or not, given a counter
125 * value.
126 * @param count The counter value.
127 */
128 inline bool getPrediction(uint8_t &count);
129
130 /**
131 * Returns the local history index, given a branch address.
132 * @param branch_addr The branch's PC address.
133 */
134 inline unsigned calcLocHistIdx(Addr &branch_addr);
135
136 /** Updates global history as taken. */
120 private:
121 /**
122 * Returns if the branch should be taken or not, given a counter
123 * value.
124 * @param count The counter value.
125 */
126 inline bool getPrediction(uint8_t &count);
127
128 /**
129 * Returns the local history index, given a branch address.
130 * @param branch_addr The branch's PC address.
131 */
132 inline unsigned calcLocHistIdx(Addr &branch_addr);
133
134 /** Updates global history as taken. */
137 inline void updateGlobalHistTaken();
135 inline void updateGlobalHistTaken(ThreadID tid);
138
139 /** Updates global history as not taken. */
136
137 /** Updates global history as not taken. */
140 inline void updateGlobalHistNotTaken();
138 inline void updateGlobalHistNotTaken(ThreadID tid);
141
142 /**
143 * Updates local histories as taken.
144 * @param local_history_idx The local history table entry that
145 * will be updated.
146 */
147 inline void updateLocalHistTaken(unsigned local_history_idx);
148

--- 57 unchanged lines hidden (view full) ---

206 unsigned globalPredictorSize;
207
208 /** Number of bits of the global predictor's counters. */
209 unsigned globalCtrBits;
210
211 /** Global history register. Contains as much history as specified by
212 * globalHistoryBits. Actual number of bits used is determined by
213 * globalHistoryMask and choiceHistoryMask. */
139
140 /**
141 * Updates local histories as taken.
142 * @param local_history_idx The local history table entry that
143 * will be updated.
144 */
145 inline void updateLocalHistTaken(unsigned local_history_idx);
146

--- 57 unchanged lines hidden (view full) ---

204 unsigned globalPredictorSize;
205
206 /** Number of bits of the global predictor's counters. */
207 unsigned globalCtrBits;
208
209 /** Global history register. Contains as much history as specified by
210 * globalHistoryBits. Actual number of bits used is determined by
211 * globalHistoryMask and choiceHistoryMask. */
214 unsigned globalHistory;
212 std::vector<unsigned> globalHistory;
215
216 /** Number of bits for the global history. Determines maximum number of
217 entries in global and choice predictor tables. */
218 unsigned globalHistoryBits;
219
220 /** Mask to apply to globalHistory to access global history table.
221 * Based on globalPredictorSize.*/
222 unsigned globalHistoryMask;

--- 27 unchanged lines hidden ---
213
214 /** Number of bits for the global history. Determines maximum number of
215 entries in global and choice predictor tables. */
216 unsigned globalHistoryBits;
217
218 /** Mask to apply to globalHistory to access global history table.
219 * Based on globalPredictorSize.*/
220 unsigned globalHistoryMask;

--- 27 unchanged lines hidden ---