get rid of all instances of readTid() and getThreadNum(). Unify and eliminate

redundancies with threadId() as their replacement.
This commit is contained in:
Lisa Hsu 2008-11-04 11:35:42 -05:00
parent d857faf073
commit dd99ff23c6
20 changed files with 112 additions and 106 deletions

View file

@ -196,7 +196,7 @@ def format MT_Control(code, *opt_flags) {{
def format MT_MFTR(code, *flags) {{ def format MT_MFTR(code, *flags) {{
flags += ('IsNonSpeculative', ) flags += ('IsNonSpeculative', )
# code = 'std::cerr << curTick << \": T\" << xc->tcBase()->getThreadNum() << \": Executing MT INST: ' + name + '\" << endl;\n' + code # code = 'std::cerr << curTick << \": T\" << xc->tcBase()->threadId() << \": Executing MT INST: ' + name + '\" << endl;\n' + code
code += 'if (MT_H == 1) {\n' code += 'if (MT_H == 1) {\n'
code += 'data = bits(data, top_bit, bottom_bit);\n' code += 'data = bits(data, top_bit, bottom_bit);\n'
@ -212,7 +212,7 @@ def format MT_MFTR(code, *flags) {{
def format MT_MTTR(code, *flags) {{ def format MT_MTTR(code, *flags) {{
flags += ('IsNonSpeculative', ) flags += ('IsNonSpeculative', )
# code = 'std::cerr << curTick << \": T\" << xc->tcBase()->getThreadNum() << \": Executing MT INST: ' + name + '\" << endl;\n' + code # code = 'std::cerr << curTick << \": T\" << xc->tcBase()->threadId() << \": Executing MT INST: ' + name + '\" << endl;\n' + code
iop = InstObjParams(name, Name, 'MTOp', code, flags) iop = InstObjParams(name, Name, 'MTOp', code, flags)
header_output = BasicDeclare.subst(iop) header_output = BasicDeclare.subst(iop)
decoder_output = BasicConstructor.subst(iop) decoder_output = BasicConstructor.subst(iop)

View file

@ -52,7 +52,7 @@ handleLockedRead(XC *xc, Request *req)
xc->setMiscRegNoEffect(LLAddr, req->getPaddr() & ~0xf); xc->setMiscRegNoEffect(LLAddr, req->getPaddr() & ~0xf);
xc->setMiscRegNoEffect(LLFlag, true); xc->setMiscRegNoEffect(LLFlag, true);
DPRINTF(LLSC, "[tid:%i]: Load-Link Flag Set & Load-Link Address set to %x.\n", DPRINTF(LLSC, "[tid:%i]: Load-Link Flag Set & Load-Link Address set to %x.\n",
req->getThreadNum(), req->getPaddr() & ~0xf); req->threadId(), req->getPaddr() & ~0xf);
} }
@ -94,10 +94,10 @@ handleLockedWrite(XC *xc, Request *req)
if (!lock_flag){ if (!lock_flag){
DPRINTF(LLSC, "[tid:%i]: Lock Flag Set, Store Conditional Failed.\n", DPRINTF(LLSC, "[tid:%i]: Lock Flag Set, Store Conditional Failed.\n",
req->getThreadNum()); req->threadId());
} else if ((req->getPaddr() & ~0xf) != lock_addr) { } else if ((req->getPaddr() & ~0xf) != lock_addr) {
DPRINTF(LLSC, "[tid:%i]: Load-Link Address Mismatch, Store Conditional Failed.\n", DPRINTF(LLSC, "[tid:%i]: Load-Link Address Mismatch, Store Conditional Failed.\n",
req->getThreadNum()); req->threadId());
} }
// store conditional failed already, so don't issue it to mem // store conditional failed already, so don't issue it to mem
return false; return false;

View file

@ -78,7 +78,7 @@ haltThread(TC *tc)
// @TODO: Needs to check if this is a branch and if so, take previous instruction // @TODO: Needs to check if this is a branch and if so, take previous instruction
tc->setMiscReg(TCRestart, tc->readNextPC()); tc->setMiscReg(TCRestart, tc->readNextPC());
warn("%i: Halting thread %i in %s @ PC %x, setting restart PC to %x", curTick, tc->getThreadNum(), tc->getCpuPtr()->name(), warn("%i: Halting thread %i in %s @ PC %x, setting restart PC to %x", curTick, tc->threadId(), tc->getCpuPtr()->name(),
tc->readPC(), tc->readNextPC()); tc->readPC(), tc->readNextPC());
} }
} }
@ -98,7 +98,7 @@ restoreThread(TC *tc)
tc->setNextNPC(pc + 8); tc->setNextNPC(pc + 8);
tc->activate(0); tc->activate(0);
warn("%i: Restoring thread %i in %s @ PC %x", curTick, tc->getThreadNum(), tc->getCpuPtr()->name(), warn("%i: Restoring thread %i in %s @ PC %x", curTick, tc->threadId(), tc->getCpuPtr()->name(),
tc->readPC()); tc->readPC());
} }
} }
@ -217,7 +217,7 @@ yieldThread(TC *tc, Fault &fault, int src_reg, uint32_t yield_mask)
if (ok == 1) { if (ok == 1) {
unsigned tcstatus = tc->readMiscRegNoEffect(TCStatus); unsigned tcstatus = tc->readMiscRegNoEffect(TCStatus);
tc->setMiscReg(TCStatus, insertBits(tcstatus, TCS_A, TCS_A, 0)); tc->setMiscReg(TCStatus, insertBits(tcstatus, TCS_A, TCS_A, 0));
warn("%i: Deactivating Hardware Thread Context #%i", curTick, tc->getThreadNum()); warn("%i: Deactivating Hardware Thread Context #%i", curTick, tc->threadId());
} }
} else if (src_reg > 0) { } else if (src_reg > 0) {
if (src_reg && !yield_mask != 0) { if (src_reg && !yield_mask != 0) {
@ -238,7 +238,7 @@ yieldThread(TC *tc, Fault &fault, int src_reg, uint32_t yield_mask)
fault = new ThreadFault(); fault = new ThreadFault();
} else { } else {
//tc->ScheduleOtherThreads(); //tc->ScheduleOtherThreads();
//std::cerr << "T" << tc->getThreadNum() << "YIELD: Schedule Other Threads.\n" << std::endl; //std::cerr << "T" << tc->threadId() << "YIELD: Schedule Other Threads.\n" << std::endl;
//tc->suspend(); //tc->suspend();
// Save last known PC in TCRestart // Save last known PC in TCRestart
// @TODO: Needs to check if this is a branch and if so, take previous instruction // @TODO: Needs to check if this is a branch and if so, take previous instruction

View file

@ -259,7 +259,7 @@ zeroRegisters(CPU *cpu)
void void
startupCPU(ThreadContext *tc, int cpuId) startupCPU(ThreadContext *tc, int cpuId)
{ {
tc->activate(0/*tc->getThreadNum()*/); tc->activate(0/*tc->threadId()*/);
} }
} // namespace MipsISA } // namespace MipsISA

View file

@ -329,6 +329,7 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU, Port *ic, Port *dc)
CpuEvent::replaceThreadContext(oldTC, newTC); CpuEvent::replaceThreadContext(oldTC, newTC);
assert(newTC->contextId() == oldTC->contextId()); assert(newTC->contextId() == oldTC->contextId());
assert(newTC->threadId() == oldTC->threadId());
system->replaceThreadContext(newTC, newTC->contextId()); system->replaceThreadContext(newTC, newTC->contextId());
if (DTRACE(Context)) if (DTRACE(Context))

View file

@ -82,7 +82,7 @@ class BaseCPU : public MemObject
Tick instCnt; Tick instCnt;
// every cpu has an id, put it in the base cpu // every cpu has an id, put it in the base cpu
// Set at initialization, only time a cpuId might change is during a // Set at initialization, only time a cpuId might change is during a
// takeover (which should be done from within the BaseCPU anyway, // takeover (which should be done from within the BaseCPU anyway,
// therefore no setCpuId() method is provided // therefore no setCpuId() method is provided
int _cpuId; int _cpuId;

View file

@ -153,7 +153,7 @@ class CheckerThreadContext : public ThreadContext
void profileSample() { return actualTC->profileSample(); } void profileSample() { return actualTC->profileSample(); }
#endif #endif
int getThreadNum() { return actualTC->getThreadNum(); } int threadId() { return actualTC->threadId(); }
// @todo: Do I need this? // @todo: Do I need this?
MachInst getInst() { return actualTC->getInst(); } MachInst getInst() { return actualTC->getInst(); }

View file

@ -59,7 +59,7 @@ Trace::ExeTracerRecord::dump()
outs << (misspeculating ? "-" : "+") << " "; outs << (misspeculating ? "-" : "+") << " ";
if (IsOn(ExecThread)) if (IsOn(ExecThread))
outs << "T" << thread->getThreadNum() << " : "; outs << "T" << thread->threadId() << " : ";
std::string sym_str; std::string sym_str;

View file

@ -82,6 +82,10 @@ class O3ThreadContext : public ThreadContext
virtual void setContextId(int id) { thread->setContextId(id); } virtual void setContextId(int id) { thread->setContextId(id); }
/** Returns this thread's ID number. */
virtual int threadId() { return thread->threadId(); }
virtual void setThreadId(int id) { return thread->setThreadId(id); }
#if FULL_SYSTEM #if FULL_SYSTEM
/** Returns a pointer to the system. */ /** Returns a pointer to the system. */
virtual System *getSystemPtr() { return cpu->system; } virtual System *getSystemPtr() { return cpu->system; }
@ -152,9 +156,6 @@ class O3ThreadContext : public ThreadContext
/** Samples the function profiling information. */ /** Samples the function profiling information. */
virtual void profileSample(); virtual void profileSample();
#endif #endif
/** Returns this thread's ID number. */
virtual int getThreadNum() { return thread->readTid(); }
/** Returns the instruction this thread is currently committing. /** Returns the instruction this thread is currently committing.
* Only used when an instruction faults. * Only used when an instruction faults.
*/ */
@ -190,36 +191,36 @@ class O3ThreadContext : public ThreadContext
/** Reads this thread's PC. */ /** Reads this thread's PC. */
virtual uint64_t readPC() virtual uint64_t readPC()
{ return cpu->readPC(thread->readTid()); } { return cpu->readPC(thread->threadId()); }
/** Sets this thread's PC. */ /** Sets this thread's PC. */
virtual void setPC(uint64_t val); virtual void setPC(uint64_t val);
/** Reads this thread's next PC. */ /** Reads this thread's next PC. */
virtual uint64_t readNextPC() virtual uint64_t readNextPC()
{ return cpu->readNextPC(thread->readTid()); } { return cpu->readNextPC(thread->threadId()); }
/** Sets this thread's next PC. */ /** Sets this thread's next PC. */
virtual void setNextPC(uint64_t val); virtual void setNextPC(uint64_t val);
virtual uint64_t readMicroPC() virtual uint64_t readMicroPC()
{ return cpu->readMicroPC(thread->readTid()); } { return cpu->readMicroPC(thread->threadId()); }
virtual void setMicroPC(uint64_t val); virtual void setMicroPC(uint64_t val);
virtual uint64_t readNextMicroPC() virtual uint64_t readNextMicroPC()
{ return cpu->readNextMicroPC(thread->readTid()); } { return cpu->readNextMicroPC(thread->threadId()); }
virtual void setNextMicroPC(uint64_t val); virtual void setNextMicroPC(uint64_t val);
/** Reads a miscellaneous register. */ /** Reads a miscellaneous register. */
virtual MiscReg readMiscRegNoEffect(int misc_reg) virtual MiscReg readMiscRegNoEffect(int misc_reg)
{ return cpu->readMiscRegNoEffect(misc_reg, thread->readTid()); } { return cpu->readMiscRegNoEffect(misc_reg, thread->threadId()); }
/** Reads a misc. register, including any side-effects the /** Reads a misc. register, including any side-effects the
* read might have as defined by the architecture. */ * read might have as defined by the architecture. */
virtual MiscReg readMiscReg(int misc_reg) virtual MiscReg readMiscReg(int misc_reg)
{ return cpu->readMiscReg(misc_reg, thread->readTid()); } { return cpu->readMiscReg(misc_reg, thread->threadId()); }
/** Sets a misc. register. */ /** Sets a misc. register. */
virtual void setMiscRegNoEffect(int misc_reg, const MiscReg &val); virtual void setMiscRegNoEffect(int misc_reg, const MiscReg &val);
@ -257,7 +258,7 @@ class O3ThreadContext : public ThreadContext
/** Executes a syscall in SE mode. */ /** Executes a syscall in SE mode. */
virtual void syscall(int64_t callnum) virtual void syscall(int64_t callnum)
{ return cpu->syscall(callnum, thread->readTid()); } { return cpu->syscall(callnum, thread->threadId()); }
/** Reads the funcExeInst counter. */ /** Reads the funcExeInst counter. */
virtual Counter readFuncExeInst() { return thread->funcExeInst; } virtual Counter readFuncExeInst() { return thread->funcExeInst; }
@ -271,7 +272,7 @@ class O3ThreadContext : public ThreadContext
virtual uint64_t readNextNPC() virtual uint64_t readNextNPC()
{ {
return this->cpu->readNextNPC(this->thread->readTid()); return this->cpu->readNextNPC(this->thread->threadId());
} }
virtual void setNextNPC(uint64_t val) virtual void setNextNPC(uint64_t val)
@ -279,7 +280,7 @@ class O3ThreadContext : public ThreadContext
#if THE_ISA == ALPHA_ISA #if THE_ISA == ALPHA_ISA
panic("Not supported on Alpha!"); panic("Not supported on Alpha!");
#endif #endif
this->cpu->setNextNPC(val, this->thread->readTid()); this->cpu->setNextNPC(val, this->thread->threadId());
} }
/** This function exits the thread context in the CPU and returns /** This function exits the thread context in the CPU and returns

View file

@ -64,6 +64,7 @@ O3ThreadContext<Impl>::takeOverFrom(ThreadContext *old_context)
setStatus(old_context->status()); setStatus(old_context->status());
copyArchRegs(old_context); copyArchRegs(old_context);
setContextId(old_context->contextId()); setContextId(old_context->contextId());
setThreadId(old_context->threadId());
#if !FULL_SYSTEM #if !FULL_SYSTEM
thread->funcExeInst = old_context->readFuncExeInst(); thread->funcExeInst = old_context->readFuncExeInst();
@ -95,7 +96,7 @@ void
O3ThreadContext<Impl>::activate(int delay) O3ThreadContext<Impl>::activate(int delay)
{ {
DPRINTF(O3CPU, "Calling activate on Thread Context %d\n", DPRINTF(O3CPU, "Calling activate on Thread Context %d\n",
getThreadNum()); threadId());
if (thread->status() == ThreadContext::Active) if (thread->status() == ThreadContext::Active)
return; return;
@ -105,14 +106,14 @@ O3ThreadContext<Impl>::activate(int delay)
#endif #endif
if (thread->status() == ThreadContext::Unallocated) { if (thread->status() == ThreadContext::Unallocated) {
cpu->activateWhenReady(thread->readTid()); cpu->activateWhenReady(thread->threadId());
return; return;
} }
thread->setStatus(ThreadContext::Active); thread->setStatus(ThreadContext::Active);
// status() == Suspended // status() == Suspended
cpu->activateContext(thread->readTid(), delay); cpu->activateContext(thread->threadId(), delay);
} }
template <class Impl> template <class Impl>
@ -120,7 +121,7 @@ void
O3ThreadContext<Impl>::suspend(int delay) O3ThreadContext<Impl>::suspend(int delay)
{ {
DPRINTF(O3CPU, "Calling suspend on Thread Context %d\n", DPRINTF(O3CPU, "Calling suspend on Thread Context %d\n",
getThreadNum()); threadId());
if (thread->status() == ThreadContext::Suspended) if (thread->status() == ThreadContext::Suspended)
return; return;
@ -139,7 +140,7 @@ O3ThreadContext<Impl>::suspend(int delay)
#endif #endif
*/ */
thread->setStatus(ThreadContext::Suspended); thread->setStatus(ThreadContext::Suspended);
cpu->suspendContext(thread->readTid()); cpu->suspendContext(thread->threadId());
} }
template <class Impl> template <class Impl>
@ -147,13 +148,13 @@ void
O3ThreadContext<Impl>::deallocate(int delay) O3ThreadContext<Impl>::deallocate(int delay)
{ {
DPRINTF(O3CPU, "Calling deallocate on Thread Context %d delay %d\n", DPRINTF(O3CPU, "Calling deallocate on Thread Context %d delay %d\n",
getThreadNum(), delay); threadId(), delay);
if (thread->status() == ThreadContext::Unallocated) if (thread->status() == ThreadContext::Unallocated)
return; return;
thread->setStatus(ThreadContext::Unallocated); thread->setStatus(ThreadContext::Unallocated);
cpu->deallocateContext(thread->readTid(), true, delay); cpu->deallocateContext(thread->threadId(), true, delay);
} }
template <class Impl> template <class Impl>
@ -161,13 +162,13 @@ void
O3ThreadContext<Impl>::halt(int delay) O3ThreadContext<Impl>::halt(int delay)
{ {
DPRINTF(O3CPU, "Calling halt on Thread Context %d\n", DPRINTF(O3CPU, "Calling halt on Thread Context %d\n",
getThreadNum()); threadId());
if (thread->status() == ThreadContext::Halted) if (thread->status() == ThreadContext::Halted)
return; return;
thread->setStatus(ThreadContext::Halted); thread->setStatus(ThreadContext::Halted);
cpu->haltContext(thread->readTid()); cpu->haltContext(thread->threadId());
} }
template <class Impl> template <class Impl>
@ -245,7 +246,7 @@ O3ThreadContext<Impl>::copyArchRegs(ThreadContext *tc)
{ {
// This function will mess things up unless the ROB is empty and // This function will mess things up unless the ROB is empty and
// there are no instructions in the pipeline. // there are no instructions in the pipeline.
unsigned tid = thread->readTid(); unsigned tid = thread->threadId();
PhysRegIndex renamed_reg; PhysRegIndex renamed_reg;
// First loop through the integer registers. // First loop through the integer registers.
@ -292,7 +293,7 @@ uint64_t
O3ThreadContext<Impl>::readIntReg(int reg_idx) O3ThreadContext<Impl>::readIntReg(int reg_idx)
{ {
reg_idx = TheISA::flattenIntIndex(this, reg_idx); reg_idx = TheISA::flattenIntIndex(this, reg_idx);
return cpu->readArchIntReg(reg_idx, thread->readTid()); return cpu->readArchIntReg(reg_idx, thread->threadId());
} }
template <class Impl> template <class Impl>
@ -302,9 +303,9 @@ O3ThreadContext<Impl>::readFloatReg(int reg_idx, int width)
reg_idx = TheISA::flattenFloatIndex(this, reg_idx); reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
switch(width) { switch(width) {
case 32: case 32:
return cpu->readArchFloatRegSingle(reg_idx, thread->readTid()); return cpu->readArchFloatRegSingle(reg_idx, thread->threadId());
case 64: case 64:
return cpu->readArchFloatRegDouble(reg_idx, thread->readTid()); return cpu->readArchFloatRegDouble(reg_idx, thread->threadId());
default: default:
panic("Unsupported width!"); panic("Unsupported width!");
return 0; return 0;
@ -316,7 +317,7 @@ TheISA::FloatReg
O3ThreadContext<Impl>::readFloatReg(int reg_idx) O3ThreadContext<Impl>::readFloatReg(int reg_idx)
{ {
reg_idx = TheISA::flattenFloatIndex(this, reg_idx); reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
return cpu->readArchFloatRegSingle(reg_idx, thread->readTid()); return cpu->readArchFloatRegSingle(reg_idx, thread->threadId());
} }
template <class Impl> template <class Impl>
@ -325,7 +326,7 @@ O3ThreadContext<Impl>::readFloatRegBits(int reg_idx, int width)
{ {
DPRINTF(Fault, "Reading floatint register through the TC!\n"); DPRINTF(Fault, "Reading floatint register through the TC!\n");
reg_idx = TheISA::flattenFloatIndex(this, reg_idx); reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
return cpu->readArchFloatRegInt(reg_idx, thread->readTid()); return cpu->readArchFloatRegInt(reg_idx, thread->threadId());
} }
template <class Impl> template <class Impl>
@ -333,7 +334,7 @@ TheISA::FloatRegBits
O3ThreadContext<Impl>::readFloatRegBits(int reg_idx) O3ThreadContext<Impl>::readFloatRegBits(int reg_idx)
{ {
reg_idx = TheISA::flattenFloatIndex(this, reg_idx); reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
return cpu->readArchFloatRegInt(reg_idx, thread->readTid()); return cpu->readArchFloatRegInt(reg_idx, thread->threadId());
} }
template <class Impl> template <class Impl>
@ -341,11 +342,11 @@ void
O3ThreadContext<Impl>::setIntReg(int reg_idx, uint64_t val) O3ThreadContext<Impl>::setIntReg(int reg_idx, uint64_t val)
{ {
reg_idx = TheISA::flattenIntIndex(this, reg_idx); reg_idx = TheISA::flattenIntIndex(this, reg_idx);
cpu->setArchIntReg(reg_idx, val, thread->readTid()); cpu->setArchIntReg(reg_idx, val, thread->threadId());
// Squash if we're not already in a state update mode. // Squash if we're not already in a state update mode.
if (!thread->trapPending && !thread->inSyscall) { if (!thread->trapPending && !thread->inSyscall) {
cpu->squashFromTC(thread->readTid()); cpu->squashFromTC(thread->threadId());
} }
} }
@ -356,16 +357,16 @@ O3ThreadContext<Impl>::setFloatReg(int reg_idx, FloatReg val, int width)
reg_idx = TheISA::flattenFloatIndex(this, reg_idx); reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
switch(width) { switch(width) {
case 32: case 32:
cpu->setArchFloatRegSingle(reg_idx, val, thread->readTid()); cpu->setArchFloatRegSingle(reg_idx, val, thread->threadId());
break; break;
case 64: case 64:
cpu->setArchFloatRegDouble(reg_idx, val, thread->readTid()); cpu->setArchFloatRegDouble(reg_idx, val, thread->threadId());
break; break;
} }
// Squash if we're not already in a state update mode. // Squash if we're not already in a state update mode.
if (!thread->trapPending && !thread->inSyscall) { if (!thread->trapPending && !thread->inSyscall) {
cpu->squashFromTC(thread->readTid()); cpu->squashFromTC(thread->threadId());
} }
} }
@ -374,10 +375,10 @@ void
O3ThreadContext<Impl>::setFloatReg(int reg_idx, FloatReg val) O3ThreadContext<Impl>::setFloatReg(int reg_idx, FloatReg val)
{ {
reg_idx = TheISA::flattenFloatIndex(this, reg_idx); reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
cpu->setArchFloatRegSingle(reg_idx, val, thread->readTid()); cpu->setArchFloatRegSingle(reg_idx, val, thread->threadId());
if (!thread->trapPending && !thread->inSyscall) { if (!thread->trapPending && !thread->inSyscall) {
cpu->squashFromTC(thread->readTid()); cpu->squashFromTC(thread->threadId());
} }
} }
@ -388,11 +389,11 @@ O3ThreadContext<Impl>::setFloatRegBits(int reg_idx, FloatRegBits val,
{ {
DPRINTF(Fault, "Setting floatint register through the TC!\n"); DPRINTF(Fault, "Setting floatint register through the TC!\n");
reg_idx = TheISA::flattenFloatIndex(this, reg_idx); reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
cpu->setArchFloatRegInt(reg_idx, val, thread->readTid()); cpu->setArchFloatRegInt(reg_idx, val, thread->threadId());
// Squash if we're not already in a state update mode. // Squash if we're not already in a state update mode.
if (!thread->trapPending && !thread->inSyscall) { if (!thread->trapPending && !thread->inSyscall) {
cpu->squashFromTC(thread->readTid()); cpu->squashFromTC(thread->threadId());
} }
} }
@ -401,11 +402,11 @@ void
O3ThreadContext<Impl>::setFloatRegBits(int reg_idx, FloatRegBits val) O3ThreadContext<Impl>::setFloatRegBits(int reg_idx, FloatRegBits val)
{ {
reg_idx = TheISA::flattenFloatIndex(this, reg_idx); reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
cpu->setArchFloatRegInt(reg_idx, val, thread->readTid()); cpu->setArchFloatRegInt(reg_idx, val, thread->threadId());
// Squash if we're not already in a state update mode. // Squash if we're not already in a state update mode.
if (!thread->trapPending && !thread->inSyscall) { if (!thread->trapPending && !thread->inSyscall) {
cpu->squashFromTC(thread->readTid()); cpu->squashFromTC(thread->threadId());
} }
} }
@ -413,11 +414,11 @@ template <class Impl>
void void
O3ThreadContext<Impl>::setPC(uint64_t val) O3ThreadContext<Impl>::setPC(uint64_t val)
{ {
cpu->setPC(val, thread->readTid()); cpu->setPC(val, thread->threadId());
// Squash if we're not already in a state update mode. // Squash if we're not already in a state update mode.
if (!thread->trapPending && !thread->inSyscall) { if (!thread->trapPending && !thread->inSyscall) {
cpu->squashFromTC(thread->readTid()); cpu->squashFromTC(thread->threadId());
} }
} }
@ -425,11 +426,11 @@ template <class Impl>
void void
O3ThreadContext<Impl>::setNextPC(uint64_t val) O3ThreadContext<Impl>::setNextPC(uint64_t val)
{ {
cpu->setNextPC(val, thread->readTid()); cpu->setNextPC(val, thread->threadId());
// Squash if we're not already in a state update mode. // Squash if we're not already in a state update mode.
if (!thread->trapPending && !thread->inSyscall) { if (!thread->trapPending && !thread->inSyscall) {
cpu->squashFromTC(thread->readTid()); cpu->squashFromTC(thread->threadId());
} }
} }
@ -437,11 +438,11 @@ template <class Impl>
void void
O3ThreadContext<Impl>::setMicroPC(uint64_t val) O3ThreadContext<Impl>::setMicroPC(uint64_t val)
{ {
cpu->setMicroPC(val, thread->readTid()); cpu->setMicroPC(val, thread->threadId());
// Squash if we're not already in a state update mode. // Squash if we're not already in a state update mode.
if (!thread->trapPending && !thread->inSyscall) { if (!thread->trapPending && !thread->inSyscall) {
cpu->squashFromTC(thread->readTid()); cpu->squashFromTC(thread->threadId());
} }
} }
@ -449,11 +450,11 @@ template <class Impl>
void void
O3ThreadContext<Impl>::setNextMicroPC(uint64_t val) O3ThreadContext<Impl>::setNextMicroPC(uint64_t val)
{ {
cpu->setNextMicroPC(val, thread->readTid()); cpu->setNextMicroPC(val, thread->threadId());
// Squash if we're not already in a state update mode. // Squash if we're not already in a state update mode.
if (!thread->trapPending && !thread->inSyscall) { if (!thread->trapPending && !thread->inSyscall) {
cpu->squashFromTC(thread->readTid()); cpu->squashFromTC(thread->threadId());
} }
} }
@ -461,11 +462,11 @@ template <class Impl>
void void
O3ThreadContext<Impl>::setMiscRegNoEffect(int misc_reg, const MiscReg &val) O3ThreadContext<Impl>::setMiscRegNoEffect(int misc_reg, const MiscReg &val)
{ {
cpu->setMiscRegNoEffect(misc_reg, val, thread->readTid()); cpu->setMiscRegNoEffect(misc_reg, val, thread->threadId());
// Squash if we're not already in a state update mode. // Squash if we're not already in a state update mode.
if (!thread->trapPending && !thread->inSyscall) { if (!thread->trapPending && !thread->inSyscall) {
cpu->squashFromTC(thread->readTid()); cpu->squashFromTC(thread->threadId());
} }
} }
@ -474,11 +475,11 @@ void
O3ThreadContext<Impl>::setMiscReg(int misc_reg, O3ThreadContext<Impl>::setMiscReg(int misc_reg,
const MiscReg &val) const MiscReg &val)
{ {
cpu->setMiscReg(misc_reg, val, thread->readTid()); cpu->setMiscReg(misc_reg, val, thread->threadId());
// Squash if we're not already in a state update mode. // Squash if we're not already in a state update mode.
if (!thread->trapPending && !thread->inSyscall) { if (!thread->trapPending && !thread->inSyscall) {
cpu->squashFromTC(thread->readTid()); cpu->squashFromTC(thread->threadId());
} }
} }
@ -488,21 +489,21 @@ template <class Impl>
TheISA::IntReg TheISA::IntReg
O3ThreadContext<Impl>::getSyscallArg(int i) O3ThreadContext<Impl>::getSyscallArg(int i)
{ {
return cpu->getSyscallArg(i, thread->readTid()); return cpu->getSyscallArg(i, thread->threadId());
} }
template <class Impl> template <class Impl>
void void
O3ThreadContext<Impl>::setSyscallArg(int i, IntReg val) O3ThreadContext<Impl>::setSyscallArg(int i, IntReg val)
{ {
cpu->setSyscallArg(i, val, thread->readTid()); cpu->setSyscallArg(i, val, thread->threadId());
} }
template <class Impl> template <class Impl>
void void
O3ThreadContext<Impl>::setSyscallReturn(SyscallReturn return_value) O3ThreadContext<Impl>::setSyscallReturn(SyscallReturn return_value)
{ {
cpu->setSyscallReturn(return_value, thread->readTid()); cpu->setSyscallReturn(return_value, thread->threadId());
} }
#endif // FULL_SYSTEM #endif // FULL_SYSTEM

View file

@ -176,7 +176,7 @@ class OzoneCPU : public BaseCPU
void profileSample(); void profileSample();
#endif #endif
int getThreadNum(); int threadId();
// Also somewhat obnoxious. Really only used for the TLB fault. // Also somewhat obnoxious. Really only used for the TLB fault.
TheISA::MachInst getInst(); TheISA::MachInst getInst();
@ -260,7 +260,7 @@ class OzoneCPU : public BaseCPU
} }
void setSyscallReturn(SyscallReturn return_value) void setSyscallReturn(SyscallReturn return_value)
{ cpu->setSyscallReturn(return_value, thread->readTid()); } { cpu->setSyscallReturn(return_value, thread->threadId()); }
Counter readFuncExeInst() { return thread->funcExeInst; } Counter readFuncExeInst() { return thread->funcExeInst; }

View file

@ -588,7 +588,7 @@ OzoneCPU<Impl>::postInterrupt(int int_num, int index)
// thread.activate(); // thread.activate();
// Hack for now. Otherwise might have to go through the tc, or // Hack for now. Otherwise might have to go through the tc, or
// I need to figure out what's the right thing to call. // I need to figure out what's the right thing to call.
activateContext(thread.readTid(), 1); activateContext(thread.threadId(), 1);
} }
} }
#endif // FULL_SYSTEM #endif // FULL_SYSTEM
@ -711,7 +711,7 @@ OzoneCPU<Impl>::simPalCheck(int palFunc)
switch (palFunc) { switch (palFunc) {
case PAL::halt: case PAL::halt:
haltContext(thread.readTid()); haltContext(thread.threadId());
if (--System::numSystemsRunning == 0) if (--System::numSystemsRunning == 0)
exitSimLoop("all cpus halted"); exitSimLoop("all cpus halted");
break; break;
@ -745,7 +745,7 @@ template <class Impl>
void void
OzoneCPU<Impl>::OzoneTC::activate(int delay) OzoneCPU<Impl>::OzoneTC::activate(int delay)
{ {
cpu->activateContext(thread->readTid(), delay); cpu->activateContext(thread->threadId(), delay);
} }
/// Set the status to Suspended. /// Set the status to Suspended.
@ -753,7 +753,7 @@ template <class Impl>
void void
OzoneCPU<Impl>::OzoneTC::suspend() OzoneCPU<Impl>::OzoneTC::suspend()
{ {
cpu->suspendContext(thread->readTid()); cpu->suspendContext(thread->threadId());
} }
/// Set the status to Unallocated. /// Set the status to Unallocated.
@ -761,7 +761,7 @@ template <class Impl>
void void
OzoneCPU<Impl>::OzoneTC::deallocate(int delay) OzoneCPU<Impl>::OzoneTC::deallocate(int delay)
{ {
cpu->deallocateContext(thread->readTid(), delay); cpu->deallocateContext(thread->threadId(), delay);
} }
/// Set the status to Halted. /// Set the status to Halted.
@ -769,7 +769,7 @@ template <class Impl>
void void
OzoneCPU<Impl>::OzoneTC::halt() OzoneCPU<Impl>::OzoneTC::halt()
{ {
cpu->haltContext(thread->readTid()); cpu->haltContext(thread->threadId());
} }
#if FULL_SYSTEM #if FULL_SYSTEM
@ -884,9 +884,9 @@ OzoneCPU<Impl>::OzoneTC::profileSample()
template <class Impl> template <class Impl>
int int
OzoneCPU<Impl>::OzoneTC::getThreadNum() OzoneCPU<Impl>::OzoneTC::threadId()
{ {
return thread->readTid(); return thread->threadId();
} }
template <class Impl> template <class Impl>

View file

@ -183,6 +183,7 @@ SimpleThread::copyState(ThreadContext *oldContext)
#endif #endif
inst = oldContext->getInst(); inst = oldContext->getInst();
_threadId = oldContext->threadId();
_contextId = oldContext->contextId(); _contextId = oldContext->contextId();
} }
@ -221,14 +222,14 @@ SimpleThread::activate(int delay)
lastActivate = curTick; lastActivate = curTick;
// if (status() == ThreadContext::Unallocated) { // if (status() == ThreadContext::Unallocated) {
// cpu->activateWhenReady(tid); // cpu->activateWhenReady(_threadId);
// return; // return;
// } // }
_status = ThreadContext::Active; _status = ThreadContext::Active;
// status() == Suspended // status() == Suspended
cpu->activateContext(tid, delay); cpu->activateContext(_threadId, delay);
} }
void void
@ -249,7 +250,7 @@ SimpleThread::suspend()
#endif #endif
*/ */
_status = ThreadContext::Suspended; _status = ThreadContext::Suspended;
cpu->suspendContext(tid); cpu->suspendContext(_threadId);
} }
void void
@ -259,7 +260,7 @@ SimpleThread::deallocate()
return; return;
_status = ThreadContext::Unallocated; _status = ThreadContext::Unallocated;
cpu->deallocateContext(tid); cpu->deallocateContext(_threadId);
} }
void void
@ -269,7 +270,7 @@ SimpleThread::halt()
return; return;
_status = ThreadContext::Halted; _status = ThreadContext::Halted;
cpu->haltContext(tid); cpu->haltContext(_threadId);
} }

View file

@ -197,8 +197,6 @@ class SimpleThread : public ThreadState
BaseCPU *getCpuPtr() { return cpu; } BaseCPU *getCpuPtr() { return cpu; }
int getThreadNum() { return tid; }
TheISA::ITB *getITBPtr() { return itb; } TheISA::ITB *getITBPtr() { return itb; }
TheISA::DTB *getDTBPtr() { return dtb; } TheISA::DTB *getDTBPtr() { return dtb; }

View file

@ -117,7 +117,9 @@ class ThreadContext
virtual int cpuId() = 0; virtual int cpuId() = 0;
virtual int getThreadNum() = 0; virtual int threadId() = 0;
virtual void setThreadId(int id) = 0;
virtual int contextId() = 0; virtual int contextId() = 0;
@ -304,7 +306,9 @@ class ProxyThreadContext : public ThreadContext
int cpuId() { return actualTC->cpuId(); } int cpuId() { return actualTC->cpuId(); }
int getThreadNum() { return actualTC->getThreadNum(); } int threadId() { return actualTC->threadId(); }
void setThreadId(int id) { return actualTC->setThreadId(id); }
int contextId() { return actualTC->contextId(); } int contextId() { return actualTC->contextId(); }

View file

@ -44,14 +44,14 @@
#if FULL_SYSTEM #if FULL_SYSTEM
ThreadState::ThreadState(BaseCPU *cpu, int _tid) ThreadState::ThreadState(BaseCPU *cpu, int _tid)
: baseCpu(cpu), tid(_tid), lastActivate(0), lastSuspend(0), : baseCpu(cpu), _threadId(_tid), lastActivate(0), lastSuspend(0),
profile(NULL), profileNode(NULL), profilePC(0), quiesceEvent(NULL), profile(NULL), profileNode(NULL), profilePC(0), quiesceEvent(NULL),
kernelStats(NULL), physPort(NULL), virtPort(NULL), kernelStats(NULL), physPort(NULL), virtPort(NULL),
microPC(0), nextMicroPC(1), funcExeInst(0), storeCondFailures(0) microPC(0), nextMicroPC(1), funcExeInst(0), storeCondFailures(0)
#else #else
ThreadState::ThreadState(BaseCPU *cpu, int _tid, Process *_process, ThreadState::ThreadState(BaseCPU *cpu, int _tid, Process *_process,
short _asid) short _asid)
: baseCpu(cpu), tid(_tid), lastActivate(0), lastSuspend(0), : baseCpu(cpu), _threadId(_tid), lastActivate(0), lastSuspend(0),
port(NULL), process(_process), asid(_asid), port(NULL), process(_process), asid(_asid),
microPC(0), nextMicroPC(1), funcExeInst(0), storeCondFailures(0) microPC(0), nextMicroPC(1), funcExeInst(0), storeCondFailures(0)
#endif #endif
@ -129,7 +129,7 @@ ThreadState::connectPhysPort()
physPort->removeConn(); physPort->removeConn();
else else
physPort = new FunctionalPort(csprintf("%s-%d-funcport", physPort = new FunctionalPort(csprintf("%s-%d-funcport",
baseCpu->name(), tid)); baseCpu->name(), _threadId));
connectToMemFunc(physPort); connectToMemFunc(physPort);
} }
@ -143,7 +143,7 @@ ThreadState::connectVirtPort(ThreadContext *tc)
virtPort->removeConn(); virtPort->removeConn();
else else
virtPort = new VirtualPort(csprintf("%s-%d-vport", virtPort = new VirtualPort(csprintf("%s-%d-vport",
baseCpu->name(), tid), tc); baseCpu->name(), _threadId), tc);
connectToMemFunc(virtPort); connectToMemFunc(virtPort);
} }
@ -169,7 +169,7 @@ ThreadState::getMemPort()
return port; return port;
/* Use this port to for syscall emulation writes to memory. */ /* Use this port to for syscall emulation writes to memory. */
port = new TranslatingPort(csprintf("%s-%d-funcport", baseCpu->name(), tid), port = new TranslatingPort(csprintf("%s-%d-funcport", baseCpu->name(), _threadId),
process, TranslatingPort::NextPage); process, TranslatingPort::NextPage);
connectToMemFunc(port); connectToMemFunc(port);

View file

@ -84,9 +84,9 @@ struct ThreadState {
void setContextId(int id) { _contextId = id; } void setContextId(int id) { _contextId = id; }
void setTid(int id) { tid = id; } void setThreadId(int id) { _threadId = id; }
int readTid() { return tid; } int threadId() { return _threadId; }
Tick readLastActivate() { return lastActivate; } Tick readLastActivate() { return lastActivate; }
@ -177,7 +177,7 @@ struct ThreadState {
int _contextId; int _contextId;
// Index of hardware thread context on the CPU that this represents. // Index of hardware thread context on the CPU that this represents.
int tid; int _threadId;
public: public:
/** Last time activate was called on this thread. */ /** Last time activate was called on this thread. */

View file

@ -481,7 +481,7 @@ class BaseCache : public MemObject
void incMissCount(PacketPtr pkt) void incMissCount(PacketPtr pkt)
{ {
misses[pkt->cmdToIndex()][0/*pkt->req->getThreadNum()*/]++; misses[pkt->cmdToIndex()][0/*pkt->req->threadId()*/]++;
if (missCount) { if (missCount) {
--missCount; --missCount;

View file

@ -296,7 +296,7 @@ Cache<TagStore>::access(PacketPtr pkt, BlkType *&blk,
if (pkt->needsExclusive() ? blk->isWritable() : blk->isReadable()) { if (pkt->needsExclusive() ? blk->isWritable() : blk->isReadable()) {
// OK to satisfy access // OK to satisfy access
hits[pkt->cmdToIndex()][0/*pkt->req->getThreadNum()*/]++; hits[pkt->cmdToIndex()][0/*pkt->req->threadId()*/]++;
satisfyCpuSideRequest(pkt, blk); satisfyCpuSideRequest(pkt, blk);
return true; return true;
} }
@ -325,7 +325,7 @@ Cache<TagStore>::access(PacketPtr pkt, BlkType *&blk,
blk->status |= BlkDirty; blk->status |= BlkDirty;
// nothing else to do; writeback doesn't expect response // nothing else to do; writeback doesn't expect response
assert(!pkt->needsResponse()); assert(!pkt->needsResponse());
hits[pkt->cmdToIndex()][0/*pkt->req->getThreadNum()*/]++; hits[pkt->cmdToIndex()][0/*pkt->req->threadId()*/]++;
return true; return true;
} }
@ -467,8 +467,8 @@ Cache<TagStore>::timingAccess(PacketPtr pkt)
if (mshr) { if (mshr) {
// MSHR hit // MSHR hit
//@todo remove hw_pf here //@todo remove hw_pf here
mshr_hits[pkt->cmdToIndex()][0/*pkt->req->getThreadNum()*/]++; mshr_hits[pkt->cmdToIndex()][0/*pkt->req->threadId()*/]++;
if (mshr->threadNum != 0/*pkt->req->getThreadNum()*/) { if (mshr->threadNum != 0/*pkt->req->threadId()*/) {
mshr->threadNum = -1; mshr->threadNum = -1;
} }
mshr->allocateTarget(pkt, time, order++); mshr->allocateTarget(pkt, time, order++);
@ -482,7 +482,7 @@ Cache<TagStore>::timingAccess(PacketPtr pkt)
} }
} else { } else {
// no MSHR // no MSHR
mshr_misses[pkt->cmdToIndex()][0/*pkt->req->getThreadNum()*/]++; mshr_misses[pkt->cmdToIndex()][0/*pkt->req->threadId()*/]++;
// always mark as cache fill for now... if we implement // always mark as cache fill for now... if we implement
// no-write-allocate or bypass accesses this will have to // no-write-allocate or bypass accesses this will have to
// be changed. // be changed.
@ -740,10 +740,10 @@ Cache<TagStore>::handleResponse(PacketPtr pkt)
PacketList writebacks; PacketList writebacks;
if (pkt->req->isUncacheable()) { if (pkt->req->isUncacheable()) {
mshr_uncacheable_lat[stats_cmd_idx][0/*pkt->req->getThreadNum()*/] += mshr_uncacheable_lat[stats_cmd_idx][0/*pkt->req->threadId()*/] +=
miss_latency; miss_latency;
} else { } else {
mshr_miss_latency[stats_cmd_idx][0/*pkt->req->getThreadNum()*/] += mshr_miss_latency[stats_cmd_idx][0/*pkt->req->threadId()*/] +=
miss_latency; miss_latency;
} }
@ -784,7 +784,7 @@ Cache<TagStore>::handleResponse(PacketPtr pkt)
(transfer_offset ? pkt->finishTime : pkt->firstWordTime); (transfer_offset ? pkt->finishTime : pkt->firstWordTime);
assert(!target->pkt->req->isUncacheable()); assert(!target->pkt->req->isUncacheable());
missLatency[target->pkt->cmdToIndex()][0/*pkt->req->getThreadNum()*/] += missLatency[target->pkt->cmdToIndex()][0/*pkt->req->threadId()*/] +=
completion_time - target->recvTime; completion_time - target->recvTime;
} else { } else {
// not a cache fill, just forwarding response // not a cache fill, just forwarding response
@ -862,7 +862,7 @@ Cache<TagStore>::writebackBlk(BlkType *blk)
{ {
assert(blk && blk->isValid() && blk->isDirty()); assert(blk && blk->isValid() && blk->isDirty());
writebacks[0/*pkt->req->getThreadNum()*/]++; writebacks[0/*pkt->req->threadId()*/]++;
Request *writebackReq = Request *writebackReq =
new Request(tags->regenerateBlkAddr(blk->tag, blk->set), blkSize, 0); new Request(tags->regenerateBlkAddr(blk->tag, blk->set), blkSize, 0);
@ -1261,7 +1261,7 @@ Cache<TagStore>::getNextMSHR()
if (pkt) { if (pkt) {
// Update statistic on number of prefetches issued // Update statistic on number of prefetches issued
// (hwpf_mshr_misses) // (hwpf_mshr_misses)
mshr_misses[pkt->cmdToIndex()][0/*pkt->req->getThreadNum()*/]++; mshr_misses[pkt->cmdToIndex()][0/*pkt->req->threadId()*/]++;
// Don't request bus, since we already have it // Don't request bus, since we already have it
return allocateMissBuffer(pkt, curTick, false); return allocateMissBuffer(pkt, curTick, false);
} }

View file

@ -230,7 +230,7 @@ MSHRQueue::squash(int threadNum)
if (mshr->threadNum == threadNum) { if (mshr->threadNum == threadNum) {
while (mshr->hasTargets()) { while (mshr->hasTargets()) {
mshr->popTarget(); mshr->popTarget();
assert(0/*target->req->getThreadNum()*/ == threadNum); assert(0/*target->req->threadId()*/ == threadNum);
} }
assert(!mshr->hasTargets()); assert(!mshr->hasTargets());
assert(mshr->ntargets==0); assert(mshr->ntargets==0);