From 62fe81e9c1ab09f1b401231f58d9c34008c7b558 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Fri, 7 Mar 2014 15:56:23 -0500 Subject: [PATCH] cpu: Make CPU and ThreadContext getters const This patch merely tidies up the CPU and ThreadContext getters by making them const where appropriate. --- src/cpu/base.hh | 2 +- src/cpu/base_dyn_inst.hh | 8 ++++---- src/cpu/checker/thread_context.hh | 6 +++--- src/cpu/inorder/inorder_dyn_inst.cc | 2 +- src/cpu/inorder/inorder_dyn_inst.hh | 4 ++-- src/cpu/inorder/thread_context.hh | 6 +++--- src/cpu/o3/thread_context.hh | 6 +++--- src/cpu/ozone/cpu.hh | 2 +- src/cpu/ozone/cpu_impl.hh | 2 +- src/cpu/thread_context.hh | 14 +++++++------- src/cpu/thread_state.hh | 10 +++++----- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/cpu/base.hh b/src/cpu/base.hh index 515f6a5a2..321b785a2 100644 --- a/src/cpu/base.hh +++ b/src/cpu/base.hh @@ -143,7 +143,7 @@ class BaseCPU : public MemObject virtual MasterPort &getInstPort() = 0; /** Reads this CPU's ID. */ - int cpuId() { return _cpuId; } + int cpuId() const { return _cpuId; } /** Reads this CPU's unique data requestor ID */ MasterID dataMasterId() { return _dataMasterId; } diff --git a/src/cpu/base_dyn_inst.hh b/src/cpu/base_dyn_inst.hh index 3ce7de75d..cafe51fd7 100644 --- a/src/cpu/base_dyn_inst.hh +++ b/src/cpu/base_dyn_inst.hh @@ -454,16 +454,16 @@ class BaseDynInst : public RefCounted void dump(std::string &outstring); /** Read this CPU's ID. */ - int cpuId() { return cpu->cpuId(); } + int cpuId() const { return cpu->cpuId(); } /** Read this CPU's data requestor ID */ - MasterID masterId() { return cpu->dataMasterId(); } + MasterID masterId() const { return cpu->dataMasterId(); } /** Read this context's system-wide ID **/ - int contextId() { return thread->contextId(); } + int contextId() const { return thread->contextId(); } /** Returns the fault type. */ - Fault getFault() { return fault; } + Fault getFault() const { return fault; } /** Checks whether or not this instruction has had its branch target * calculated yet. For now it is not utilized and is hacked to be diff --git a/src/cpu/checker/thread_context.hh b/src/cpu/checker/thread_context.hh index 5c695c750..ddd07ea58 100644 --- a/src/cpu/checker/thread_context.hh +++ b/src/cpu/checker/thread_context.hh @@ -92,9 +92,9 @@ class CheckerThreadContext : public ThreadContext BaseCPU *getCpuPtr() { return actualTC->getCpuPtr(); } - int cpuId() { return actualTC->cpuId(); } + int cpuId() const { return actualTC->cpuId(); } - int contextId() { return actualTC->contextId(); } + int contextId() const { return actualTC->contextId(); } void setContextId(int id) { @@ -103,7 +103,7 @@ class CheckerThreadContext : public ThreadContext } /** Returns this thread's ID number. */ - int threadId() { return actualTC->threadId(); } + int threadId() const { return actualTC->threadId(); } void setThreadId(int id) { checkerTC->setThreadId(id); diff --git a/src/cpu/inorder/inorder_dyn_inst.cc b/src/cpu/inorder/inorder_dyn_inst.cc index aedc630f5..86dbdf97c 100644 --- a/src/cpu/inorder/inorder_dyn_inst.cc +++ b/src/cpu/inorder/inorder_dyn_inst.cc @@ -91,7 +91,7 @@ InOrderDynInst::InOrderDynInst(InOrderCPU *cpu, int InOrderDynInst::instcount = 0; int -InOrderDynInst::cpuId() +InOrderDynInst::cpuId() const { return cpu->cpuId(); } diff --git a/src/cpu/inorder/inorder_dyn_inst.hh b/src/cpu/inorder/inorder_dyn_inst.hh index 48c15e292..578fd604a 100644 --- a/src/cpu/inorder/inorder_dyn_inst.hh +++ b/src/cpu/inorder/inorder_dyn_inst.hh @@ -357,10 +357,10 @@ class InOrderDynInst : public RefCounted Fault getFault() { return fault; } /** Read this CPU's ID. */ - int cpuId(); + int cpuId() const; /** Read this context's system-wide ID **/ - int contextId() { return thread->contextId(); } + int contextId() const { return thread->contextId(); } //////////////////////////////////////////////////////////// // diff --git a/src/cpu/inorder/thread_context.hh b/src/cpu/inorder/thread_context.hh index b1a361027..96ec063c8 100644 --- a/src/cpu/inorder/thread_context.hh +++ b/src/cpu/inorder/thread_context.hh @@ -111,14 +111,14 @@ class InOrderThreadContext : public ThreadContext std::string getCpuName() { return cpu->name(); } /** Reads this CPU's ID. */ - int cpuId() { return cpu->cpuId(); } + int cpuId() const { return cpu->cpuId(); } - int contextId() { return thread->contextId(); } + int contextId() const { return thread->contextId(); } void setContextId(int id) { thread->setContextId(id); } /** Returns this thread's ID number. */ - int threadId() { return thread->threadId(); } + int threadId() const { return thread->threadId(); } void setThreadId(int id) { return thread->setThreadId(id); } uint64_t readMicroPC() diff --git a/src/cpu/o3/thread_context.hh b/src/cpu/o3/thread_context.hh index 27f8e9561..ef72fdb03 100755 --- a/src/cpu/o3/thread_context.hh +++ b/src/cpu/o3/thread_context.hh @@ -96,14 +96,14 @@ class O3ThreadContext : public ThreadContext virtual BaseCPU *getCpuPtr() { return cpu; } /** Reads this CPU's ID. */ - virtual int cpuId() { return cpu->cpuId(); } + virtual int cpuId() const { return cpu->cpuId(); } - virtual int contextId() { return thread->contextId(); } + virtual int contextId() const { return thread->contextId(); } virtual void setContextId(int id) { thread->setContextId(id); } /** Returns this thread's ID number. */ - virtual int threadId() { return thread->threadId(); } + virtual int threadId() const { return thread->threadId(); } virtual void setThreadId(int id) { return thread->setThreadId(id); } /** Returns a pointer to the system. */ diff --git a/src/cpu/ozone/cpu.hh b/src/cpu/ozone/cpu.hh index 91de37eff..673ca535e 100644 --- a/src/cpu/ozone/cpu.hh +++ b/src/cpu/ozone/cpu.hh @@ -149,7 +149,7 @@ class OzoneCPU : public BaseCPU void profileClear(); void profileSample(); - int threadId(); + int threadId() const; void copyArchRegs(ThreadContext *tc); diff --git a/src/cpu/ozone/cpu_impl.hh b/src/cpu/ozone/cpu_impl.hh index ff99cc7f6..2556ab6da 100644 --- a/src/cpu/ozone/cpu_impl.hh +++ b/src/cpu/ozone/cpu_impl.hh @@ -704,7 +704,7 @@ OzoneCPU::OzoneTC::profileSample() template int -OzoneCPU::OzoneTC::threadId() +OzoneCPU::OzoneTC::threadId() const { return thread->threadId(); } diff --git a/src/cpu/thread_context.hh b/src/cpu/thread_context.hh index efd3cc800..4b88b4a0b 100644 --- a/src/cpu/thread_context.hh +++ b/src/cpu/thread_context.hh @@ -121,13 +121,13 @@ class ThreadContext virtual BaseCPU *getCpuPtr() = 0; - virtual int cpuId() = 0; + virtual int cpuId() const = 0; - virtual int threadId() = 0; + virtual int threadId() const = 0; virtual void setThreadId(int id) = 0; - virtual int contextId() = 0; + virtual int contextId() const = 0; virtual void setContextId(int id) = 0; @@ -321,13 +321,13 @@ class ProxyThreadContext : public ThreadContext BaseCPU *getCpuPtr() { return actualTC->getCpuPtr(); } - int cpuId() { return actualTC->cpuId(); } + int cpuId() const { return actualTC->cpuId(); } - int threadId() { return actualTC->threadId(); } + int threadId() const { return actualTC->threadId(); } - void setThreadId(int id) { return actualTC->setThreadId(id); } + void setThreadId(int id) { actualTC->setThreadId(id); } - int contextId() { return actualTC->contextId(); } + int contextId() const { return actualTC->contextId(); } void setContextId(int id) { actualTC->setContextId(id); } diff --git a/src/cpu/thread_state.hh b/src/cpu/thread_state.hh index d8dccc4ae..775f6fbd4 100644 --- a/src/cpu/thread_state.hh +++ b/src/cpu/thread_state.hh @@ -67,19 +67,19 @@ struct ThreadState { void unserialize(Checkpoint *cp, const std::string §ion); - int cpuId() { return baseCpu->cpuId(); } + int cpuId() const { return baseCpu->cpuId(); } - int contextId() { return _contextId; } + int contextId() const { return _contextId; } void setContextId(int id) { _contextId = id; } void setThreadId(ThreadID id) { _threadId = id; } - ThreadID threadId() { return _threadId; } + ThreadID threadId() const { return _threadId; } - Tick readLastActivate() { return lastActivate; } + Tick readLastActivate() const { return lastActivate; } - Tick readLastSuspend() { return lastSuspend; } + Tick readLastSuspend() const { return lastSuspend; } /** * Initialise the physical and virtual port proxies and tie them to -- 2.30.2