arch: Make the decoder takeOverFrom method virtual.

This is only implemented for x86. It's called very rarely, and so
virtual function overhead is practically irrelevant.

Change-Id: Ib6e05a903df95b801164e44d1662e130419fdbd8
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52076
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Earl Ou <shunhsingou@google.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
This commit is contained in:
Gabe Black
2021-10-25 02:45:05 -07:00
parent 4ed7341abb
commit 792745f4f0
7 changed files with 25 additions and 24 deletions

View File

@@ -176,14 +176,6 @@ class Decoder : public InstDecoder
*/
StaticInstPtr decode(PCStateBase &pc);
/**
* Take over the state from an old decoder when switching CPUs.
*
* @param old Decoder used in old CPU
*/
void takeOverFrom(Decoder *old) {}
public: // ARM-specific decoder state manipulation
void
setContext(FPSCR fpscr)

View File

@@ -62,6 +62,18 @@ class InstDecoder
outOfBytes = true;
}
/**
* Take over the state from an old decoder when switching CPUs.
*
* @param old Decoder used in old CPU
*/
virtual void
takeOverFrom(InstDecoder *old)
{
instDone = old->instDone;
outOfBytes = old->outOfBytes;
}
void *moreBytesPtr() const { return _moreBytesPtr; }
size_t moreBytesSize() const { return _moreBytesSize; }
Addr pcMask() const { return _pcMask; }

View File

@@ -64,8 +64,6 @@ class Decoder : public InstDecoder
instDone = true;
}
void takeOverFrom(Decoder *old) {}
protected:
/// A cache of decoded instruction objects.
static GenericISA::BasicDecodeCache<Decoder, ExtMachInst> defaultCache;

View File

@@ -61,8 +61,6 @@ class Decoder : public InstDecoder
instDone = true;
}
void takeOverFrom(Decoder *old) {}
protected:
/// A cache of decoded instruction objects.
static GenericISA::BasicDecodeCache<Decoder, ExtMachInst> defaultCache;

View File

@@ -75,8 +75,6 @@ class Decoder : public InstDecoder
//when there is control flow.
void moreBytes(const PCStateBase &pc, Addr fetchPC);
void takeOverFrom(Decoder *old) {}
StaticInstPtr decode(PCStateBase &nextPC);
};

View File

@@ -80,8 +80,6 @@ class Decoder : public InstDecoder
asi = _asi;
}
void takeOverFrom(Decoder *old) {}
protected:
/// A cache of decoded instruction objects.
static GenericISA::BasicDecodeCache<Decoder, ExtMachInst> defaultCache;

View File

@@ -291,17 +291,22 @@ class Decoder : public InstDecoder
}
void
takeOverFrom(Decoder *old)
takeOverFrom(InstDecoder *old) override
{
mode = old->mode;
submode = old->submode;
InstDecoder::takeOverFrom(old);
Decoder *dec = dynamic_cast<Decoder *>(old);
assert(dec);
mode = dec->mode;
submode = dec->submode;
emi.mode.mode = mode;
emi.mode.submode = submode;
altOp = old->altOp;
defOp = old->defOp;
altAddr = old->altAddr;
defAddr = old->defAddr;
stack = old->stack;
altOp = dec->altOp;
defOp = dec->defOp;
altAddr = dec->altAddr;
defAddr = dec->defAddr;
stack = dec->stack;
}
void