Skip to content

Commit e1c5b82

Browse files
committed
cpu-o3: mark resolved info in potential new entries correctly
Change-Id: I95daed85988b0751001fabafe8f30716e82fa3ba
1 parent 6d0f724 commit e1c5b82

File tree

5 files changed

+28
-21
lines changed

5 files changed

+28
-21
lines changed

src/cpu/pred/btb/abtb.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ AheadBTB::updateBTBEntry(Addr btb_idx, Addr btb_tag, const BTBEntry& entry, cons
521521
// if cond entry in btb now, use the one in btb, since we need the up-to-date counter
522522
// else use the recorded entry
523523
auto entry_to_write = entry.isCond && found ? BTBEntry(*it) : entry;
524+
entry_to_write.resolved = false; // reset resolved bit on update
524525
entry_to_write.tag = btb_tag; // update tag after found it!
525526
// update saturating counter if necessary
526527
if (entry_to_write.isCond) {

src/cpu/pred/btb/btb_tage.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ BTBTAGE::prepareUpdateEntries(const FetchStream &stream) {
399399
if (!new_entry_taken) {
400400
potential_new_entry.alwaysTaken = false;
401401
}
402-
potential_new_entry.resolved = true;
403402
all_entries.push_back(potential_new_entry);
404403
}
405404

src/cpu/pred/btb/decoupled_bpred.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ DecoupledBPUWithBTB::handleSquash(unsigned target_id,
463463
if (squash_type == SQUASH_CTRL && static_inst) {
464464
// Use full branch info with static_inst if available
465465
stream.exeBranchInfo = BranchInfo(squash_pc.instAddr(), redirect_pc, static_inst, control_inst_size);
466+
stream.exeBranchInfo.resolved = true;
466467
dumpFsq("Before control squash");
467468
}
468469

@@ -631,6 +632,7 @@ DecoupledBPUWithBTB::resolveUpdate(unsigned &stream_id)
631632
}
632633
}
633634
}
635+
stream.exeBranchInfo.resolved = false;
634636
}
635637

636638
void

src/cpu/pred/btb/mbtb.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ MBTB::getAndSetNewBTBEntry(FetchStream &stream)
435435
// Get prediction metadata from previous stages
436436
auto meta = std::static_pointer_cast<BTBMeta>(stream.predMetas[getComponentIdx()]);
437437
auto &predBTBEntries = meta->hit_entries;
438-
438+
439439
// Check if this branch was predicted (exists in BTB)
440440
bool pred_branch_hit = false;
441441
BTBEntry entry_to_write = BTBEntry();
@@ -463,6 +463,7 @@ MBTB::getAndSetNewBTBEntry(FetchStream &stream)
463463
}
464464
incNonL0Stat(btbStats.newEntry);
465465
entry_to_write = new_entry;
466+
entry_to_write.resolved = stream.exeBranchInfo.resolved;
466467
is_old_entry = false;
467468
} else {
468469
DPRINTF(BTB, "Not creating new entry: pred_branch_hit=%d, stream.exeTaken=%d\n",
@@ -590,6 +591,7 @@ MBTB::buildUpdatedEntry(const BTBEntry& req_entry,
590591
? BTBEntry(*existing_entry)
591592
: req_entry;
592593
entry_to_write.tag = btb_tag; // update tag
594+
entry_to_write.resolved = false; // reset resolved status
593595

594596
// Update saturating counter and alwaysTaken
595597
if (entry_to_write.isCond) {

src/cpu/pred/btb/stream_struct.hh

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,35 @@ struct BranchInfo
7878
{
7979
Addr pc;
8080
Addr target;
81+
// An independent resolved bit to indicate whether CFI is resolved
82+
// or not for TAGE training, which is trained in resolve stage so
83+
// it's necessary to know whether the branch is resolved and skip
84+
// the BTB entry or not.
85+
bool resolved;
8186
bool isCond;
8287
bool isIndirect;
8388
bool isCall;
8489
bool isReturn;
8590
uint8_t size;
8691
bool isUncond() const { return !this->isCond; }
8792
Addr getEnd() { return this->pc + this->size; }
88-
BranchInfo() : pc(0), target(0), isCond(false), isIndirect(false), isCall(false), isReturn(false), size(0) {}
93+
BranchInfo()
94+
: pc(0), target(0), resolved(false), isCond(false), isIndirect(false), isCall(false), isReturn(false), size(0)
95+
{
96+
}
8997
// BranchInfo(const Addr &pc, const Addr &target_pc, bool is_cond) :
9098
// pc(pc), target(target_pc), isCond(is_cond), isIndirect(false), isCall(false), isReturn(false), size(0) {}
91-
BranchInfo (const Addr &control_pc,
92-
const Addr &target_pc,
93-
const StaticInstPtr &static_inst,
94-
unsigned size) :
95-
pc(control_pc),
96-
target(target_pc),
97-
isCond(static_inst->isCondCtrl()),
98-
isIndirect(static_inst->isIndirectCtrl()),
99-
isCall(static_inst->isCall()),
100-
isReturn(static_inst->isReturn() && !static_inst->isNonSpeculative() && !static_inst->isDirectCtrl()),
101-
size(size) {}
99+
BranchInfo(const Addr &control_pc, const Addr &target_pc, const StaticInstPtr &static_inst, unsigned size)
100+
: pc(control_pc),
101+
target(target_pc),
102+
resolved(false),
103+
isCond(static_inst->isCondCtrl()),
104+
isIndirect(static_inst->isIndirectCtrl()),
105+
isCall(static_inst->isCall()),
106+
isReturn(static_inst->isReturn() && !static_inst->isNonSpeculative() && !static_inst->isDirectCtrl()),
107+
size(size)
108+
{
109+
}
102110
int getType() const {
103111
if (isCond) {
104112
return BR_COND;
@@ -165,16 +173,11 @@ struct BTBEntry : BranchInfo
165173
{
166174
bool valid;
167175
bool alwaysTaken;
168-
// An independent resolved bit to indicate whether CFI is resolved
169-
// or not for TAGE training, which is trained in resolve stage so
170-
// it's necessary to know whether the branch is resolved and skip
171-
// the BTB entry or not.
172-
bool resolved;
173176
int ctr;
174177
Addr tag;
175178
// Addr offset; // retrived from lowest bits of pc
176-
BTBEntry() : valid(false), alwaysTaken(false), resolved(false), ctr(0), tag(0) {}
177-
BTBEntry(const BranchInfo &bi) : BranchInfo(bi), valid(true), alwaysTaken(true), resolved(false), ctr(0) {}
179+
BTBEntry() : valid(false), alwaysTaken(false), ctr(0), tag(0) {}
180+
BTBEntry(const BranchInfo &bi) : BranchInfo(bi), valid(true), alwaysTaken(true), ctr(0) {}
178181
BranchInfo getBranchInfo() { return BranchInfo(*this); }
179182
};
180183

0 commit comments

Comments
 (0)