1/*
2 * Copyright (c) 2004-2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 373 unchanged lines hidden (view full) ---

382 rob->takeOverFrom();
383}
384
385template <class Impl>
386void
387DefaultCommit<Impl>::updateStatus()
388{
389 // reset ROB changed variable
390 std::list<unsigned>::iterator threads = (*activeThreads).begin();
391 while (threads != (*activeThreads).end()) {
390 std::list<unsigned>::iterator threads = activeThreads->begin();
391 std::list<unsigned>::iterator end = activeThreads->end();
392
393 while (threads != end) {
394 unsigned tid = *threads++;
395
396 changedROBNumEntries[tid] = false;
397
398 // Also check if any of the threads has a trap pending
399 if (commitStatus[tid] == TrapPending ||
400 commitStatus[tid] == FetchTrapPending) {
401 _nextStatus = Active;
402 }
403 }

--- 10 unchanged lines hidden (view full) ---

414}
415
416template <class Impl>
417void
418DefaultCommit<Impl>::setNextStatus()
419{
420 int squashes = 0;
421
419 std::list<unsigned>::iterator threads = (*activeThreads).begin();
422 std::list<unsigned>::iterator threads = activeThreads->begin();
423 std::list<unsigned>::iterator end = activeThreads->end();
424
421 while (threads != (*activeThreads).end()) {
425 while (threads != end) {
426 unsigned tid = *threads++;
427
428 if (commitStatus[tid] == ROBSquashing) {
429 squashes++;
430 }
431 }
432
433 squashCounter = squashes;

--- 4 unchanged lines hidden (view full) ---

438 _nextStatus = Active;
439 }
440}
441
442template <class Impl>
443bool
444DefaultCommit<Impl>::changedROBEntries()
445{
442 std::list<unsigned>::iterator threads = (*activeThreads).begin();
446 std::list<unsigned>::iterator threads = activeThreads->begin();
447 std::list<unsigned>::iterator end = activeThreads->end();
448
444 while (threads != (*activeThreads).end()) {
449 while (threads != end) {
450 unsigned tid = *threads++;
451
452 if (changedROBNumEntries[tid]) {
453 return true;
454 }
455 }
456
457 return false;

--- 106 unchanged lines hidden (view full) ---

564 _nextStatus = Inactive;
565
566 if (drainPending && rob->isEmpty() && !iewStage->hasStoresToWB()) {
567 cpu->signalDrained();
568 drainPending = false;
569 return;
570 }
571
567 if ((*activeThreads).size() <= 0)
572 if (activeThreads->empty())
573 return;
574
570 std::list<unsigned>::iterator threads = (*activeThreads).begin();
575 std::list<unsigned>::iterator threads = activeThreads->begin();
576 std::list<unsigned>::iterator end = activeThreads->end();
577
578 // Check if any of the threads are done squashing. Change the
579 // status if they are done.
574 while (threads != (*activeThreads).end()) {
580 while (threads != end) {
581 unsigned tid = *threads++;
582
583 if (commitStatus[tid] == ROBSquashing) {
584
585 if (rob->isDoneSquashing(tid)) {
586 commitStatus[tid] = Running;
587 } else {
588 DPRINTF(Commit,"[tid:%u]: Still Squashing, cannot commit any"

--- 4 unchanged lines hidden (view full) ---

593 }
594 }
595 }
596
597 commit();
598
599 markCompletedInsts();
600
595 threads = (*activeThreads).begin();
601 threads = activeThreads->begin();
602
597 while (threads != (*activeThreads).end()) {
603 while (threads != end) {
604 unsigned tid = *threads++;
605
606 if (!rob->isEmpty(tid) && rob->readHeadInst(tid)->readyToCommit()) {
607 // The ROB has more instructions it can commit. Its next status
608 // will be active.
609 _nextStatus = Active;
610
611 DynInstPtr inst = rob->readHeadInst(tid);

--- 81 unchanged lines hidden (view full) ---

693 }
694 }
695
696#endif // FULL_SYSTEM
697
698 ////////////////////////////////////
699 // Check for any possible squashes, handle them first
700 ////////////////////////////////////
695 std::list<unsigned>::iterator threads = (*activeThreads).begin();
701 std::list<unsigned>::iterator threads = activeThreads->begin();
702 std::list<unsigned>::iterator end = activeThreads->end();
703
697 while (threads != (*activeThreads).end()) {
704 while (threads != end) {
705 unsigned tid = *threads++;
706
707 // Not sure which one takes priority. I think if we have
708 // both, that's a bad sign.
709 if (trapSquash[tid] == true) {
710 assert(!tcSquash[tid]);
711 squashFromTrap(tid);
712 } else if (tcSquash[tid] == true) {

--- 91 unchanged lines hidden (view full) ---

804 commitInsts();
805 } else {
806#if ISA_HAS_DELAY_SLOT
807 skidInsert();
808#endif
809 }
810
811 //Check for any activity
805 threads = (*activeThreads).begin();
812 threads = activeThreads->begin();
813
807 while (threads != (*activeThreads).end()) {
814 while (threads != end) {
815 unsigned tid = *threads++;
816
817 if (changedROBNumEntries[tid]) {
818 toIEW->commitInfo[tid].usedROB = true;
819 toIEW->commitInfo[tid].freeROBEntries = rob->numFreeEntries(tid);
820
821 if (rob->isEmpty(tid)) {
822 toIEW->commitInfo[tid].emptyROB = true;

--- 150 unchanged lines hidden (view full) ---

973 head_inst->isStoreConditional() ||
974 head_inst->isMemBarrier() ||
975 head_inst->isWriteBarrier()) {
976
977 DPRINTF(Commit, "Encountered a barrier or non-speculative "
978 "instruction [sn:%lli] at the head of the ROB, PC %#x.\n",
979 head_inst->seqNum, head_inst->readPC());
980
974#if !FULL_SYSTEM
981 // Hack to make sure syscalls/memory barriers/quiesces
982 // aren't executed until all stores write back their data.
983 // This direct communication shouldn't be used for
984 // anything other than this.
979 if (inst_num > 0 || iewStage->hasStoresToWB())
980#else
985 if ((head_inst->isMemBarrier() || head_inst->isWriteBarrier() ||
986 head_inst->isQuiesce()) &&
987 iewStage->hasStoresToWB())
984#endif
988 {
989 DPRINTF(Commit, "Waiting for all stores to writeback.\n");
990 return false;
991 } else if (inst_num > 0 || iewStage->hasStoresToWB()) {
992 DPRINTF(Commit, "Waiting to become head of commit.\n");
993 return false;
994 }
995
996 toIEW->commitInfo[tid].nonSpecSeqNum = head_inst->seqNum;
997
998 // Change the instruction so it won't try to commit again until
999 // it is executed.
1000 head_inst->clearCanCommit();
1001

--- 253 unchanged lines hidden (view full) ---

1255 }
1256 }
1257}
1258
1259template <class Impl>
1260bool
1261DefaultCommit<Impl>::robDoneSquashing()
1262{
1257 std::list<unsigned>::iterator threads = (*activeThreads).begin();
1263 std::list<unsigned>::iterator threads = activeThreads->begin();
1264 std::list<unsigned>::iterator end = activeThreads->end();
1265
1259 while (threads != (*activeThreads).end()) {
1266 while (threads != end) {
1267 unsigned tid = *threads++;
1268
1269 if (!rob->isDoneSquashing(tid))
1270 return false;
1271 }
1272
1273 return true;
1274}

--- 62 unchanged lines hidden (view full) ---

1337
1338 case OldestReady:
1339 return oldestReady();
1340
1341 default:
1342 return -1;
1343 }
1344 } else {
1338 int tid = (*activeThreads).front();
1345 assert(!activeThreads->empty());
1346 int tid = activeThreads->front();
1347
1348 if (commitStatus[tid] == Running ||
1349 commitStatus[tid] == Idle ||
1350 commitStatus[tid] == FetchTrapPending) {
1351 return tid;
1352 } else {
1353 return -1;
1354 }

--- 30 unchanged lines hidden (view full) ---

1385
1386template<class Impl>
1387int
1388DefaultCommit<Impl>::oldestReady()
1389{
1390 unsigned oldest = 0;
1391 bool first = true;
1392
1385 std::list<unsigned>::iterator threads = (*activeThreads).begin();
1393 std::list<unsigned>::iterator threads = activeThreads->begin();
1394 std::list<unsigned>::iterator end = activeThreads->end();
1395
1387 while (threads != (*activeThreads).end()) {
1396 while (threads != end) {
1397 unsigned tid = *threads++;
1398
1399 if (!rob->isEmpty(tid) &&
1400 (commitStatus[tid] == Running ||
1401 commitStatus[tid] == Idle ||
1402 commitStatus[tid] == FetchTrapPending)) {
1403
1404 if (rob->isHeadReady(tid)) {

--- 19 unchanged lines hidden ---