arch: Add a virtual clone() method to PCState.
This will let callers create a separate copy of a PCState class instance. This makes it more explicit when creating copies of a PCState to make sure the programmer is more aware, and avoids having to know what the actual type is to make a copy. Change-Id: I728a278afdb55b800c753a5b7f65f62f4a80c043 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52035 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
@@ -102,6 +102,8 @@ class PCState : public GenericISA::UPCState<4>
|
||||
|
||||
PCState(Addr val) { set(val); }
|
||||
|
||||
PCStateBase *clone() const override { return new PCState(*this); }
|
||||
|
||||
bool
|
||||
illegalExec() const
|
||||
{
|
||||
|
||||
@@ -68,6 +68,8 @@ class PCStateBase : public Serializable
|
||||
{
|
||||
return static_cast<const Target &>(*this);
|
||||
}
|
||||
|
||||
virtual PCStateBase *clone() const = 0;
|
||||
};
|
||||
|
||||
namespace GenericISA
|
||||
@@ -188,6 +190,12 @@ class SimplePCState : public PCStateCommon
|
||||
SimplePCState() {}
|
||||
SimplePCState(Addr val) { set(val); }
|
||||
|
||||
PCStateBase *
|
||||
clone() const override
|
||||
{
|
||||
return new SimplePCState<InstWidth>(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force this PC to reflect a particular value, resetting all its other
|
||||
* fields around it. This is useful for in place (re)initialization.
|
||||
@@ -232,6 +240,11 @@ class UPCState : public SimplePCState<InstWidth>
|
||||
typedef SimplePCState<InstWidth> Base;
|
||||
|
||||
public:
|
||||
PCStateBase *
|
||||
clone() const override
|
||||
{
|
||||
return new UPCState<InstWidth>(*this);
|
||||
}
|
||||
|
||||
MicroPC upc() const { return this->_upc; }
|
||||
void upc(MicroPC val) { this->_upc = val; }
|
||||
@@ -307,6 +320,11 @@ class DelaySlotPCState : public SimplePCState<InstWidth>
|
||||
Addr _nnpc;
|
||||
|
||||
public:
|
||||
PCStateBase *
|
||||
clone() const override
|
||||
{
|
||||
return new DelaySlotPCState<InstWidth>(*this);
|
||||
}
|
||||
|
||||
Addr nnpc() const { return _nnpc; }
|
||||
void nnpc(Addr val) { _nnpc = val; }
|
||||
@@ -387,6 +405,11 @@ class DelaySlotUPCState : public DelaySlotPCState<InstWidth>
|
||||
MicroPC _nupc;
|
||||
|
||||
public:
|
||||
PCStateBase *
|
||||
clone() const override
|
||||
{
|
||||
return new DelaySlotUPCState<InstWidth>(*this);
|
||||
}
|
||||
|
||||
MicroPC upc() const { return _upc; }
|
||||
void upc(MicroPC val) { _upc = val; }
|
||||
|
||||
@@ -47,6 +47,8 @@ class PCState : public GenericISA::SimplePCState<4>
|
||||
public:
|
||||
using GenericISA::SimplePCState<4>::SimplePCState;
|
||||
|
||||
PCStateBase *clone() const override { return new PCState(*this); }
|
||||
|
||||
ByteOrder
|
||||
byteOrder() const
|
||||
{
|
||||
|
||||
@@ -59,6 +59,8 @@ class PCState : public GenericISA::UPCState<4>
|
||||
public:
|
||||
using GenericISA::UPCState<4>::UPCState;
|
||||
|
||||
PCStateBase *clone() const override { return new PCState(*this); }
|
||||
|
||||
void compressed(bool c) { _compressed = c; }
|
||||
bool compressed() const { return _compressed; }
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ class PCState : public GenericISA::UPCState<8>
|
||||
uint8_t _size;
|
||||
|
||||
public:
|
||||
PCStateBase *clone() const override { return new PCState(*this); }
|
||||
|
||||
void
|
||||
set(Addr val)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user