O3: When squashing, restore the macroop that should be used for fetching.

This commit is contained in:
Gabe Black 2011-08-14 17:41:34 -07:00
parent ec204f003c
commit 0e6dc00497
4 changed files with 20 additions and 10 deletions

View file

@ -135,6 +135,7 @@ struct TimeBufStruct {
bool branchTaken; bool branchTaken;
Addr mispredPC; Addr mispredPC;
TheISA::PCState nextPC; TheISA::PCState nextPC;
DynInstPtr squashInst;
unsigned branchCount; unsigned branchCount;
}; };

View file

@ -280,6 +280,7 @@ DefaultDecode<Impl>::squash(DynInstPtr &inst, ThreadID tid)
toFetch->decodeInfo[tid].doneSeqNum = inst->seqNum; toFetch->decodeInfo[tid].doneSeqNum = inst->seqNum;
toFetch->decodeInfo[tid].nextPC = inst->branchTarget(); toFetch->decodeInfo[tid].nextPC = inst->branchTarget();
toFetch->decodeInfo[tid].branchTaken = inst->pcState().branching(); toFetch->decodeInfo[tid].branchTaken = inst->pcState().branching();
toFetch->decodeInfo[tid].squashInst = inst;
InstSeqNum squash_seq_num = inst->seqNum; InstSeqNum squash_seq_num = inst->seqNum;

View file

@ -332,13 +332,15 @@ class DefaultFetch
} }
/** Squashes a specific thread and resets the PC. */ /** Squashes a specific thread and resets the PC. */
inline void doSquash(const TheISA::PCState &newPC, ThreadID tid); inline void doSquash(const TheISA::PCState &newPC,
const DynInstPtr squashInst, ThreadID tid);
/** Squashes a specific thread and resets the PC. Also tells the CPU to /** Squashes a specific thread and resets the PC. Also tells the CPU to
* remove any instructions between fetch and decode that should be sqaushed. * remove any instructions between fetch and decode that should be sqaushed.
*/ */
void squashFromDecode(const TheISA::PCState &newPC, void squashFromDecode(const TheISA::PCState &newPC,
const InstSeqNum &seq_num, ThreadID tid); const DynInstPtr squashInst,
const InstSeqNum seq_num, ThreadID tid);
/** Checks if a thread is stalled. */ /** Checks if a thread is stalled. */
bool checkStall(ThreadID tid) const; bool checkStall(ThreadID tid) const;
@ -352,8 +354,8 @@ class DefaultFetch
* remove any instructions that are not in the ROB. The source of this * remove any instructions that are not in the ROB. The source of this
* squash should be the commit stage. * squash should be the commit stage.
*/ */
void squash(const TheISA::PCState &newPC, const InstSeqNum &seq_num, void squash(const TheISA::PCState &newPC, const InstSeqNum seq_num,
DynInstPtr &squashInst, ThreadID tid); DynInstPtr squashInst, ThreadID tid);
/** Ticks the fetch stage, processing all inputs signals and fetching /** Ticks the fetch stage, processing all inputs signals and fetching
* as many instructions as possible. * as many instructions as possible.

View file

@ -746,13 +746,17 @@ DefaultFetch<Impl>::finishTranslation(Fault fault, RequestPtr mem_req)
template <class Impl> template <class Impl>
inline void inline void
DefaultFetch<Impl>::doSquash(const TheISA::PCState &newPC, ThreadID tid) DefaultFetch<Impl>::doSquash(const TheISA::PCState &newPC,
const DynInstPtr squashInst, ThreadID tid)
{ {
DPRINTF(Fetch, "[tid:%i]: Squashing, setting PC to: %s.\n", DPRINTF(Fetch, "[tid:%i]: Squashing, setting PC to: %s.\n",
tid, newPC); tid, newPC);
pc[tid] = newPC; pc[tid] = newPC;
fetchOffset[tid] = 0; fetchOffset[tid] = 0;
if (squashInst && squashInst->pcState().instAddr() == newPC.instAddr())
macroop[tid] = squashInst->macroop;
else
macroop[tid] = NULL; macroop[tid] = NULL;
predecoder.reset(); predecoder.reset();
@ -786,11 +790,12 @@ DefaultFetch<Impl>::doSquash(const TheISA::PCState &newPC, ThreadID tid)
template<class Impl> template<class Impl>
void void
DefaultFetch<Impl>::squashFromDecode(const TheISA::PCState &newPC, DefaultFetch<Impl>::squashFromDecode(const TheISA::PCState &newPC,
const InstSeqNum &seq_num, ThreadID tid) const DynInstPtr squashInst,
const InstSeqNum seq_num, ThreadID tid)
{ {
DPRINTF(Fetch, "[tid:%i]: Squashing from decode.\n", tid); DPRINTF(Fetch, "[tid:%i]: Squashing from decode.\n", tid);
doSquash(newPC, tid); doSquash(newPC, squashInst, tid);
// Tell the CPU to remove any instructions that are in flight between // Tell the CPU to remove any instructions that are in flight between
// fetch and decode. // fetch and decode.
@ -866,12 +871,12 @@ DefaultFetch<Impl>::updateFetchStatus()
template <class Impl> template <class Impl>
void void
DefaultFetch<Impl>::squash(const TheISA::PCState &newPC, DefaultFetch<Impl>::squash(const TheISA::PCState &newPC,
const InstSeqNum &seq_num, DynInstPtr &squashInst, const InstSeqNum seq_num, DynInstPtr squashInst,
ThreadID tid) ThreadID tid)
{ {
DPRINTF(Fetch, "[tid:%u]: Squash from commit.\n", tid); DPRINTF(Fetch, "[tid:%u]: Squash from commit.\n", tid);
doSquash(newPC, tid); doSquash(newPC, squashInst, tid);
// Tell the CPU to remove any instructions that are not in the ROB. // Tell the CPU to remove any instructions that are not in the ROB.
cpu->removeInstsNotInROB(tid); cpu->removeInstsNotInROB(tid);
@ -1052,6 +1057,7 @@ DefaultFetch<Impl>::checkSignalsAndUpdate(ThreadID tid)
DPRINTF(Fetch, "Squashing from decode with PC = %s\n", nextPC); DPRINTF(Fetch, "Squashing from decode with PC = %s\n", nextPC);
// Squash unless we're already squashing // Squash unless we're already squashing
squashFromDecode(fromDecode->decodeInfo[tid].nextPC, squashFromDecode(fromDecode->decodeInfo[tid].nextPC,
fromDecode->decodeInfo[tid].squashInst,
fromDecode->decodeInfo[tid].doneSeqNum, fromDecode->decodeInfo[tid].doneSeqNum,
tid); tid);