From 26c03495fad2a73242d779b67650a33843d318aa Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 13 May 2021 23:12:19 -0700 Subject: [PATCH] cpu: Stop using macros for constants in the multiperpsective_perceptron. Enums work just as well and respect namespaces and scopes. Change-Id: If726ff325be7114c9a749f5f4e1a193552a24c2b Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45519 Reviewed-by: Gabe Black Maintainer: Gabe Black Tested-by: kokoro --- src/cpu/pred/multiperspective_perceptron.cc | 39 +++++++++++---------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/cpu/pred/multiperspective_perceptron.cc b/src/cpu/pred/multiperspective_perceptron.cc index f46241bf76..3e68e1a039 100644 --- a/src/cpu/pred/multiperspective_perceptron.cc +++ b/src/cpu/pred/multiperspective_perceptron.cc @@ -672,18 +672,21 @@ MultiperspectivePerceptron::update(ThreadID tid, Addr instPC, bool taken, train(tid, *bi, taken); } -#define RECORD_FILTERED_IMLI 1 -#define RECORD_FILTERED_GHIST 2 -#define RECORD_FILTERED_PATH 4 -#define RECORD_FILTERED_ACYCLIC 8 -#define RECORD_FILTERED_MOD 16 -#define RECORD_FILTERED_BLURRY 32 -// should never record a filtered local branch - duh! -#define RECORD_FILTERED_LOCAL 64 -#define RECORD_FILTERED_RECENCY 128 + enum RecordFiltered + { + Imli = 1, + GHist = 2, + Path = 4, + Acyclic = 8, + Mod = 16, + Blurry = 32, + // Should never record a filtered local branch - duh! + Local = 64, + Recency = 128 + }; // four different styles of IMLI - if (!bi->filtered || (record_mask & RECORD_FILTERED_IMLI)) { + if (!bi->filtered || (record_mask & Imli)) { unsigned int target = corrTarget; if (target < bi->getPC()) { if (taken) { @@ -713,7 +716,7 @@ MultiperspectivePerceptron::update(ThreadID tid, Addr instPC, bool taken, bool hashed_taken = hash_taken ? (taken ^ !!(bi->getPC() & (1<filtered || (record_mask & RECORD_FILTERED_GHIST)) { + if (!bi->filtered || (record_mask & GHist)) { bool ab = hashed_taken; assert(threadData[tid]->ghist_words.size() > 0); for (int i = 0; i < ghist_length / blockSize + 1; i += 1) { @@ -728,7 +731,7 @@ MultiperspectivePerceptron::update(ThreadID tid, Addr instPC, bool taken, } // record into path history - if (!bi->filtered || (record_mask & RECORD_FILTERED_PATH)) { + if (!bi->filtered || (record_mask & Path)) { assert(threadData[tid]->path_history.size() > 0); memmove(&threadData[tid]->path_history[1], &threadData[tid]->path_history[0], @@ -737,12 +740,12 @@ MultiperspectivePerceptron::update(ThreadID tid, Addr instPC, bool taken, } // record into acyclic history - if (!bi->filtered || (record_mask & RECORD_FILTERED_ACYCLIC)) { + if (!bi->filtered || (record_mask & Acyclic)) { threadData[tid]->updateAcyclic(hashed_taken, bi->getHPC()); } // record into modulo path history - if (!bi->filtered || (record_mask & RECORD_FILTERED_MOD)) { + if (!bi->filtered || (record_mask & Mod)) { for (int ii = 0; ii < modpath_indices.size(); ii += 1) { int i = modpath_indices[ii]; if (bi->getHPC() % (i + 2) == 0) { @@ -755,7 +758,7 @@ MultiperspectivePerceptron::update(ThreadID tid, Addr instPC, bool taken, } // update blurry history - if (!bi->filtered || (record_mask & RECORD_FILTERED_BLURRY)) { + if (!bi->filtered || (record_mask & Blurry)) { std::vector> &blurrypath_histories = threadData[tid]->blurrypath_histories; @@ -775,7 +778,7 @@ MultiperspectivePerceptron::update(ThreadID tid, Addr instPC, bool taken, } // record into modulo pattern history - if (!bi->filtered || (record_mask & RECORD_FILTERED_MOD)) { + if (!bi->filtered || (record_mask & Mod)) { for (int ii = 0; ii < modhist_indices.size(); ii += 1) { int i = modhist_indices[ii]; if (bi->getHPC() % (i + 2) == 0) { @@ -790,13 +793,13 @@ MultiperspectivePerceptron::update(ThreadID tid, Addr instPC, bool taken, // insert this PC into the recency stack if (doing_recency) { - if (!bi->filtered || (record_mask & RECORD_FILTERED_RECENCY)) { + if (!bi->filtered || (record_mask & Recency)) { threadData[tid]->insertRecency(bi->getPC2(), assoc); } } // record into a local history - if (!bi->filtered || (record_mask & RECORD_FILTERED_LOCAL)) { + if (!bi->filtered || (record_mask & Local)) { threadData[tid]->localHistories.update(bi->getPC(), hashed_taken); }