From 37b9966eb466b1655f0d4e604bafa729a3aaea6a Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sat, 16 Dec 2006 07:32:06 -0500 Subject: Made branch delay slots get squashed, and passed back an NPC and NNPC to start fetching from. --HG-- extra : convert_revision : a2e4845fedf113b5a2fd92d3d28ce5b006278103 --- src/cpu/o3/iew_impl.hh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/cpu/o3/iew_impl.hh') diff --git a/src/cpu/o3/iew_impl.hh b/src/cpu/o3/iew_impl.hh index 85db68576..24c8484b4 100644 --- a/src/cpu/o3/iew_impl.hh +++ b/src/cpu/o3/iew_impl.hh @@ -481,25 +481,28 @@ DefaultIEW::squashDueToBranch(DynInstPtr &inst, unsigned tid) toCommit->branchMispredict[tid] = true; #if ISA_HAS_DELAY_SLOT + int instSize = sizeof(TheISA::MachInst); bool branch_taken = - (inst->readNextNPC() != (inst->readPC() + 2 * sizeof(TheISA::MachInst)) && - inst->readNextNPC() != (inst->readPC() + 3 * sizeof(TheISA::MachInst))); + !(inst->readNextPC() + instSize == inst->readNextNPC() && + (inst->readNextPC() == inst->readPC() + instSize || + inst->readNextPC() == inst->readPC() + 2 * instSize)); DPRINTF(Sparc, "Branch taken = %s [sn:%i]\n", branch_taken ? "true": "false", inst->seqNum); toCommit->branchTaken[tid] = branch_taken; - bool squashDelaySlot = - (inst->readNextPC() != inst->readPC() + sizeof(TheISA::MachInst)); + bool squashDelaySlot = true; +// (inst->readNextPC() != inst->readPC() + sizeof(TheISA::MachInst)); DPRINTF(Sparc, "Squash delay slot = %s [sn:%i]\n", squashDelaySlot ? "true": "false", inst->seqNum); toCommit->squashDelaySlot[tid] = squashDelaySlot; //If we're squashing the delay slot, we need to pick back up at NextPC. //Otherwise, NextPC isn't being squashed, so we should pick back up at //NextNPC. - if (squashDelaySlot) + if (squashDelaySlot) { toCommit->nextPC[tid] = inst->readNextPC(); - else + toCommit->nextNPC[tid] = inst->readNextNPC(); + } else toCommit->nextPC[tid] = inst->readNextNPC(); #else toCommit->branchTaken[tid] = inst->readNextPC() != @@ -522,6 +525,9 @@ DefaultIEW::squashDueToMemOrder(DynInstPtr &inst, unsigned tid) toCommit->squash[tid] = true; toCommit->squashedSeqNum[tid] = inst->seqNum; toCommit->nextPC[tid] = inst->readNextPC(); +#if ISA_HAS_DELAY_SLOT + toCommit->nextNPC[tid] = inst->readNextNPC(); +#endif toCommit->includeSquashInst[tid] = false; @@ -538,6 +544,9 @@ DefaultIEW::squashDueToMemBlocked(DynInstPtr &inst, unsigned tid) toCommit->squash[tid] = true; toCommit->squashedSeqNum[tid] = inst->seqNum; toCommit->nextPC[tid] = inst->readPC(); +#if ISA_HAS_DELAY_SLOT + toCommit->nextNPC[tid] = inst->readNextNPC(); +#endif // Must include the broadcasted SN in the squash. toCommit->includeSquashInst[tid] = true; @@ -1342,6 +1351,7 @@ DefaultIEW::executeInsts() fetchRedirect[tid] = true; DPRINTF(IEW, "Execute: Branch mispredict detected.\n"); + DPRINTF(IEW, "Predicted target was %#x.\n", inst->predPC); #if ISA_HAS_DELAY_SLOT DPRINTF(IEW, "Execute: Redirecting fetch to PC: %#x.\n", inst->nextNPC); @@ -1352,7 +1362,7 @@ DefaultIEW::executeInsts() // If incorrect, then signal the ROB that it must be squashed. squashDueToBranch(inst, tid); - if (inst->predTaken()) { + if (inst->readPredTaken()) { predictedTakenIncorrect++; } else { predictedNotTakenIncorrect++; -- cgit v1.2.3