cpu: Access inst events through ThreadContext instead of the CPU.
Also delete the CPU interface.
Change-Id: I62a6b0a9a303d672f4083bdedf393f9f6d07331f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22109
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index b45ef10..9a1f7bf 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -753,18 +753,16 @@
void
BaseRemoteGDB::scheduleInstCommitEvent(Event *ev, int delta)
{
- auto *cpu = tc->getCpuPtr();
// Here "ticks" aren't simulator ticks which measure time, they're
// instructions committed by the CPU.
- cpu->scheduleInstCountEvent(tc->threadId(), ev,
- cpu->getCurrentInstCount(tc->threadId()) + delta);
+ tc->scheduleInstCountEvent(ev, tc->getCurrentInstCount() + delta);
}
void
BaseRemoteGDB::descheduleInstCommitEvent(Event *ev)
{
if (ev->scheduled())
- tc->getCpuPtr()->descheduleInstCountEvent(tc->threadId(), ev);
+ tc->descheduleInstCountEvent(ev);
}
std::map<char, BaseRemoteGDB::GdbCommand> BaseRemoteGDB::command_map = {
diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index 7040cb7..e8927df 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -314,8 +314,8 @@
*counter = numThreads;
for (ThreadID tid = 0; tid < numThreads; ++tid) {
Event *event = new CountedExitEvent(cause, *counter);
- scheduleInstCountEvent(
- tid, event, params()->max_insts_all_threads);
+ threadContexts[tid]->scheduleInstCountEvent(
+ event, params()->max_insts_all_threads);
}
}
@@ -725,7 +725,7 @@
const Tick now(getCurrentInstCount(tid));
Event *event(new LocalSimLoopExitEvent(cause, 0));
- scheduleInstCountEvent(tid, event, now + insts);
+ threadContexts[tid]->scheduleInstCountEvent(event, now + insts);
}
Tick
diff --git a/src/cpu/base.hh b/src/cpu/base.hh
index d73f4a2..cb23cb1 100644
--- a/src/cpu/base.hh
+++ b/src/cpu/base.hh
@@ -465,30 +465,6 @@
*/
uint64_t getCurrentInstCount(ThreadID tid);
- Tick
- nextInstEventCount(ThreadID tid)
- {
- return threadContexts[tid]->nextInstEventCount();
- }
-
- void
- serviceInstCountEvents(ThreadID tid, Tick count)
- {
- threadContexts[tid]->serviceInstCountEvents(count);
- }
-
- void
- scheduleInstCountEvent(ThreadID tid, Event *event, Tick count)
- {
- threadContexts[tid]->scheduleInstCountEvent(event, count);
- }
-
- void
- descheduleInstCountEvent(ThreadID tid, Event *event)
- {
- threadContexts[tid]->descheduleInstCountEvent(event);
- }
-
public:
/**
* @{
diff --git a/src/cpu/kvm/base.cc b/src/cpu/kvm/base.cc
index 384abb0..da3e87e 100644
--- a/src/cpu/kvm/base.cc
+++ b/src/cpu/kvm/base.cc
@@ -630,7 +630,7 @@
case RunningServiceCompletion:
case Running: {
- const uint64_t nextInstEvent(nextInstEventCount(0));
+ const uint64_t nextInstEvent(tc->nextInstEventCount());
// Enter into KVM and complete pending IO instructions if we
// have an instruction event pending.
const Tick ticksToExecute(
@@ -686,7 +686,7 @@
// Service any pending instruction events. The vCPU should
// have exited in time for the event using the instruction
// counter configured by setupInstStop().
- serviceInstCountEvents(0, ctrInsts);
+ tc->serviceInstCountEvents(ctrInsts);
if (tryDrain())
_status = Idle;
@@ -1346,7 +1346,7 @@
void
BaseKvmCPU::setupInstStop()
{
- Tick next = nextInstEventCount(0);
+ Tick next = tc->nextInstEventCount();
if (next == MaxTick) {
setupInstCounter(0);
} else {
diff --git a/src/cpu/minor/execute.cc b/src/cpu/minor/execute.cc
index 9317f61..0e83db3 100644
--- a/src/cpu/minor/execute.cc
+++ b/src/cpu/minor/execute.cc
@@ -870,7 +870,8 @@
cpu.system->totalNumInsts++;
/* Act on events related to instruction counts */
- cpu.serviceInstCountEvents(inst->id.threadId, thread->numInst);
+ cpu.getContext(inst->id.threadId)->
+ serviceInstCountEvents(thread->numInst);
}
thread->numOp++;
thread->numOps++;
diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc
index e49d499..bb3f0c3 100644
--- a/src/cpu/o3/cpu.cc
+++ b/src/cpu/o3/cpu.cc
@@ -1521,7 +1521,7 @@
system->totalNumInsts++;
// Check for instruction-count-based events.
- serviceInstCountEvents(tid, thread[tid]->numInst);
+ thread[tid]->tc->serviceInstCountEvents(thread[tid]->numInst);
}
thread[tid]->numOp++;
thread[tid]->numOps++;
diff --git a/src/cpu/o3/probe/elastic_trace.cc b/src/cpu/o3/probe/elastic_trace.cc
index 5866886..3e98e5a 100644
--- a/src/cpu/o3/probe/elastic_trace.cc
+++ b/src/cpu/o3/probe/elastic_trace.cc
@@ -109,8 +109,8 @@
} else {
// Schedule an event to register all elastic trace probes when
// specified no. of instructions are committed.
- cpu->scheduleInstCountEvent(
- 0, ®EtraceListenersEvent, startTraceInst);
+ cpu->getContext(0)->scheduleInstCountEvent(
+ ®EtraceListenersEvent, startTraceInst);
}
}
diff --git a/src/cpu/simple/base.cc b/src/cpu/simple/base.cc
index fc07fed..f45165b 100644
--- a/src/cpu/simple/base.cc
+++ b/src/cpu/simple/base.cc
@@ -500,7 +500,7 @@
t_info.setMemAccPredicate(true);
// check for instruction-count-based events
- serviceInstCountEvents(curThread, t_info.numInst);
+ thread->getTC()->serviceInstCountEvents(t_info.numInst);
// decode the instruction
inst = gtoh(inst);