X86: Make the timing simple CPU handle variable length instructions.
authorGabe Black <gblack@eecs.umich.edu>
Mon, 10 Nov 2008 05:55:01 +0000 (21:55 -0800)
committerGabe Black <gblack@eecs.umich.edu>
Mon, 10 Nov 2008 05:55:01 +0000 (21:55 -0800)
src/cpu/simple/timing.cc

index ca1f0283e3e47e6c40c8af88f6b00039e94b2b47..f5eeeba601868c2266fd872e3cdb45a440324d69 100644 (file)
@@ -561,7 +561,8 @@ TimingSimpleCPU::fetch()
 void
 TimingSimpleCPU::advanceInst(Fault fault)
 {
-    advancePC(fault);
+    if (fault != NoFault || !stayAtPC)
+        advancePC(fault);
 
     if (_status == Running) {
         // kick off fetch of next instruction... callback from icache
@@ -599,7 +600,8 @@ TimingSimpleCPU::completeIfetch(PacketPtr pkt)
     }
 
     preExecute();
-    if (curStaticInst->isMemRef() && !curStaticInst->isDataPrefetch()) {
+    if (curStaticInst &&
+            curStaticInst->isMemRef() && !curStaticInst->isDataPrefetch()) {
         // load or store: just send to dcache
         Fault fault = curStaticInst->initiateAcc(this, traceData);
         if (_status != Running) {
@@ -638,7 +640,7 @@ TimingSimpleCPU::completeIfetch(PacketPtr pkt)
                 instCnt++;
             advanceInst(fault);
         }
-    } else {
+    } else if (curStaticInst) {
         // non-memory instruction: execute completely now
         Fault fault = curStaticInst->execute(this, traceData);
 
@@ -657,6 +659,8 @@ TimingSimpleCPU::completeIfetch(PacketPtr pkt)
                     curStaticInst->isFirstMicroop()))
             instCnt++;
         advanceInst(fault);
+    } else {
+        advanceInst(NoFault);
     }
 
     if (pkt) {