arch-arm: Reduce boilerplate when extracting SelfDebug from tc

Change-Id: I1746400617be64ac9c2f3194442734e178342909
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Richard Cooper <richard.cooper@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/31354
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Giacomo Travaglini
2020-07-09 10:24:16 +01:00
parent 9ba0807ab4
commit bef04bca28
8 changed files with 28 additions and 23 deletions

View File

@@ -723,8 +723,7 @@ ArmFault::invoke64(ThreadContext *tc, const StaticInstPtr &inst)
bool
ArmFault::vectorCatch(ThreadContext *tc, const StaticInstPtr &inst)
{
auto *isa = static_cast<ArmISA::ISA *>(tc->getIsaPtr());
SelfDebug * sd = isa->getSelfDebug();
SelfDebug *sd = ArmISA::ISA::getSelfDebug(tc);
VectorCatch* vc = sd->getVectorCatch(tc);
if (!vc->isVCMatch()) {
Fault fault = sd->testVectorCatch(tc, 0x0, this);

View File

@@ -201,8 +201,11 @@ DebugStep::execute(ExecContext *xc, Trace::InstRecord *traceData) const
PCState pc_state(xc->pcState());
pc_state.debugStep(false);
xc->pcState(pc_state);
auto *isa = static_cast<ArmISA::ISA *>(xc->tcBase()->getIsaPtr());
bool ldx = isa->getSelfDebug()->getSstep()->getLdx();
SelfDebug *sd = ArmISA::ISA::getSelfDebug(xc->tcBase());
bool ldx = sd->getSstep()->getLdx();
return std::make_shared<SoftwareStepFault>(machInst, ldx,
pc_state.stepped());

View File

@@ -1192,8 +1192,8 @@ ArmStaticInst::getPSTATEFromPSR(ThreadContext *tc, CPSR cpsr, CPSR spsr) const
new_cpsr.daif = spsr.daif;
}
auto *isa = static_cast<ArmISA::ISA *>(tc->getIsaPtr());
SoftwareStep * ss = (isa->getSelfDebug())->getSstep();
SelfDebug *sd = ArmISA::ISA::getSelfDebug(tc);
SoftwareStep *ss = sd->getSstep();
new_cpsr.ss = ss->debugExceptionReturnSS(tc, spsr, dest, new_cpsr.width);
return new_cpsr;

View File

@@ -203,8 +203,7 @@ class ArmStaticInst : public StaticInst
static void
activateBreakpoint(ThreadContext *tc)
{
auto *isa = static_cast<ArmISA::ISA *>(tc->getIsaPtr());
SelfDebug * sd = isa->getSelfDebug();
SelfDebug *sd = ArmISA::ISA::getSelfDebug(tc);
sd->activateDebug();
}

View File

@@ -466,10 +466,19 @@ namespace ArmISA
void initID64(const ArmISAParams *p);
public:
SelfDebug * getSelfDebug()
SelfDebug*
getSelfDebug() const
{
return selfDebug;
}
static SelfDebug*
getSelfDebug(ThreadContext *tc)
{
auto *arm_isa = static_cast<ArmISA::ISA *>(tc->getIsaPtr());
return arm_isa->getSelfDebug();
}
RegVal readMiscRegNoEffect(int misc_reg) const;
RegVal readMiscReg(int misc_reg);
void setMiscRegNoEffect(int misc_reg, RegVal val);

View File

@@ -211,9 +211,8 @@ let {{
if self.flavor in ('exclusive', 'acex'):
accCode += '''
auto *isa = static_cast<ArmISA::ISA *>(xc->tcBase()->getIsaPtr());
SelfDebug * sd = isa->getSelfDebug();
sd->getSstep()->setLdx();
SelfDebug *sd = ArmISA::ISA::getSelfDebug(xc->tcBase());
sd->getSstep()->setLdx();
'''
self.codeBlobs["memacc_code"] = accCode
@@ -293,9 +292,8 @@ let {{
'''
if self.flavor in ('exclusive', 'acex'):
accCode += '''
auto *isa = static_cast<ArmISA::ISA *>(xc->tcBase()->getIsaPtr());
SelfDebug * sd = isa->getSelfDebug();
sd->getSstep()->setLdx();
SelfDebug *sd = ArmISA::ISA::getSelfDebug(xc->tcBase());
sd->getSstep()->setLdx();
'''
self.codeBlobs["memacc_code"] = accCode

View File

@@ -243,9 +243,8 @@ let {{
accCode = accCode % buildMemSuffix(self.sign, self.size)
if self.flavor in ('exclusive', 'acex'):
accCode += '''
auto *isa = static_cast<ArmISA::ISA *>(xc->tcBase()->getIsaPtr());
SelfDebug * sd = isa->getSelfDebug();
sd->getSstep()->setLdx();
SelfDebug *sd = ArmISA::ISA::getSelfDebug(xc->tcBase());
sd->getSstep()->setLdx();
'''
self.codeBlobs["memacc_code"] = accCode
if accEpilogCode:
@@ -344,9 +343,8 @@ let {{
'''
if self.flavor in ('exp', 'acexp'):
accCode += '''
auto *isa = static_cast<ArmISA::ISA *>(xc->tcBase()->getIsaPtr());
SelfDebug * sd = isa->getSelfDebug();
sd->getSstep()->setLdx();
SelfDebug *sd = ArmISA::ISA::getSelfDebug(xc->tcBase());
sd->getSstep()->setLdx();
'''
self.codeBlobs["memacc_code"] = accCode
if accEpilogCode:

View File

@@ -1234,8 +1234,7 @@ TLB::translateFs(const RequestPtr &req, ThreadContext *tc, Mode mode,
//Check for Debug Exceptions
if (fault == NoFault) {
auto *isa = static_cast<ArmISA::ISA *>(tc->getIsaPtr());
SelfDebug *sd = isa->getSelfDebug();
SelfDebug *sd = ArmISA::ISA::getSelfDebug(tc);
fault = sd->testDebug(tc, req, mode);
}