tournament.cc (9360:515891d9057a) | tournament.cc (9480:d059f8a95a42) |
---|---|
1/* 2 * Copyright (c) 2011 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 --- 30 unchanged lines hidden (view full) --- 39 * 40 * Authors: Kevin Lim 41 */ 42 43#include "base/bitfield.hh" 44#include "base/intmath.hh" 45#include "cpu/pred/tournament.hh" 46 | 1/* 2 * Copyright (c) 2011 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 --- 30 unchanged lines hidden (view full) --- 39 * 40 * Authors: Kevin Lim 41 */ 42 43#include "base/bitfield.hh" 44#include "base/intmath.hh" 45#include "cpu/pred/tournament.hh" 46 |
47TournamentBP::TournamentBP(unsigned _localCtrBits, 48 unsigned _localHistoryTableSize, 49 unsigned _localHistoryBits, 50 unsigned _globalPredictorSize, 51 unsigned _globalHistoryBits, 52 unsigned _globalCtrBits, 53 unsigned _choicePredictorSize, 54 unsigned _choiceCtrBits, 55 unsigned _instShiftAmt) 56 : localCtrBits(_localCtrBits), 57 localHistoryTableSize(_localHistoryTableSize), 58 localHistoryBits(_localHistoryBits), 59 globalPredictorSize(_globalPredictorSize), 60 globalCtrBits(_globalCtrBits), 61 globalHistoryBits(_globalHistoryBits), 62 choicePredictorSize(_choicePredictorSize), 63 choiceCtrBits(_choiceCtrBits), 64 instShiftAmt(_instShiftAmt) | 47TournamentBP::TournamentBP(const Params *params) 48 : BPredUnit(params), 49 localCtrBits(params->localCtrBits), 50 localHistoryTableSize(params->localHistoryTableSize), 51 localHistoryBits(params->localHistoryBits), 52 globalPredictorSize(params->globalPredictorSize), 53 globalCtrBits(params->globalCtrBits), 54 globalHistoryBits(params->globalHistoryBits), 55 choicePredictorSize(params->choicePredictorSize), 56 choiceCtrBits(params->choiceCtrBits), 57 instShiftAmt(params->instShiftAmt) |
65{ 66 localPredictorSize = ULL(1) << localHistoryBits; 67 68 //Set up the array of counters for the local predictor 69 localCtrs.resize(localPredictorSize); 70 71 for (int i = 0; i < localPredictorSize; ++i) 72 localCtrs[i].setBits(localCtrBits); --- 100 unchanged lines hidden (view full) --- 173TournamentBP::updateLocalHistNotTaken(unsigned local_history_idx) 174{ 175 localHistoryTable[local_history_idx] = 176 (localHistoryTable[local_history_idx] << 1); 177} 178 179 180void | 58{ 59 localPredictorSize = ULL(1) << localHistoryBits; 60 61 //Set up the array of counters for the local predictor 62 localCtrs.resize(localPredictorSize); 63 64 for (int i = 0; i < localPredictorSize; ++i) 65 localCtrs[i].setBits(localCtrBits); --- 100 unchanged lines hidden (view full) --- 166TournamentBP::updateLocalHistNotTaken(unsigned local_history_idx) 167{ 168 localHistoryTable[local_history_idx] = 169 (localHistoryTable[local_history_idx] << 1); 170} 171 172 173void |
181TournamentBP::BTBUpdate(Addr &branch_addr, void * &bp_history) | 174TournamentBP::btbUpdate(Addr branch_addr, void * &bp_history) |
182{ 183 unsigned local_history_idx = calcLocHistIdx(branch_addr); 184 //Update Global History to Not Taken (clear LSB) 185 globalHistory &= (historyRegisterMask & ~ULL(1)); 186 //Update Local History to Not Taken 187 localHistoryTable[local_history_idx] = 188 localHistoryTable[local_history_idx] & (localPredictorMask & ~ULL(1)); 189} 190 191bool | 175{ 176 unsigned local_history_idx = calcLocHistIdx(branch_addr); 177 //Update Global History to Not Taken (clear LSB) 178 globalHistory &= (historyRegisterMask & ~ULL(1)); 179 //Update Local History to Not Taken 180 localHistoryTable[local_history_idx] = 181 localHistoryTable[local_history_idx] & (localPredictorMask & ~ULL(1)); 182} 183 184bool |
192TournamentBP::lookup(Addr &branch_addr, void * &bp_history) | 185TournamentBP::lookup(Addr branch_addr, void * &bp_history) |
193{ 194 bool local_prediction; 195 unsigned local_history_idx; 196 unsigned local_predictor_idx; 197 198 bool global_prediction; 199 bool choice_prediction; 200 --- 43 unchanged lines hidden (view full) --- 244 updateGlobalHistNotTaken(); 245 updateLocalHistNotTaken(local_history_idx); 246 return false; 247 } 248 } 249} 250 251void | 186{ 187 bool local_prediction; 188 unsigned local_history_idx; 189 unsigned local_predictor_idx; 190 191 bool global_prediction; 192 bool choice_prediction; 193 --- 43 unchanged lines hidden (view full) --- 237 updateGlobalHistNotTaken(); 238 updateLocalHistNotTaken(local_history_idx); 239 return false; 240 } 241 } 242} 243 244void |
252TournamentBP::uncondBr(void * &bp_history) | 245TournamentBP::uncondBranch(void * &bp_history) |
253{ 254 // Create BPHistory and pass it back to be recorded. 255 BPHistory *history = new BPHistory; 256 history->globalHistory = globalHistory; 257 history->localPredTaken = true; 258 history->globalPredTaken = true; 259 history->globalUsed = true; 260 history->localHistory = invalidPredictorIndex; 261 bp_history = static_cast<void *>(history); 262 263 updateGlobalHistTaken(); 264} 265 266void | 246{ 247 // Create BPHistory and pass it back to be recorded. 248 BPHistory *history = new BPHistory; 249 history->globalHistory = globalHistory; 250 history->localPredTaken = true; 251 history->globalPredTaken = true; 252 history->globalUsed = true; 253 history->localHistory = invalidPredictorIndex; 254 bp_history = static_cast<void *>(history); 255 256 updateGlobalHistTaken(); 257} 258 259void |
267TournamentBP::update(Addr &branch_addr, bool taken, void *bp_history, | 260TournamentBP::update(Addr branch_addr, bool taken, void *bp_history, |
268 bool squashed) 269{ 270 unsigned local_history_idx; 271 unsigned local_predictor_idx M5_VAR_USED; 272 unsigned local_predictor_hist; 273 274 // Get the local predictor's current prediction 275 local_history_idx = calcLocHistIdx(branch_addr); --- 100 unchanged lines hidden --- | 261 bool squashed) 262{ 263 unsigned local_history_idx; 264 unsigned local_predictor_idx M5_VAR_USED; 265 unsigned local_predictor_hist; 266 267 // Get the local predictor's current prediction 268 local_history_idx = calcLocHistIdx(branch_addr); --- 100 unchanged lines hidden --- |