base.cc (4495:dbd2943590e6) base.cc (4501:b5f473594687)
1/*
2 * Copyright (c) 2002-2005 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;

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

86 numInst = 0;
87 startNumInst = 0;
88 numLoad = 0;
89 startNumLoad = 0;
90 lastIcacheStall = 0;
91 lastDcacheStall = 0;
92
93 threadContexts.push_back(tc);
1/*
2 * Copyright (c) 2002-2005 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;

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

86 numInst = 0;
87 startNumInst = 0;
88 numLoad = 0;
89 startNumLoad = 0;
90 lastIcacheStall = 0;
91 lastDcacheStall = 0;
92
93 threadContexts.push_back(tc);
94
95 fetchOffset = 0;
96 stayAtPC = false;
94}
95
96BaseSimpleCPU::~BaseSimpleCPU()
97{
98}
99
100void
101BaseSimpleCPU::deallocateContext(int thread_num)

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

332#if ISA_HAS_DELAY_SLOT
333 DPRINTF(Fetch,"Fetch: PC:%08p NPC:%08p NNPC:%08p\n",threadPC,
334 thread->readNextPC(),thread->readNextNPC());
335#else
336 DPRINTF(Fetch,"Fetch: PC:%08p NPC:%08p",threadPC,
337 thread->readNextPC());
338#endif
339
97}
98
99BaseSimpleCPU::~BaseSimpleCPU()
100{
101}
102
103void
104BaseSimpleCPU::deallocateContext(int thread_num)

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

335#if ISA_HAS_DELAY_SLOT
336 DPRINTF(Fetch,"Fetch: PC:%08p NPC:%08p NNPC:%08p\n",threadPC,
337 thread->readNextPC(),thread->readNextNPC());
338#else
339 DPRINTF(Fetch,"Fetch: PC:%08p NPC:%08p",threadPC,
340 thread->readNextPC());
341#endif
342
340 req->setVirt(0, threadPC & ~3, sizeof(MachInst),
341 (FULL_SYSTEM && (threadPC & 1)) ? PHYSICAL : 0,
342 threadPC);
343 const Addr PCMask = ~(sizeof(MachInst) - 1);
344 Addr fetchPC = thread->readPC() + fetchOffset;
345 req->setVirt(0, fetchPC & PCMask, sizeof(MachInst), 0, threadPC());
343
344 Fault fault = thread->translateInstReq(req);
345
346 return fault;
347}
348
349
350void

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

362
363 thread->funcExeInst++;
364
365 // check for instruction-count-based events
366 comInstEventQueue[0]->serviceEvents(numInst);
367
368 // decode the instruction
369 inst = gtoh(inst);
346
347 Fault fault = thread->translateInstReq(req);
348
349 return fault;
350}
351
352
353void

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

365
366 thread->funcExeInst++;
367
368 // check for instruction-count-based events
369 comInstEventQueue[0]->serviceEvents(numInst);
370
371 // decode the instruction
372 inst = gtoh(inst);
373
370 //If we're not in the middle of a macro instruction
371 if (!curMacroStaticInst) {
374 //If we're not in the middle of a macro instruction
375 if (!curMacroStaticInst) {
376
372 StaticInstPtr instPtr = NULL;
373
374 //Predecode, ie bundle up an ExtMachInst
375 //This should go away once the constructor can be set up properly
376 predecoder.setTC(thread->getTC());
377 //If more fetch data is needed, pass it in.
377 StaticInstPtr instPtr = NULL;
378
379 //Predecode, ie bundle up an ExtMachInst
380 //This should go away once the constructor can be set up properly
381 predecoder.setTC(thread->getTC());
382 //If more fetch data is needed, pass it in.
383 const Addr PCMask = ~(sizeof(MachInst) - 1);
378 if(predecoder.needMoreBytes())
384 if(predecoder.needMoreBytes())
379 predecoder.moreBytes(thread->readPC(), 0, inst);
385 predecoder.moreBytes((thread->readPC() & PCMask) + fetchOffset,
386 0, inst);
380 else
381 predecoder.process();
387 else
388 predecoder.process();
382 //If an instruction is ready, decode it
383 if (predecoder.extMachInstReady())
389
390 //If an instruction is ready, decode it. Otherwise, we'll have to
391 //fetch beyond the MachInst at the current pc.
392 if (predecoder.extMachInstReady()) {
393#if THE_ISA == X86_ISA
394 thread->setNextPC(thread->readPC() + predecoder.getInstSize());
395#endif // X86_ISA
396 stayAtPC = false;
384 instPtr = StaticInst::decode(predecoder.getExtMachInst());
397 instPtr = StaticInst::decode(predecoder.getExtMachInst());
398 } else {
399 stayAtPC = true;
400 fetchOffset += sizeof(MachInst);
401 }
385
386 //If we decoded an instruction and it's microcoded, start pulling
387 //out micro ops
388 if (instPtr && instPtr->isMacroOp()) {
389 curMacroStaticInst = instPtr;
390 curStaticInst = curMacroStaticInst->
391 fetchMicroOp(thread->readMicroPC());
392 } else {

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

446 traceData = NULL;
447 }
448}
449
450
451void
452BaseSimpleCPU::advancePC(Fault fault)
453{
402
403 //If we decoded an instruction and it's microcoded, start pulling
404 //out micro ops
405 if (instPtr && instPtr->isMacroOp()) {
406 curMacroStaticInst = instPtr;
407 curStaticInst = curMacroStaticInst->
408 fetchMicroOp(thread->readMicroPC());
409 } else {

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

463 traceData = NULL;
464 }
465}
466
467
468void
469BaseSimpleCPU::advancePC(Fault fault)
470{
471 //Since we're moving to a new pc, zero out the offset
472 fetchOffset = 0;
454 if (fault != NoFault) {
455 curMacroStaticInst = StaticInst::nullStaticInstPtr;
456 fault->invoke(tc);
457 thread->setMicroPC(0);
458 thread->setNextMicroPC(1);
473 if (fault != NoFault) {
474 curMacroStaticInst = StaticInst::nullStaticInstPtr;
475 fault->invoke(tc);
476 thread->setMicroPC(0);
477 thread->setNextMicroPC(1);
459 } else if (predecoder.needMoreBytes()) {
478 } else {
460 //If we're at the last micro op for this instruction
461 if (curStaticInst && curStaticInst->isLastMicroOp()) {
462 //We should be working with a macro op
463 assert(curMacroStaticInst);
464 //Close out this macro op, and clean up the
465 //microcode state
466 curMacroStaticInst = StaticInst::nullStaticInstPtr;
467 thread->setMicroPC(0);

--- 27 unchanged lines hidden ---
479 //If we're at the last micro op for this instruction
480 if (curStaticInst && curStaticInst->isLastMicroOp()) {
481 //We should be working with a macro op
482 assert(curMacroStaticInst);
483 //Close out this macro op, and clean up the
484 //microcode state
485 curMacroStaticInst = StaticInst::nullStaticInstPtr;
486 thread->setMicroPC(0);

--- 27 unchanged lines hidden ---