From 16882b04838c33e7de5456937b8b069547827b2a Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sun, 7 Aug 2011 09:21:48 -0700 Subject: Translation: Use a pointer type as the template argument. This allows regular pointers and reference counted pointers without having to use any shim structures or other tricks. --- src/cpu/base_dyn_inst.hh | 13 +++++++------ src/cpu/simple/timing.cc | 24 ++++++++++++------------ src/cpu/translation.hh | 8 ++++---- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/cpu/base_dyn_inst.hh b/src/cpu/base_dyn_inst.hh index 18a178c4a..cb9294481 100644 --- a/src/cpu/base_dyn_inst.hh +++ b/src/cpu/base_dyn_inst.hh @@ -91,6 +91,7 @@ class BaseDynInst : public FastAlloc, public RefCounted // The DynInstPtr type. typedef typename Impl::DynInstPtr DynInstPtr; + typedef RefCountingPtr > BaseDynInstPtr; // The list of instructions iterator type. typedef typename std::list::iterator ListIt; @@ -950,8 +951,8 @@ BaseDynInst::initiateTranslation(RequestPtr req, RequestPtr sreqLow, new WholeTranslationState(req, NULL, res, mode); // One translation if the request isn't split. - DataTranslation > *trans = - new DataTranslation >(this, state); + DataTranslation *trans = + new DataTranslation(this, state); cpu->dtb->translateTiming(req, thread->getTC(), trans, mode); if (!translationCompleted) { // Save memory requests. @@ -964,10 +965,10 @@ BaseDynInst::initiateTranslation(RequestPtr req, RequestPtr sreqLow, new WholeTranslationState(req, sreqLow, sreqHigh, NULL, res, mode); // Two translations when the request is split. - DataTranslation > *stransLow = - new DataTranslation >(this, state, 0); - DataTranslation > *stransHigh = - new DataTranslation >(this, state, 1); + DataTranslation *stransLow = + new DataTranslation(this, state, 0); + DataTranslation *stransHigh = + new DataTranslation(this, state, 1); cpu->dtb->translateTiming(sreqLow, thread->getTC(), stransLow, mode); cpu->dtb->translateTiming(sreqHigh, thread->getTC(), stransHigh, mode); diff --git a/src/cpu/simple/timing.cc b/src/cpu/simple/timing.cc index 1c726ba57..e2151d974 100644 --- a/src/cpu/simple/timing.cc +++ b/src/cpu/simple/timing.cc @@ -461,18 +461,18 @@ TimingSimpleCPU::readMem(Addr addr, uint8_t *data, WholeTranslationState *state = new WholeTranslationState(req, req1, req2, new uint8_t[size], NULL, mode); - DataTranslation *trans1 = - new DataTranslation(this, state, 0); - DataTranslation *trans2 = - new DataTranslation(this, state, 1); + DataTranslation *trans1 = + new DataTranslation(this, state, 0); + DataTranslation *trans2 = + new DataTranslation(this, state, 1); thread->dtb->translateTiming(req1, tc, trans1, mode); thread->dtb->translateTiming(req2, tc, trans2, mode); } else { WholeTranslationState *state = new WholeTranslationState(req, new uint8_t[size], NULL, mode); - DataTranslation *translation - = new DataTranslation(this, state); + DataTranslation *translation + = new DataTranslation(this, state); thread->dtb->translateTiming(req, tc, translation, mode); } @@ -530,18 +530,18 @@ TimingSimpleCPU::writeMem(uint8_t *data, unsigned size, WholeTranslationState *state = new WholeTranslationState(req, req1, req2, newData, res, mode); - DataTranslation *trans1 = - new DataTranslation(this, state, 0); - DataTranslation *trans2 = - new DataTranslation(this, state, 1); + DataTranslation *trans1 = + new DataTranslation(this, state, 0); + DataTranslation *trans2 = + new DataTranslation(this, state, 1); thread->dtb->translateTiming(req1, tc, trans1, mode); thread->dtb->translateTiming(req2, tc, trans2, mode); } else { WholeTranslationState *state = new WholeTranslationState(req, newData, res, mode); - DataTranslation *translation = - new DataTranslation(this, state); + DataTranslation *translation = + new DataTranslation(this, state); thread->dtb->translateTiming(req, tc, translation, mode); } diff --git a/src/cpu/translation.hh b/src/cpu/translation.hh index 60953540f..b6bc2182c 100644 --- a/src/cpu/translation.hh +++ b/src/cpu/translation.hh @@ -214,21 +214,21 @@ class WholeTranslationState * translation state class indicate that the whole translation is complete * then the execution context is informed. */ -template +template class DataTranslation : public BaseTLB::Translation { protected: - ExecContext *xc; + ExecContextPtr xc; WholeTranslationState *state; int index; public: - DataTranslation(ExecContext *_xc, WholeTranslationState* _state) + DataTranslation(ExecContextPtr _xc, WholeTranslationState* _state) : xc(_xc), state(_state), index(0) { } - DataTranslation(ExecContext *_xc, WholeTranslationState* _state, + DataTranslation(ExecContextPtr _xc, WholeTranslationState* _state, int _index) : xc(_xc), state(_state), index(_index) { -- cgit v1.2.3