Deleted Added
sdiff udiff text old ( 7082:070529b41c1e ) new ( 8463:7a48916a32a8 )
full compact
1/*
2 * Copyright (c) 2004-2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

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

31#include "base/intmath.hh"
32#include "cpu/pred/tournament.hh"
33
34TournamentBP::TournamentBP(unsigned _localPredictorSize,
35 unsigned _localCtrBits,
36 unsigned _localHistoryTableSize,
37 unsigned _localHistoryBits,
38 unsigned _globalPredictorSize,
39 unsigned _globalCtrBits,
40 unsigned _globalHistoryBits,
41 unsigned _choicePredictorSize,
42 unsigned _choiceCtrBits,
43 unsigned _instShiftAmt)
44 : localPredictorSize(_localPredictorSize),
45 localCtrBits(_localCtrBits),
46 localHistoryTableSize(_localHistoryTableSize),
47 localHistoryBits(_localHistoryBits),
48 globalPredictorSize(_globalPredictorSize),

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

242 // there was a prediction.
243 if (bp_history) {
244 BPHistory *history = static_cast<BPHistory *>(bp_history);
245 if (history->localPredTaken != history->globalPredTaken) {
246 // If the local prediction matches the actual outcome,
247 // decerement the counter. Otherwise increment the
248 // counter.
249 if (history->localPredTaken == taken) {
250 choiceCtrs[globalHistory].decrement();
251 } else if (history->globalPredTaken == taken){
252 choiceCtrs[globalHistory].increment();
253 }
254 }
255
256 // We're done with this history, now delete it.
257 delete history;
258 }
259
260 assert(globalHistory < globalPredictorSize &&
261 local_history_idx < localHistoryTableSize &&
262 local_predictor_idx < localPredictorSize);
263
264 // Update the counters and local history with the proper
265 // resolution of the branch. Global history is updated
266 // speculatively and restored upon squash() calls, so it does not
267 // need to be updated.
268 if (taken) {
269 localCtrs[local_predictor_idx].increment();
270 globalCtrs[globalHistory].increment();
271
272 updateLocalHistTaken(local_history_idx);
273 } else {
274 localCtrs[local_predictor_idx].decrement();
275 globalCtrs[globalHistory].decrement();
276
277 updateLocalHistNotTaken(local_history_idx);
278 }
279}
280
281void
282TournamentBP::squash(void *bp_history)
283{
284 BPHistory *history = static_cast<BPHistory *>(bp_history);
285
286 // Restore global history to state prior to this branch.
287 globalHistory = history->globalHistory;
288
289 // Delete this BPHistory now that we're done with it.
290 delete history;
291}
292
293#ifdef DEBUG
294int
295TournamentBP::BPHistory::newCount = 0;
296#endif