arch: Add a newPCState method to the ISA class.
This method is the seed which creates a new PCState object of the appropriate type. It can be used to initialize PCStateBase *s so that they always point to something valid and can be manipulated without having to first check if there's something there, as opposed to the alternative where a pointer might be null until it's first pointed at something. Change-Id: If06ee633846603acbfd2432f3d8bac6746a8b729 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52040 Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -52,6 +52,12 @@ class ISA : public BaseISA
|
||||
ArmISA::CPSR cpsr = tc->readMiscRegNoEffect(ArmISA::MISCREG_CPSR);
|
||||
return ArmISA::inUserMode(cpsr);
|
||||
}
|
||||
|
||||
PCStateBase *
|
||||
newPCState(Addr new_inst_addr=0) const override
|
||||
{
|
||||
return new ArmISA::PCState(new_inst_addr);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Iris
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
#include "arch/arm/isa_device.hh"
|
||||
#include "arch/arm/mmu.hh"
|
||||
#include "arch/arm/pcstate.hh"
|
||||
#include "arch/arm/regs/int.hh"
|
||||
#include "arch/arm/regs/misc.hh"
|
||||
#include "arch/arm/self_debug.hh"
|
||||
@@ -868,6 +869,12 @@ namespace ArmISA
|
||||
|
||||
void setupThreadContext();
|
||||
|
||||
PCStateBase *
|
||||
newPCState(Addr new_inst_addr=0) const override
|
||||
{
|
||||
return new PCState(new_inst_addr);
|
||||
}
|
||||
|
||||
void takeOverFrom(ThreadContext *new_tc,
|
||||
ThreadContext *old_tc) override;
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "arch/generic/pcstate.hh"
|
||||
#include "cpu/reg_class.hh"
|
||||
#include "mem/packet.hh"
|
||||
#include "mem/request.hh"
|
||||
@@ -66,6 +67,7 @@ class BaseISA : public SimObject
|
||||
RegClasses _regClasses;
|
||||
|
||||
public:
|
||||
virtual PCStateBase *newPCState(Addr new_inst_addr=0) const = 0;
|
||||
virtual void takeOverFrom(ThreadContext *new_tc, ThreadContext *old_tc) {}
|
||||
virtual void setThreadContext(ThreadContext *_tc) { tc = _tc; }
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "arch/generic/isa.hh"
|
||||
#include "arch/mips/pcstate.hh"
|
||||
#include "arch/mips/regs/misc.hh"
|
||||
#include "arch/mips/types.hh"
|
||||
#include "base/types.hh"
|
||||
@@ -78,6 +79,12 @@ namespace MipsISA
|
||||
public:
|
||||
void clear();
|
||||
|
||||
PCStateBase *
|
||||
newPCState(Addr new_inst_addr=0) const override
|
||||
{
|
||||
return new PCState(new_inst_addr);
|
||||
}
|
||||
|
||||
public:
|
||||
void configCP();
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#define __ARCH_POWER_ISA_HH__
|
||||
|
||||
#include "arch/generic/isa.hh"
|
||||
#include "arch/power/pcstate.hh"
|
||||
#include "arch/power/regs/misc.hh"
|
||||
#include "arch/power/types.hh"
|
||||
#include "base/logging.hh"
|
||||
@@ -58,6 +59,12 @@ class ISA : public BaseISA
|
||||
public:
|
||||
void clear() {}
|
||||
|
||||
PCStateBase *
|
||||
newPCState(Addr new_inst_addr=0) const override
|
||||
{
|
||||
return new PCState(new_inst_addr);
|
||||
}
|
||||
|
||||
public:
|
||||
RegVal
|
||||
readMiscRegNoEffect(int misc_reg) const
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "arch/generic/isa.hh"
|
||||
#include "arch/riscv/pcstate.hh"
|
||||
#include "arch/riscv/types.hh"
|
||||
#include "base/types.hh"
|
||||
|
||||
@@ -76,6 +77,12 @@ class ISA : public BaseISA
|
||||
|
||||
void clear();
|
||||
|
||||
PCStateBase *
|
||||
newPCState(Addr new_inst_addr=0) const override
|
||||
{
|
||||
return new PCState(new_inst_addr);
|
||||
}
|
||||
|
||||
public:
|
||||
RegVal readMiscRegNoEffect(int misc_reg) const;
|
||||
RegVal readMiscReg(int misc_reg);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "arch/generic/isa.hh"
|
||||
#include "arch/sparc/pcstate.hh"
|
||||
#include "arch/sparc/regs/int.hh"
|
||||
#include "arch/sparc/regs/misc.hh"
|
||||
#include "arch/sparc/sparc_traits.hh"
|
||||
@@ -166,9 +167,14 @@ class ISA : public BaseISA
|
||||
void reloadRegMap();
|
||||
|
||||
public:
|
||||
|
||||
void clear();
|
||||
|
||||
PCStateBase *
|
||||
newPCState(Addr new_inst_addr=0) const override
|
||||
{
|
||||
return new PCState(new_inst_addr);
|
||||
}
|
||||
|
||||
void serialize(CheckpointOut &cp) const override;
|
||||
void unserialize(CheckpointIn &cp) override;
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "arch/generic/isa.hh"
|
||||
#include "arch/x86/pcstate.hh"
|
||||
#include "arch/x86/regs/float.hh"
|
||||
#include "arch/x86/regs/misc.hh"
|
||||
#include "base/types.hh"
|
||||
@@ -59,6 +60,12 @@ class ISA : public BaseISA
|
||||
public:
|
||||
void clear();
|
||||
|
||||
PCStateBase *
|
||||
newPCState(Addr new_inst_addr=0) const override
|
||||
{
|
||||
return new PCState(new_inst_addr);
|
||||
}
|
||||
|
||||
using Params = X86ISAParams;
|
||||
|
||||
ISA(const Params &p);
|
||||
|
||||
Reference in New Issue
Block a user