cpu: Add a branch_prediction namespace

Encapsulate all branch-prediction-related files
in a branch_prediction namespace. This will allow
these files to be renamed to drop the BP suffix.

Issued-on: https://gem5.atlassian.net/browse/GEM5-982
Change-Id: I640c0caa846a3aade6fae95e9a93e4318ae9fca0
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47303
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/cpu/minor/fetch2.hh b/src/cpu/minor/fetch2.hh
index 09b7867..41a7a7f 100644
--- a/src/cpu/minor/fetch2.hh
+++ b/src/cpu/minor/fetch2.hh
@@ -93,7 +93,7 @@
     bool processMoreThanOneInput;
 
     /** Branch predictor passed from Python configuration */
-    BPredUnit &branchPredictor;
+    branch_prediction::BPredUnit &branchPredictor;
 
   public:
     /* Public so that Pipeline can pass it to Fetch1 */
diff --git a/src/cpu/o3/fetch.hh b/src/cpu/o3/fetch.hh
index f138718..5bfb01a 100644
--- a/src/cpu/o3/fetch.hh
+++ b/src/cpu/o3/fetch.hh
@@ -411,7 +411,7 @@
     TimeBuffer<FetchStruct>::wire toDecode;
 
     /** BPredUnit. */
-    BPredUnit *branchPred;
+    branch_prediction::BPredUnit *branchPred;
 
     TheISA::PCState pc[MaxThreads];
 
diff --git a/src/cpu/pred/2bit_local.cc b/src/cpu/pred/2bit_local.cc
index 61ce776..c9aa714 100644
--- a/src/cpu/pred/2bit_local.cc
+++ b/src/cpu/pred/2bit_local.cc
@@ -36,6 +36,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 LocalBP::LocalBP(const LocalBPParams &params)
     : BPredUnit(params),
       localPredictorSize(params.localPredictorSize),
@@ -137,4 +140,5 @@
 {
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/2bit_local.hh b/src/cpu/pred/2bit_local.hh
index 8d2a09b..55f45ca 100644
--- a/src/cpu/pred/2bit_local.hh
+++ b/src/cpu/pred/2bit_local.hh
@@ -51,6 +51,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 /**
  * Implements a local predictor that uses the PC to index into a table of
  * counters.  Note that any time a pointer to the bp_history is given, it
@@ -125,6 +128,7 @@
     const unsigned indexMask;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_2BIT_LOCAL_PRED_HH__
diff --git a/src/cpu/pred/BranchPredictor.py b/src/cpu/pred/BranchPredictor.py
index aa8e5cf..c6abebb 100644
--- a/src/cpu/pred/BranchPredictor.py
+++ b/src/cpu/pred/BranchPredictor.py
@@ -31,7 +31,7 @@
 
 class IndirectPredictor(SimObject):
     type = 'IndirectPredictor'
-    cxx_class = 'gem5::IndirectPredictor'
+    cxx_class = 'gem5::branch_prediction::IndirectPredictor'
     cxx_header = "cpu/pred/indirect.hh"
     abstract = True
 
@@ -39,7 +39,7 @@
 
 class SimpleIndirectPredictor(IndirectPredictor):
     type = 'SimpleIndirectPredictor'
-    cxx_class = 'gem5::SimpleIndirectPredictor'
+    cxx_class = 'gem5::branch_prediction::SimpleIndirectPredictor'
     cxx_header = "cpu/pred/simple_indirect.hh"
 
     indirectHashGHR = Param.Bool(True, "Hash branch predictor GHR")
@@ -54,7 +54,7 @@
 
 class BranchPredictor(SimObject):
     type = 'BranchPredictor'
-    cxx_class = 'gem5::BPredUnit'
+    cxx_class = 'gem5::branch_prediction::BPredUnit'
     cxx_header = "cpu/pred/bpred_unit.hh"
     abstract = True
 
@@ -69,7 +69,7 @@
 
 class LocalBP(BranchPredictor):
     type = 'LocalBP'
-    cxx_class = 'gem5::LocalBP'
+    cxx_class = 'gem5::branch_prediction::LocalBP'
     cxx_header = "cpu/pred/2bit_local.hh"
 
     localPredictorSize = Param.Unsigned(2048, "Size of local predictor")
@@ -78,7 +78,7 @@
 
 class TournamentBP(BranchPredictor):
     type = 'TournamentBP'
-    cxx_class = 'gem5::TournamentBP'
+    cxx_class = 'gem5::branch_prediction::TournamentBP'
     cxx_header = "cpu/pred/tournament.hh"
 
     localPredictorSize = Param.Unsigned(2048, "Size of local predictor")
@@ -92,7 +92,7 @@
 
 class BiModeBP(BranchPredictor):
     type = 'BiModeBP'
-    cxx_class = 'gem5::BiModeBP'
+    cxx_class = 'gem5::branch_prediction::BiModeBP'
     cxx_header = "cpu/pred/bi_mode.hh"
 
     globalPredictorSize = Param.Unsigned(8192, "Size of global predictor")
@@ -102,7 +102,7 @@
 
 class TAGEBase(SimObject):
     type = 'TAGEBase'
-    cxx_class = 'gem5::TAGEBase'
+    cxx_class = 'gem5::branch_prediction::TAGEBase'
     cxx_header = "cpu/pred/tage_base.hh"
 
     numThreads = Param.Unsigned(Parent.numThreads, "Number of threads")
@@ -147,8 +147,9 @@
 # The default sizes below are for the 8C-TAGE configuration (63.5 Kbits)
 class TAGE(BranchPredictor):
     type = 'TAGE'
-    cxx_class = 'gem5::TAGE'
+    cxx_class = 'gem5::branch_prediction::TAGE'
     cxx_header = "cpu/pred/tage.hh"
+
     tage = Param.TAGEBase(TAGEBase(), "Tage object")
 
 class LTAGE_TAGE(TAGEBase):
@@ -161,7 +162,7 @@
 
 class LoopPredictor(SimObject):
     type = 'LoopPredictor'
-    cxx_class = 'gem5::LoopPredictor'
+    cxx_class = 'gem5::branch_prediction::LoopPredictor'
     cxx_header = 'cpu/pred/loop_predictor.hh'
 
     logSizeLoopPred = Param.Unsigned(8, "Log size of the loop predictor")
@@ -201,9 +202,10 @@
 
 class TAGE_SC_L_TAGE(TAGEBase):
     type = 'TAGE_SC_L_TAGE'
-    cxx_class = 'gem5::TAGE_SC_L_TAGE'
+    cxx_class = 'gem5::branch_prediction::TAGE_SC_L_TAGE'
     cxx_header = "cpu/pred/tage_sc_l.hh"
     abstract = True
+
     tagTableTagWidths = [0]
     numUseAltOnNa = 16
     pathHistBits = 27
@@ -238,8 +240,9 @@
 
 class TAGE_SC_L_TAGE_64KB(TAGE_SC_L_TAGE):
     type = 'TAGE_SC_L_TAGE_64KB'
-    cxx_class = 'gem5::TAGE_SC_L_TAGE_64KB'
+    cxx_class = 'gem5::branch_prediction::TAGE_SC_L_TAGE_64KB'
     cxx_header = "cpu/pred/tage_sc_l_64KB.hh"
+
     nHistoryTables = 36
 
     minHist = 6
@@ -268,7 +271,7 @@
 
 class TAGE_SC_L_TAGE_8KB(TAGE_SC_L_TAGE):
     type = 'TAGE_SC_L_TAGE_8KB'
-    cxx_class = 'gem5::TAGE_SC_L_TAGE_8KB'
+    cxx_class = 'gem5::branch_prediction::TAGE_SC_L_TAGE_8KB'
     cxx_header = "cpu/pred/tage_sc_l_8KB.hh"
 
     nHistoryTables = 30
@@ -297,7 +300,7 @@
 # The differnt TAGE sizes are updated according to the paper values (256 Kbits)
 class LTAGE(TAGE):
     type = 'LTAGE'
-    cxx_class = 'gem5::LTAGE'
+    cxx_class = 'gem5::branch_prediction::LTAGE'
     cxx_header = "cpu/pred/ltage.hh"
 
     tage = LTAGE_TAGE()
@@ -306,8 +309,9 @@
 
 class TAGE_SC_L_LoopPredictor(LoopPredictor):
     type = 'TAGE_SC_L_LoopPredictor'
-    cxx_class  = 'gem5::TAGE_SC_L_LoopPredictor'
+    cxx_class  = 'gem5::branch_prediction::TAGE_SC_L_LoopPredictor'
     cxx_header = "cpu/pred/tage_sc_l.hh"
+
     loopTableAgeBits = 4
     loopTableConfidenceBits = 4
     loopTableTagBits = 10
@@ -322,7 +326,7 @@
 
 class StatisticalCorrector(SimObject):
     type = 'StatisticalCorrector'
-    cxx_class  = 'gem5::StatisticalCorrector'
+    cxx_class  = 'gem5::branch_prediction::StatisticalCorrector'
     cxx_header = "cpu/pred/statistical_corrector.hh"
     abstract = True
 
@@ -385,7 +389,7 @@
 # of speculation: All the structures/histories are updated at commit time
 class TAGE_SC_L(LTAGE):
     type = 'TAGE_SC_L'
-    cxx_class = 'gem5::TAGE_SC_L'
+    cxx_class = 'gem5::branch_prediction::TAGE_SC_L'
     cxx_header = "cpu/pred/tage_sc_l.hh"
     abstract = True
 
@@ -400,7 +404,7 @@
 
 class TAGE_SC_L_64KB_StatisticalCorrector(StatisticalCorrector):
     type = 'TAGE_SC_L_64KB_StatisticalCorrector'
-    cxx_class  = 'gem5::TAGE_SC_L_64KB_StatisticalCorrector'
+    cxx_class  = 'gem5::branch_prediction::TAGE_SC_L_64KB_StatisticalCorrector'
     cxx_header = "cpu/pred/tage_sc_l_64KB.hh"
 
     pnb = Param.Unsigned(3, "Num variation global branch GEHL lengths")
@@ -446,7 +450,7 @@
 
 class TAGE_SC_L_8KB_StatisticalCorrector(StatisticalCorrector):
     type = 'TAGE_SC_L_8KB_StatisticalCorrector'
-    cxx_class  = 'gem5::TAGE_SC_L_8KB_StatisticalCorrector'
+    cxx_class  = 'gem5::branch_prediction::TAGE_SC_L_8KB_StatisticalCorrector'
     cxx_header = "cpu/pred/tage_sc_l_8KB.hh"
 
     gnb = Param.Unsigned(2, "Num global branch GEHL lengths")
@@ -474,7 +478,7 @@
 # http://www.jilp.org/cbp2016/paper/AndreSeznecLimited.pdf
 class TAGE_SC_L_64KB(TAGE_SC_L):
     type = 'TAGE_SC_L_64KB'
-    cxx_class = 'gem5::TAGE_SC_L_64KB'
+    cxx_class = 'gem5::branch_prediction::TAGE_SC_L_64KB'
     cxx_header = "cpu/pred/tage_sc_l_64KB.hh"
 
     tage = TAGE_SC_L_TAGE_64KB()
@@ -485,7 +489,7 @@
 # http://www.jilp.org/cbp2016/paper/AndreSeznecLimited.pdf
 class TAGE_SC_L_8KB(TAGE_SC_L):
     type = 'TAGE_SC_L_8KB'
-    cxx_class = 'gem5::TAGE_SC_L_8KB'
+    cxx_class = 'gem5::branch_prediction::TAGE_SC_L_8KB'
     cxx_header = "cpu/pred/tage_sc_l_8KB.hh"
 
     tage = TAGE_SC_L_TAGE_8KB()
@@ -494,7 +498,7 @@
 
 class MultiperspectivePerceptron(BranchPredictor):
     type = 'MultiperspectivePerceptron'
-    cxx_class = 'gem5::MultiperspectivePerceptron'
+    cxx_class = 'gem5::branch_prediction::MultiperspectivePerceptron'
     cxx_header = 'cpu/pred/multiperspective_perceptron.hh'
     abstract = True
 
@@ -557,7 +561,7 @@
 
 class MultiperspectivePerceptron8KB(MultiperspectivePerceptron):
     type = 'MultiperspectivePerceptron8KB'
-    cxx_class = 'gem5::MultiperspectivePerceptron8KB'
+    cxx_class = 'gem5::branch_prediction::MultiperspectivePerceptron8KB'
     cxx_header = 'cpu/pred/multiperspective_perceptron_8KB.hh'
 
     budgetbits = 8192 * 8 + 2048
@@ -569,7 +573,7 @@
 
 class MultiperspectivePerceptron64KB(MultiperspectivePerceptron):
     type = 'MultiperspectivePerceptron64KB'
-    cxx_class = 'gem5::MultiperspectivePerceptron64KB'
+    cxx_class = 'gem5::branch_prediction::MultiperspectivePerceptron64KB'
     cxx_header = 'cpu/pred/multiperspective_perceptron_64KB.hh'
 
     budgetbits = 65536 * 8 + 2048
@@ -581,7 +585,7 @@
 
 class MPP_TAGE(TAGEBase):
     type = 'MPP_TAGE'
-    cxx_class = 'gem5::MPP_TAGE'
+    cxx_class = 'gem5::branch_prediction::MPP_TAGE'
     cxx_header = 'cpu/pred/multiperspective_perceptron_tage.hh'
 
     nHistoryTables = 15
@@ -603,7 +607,7 @@
 
 class MPP_LoopPredictor(LoopPredictor):
     type = 'MPP_LoopPredictor'
-    cxx_class = 'gem5::MPP_LoopPredictor'
+    cxx_class = 'gem5::branch_prediction::MPP_LoopPredictor'
     cxx_header = 'cpu/pred/multiperspective_perceptron_tage.hh'
 
     useDirectionBit = True
@@ -621,7 +625,7 @@
 
 class MPP_StatisticalCorrector(StatisticalCorrector):
     type = 'MPP_StatisticalCorrector'
-    cxx_class = 'gem5::MPP_StatisticalCorrector'
+    cxx_class = 'gem5::branch_prediction::MPP_StatisticalCorrector'
     cxx_header = 'cpu/pred/multiperspective_perceptron_tage.hh'
     abstract = True
 
@@ -657,7 +661,7 @@
 
 class MultiperspectivePerceptronTAGE(MultiperspectivePerceptron):
     type = 'MultiperspectivePerceptronTAGE'
-    cxx_class = 'gem5::MultiperspectivePerceptronTAGE'
+    cxx_class = 'gem5::branch_prediction::MultiperspectivePerceptronTAGE'
     cxx_header = 'cpu/pred/multiperspective_perceptron_tage.hh'
     abstract = True
 
@@ -679,7 +683,7 @@
 
 class MPP_StatisticalCorrector_64KB(MPP_StatisticalCorrector):
     type = 'MPP_StatisticalCorrector_64KB'
-    cxx_class = 'gem5::MPP_StatisticalCorrector_64KB'
+    cxx_class = 'gem5::branch_prediction::MPP_StatisticalCorrector_64KB'
     cxx_header = 'cpu/pred/multiperspective_perceptron_tage_64KB.hh'
 
     logBias = 8
@@ -703,7 +707,7 @@
 
 class MultiperspectivePerceptronTAGE64KB(MultiperspectivePerceptronTAGE):
     type = 'MultiperspectivePerceptronTAGE64KB'
-    cxx_class = 'gem5::MultiperspectivePerceptronTAGE64KB'
+    cxx_class = 'gem5::branch_prediction::MultiperspectivePerceptronTAGE64KB'
     cxx_header = 'cpu/pred/multiperspective_perceptron_tage_64KB.hh'
 
     budgetbits = 65536 * 8 + 2048
@@ -714,7 +718,7 @@
 
 class MPP_TAGE_8KB(MPP_TAGE):
     type = 'MPP_TAGE_8KB'
-    cxx_class = 'gem5::MPP_TAGE_8KB'
+    cxx_class = 'gem5::branch_prediction::MPP_TAGE_8KB'
     cxx_header = 'cpu/pred/multiperspective_perceptron_tage_8KB.hh'
 
     nHistoryTables = 10
@@ -724,7 +728,7 @@
 
 class MPP_LoopPredictor_8KB(MPP_LoopPredictor):
     type = 'MPP_LoopPredictor_8KB'
-    cxx_class = 'gem5::MPP_LoopPredictor_8KB'
+    cxx_class = 'gem5::branch_prediction::MPP_LoopPredictor_8KB'
     cxx_header = 'cpu/pred/multiperspective_perceptron_tage_8KB.hh'
 
     loopTableIterBits = 10
@@ -732,7 +736,7 @@
 
 class MPP_StatisticalCorrector_8KB(MPP_StatisticalCorrector):
     type = 'MPP_StatisticalCorrector_8KB'
-    cxx_class = 'gem5::MPP_StatisticalCorrector_8KB'
+    cxx_class = 'gem5::branch_prediction::MPP_StatisticalCorrector_8KB'
     cxx_header = 'cpu/pred/multiperspective_perceptron_tage_8KB.hh'
 
     logBias = 7
@@ -749,7 +753,7 @@
 
 class MultiperspectivePerceptronTAGE8KB(MultiperspectivePerceptronTAGE):
     type = 'MultiperspectivePerceptronTAGE8KB'
-    cxx_class = 'gem5::MultiperspectivePerceptronTAGE8KB'
+    cxx_class = 'gem5::branch_prediction::MultiperspectivePerceptronTAGE8KB'
     cxx_header = 'cpu/pred/multiperspective_perceptron_tage_8KB.hh'
 
     budgetbits = 8192 * 8 + 2048
diff --git a/src/cpu/pred/bi_mode.cc b/src/cpu/pred/bi_mode.cc
index 230d3a3..40dcbad 100644
--- a/src/cpu/pred/bi_mode.cc
+++ b/src/cpu/pred/bi_mode.cc
@@ -38,6 +38,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 BiModeBP::BiModeBP(const BiModeBPParams &params)
     : BPredUnit(params),
       globalHistoryReg(params.numThreads, 0),
@@ -229,4 +232,5 @@
     globalHistoryReg[tid] &= historyRegisterMask;
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/bi_mode.hh b/src/cpu/pred/bi_mode.hh
index 1135770..721d21b 100644
--- a/src/cpu/pred/bi_mode.hh
+++ b/src/cpu/pred/bi_mode.hh
@@ -40,6 +40,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 /**
  * Implements a bi-mode branch predictor. The bi-mode predictor is a two-level
  * branch predictor that has three seprate history arrays: a taken array, a
@@ -112,6 +115,7 @@
     unsigned notTakenThreshold;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_BI_MODE_PRED_HH__
diff --git a/src/cpu/pred/bpred_unit.cc b/src/cpu/pred/bpred_unit.cc
index a1ffeed..c80fd40 100644
--- a/src/cpu/pred/bpred_unit.cc
+++ b/src/cpu/pred/bpred_unit.cc
@@ -53,6 +53,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 BPredUnit::BPredUnit(const Params &params)
     : SimObject(params),
       numThreads(params.numThreads),
@@ -521,4 +524,5 @@
     }
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/bpred_unit.hh b/src/cpu/pred/bpred_unit.hh
index 11f9452..d6b40e1 100644
--- a/src/cpu/pred/bpred_unit.hh
+++ b/src/cpu/pred/bpred_unit.hh
@@ -58,6 +58,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 /**
  * Basically a wrapper class to hold both the branch predictor
  * and the BTB.
@@ -344,6 +347,7 @@
     /** @} */
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_BPRED_UNIT_HH__
diff --git a/src/cpu/pred/btb.cc b/src/cpu/pred/btb.cc
index 755c69f..a88ce67 100644
--- a/src/cpu/pred/btb.cc
+++ b/src/cpu/pred/btb.cc
@@ -35,6 +35,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 DefaultBTB::DefaultBTB(unsigned _numEntries,
                        unsigned _tagBits,
                        unsigned _instShiftAmt,
@@ -140,4 +143,5 @@
     btb[btb_idx].tag = getTag(instPC);
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/btb.hh b/src/cpu/pred/btb.hh
index 8b99b6e..e3c2f5f 100644
--- a/src/cpu/pred/btb.hh
+++ b/src/cpu/pred/btb.hh
@@ -37,6 +37,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class DefaultBTB
 {
   private:
@@ -131,6 +134,7 @@
     unsigned log2NumThreads;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_BTB_HH__
diff --git a/src/cpu/pred/indirect.hh b/src/cpu/pred/indirect.hh
index 365d0e0..e744a1b 100644
--- a/src/cpu/pred/indirect.hh
+++ b/src/cpu/pred/indirect.hh
@@ -38,6 +38,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class IndirectPredictor : public SimObject
 {
   public:
@@ -66,6 +69,7 @@
                                            bool actually_taken) = 0;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_INDIRECT_BASE_HH__
diff --git a/src/cpu/pred/loop_predictor.cc b/src/cpu/pred/loop_predictor.cc
index 4333d9d8..6574d61 100644
--- a/src/cpu/pred/loop_predictor.cc
+++ b/src/cpu/pred/loop_predictor.cc
@@ -41,6 +41,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 LoopPredictor::LoopPredictor(const LoopPredictorParams &p)
   : SimObject(p), logSizeLoopPred(p.logSizeLoopPred),
     loopTableAgeBits(p.loopTableAgeBits),
@@ -369,4 +372,5 @@
         loopTableAgeBits + useDirectionBit);
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/loop_predictor.hh b/src/cpu/pred/loop_predictor.hh
index e8967f9..44d75ab 100644
--- a/src/cpu/pred/loop_predictor.hh
+++ b/src/cpu/pred/loop_predictor.hh
@@ -43,6 +43,9 @@
 
 struct LoopPredictorParams;
 
+namespace branch_prediction
+{
+
 class LoopPredictor : public SimObject
 {
   protected:
@@ -261,6 +264,7 @@
     size_t getSizeInBits() const;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif//__CPU_PRED_LOOP_PREDICTOR_HH__
diff --git a/src/cpu/pred/ltage.cc b/src/cpu/pred/ltage.cc
index 56375cf..930d6bf 100644
--- a/src/cpu/pred/ltage.cc
+++ b/src/cpu/pred/ltage.cc
@@ -47,6 +47,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 LTAGE::LTAGE(const LTAGEParams &params)
   : TAGE(params), loopPredictor(params.loop_predictor)
 {
@@ -144,4 +147,5 @@
     TAGE::squash(tid, bp_history);
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/ltage.hh b/src/cpu/pred/ltage.hh
index fbd6671..7deaa2b 100644
--- a/src/cpu/pred/ltage.hh
+++ b/src/cpu/pred/ltage.hh
@@ -60,6 +60,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class LTAGE : public TAGE
 {
   public:
@@ -112,6 +115,7 @@
         ThreadID tid, Addr branch_pc, bool cond_branch, void* &b) override;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_LTAGE_HH__
diff --git a/src/cpu/pred/multiperspective_perceptron.cc b/src/cpu/pred/multiperspective_perceptron.cc
index fdb8077..25b4d7d 100644
--- a/src/cpu/pred/multiperspective_perceptron.cc
+++ b/src/cpu/pred/multiperspective_perceptron.cc
@@ -44,6 +44,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 int
 MultiperspectivePerceptron::xlat[] =
     {1,3,4,5,7,8,9,11,12,14,15,17,19,21,23,25,27,29,32,34,37,41,45,49,53,58,63,
@@ -826,4 +829,5 @@
     delete bi;
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/multiperspective_perceptron.hh b/src/cpu/pred/multiperspective_perceptron.hh
index 6a67a7c..68ab5f1 100644
--- a/src/cpu/pred/multiperspective_perceptron.hh
+++ b/src/cpu/pred/multiperspective_perceptron.hh
@@ -48,6 +48,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class MultiperspectivePerceptron : public BPredUnit
 {
   protected:
@@ -1055,6 +1058,7 @@
     void btbUpdate(ThreadID tid, Addr branch_addr, void* &bp_history) override;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif//__CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_HH__
diff --git a/src/cpu/pred/multiperspective_perceptron_64KB.cc b/src/cpu/pred/multiperspective_perceptron_64KB.cc
index e853c0e..39c51c5 100644
--- a/src/cpu/pred/multiperspective_perceptron_64KB.cc
+++ b/src/cpu/pred/multiperspective_perceptron_64KB.cc
@@ -42,6 +42,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 MultiperspectivePerceptron64KB::MultiperspectivePerceptron64KB(
         const MultiperspectivePerceptron64KBParams &p)
     : MultiperspectivePerceptron(p)
@@ -89,4 +92,5 @@
     addSpec(new SGHISTPATH(1, 5, 2, 1.3125, 972, 6, *this));
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/multiperspective_perceptron_64KB.hh b/src/cpu/pred/multiperspective_perceptron_64KB.hh
index 10851fa..5e893c2 100644
--- a/src/cpu/pred/multiperspective_perceptron_64KB.hh
+++ b/src/cpu/pred/multiperspective_perceptron_64KB.hh
@@ -46,6 +46,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class MultiperspectivePerceptron64KB : public MultiperspectivePerceptron
 {
     void createSpecs() override;
@@ -54,6 +57,7 @@
             const MultiperspectivePerceptron64KBParams &p);
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_64KB_HH__
diff --git a/src/cpu/pred/multiperspective_perceptron_8KB.cc b/src/cpu/pred/multiperspective_perceptron_8KB.cc
index b341ada..3a3dbd8 100644
--- a/src/cpu/pred/multiperspective_perceptron_8KB.cc
+++ b/src/cpu/pred/multiperspective_perceptron_8KB.cc
@@ -42,6 +42,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 MultiperspectivePerceptron8KB::MultiperspectivePerceptron8KB(
         const MultiperspectivePerceptron8KBParams &p)
     : MultiperspectivePerceptron(p)
@@ -68,4 +71,5 @@
     addSpec(new SGHISTPATH(1, 2, 5, 2.53125, 0, 5, *this));
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/multiperspective_perceptron_8KB.hh b/src/cpu/pred/multiperspective_perceptron_8KB.hh
index 58d1d02..085b674 100644
--- a/src/cpu/pred/multiperspective_perceptron_8KB.hh
+++ b/src/cpu/pred/multiperspective_perceptron_8KB.hh
@@ -46,6 +46,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class MultiperspectivePerceptron8KB : public MultiperspectivePerceptron
 {
     void createSpecs() override;
@@ -54,6 +57,7 @@
             const MultiperspectivePerceptron8KBParams &p);
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_8KB_HH__
diff --git a/src/cpu/pred/multiperspective_perceptron_tage.cc b/src/cpu/pred/multiperspective_perceptron_tage.cc
index f0da006..67c470f 100644
--- a/src/cpu/pred/multiperspective_perceptron_tage.cc
+++ b/src/cpu/pred/multiperspective_perceptron_tage.cc
@@ -43,6 +43,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 void
 MPP_TAGE::calculateParameters()
 {
@@ -684,4 +687,5 @@
     delete bi;
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/multiperspective_perceptron_tage.hh b/src/cpu/pred/multiperspective_perceptron_tage.hh
index b79c06b..3a92e3c 100644
--- a/src/cpu/pred/multiperspective_perceptron_tage.hh
+++ b/src/cpu/pred/multiperspective_perceptron_tage.hh
@@ -51,6 +51,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class MPP_TAGE : public TAGEBase
 {
     std::vector<unsigned int> tunedHistoryLengths;
@@ -242,6 +245,7 @@
 
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif//__CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_TAGE_HH__
diff --git a/src/cpu/pred/multiperspective_perceptron_tage_64KB.cc b/src/cpu/pred/multiperspective_perceptron_tage_64KB.cc
index af1d5c5..2d7b991 100644
--- a/src/cpu/pred/multiperspective_perceptron_tage_64KB.cc
+++ b/src/cpu/pred/multiperspective_perceptron_tage_64KB.cc
@@ -42,6 +42,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 MPP_StatisticalCorrector_64KB::MPP_StatisticalCorrector_64KB(
     const MPP_StatisticalCorrector_64KBParams &p)
   : MPP_StatisticalCorrector(p),
@@ -219,4 +222,5 @@
     addSpec(new ACYCLIC(12, -1, -1, 2.0, 0, 6, *this));
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/multiperspective_perceptron_tage_64KB.hh b/src/cpu/pred/multiperspective_perceptron_tage_64KB.hh
index 41b7ae7..88d041f 100644
--- a/src/cpu/pred/multiperspective_perceptron_tage_64KB.hh
+++ b/src/cpu/pred/multiperspective_perceptron_tage_64KB.hh
@@ -46,6 +46,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class MPP_StatisticalCorrector_64KB : public MPP_StatisticalCorrector
 {
     const unsigned numEntriesSecondLocalHistories;
@@ -89,6 +92,7 @@
             const MultiperspectivePerceptronTAGE64KBParams &p);
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_TAGE_64KB_HH__
diff --git a/src/cpu/pred/multiperspective_perceptron_tage_8KB.cc b/src/cpu/pred/multiperspective_perceptron_tage_8KB.cc
index 8d8ce3b..72d3114 100644
--- a/src/cpu/pred/multiperspective_perceptron_tage_8KB.cc
+++ b/src/cpu/pred/multiperspective_perceptron_tage_8KB.cc
@@ -42,6 +42,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 MPP_StatisticalCorrector_8KB::MPP_StatisticalCorrector_8KB(
         const MPP_StatisticalCorrector_8KBParams &p)
   : MPP_StatisticalCorrector(p)
@@ -174,4 +177,5 @@
     addSpec(new IMLI(4, 1.98, 0, 6, *this));
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/multiperspective_perceptron_tage_8KB.hh b/src/cpu/pred/multiperspective_perceptron_tage_8KB.hh
index 3adbcd4..62d72b6 100644
--- a/src/cpu/pred/multiperspective_perceptron_tage_8KB.hh
+++ b/src/cpu/pred/multiperspective_perceptron_tage_8KB.hh
@@ -49,6 +49,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class MPP_TAGE_8KB : public MPP_TAGE
 {
   public:
@@ -88,6 +91,7 @@
             const MultiperspectivePerceptronTAGE8KBParams &p);
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_TAGE_8KB_HH__
diff --git a/src/cpu/pred/ras.cc b/src/cpu/pred/ras.cc
index 49969b7..6a81446 100644
--- a/src/cpu/pred/ras.cc
+++ b/src/cpu/pred/ras.cc
@@ -31,6 +31,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 void
 ReturnAddrStack::init(unsigned _numEntries)
 {
@@ -83,4 +86,5 @@
     }
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/ras.hh b/src/cpu/pred/ras.hh
index a41ab88..6edcc0e 100644
--- a/src/cpu/pred/ras.hh
+++ b/src/cpu/pred/ras.hh
@@ -38,6 +38,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 /** Return address stack class, implements a simple RAS. */
 class ReturnAddrStack
 {
@@ -100,6 +103,7 @@
     unsigned tos;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_RAS_HH__
diff --git a/src/cpu/pred/simple_indirect.cc b/src/cpu/pred/simple_indirect.cc
index 7e9998f..7fd75f4 100644
--- a/src/cpu/pred/simple_indirect.cc
+++ b/src/cpu/pred/simple_indirect.cc
@@ -34,6 +34,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 SimpleIndirectPredictor::SimpleIndirectPredictor(
         const SimpleIndirectPredictorParams &params)
     : IndirectPredictor(params),
@@ -237,4 +240,5 @@
     return (br_addr >> instShift) & ((0x1<<tagBits)-1);
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/simple_indirect.hh b/src/cpu/pred/simple_indirect.hh
index a66b484..0949a76 100644
--- a/src/cpu/pred/simple_indirect.hh
+++ b/src/cpu/pred/simple_indirect.hh
@@ -39,6 +39,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class SimpleIndirectPredictor : public IndirectPredictor
 {
   public:
@@ -102,6 +105,7 @@
     std::vector<ThreadInfo> threadInfo;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_INDIRECT_HH__
diff --git a/src/cpu/pred/statistical_corrector.cc b/src/cpu/pred/statistical_corrector.cc
index c50686d..d5b32cc 100644
--- a/src/cpu/pred/statistical_corrector.cc
+++ b/src/cpu/pred/statistical_corrector.cc
@@ -46,6 +46,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 StatisticalCorrector::StatisticalCorrector(
     const StatisticalCorrectorParams &p)
   : SimObject(p),
@@ -412,4 +415,5 @@
 {
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/statistical_corrector.hh b/src/cpu/pred/statistical_corrector.hh
index 508fa67..b1c48c2 100644
--- a/src/cpu/pred/statistical_corrector.hh
+++ b/src/cpu/pred/statistical_corrector.hh
@@ -52,6 +52,9 @@
 
 struct StatisticalCorrectorParams;
 
+namespace branch_prediction
+{
+
 class StatisticalCorrector : public SimObject
 {
   protected:
@@ -277,6 +280,7 @@
     virtual size_t getSizeInBits() const;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif//__CPU_PRED_STATISTICAL_CORRECTOR_HH__
diff --git a/src/cpu/pred/tage.cc b/src/cpu/pred/tage.cc
index 0569050..1ba52e2 100644
--- a/src/cpu/pred/tage.cc
+++ b/src/cpu/pred/tage.cc
@@ -47,6 +47,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 TAGE::TAGE(const TAGEParams &params) : BPredUnit(params), tage(params.tage)
 {
 }
@@ -129,4 +132,5 @@
     tage->updateHistories(tid, br_pc, true, bi->tageBranchInfo, true);
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/tage.hh b/src/cpu/pred/tage.hh
index 301c585..568f07b 100644
--- a/src/cpu/pred/tage.hh
+++ b/src/cpu/pred/tage.hh
@@ -58,6 +58,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class TAGE: public BPredUnit
 {
   protected:
@@ -93,6 +96,7 @@
     virtual void squash(ThreadID tid, void *bp_history) override;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_TAGE_HH__
diff --git a/src/cpu/pred/tage_base.cc b/src/cpu/pred/tage_base.cc
index 72e454c..1ff8eba 100644
--- a/src/cpu/pred/tage_base.cc
+++ b/src/cpu/pred/tage_base.cc
@@ -45,6 +45,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 TAGEBase::TAGEBase(const TAGEBaseParams &p)
    : SimObject(p),
      logRatioBiModalHystEntries(p.logRatioBiModalHystEntries),
@@ -802,4 +805,5 @@
     return bits;
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/tage_base.hh b/src/cpu/pred/tage_base.hh
index 7063e6b..4cc83ef 100644
--- a/src/cpu/pred/tage_base.hh
+++ b/src/cpu/pred/tage_base.hh
@@ -59,6 +59,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class TAGEBase : public SimObject
 {
   public:
@@ -508,6 +511,7 @@
     } stats;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_TAGE_BASE_HH__
diff --git a/src/cpu/pred/tage_sc_l.cc b/src/cpu/pred/tage_sc_l.cc
index c1d05fc..615c623 100644
--- a/src/cpu/pred/tage_sc_l.cc
+++ b/src/cpu/pred/tage_sc_l.cc
@@ -48,6 +48,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 bool
 TAGE_SC_L_LoopPredictor::calcConf(int index) const
 {
@@ -462,4 +465,5 @@
     delete bi;
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/tage_sc_l.hh b/src/cpu/pred/tage_sc_l.hh
index c9fe0e9..7dead58 100644
--- a/src/cpu/pred/tage_sc_l.hh
+++ b/src/cpu/pred/tage_sc_l.hh
@@ -52,6 +52,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class TAGE_SC_L_TAGE : public TAGEBase
 {
     const unsigned firstLongTagTable;
@@ -188,6 +191,7 @@
 
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_TAGE_SC_L_HH__
diff --git a/src/cpu/pred/tage_sc_l_64KB.cc b/src/cpu/pred/tage_sc_l_64KB.cc
index aecc935..b42590e 100644
--- a/src/cpu/pred/tage_sc_l_64KB.cc
+++ b/src/cpu/pred/tage_sc_l_64KB.cc
@@ -44,6 +44,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 TAGE_SC_L_64KB_StatisticalCorrector::TAGE_SC_L_64KB_StatisticalCorrector(
     const TAGE_SC_L_64KB_StatisticalCorrectorParams &p)
   : StatisticalCorrector(p),
@@ -311,4 +314,5 @@
 {
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/tage_sc_l_64KB.hh b/src/cpu/pred/tage_sc_l_64KB.hh
index 7dff998..ff3fbac 100644
--- a/src/cpu/pred/tage_sc_l_64KB.hh
+++ b/src/cpu/pred/tage_sc_l_64KB.hh
@@ -53,6 +53,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class TAGE_SC_L_TAGE_64KB : public TAGE_SC_L_TAGE
 {
     public:
@@ -135,6 +138,7 @@
     TAGE_SC_L_64KB(const TAGE_SC_L_64KBParams &params);
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_TAGE_SC_L_64KB_HH__
diff --git a/src/cpu/pred/tage_sc_l_8KB.cc b/src/cpu/pred/tage_sc_l_8KB.cc
index 9218820..04b9588 100644
--- a/src/cpu/pred/tage_sc_l_8KB.cc
+++ b/src/cpu/pred/tage_sc_l_8KB.cc
@@ -47,6 +47,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 TAGE_SC_L_8KB_StatisticalCorrector::TAGE_SC_L_8KB_StatisticalCorrector(
     const TAGE_SC_L_8KB_StatisticalCorrectorParams &p)
   : StatisticalCorrector(p),
@@ -314,4 +317,5 @@
     }
 }
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/tage_sc_l_8KB.hh b/src/cpu/pred/tage_sc_l_8KB.hh
index 54157e0..f93c56a 100644
--- a/src/cpu/pred/tage_sc_l_8KB.hh
+++ b/src/cpu/pred/tage_sc_l_8KB.hh
@@ -50,6 +50,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 class TAGE_SC_L_TAGE_8KB : public TAGE_SC_L_TAGE
 {
   public:
@@ -115,6 +118,7 @@
     TAGE_SC_L_8KB(const TAGE_SC_L_8KBParams &params);
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_TAGE_SC_L_8KB_HH__
diff --git a/src/cpu/pred/tournament.cc b/src/cpu/pred/tournament.cc
index 53d8172..c059b5d 100644
--- a/src/cpu/pred/tournament.cc
+++ b/src/cpu/pred/tournament.cc
@@ -46,6 +46,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 TournamentBP::TournamentBP(const TournamentBPParams &params)
     : BPredUnit(params),
       localPredictorSize(params.localPredictorSize),
@@ -351,4 +354,5 @@
 TournamentBP::BPHistory::newCount = 0;
 #endif
 
+} // namespace branch_prediction
 } // namespace gem5
diff --git a/src/cpu/pred/tournament.hh b/src/cpu/pred/tournament.hh
index 2adeba3..3f2eb25 100644
--- a/src/cpu/pred/tournament.hh
+++ b/src/cpu/pred/tournament.hh
@@ -51,6 +51,9 @@
 namespace gem5
 {
 
+namespace branch_prediction
+{
+
 /**
  * Implements a tournament branch predictor, hopefully identical to the one
  * used in the 21264.  It has a local predictor, which uses a local history
@@ -242,6 +245,7 @@
     unsigned choiceThreshold;
 };
 
+} // namespace branch_prediction
 } // namespace gem5
 
 #endif // __CPU_PRED_TOURNAMENT_PRED_HH__
diff --git a/src/cpu/simple/base.hh b/src/cpu/simple/base.hh
index cee786d..ee75d78 100644
--- a/src/cpu/simple/base.hh
+++ b/src/cpu/simple/base.hh
@@ -71,14 +71,17 @@
 }
 
 struct BaseSimpleCPUParams;
-class BPredUnit;
+namespace branch_prediction
+{
+    class BPredUnit;
+} // namespace branch_prediction
 class SimpleExecContext;
 
 class BaseSimpleCPU : public BaseCPU
 {
   protected:
     ThreadID curThread;
-    BPredUnit *branchPred;
+    branch_prediction::BPredUnit *branchPred;
 
     const RegIndex zeroReg;