diff --git a/src/arch/arm/decoder.hh b/src/arch/arm/decoder.hh index d2e0c68389..ba2cb70e70 100644 --- a/src/arch/arm/decoder.hh +++ b/src/arch/arm/decoder.hh @@ -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) diff --git a/src/arch/generic/decoder.hh b/src/arch/generic/decoder.hh index e9ebba8bb0..5033554794 100644 --- a/src/arch/generic/decoder.hh +++ b/src/arch/generic/decoder.hh @@ -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; } diff --git a/src/arch/mips/decoder.hh b/src/arch/mips/decoder.hh index d7387679d7..72b9c69171 100644 --- a/src/arch/mips/decoder.hh +++ b/src/arch/mips/decoder.hh @@ -64,8 +64,6 @@ class Decoder : public InstDecoder instDone = true; } - void takeOverFrom(Decoder *old) {} - protected: /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; diff --git a/src/arch/power/decoder.hh b/src/arch/power/decoder.hh index dcd1e53098..f275ecf74f 100644 --- a/src/arch/power/decoder.hh +++ b/src/arch/power/decoder.hh @@ -61,8 +61,6 @@ class Decoder : public InstDecoder instDone = true; } - void takeOverFrom(Decoder *old) {} - protected: /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; diff --git a/src/arch/riscv/decoder.hh b/src/arch/riscv/decoder.hh index 718e69899d..a1a893a00c 100644 --- a/src/arch/riscv/decoder.hh +++ b/src/arch/riscv/decoder.hh @@ -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); }; diff --git a/src/arch/sparc/decoder.hh b/src/arch/sparc/decoder.hh index 31b30145d7..e6bd817264 100644 --- a/src/arch/sparc/decoder.hh +++ b/src/arch/sparc/decoder.hh @@ -80,8 +80,6 @@ class Decoder : public InstDecoder asi = _asi; } - void takeOverFrom(Decoder *old) {} - protected: /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; diff --git a/src/arch/x86/decoder.hh b/src/arch/x86/decoder.hh index a965fab734..ff136af8d8 100644 --- a/src/arch/x86/decoder.hh +++ b/src/arch/x86/decoder.hh @@ -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(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