cpu: split LTAGE implementation into a base TAGE and a derived LTAGE
[gem5.git] / src / cpu / pred / 2bit_local.cc
index 0fd0a10d3b53360bd3549d37684d5a193f64799e..cd97f2bdf587b7fdb7016999c45a2dcdce4a0397 100644 (file)
  * Authors: Kevin Lim
  */
 
+#include "cpu/pred/2bit_local.hh"
+
 #include "base/intmath.hh"
-#include "base/misc.hh"
+#include "base/logging.hh"
 #include "base/trace.hh"
-#include "cpu/pred/2bit_local.hh"
 #include "debug/Fetch.hh"
 
-LocalBP::LocalBP(const Params *params)
+LocalBP::LocalBP(const LocalBPParams *params)
     : BPredUnit(params),
       localPredictorSize(params->localPredictorSize),
-      localCtrBits(params->localCtrBits),
-      instShiftAmt(params->instShiftAmt)
+      localCtrBits(params->localCtrBits)
 {
     if (!isPowerOf2(localPredictorSize)) {
         fatal("Invalid local predictor size!\n");
@@ -79,7 +79,7 @@ LocalBP::reset()
 }
 
 void
-LocalBP::btbUpdate(Addr branch_addr, void * &bp_history)
+LocalBP::btbUpdate(ThreadID tid, Addr branch_addr, void * &bp_history)
 {
 // Place holder for a function that is called to update predictor history when
 // a BTB entry is invalid or not found.
@@ -87,7 +87,7 @@ LocalBP::btbUpdate(Addr branch_addr, void * &bp_history)
 
 
 bool
-LocalBP::lookup(Addr branch_addr, void * &bp_history)
+LocalBP::lookup(ThreadID tid, Addr branch_addr, void * &bp_history)
 {
     bool taken;
     uint8_t counter_val;
@@ -118,11 +118,18 @@ LocalBP::lookup(Addr branch_addr, void * &bp_history)
 }
 
 void
-LocalBP::update(Addr branch_addr, bool taken, void *bp_history, bool squashed)
+LocalBP::update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history,
+                bool squashed)
 {
     assert(bp_history == NULL);
     unsigned local_predictor_idx;
 
+    // No state to restore, and we do not update on the wrong
+    // path.
+    if (squashed) {
+        return;
+    }
+
     // Update the local predictor.
     local_predictor_idx = getLocalIndex(branch_addr);
 
@@ -153,6 +160,12 @@ LocalBP::getLocalIndex(Addr &branch_addr)
 }
 
 void
-LocalBP::uncondBranch(void *&bp_history)
+LocalBP::uncondBranch(ThreadID tid, Addr pc, void *&bp_history)
+{
+}
+
+LocalBP*
+LocalBPParams::create()
 {
+    return new LocalBP(this);
 }