From 5c1742b822c1f4d640d30963a908386caf8c4a6e Mon Sep 17 00:00:00 2001 From: Korey Sewell Date: Sat, 18 Apr 2009 10:42:29 -0400 Subject: o3-delay-slot-bpred: fix decode stage handling of uncdtl. branches.\n decode stage was not setting the predicted PC correctly or passing that information back to fetch correctly --- src/cpu/o3/decode_impl.hh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/cpu/o3/decode_impl.hh') diff --git a/src/cpu/o3/decode_impl.hh b/src/cpu/o3/decode_impl.hh index 015bc8d7f..d92e97f61 100644 --- a/src/cpu/o3/decode_impl.hh +++ b/src/cpu/o3/decode_impl.hh @@ -262,28 +262,30 @@ template void DefaultDecode::squash(DynInstPtr &inst, unsigned tid) { - DPRINTF(Decode, "[tid:%i]: Squashing due to incorrect branch prediction " - "detected at decode.\n", tid); + DPRINTF(Decode, "[tid:%i]: [sn:%i] Squashing due to incorrect branch prediction " + "detected at decode.\n", tid, inst->seqNum); // Send back mispredict information. toFetch->decodeInfo[tid].branchMispredict = true; toFetch->decodeInfo[tid].predIncorrect = true; - toFetch->decodeInfo[tid].doneSeqNum = inst->seqNum; toFetch->decodeInfo[tid].squash = true; - toFetch->decodeInfo[tid].nextPC = inst->branchTarget(); - ///FIXME There needs to be a way to set the nextPC and nextNPC - ///explicitly for ISAs with delay slots. - toFetch->decodeInfo[tid].nextNPC = - inst->branchTarget() + sizeof(TheISA::MachInst); + toFetch->decodeInfo[tid].doneSeqNum = inst->seqNum; toFetch->decodeInfo[tid].nextMicroPC = inst->readMicroPC(); + #if ISA_HAS_DELAY_SLOT + toFetch->decodeInfo[tid].nextPC = inst->readPC() + sizeof(TheISA::MachInst); + toFetch->decodeInfo[tid].nextNPC = inst->branchTarget(); toFetch->decodeInfo[tid].branchTaken = inst->readNextNPC() != (inst->readNextPC() + sizeof(TheISA::MachInst)); #else + toFetch->decodeInfo[tid].nextPC = inst->branchTarget(); + toFetch->decodeInfo[tid].nextNPC = + inst->branchTarget() + sizeof(TheISA::MachInst); toFetch->decodeInfo[tid].branchTaken = inst->readNextPC() != (inst->readPC() + sizeof(TheISA::MachInst)); #endif + InstSeqNum squash_seq_num = inst->seqNum; // Might have to tell fetch to unblock. @@ -738,8 +740,19 @@ DefaultDecode::decodeInsts(unsigned tid) // a check at the end squash(inst, inst->threadNumber); Addr target = inst->branchTarget(); + +#if ISA_HAS_DELAY_SLOT + DPRINTF(Decode, "[sn:%i]: Updating predictions: PredPC: %#x PredNextPC: %#x\n", + inst->seqNum, inst->readPC() + sizeof(TheISA::MachInst), target); + + //The micro pc after an instruction level branch should be 0 + inst->setPredTarg(inst->readPC() + sizeof(TheISA::MachInst), target, 0); +#else + DPRINTF(Decode, "[sn:%i]: Updating predictions: PredPC: %#x PredNextPC: %#x\n", + inst->seqNum, target, target + sizeof(TheISA::MachInst)); //The micro pc after an instruction level branch should be 0 inst->setPredTarg(target, target + sizeof(TheISA::MachInst), 0); +#endif break; } } -- cgit v1.2.3