From 0cba96ba6a5d7a4dab2a63b14149c49dfbfbb3bc Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sat, 26 May 2012 13:44:46 -0700 Subject: CPU: Merge the predecoder and decoder. These classes are always used together, and merging them will give the ISAs more flexibility in how they cache things and manage the process. --HG-- rename : src/arch/x86/predecoder_tables.cc => src/arch/x86/decoder_tables.cc --- src/cpu/simple/atomic.cc | 4 ++-- src/cpu/simple/base.cc | 23 ++++++++++++----------- src/cpu/simple/base.hh | 6 ------ 3 files changed, 14 insertions(+), 19 deletions(-) (limited to 'src/cpu/simple') diff --git a/src/cpu/simple/atomic.cc b/src/cpu/simple/atomic.cc index 87f41a721..f12c2c174 100644 --- a/src/cpu/simple/atomic.cc +++ b/src/cpu/simple/atomic.cc @@ -465,12 +465,12 @@ AtomicSimpleCPU::tick() dcache_access = false; // assume no dcache access if (needToFetch) { - // This is commented out because the predecoder would act like + // This is commented out because the decoder would act like // a tiny cache otherwise. It wouldn't be flushed when needed // like the I cache. It should be flushed, and when that works // this code should be uncommented. //Fetch more instruction memory if necessary - //if(predecoder.needMoreBytes()) + //if(decoder.needMoreBytes()) //{ icache_access = true; Packet ifetch_pkt = Packet(&ifetch_req, MemCmd::ReadReq); diff --git a/src/cpu/simple/base.cc b/src/cpu/simple/base.cc index ca4090870..bdc4b0f44 100644 --- a/src/cpu/simple/base.cc +++ b/src/cpu/simple/base.cc @@ -85,7 +85,7 @@ using namespace std; using namespace TheISA; BaseSimpleCPU::BaseSimpleCPU(BaseSimpleCPUParams *p) - : BaseCPU(p), traceData(NULL), thread(NULL), predecoder(NULL) + : BaseCPU(p), traceData(NULL), thread(NULL) { if (FullSystem) thread = new SimpleThread(this, 0, p->system, p->itb, p->dtb); @@ -332,7 +332,7 @@ BaseSimpleCPU::checkForInterrupts() fetchOffset = 0; interrupts->updateIntrInfo(tc); interrupt->invoke(tc); - predecoder.reset(); + thread->decoder.reset(); } } } @@ -378,23 +378,24 @@ BaseSimpleCPU::preExecute() //We're not in the middle of a macro instruction StaticInstPtr instPtr = NULL; + TheISA::Decoder *decoder = &(thread->decoder); + //Predecode, ie bundle up an ExtMachInst //This should go away once the constructor can be set up properly - predecoder.setTC(thread->getTC()); + decoder->setTC(thread->getTC()); //If more fetch data is needed, pass it in. Addr fetchPC = (pcState.instAddr() & PCMask) + fetchOffset; - //if(predecoder.needMoreBytes()) - predecoder.moreBytes(pcState, fetchPC, inst); + //if(decoder->needMoreBytes()) + decoder->moreBytes(pcState, fetchPC, inst); //else - // predecoder.process(); + // decoder->process(); - //If an instruction is ready, decode it. Otherwise, we'll have to + //Decode an instruction if one is ready. Otherwise, we'll have to //fetch beyond the MachInst at the current pc. - if (predecoder.extMachInstReady()) { + instPtr = decoder->decode(pcState); + if (instPtr) { stayAtPC = false; - ExtMachInst machInst = predecoder.getExtMachInst(pcState); thread->pcState(pcState); - instPtr = thread->decoder.decode(machInst, pcState.instAddr()); } else { stayAtPC = true; fetchOffset += sizeof(MachInst); @@ -505,7 +506,7 @@ BaseSimpleCPU::advancePC(Fault fault) if (fault != NoFault) { curMacroStaticInst = StaticInst::nullStaticInstPtr; fault->invoke(tc, curStaticInst); - predecoder.reset(); + thread->decoder.reset(); } else { if (curStaticInst) { if (curStaticInst->isLastMicroop()) diff --git a/src/cpu/simple/base.hh b/src/cpu/simple/base.hh index 34b039fc0..9bf144326 100644 --- a/src/cpu/simple/base.hh +++ b/src/cpu/simple/base.hh @@ -45,8 +45,6 @@ #ifndef __CPU_SIMPLE_BASE_HH__ #define __CPU_SIMPLE_BASE_HH__ -#include "arch/decoder.hh" -#include "arch/predecoder.hh" #include "base/statistics.hh" #include "config/the_isa.hh" #include "cpu/base.hh" @@ -71,7 +69,6 @@ namespace TheISA { class DTB; class ITB; - class Predecoder; } namespace Trace { @@ -154,9 +151,6 @@ class BaseSimpleCPU : public BaseCPU // current instruction TheISA::MachInst inst; - // The predecoder - TheISA::Predecoder predecoder; - StaticInstPtr curStaticInst; StaticInstPtr curMacroStaticInst; -- cgit v1.2.3