bpred_unit.cc (13733:e0829ba19545) | bpred_unit.cc (13810:f50e3b82df73) |
---|---|
1/* 2 * Copyright (c) 2011-2012, 2014 ARM Limited 3 * Copyright (c) 2010 The University of Edinburgh 4 * Copyright (c) 2012 Mark D. Hill and David A. Wood 5 * All rights reserved 6 * 7 * The license below extends only to copyright in the software and shall 8 * not be construed as granting a license to any other intellectual --- 56 unchanged lines hidden (view full) --- 65 useIndirect(params->useIndirect), 66 iPred(params->indirectHashGHR, 67 params->indirectHashTargets, 68 params->indirectSets, 69 params->indirectWays, 70 params->indirectTagSize, 71 params->indirectPathLength, 72 params->instShiftAmt, | 1/* 2 * Copyright (c) 2011-2012, 2014 ARM Limited 3 * Copyright (c) 2010 The University of Edinburgh 4 * Copyright (c) 2012 Mark D. Hill and David A. Wood 5 * All rights reserved 6 * 7 * The license below extends only to copyright in the software and shall 8 * not be construed as granting a license to any other intellectual --- 56 unchanged lines hidden (view full) --- 65 useIndirect(params->useIndirect), 66 iPred(params->indirectHashGHR, 67 params->indirectHashTargets, 68 params->indirectSets, 69 params->indirectWays, 70 params->indirectTagSize, 71 params->indirectPathLength, 72 params->instShiftAmt, |
73 params->numThreads), | 73 params->numThreads, 74 params->indirectGHRBits), |
74 instShiftAmt(params->instShiftAmt) 75{ 76 for (auto& r : RAS) 77 r.init(params->RASSize); 78} 79 80void 81BPredUnit::regStats() --- 120 unchanged lines hidden (view full) --- 202 } else { 203 ++condPredicted; 204 pred_taken = lookup(tid, pc.instAddr(), bp_history); 205 206 DPRINTF(Branch, "[tid:%i]: [sn:%i] Branch predictor" 207 " predicted %i for PC %s\n", tid, seqNum, pred_taken, pc); 208 } 209 | 75 instShiftAmt(params->instShiftAmt) 76{ 77 for (auto& r : RAS) 78 r.init(params->RASSize); 79} 80 81void 82BPredUnit::regStats() --- 120 unchanged lines hidden (view full) --- 203 } else { 204 ++condPredicted; 205 pred_taken = lookup(tid, pc.instAddr(), bp_history); 206 207 DPRINTF(Branch, "[tid:%i]: [sn:%i] Branch predictor" 208 " predicted %i for PC %s\n", tid, seqNum, pred_taken, pc); 209 } 210 |
211 const bool orig_pred_taken = pred_taken; |
|
210 if (useIndirect) { | 212 if (useIndirect) { |
211 iPred.updateDirectionInfo(tid, pred_taken, indirect_history); | 213 iPred.genIndirectInfo(tid, indirect_history); |
212 } 213 214 DPRINTF(Branch, "[tid:%i]: [sn:%i] Creating prediction history " 215 "for PC %s\n", tid, seqNum, pc); 216 217 PredictorHistory predict_record(seqNum, pc.instAddr(), pred_taken, 218 bp_history, indirect_history, tid, inst); 219 --- 92 unchanged lines hidden (view full) --- 312 predict_record.wasReturn = true; 313 } 314 TheISA::advancePC(target, inst); 315 } 316 predict_record.target = target.instAddr(); 317 318 pc = target; 319 | 214 } 215 216 DPRINTF(Branch, "[tid:%i]: [sn:%i] Creating prediction history " 217 "for PC %s\n", tid, seqNum, pc); 218 219 PredictorHistory predict_record(seqNum, pc.instAddr(), pred_taken, 220 bp_history, indirect_history, tid, inst); 221 --- 92 unchanged lines hidden (view full) --- 314 predict_record.wasReturn = true; 315 } 316 TheISA::advancePC(target, inst); 317 } 318 predict_record.target = target.instAddr(); 319 320 pc = target; 321 |
322 if (useIndirect) { 323 // Update the indirect predictor with the direction prediction 324 // Note that this happens after indirect lookup, so it does not use 325 // the new information 326 // Note also that we use orig_pred_taken instead of pred_taken in 327 // as this is the actual outcome of the direction prediction 328 iPred.updateDirectionInfo(tid, orig_pred_taken); 329 } 330 |
|
320 predHist[tid].push_front(predict_record); 321 322 DPRINTF(Branch, "[tid:%i]: [sn:%i]: History entry added." 323 "predHist.size(): %i\n", tid, seqNum, predHist[tid].size()); 324 325 return pred_taken; 326} 327 --- 7 unchanged lines hidden (view full) --- 335 predHist[tid].back().seqNum <= done_sn) { 336 // Update the branch predictor with the correct results. 337 update(tid, predHist[tid].back().pc, 338 predHist[tid].back().predTaken, 339 predHist[tid].back().bpHistory, false, 340 predHist[tid].back().inst, 341 predHist[tid].back().target); 342 | 331 predHist[tid].push_front(predict_record); 332 333 DPRINTF(Branch, "[tid:%i]: [sn:%i]: History entry added." 334 "predHist.size(): %i\n", tid, seqNum, predHist[tid].size()); 335 336 return pred_taken; 337} 338 --- 7 unchanged lines hidden (view full) --- 346 predHist[tid].back().seqNum <= done_sn) { 347 // Update the branch predictor with the correct results. 348 update(tid, predHist[tid].back().pc, 349 predHist[tid].back().predTaken, 350 predHist[tid].back().bpHistory, false, 351 predHist[tid].back().inst, 352 predHist[tid].back().target); 353 |
343 iPred.commit(done_sn, tid, predHist[tid].back().indirectHistory); | 354 if (useIndirect) { 355 iPred.commit(done_sn, tid, predHist[tid].back().indirectHistory); 356 } |
344 345 predHist[tid].pop_back(); 346 } 347} 348 349void 350BPredUnit::squash(const InstSeqNum &squashed_sn, ThreadID tid) 351{ 352 History &pred_hist = predHist[tid]; 353 | 357 358 predHist[tid].pop_back(); 359 } 360} 361 362void 363BPredUnit::squash(const InstSeqNum &squashed_sn, ThreadID tid) 364{ 365 History &pred_hist = predHist[tid]; 366 |
354 iPred.squash(squashed_sn, tid); | 367 if (useIndirect) { 368 iPred.squash(squashed_sn, tid); 369 } 370 |
355 while (!pred_hist.empty() && 356 pred_hist.front().seqNum > squashed_sn) { 357 if (pred_hist.front().usedRAS) { 358 DPRINTF(Branch, "[tid:%i]: Restoring top of RAS to: %i," 359 " target: %s.\n", tid, 360 pred_hist.front().RASIndex, pred_hist.front().RASTarget); 361 362 RAS[tid].restore(pred_hist.front().RASIndex, --- 4 unchanged lines hidden (view full) --- 367 " Call [sn:%i] PC: %s Popping RAS\n", tid, 368 pred_hist.front().seqNum, pred_hist.front().pc); 369 RAS[tid].pop(); 370 } 371 372 // This call should delete the bpHistory. 373 squash(tid, pred_hist.front().bpHistory); 374 if (useIndirect) { | 371 while (!pred_hist.empty() && 372 pred_hist.front().seqNum > squashed_sn) { 373 if (pred_hist.front().usedRAS) { 374 DPRINTF(Branch, "[tid:%i]: Restoring top of RAS to: %i," 375 " target: %s.\n", tid, 376 pred_hist.front().RASIndex, pred_hist.front().RASTarget); 377 378 RAS[tid].restore(pred_hist.front().RASIndex, --- 4 unchanged lines hidden (view full) --- 383 " Call [sn:%i] PC: %s Popping RAS\n", tid, 384 pred_hist.front().seqNum, pred_hist.front().pc); 385 RAS[tid].pop(); 386 } 387 388 // This call should delete the bpHistory. 389 squash(tid, pred_hist.front().bpHistory); 390 if (useIndirect) { |
375 iPred.deleteDirectionInfo(tid, pred_hist.front().indirectHistory); | 391 iPred.deleteIndirectInfo(tid, pred_hist.front().indirectHistory); |
376 } 377 378 DPRINTF(Branch, "[tid:%i]: Removing history for [sn:%i] " 379 "PC %s.\n", tid, pred_hist.front().seqNum, 380 pred_hist.front().pc); 381 382 pred_hist.pop_front(); 383 --- 80 unchanged lines hidden (view full) --- 464 DPRINTF(Branch, "[tid: %i] Incorrectly predicted" 465 " return [sn:%i] PC: %s\n", tid, hist_it->seqNum, 466 hist_it->pc); 467 RAS[tid].pop(); 468 hist_it->usedRAS = true; 469 } 470 if (hist_it->wasIndirect) { 471 ++indirectMispredicted; | 392 } 393 394 DPRINTF(Branch, "[tid:%i]: Removing history for [sn:%i] " 395 "PC %s.\n", tid, pred_hist.front().seqNum, 396 pred_hist.front().pc); 397 398 pred_hist.pop_front(); 399 --- 80 unchanged lines hidden (view full) --- 480 DPRINTF(Branch, "[tid: %i] Incorrectly predicted" 481 " return [sn:%i] PC: %s\n", tid, hist_it->seqNum, 482 hist_it->pc); 483 RAS[tid].pop(); 484 hist_it->usedRAS = true; 485 } 486 if (hist_it->wasIndirect) { 487 ++indirectMispredicted; |
472 iPred.recordTarget(hist_it->seqNum, corrTarget, tid); | 488 iPred.recordTarget( 489 hist_it->seqNum, pred_hist.front().indirectHistory, 490 corrTarget, tid); |
473 } else { 474 DPRINTF(Branch,"[tid: %i] BTB Update called for [sn:%i]" 475 " PC: %s\n", tid,hist_it->seqNum, hist_it->pc); 476 477 BTB.update((*hist_it).pc, corrTarget, tid); 478 } 479 } else { 480 //Actually not Taken --- 48 unchanged lines hidden --- | 491 } else { 492 DPRINTF(Branch,"[tid: %i] BTB Update called for [sn:%i]" 493 " PC: %s\n", tid,hist_it->seqNum, hist_it->pc); 494 495 BTB.update((*hist_it).pc, corrTarget, tid); 496 } 497 } else { 498 //Actually not Taken --- 48 unchanged lines hidden --- |