cpu: Eliminate some macros in the minor CPU.

These were MINORTRACE, MINORINST, and MINORLINE. Replace them with
inline template functions.

Change-Id: I02b13d60b41349dfe7ac33e6009c0e3e5cf11156
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45620
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2021-05-17 22:35:02 -07:00
parent 49000fc3b6
commit db21d1bb39
10 changed files with 40 additions and 23 deletions

View File

@@ -59,7 +59,8 @@ MinorActivityRecorder::minorTrace() const
stages << ',';
}
MINORTRACE("activity=%d stages=%s\n", getActivityCount(), stages.str());
Minor::minorTrace("activity=%d stages=%s\n", getActivityCount(),
stages.str());
}
}

View File

@@ -208,7 +208,7 @@ class MinorBuffer : public Named, public TimeBuffer<ElemType>
data << ',';
}
MINORTRACE("%s=%s\n", dataName, data.str());
Minor::minorTrace("%s=%s\n", dataName, data.str());
}
};
@@ -547,7 +547,7 @@ class Queue : public Named, public Reservable
data << ',';
}
MINORTRACE("%s=%s\n", dataName, data.str());
Minor::minorTrace("%s=%s\n", dataName, data.str());
}
};

View File

@@ -344,7 +344,7 @@ Decode::minorTrace() const
else
(*out.inputWire).reportData(data);
MINORTRACE("insts=%s\n", data.str());
Minor::minorTrace("insts=%s\n", data.str());
inputBuffer[0].minorTrace();
}

View File

@@ -182,7 +182,7 @@ MinorDynInst::minorTraceInst(const Named &named_object,
const BaseISA::RegClasses &reg_classes) const
{
if (isFault()) {
MINORINST(&named_object, "id=F;%s addr=0x%x fault=\"%s\"\n",
minorInst(named_object, "id=F;%s addr=0x%x fault=\"%s\"\n",
id, pc.instAddr(), fault->name());
} else {
unsigned int num_src_regs = staticInst->numSrcRegs();
@@ -223,7 +223,7 @@ MinorDynInst::minorTraceInst(const Named &named_object,
std::ostringstream flags;
staticInst->printFlags(flags, " ");
MINORINST(&named_object, "id=%s addr=0x%x inst=\"%s\" class=%s"
minorInst(named_object, "id=%s addr=0x%x inst=\"%s\" class=%s"
" flags=\"%s\"%s%s\n",
id, pc.instAddr(),
(staticInst->opClass() == No_OpClass ?

View File

@@ -1675,7 +1675,7 @@ Execute::minorTrace() const
stalled << ',';
}
MINORTRACE("insts=%s inputIndex=%d streamSeqNum=%d"
Minor::minorTrace("insts=%s inputIndex=%d streamSeqNum=%d"
" stalled=%s drainState=%d isInbetweenInsts=%d\n",
insts.str(), executeInfo[0].inputIndex, executeInfo[0].streamSeqNum,
stalled.str(), executeInfo[0].drainState, isInbetweenInsts(0));

View File

@@ -391,16 +391,16 @@ void
Fetch1::minorTraceResponseLine(const std::string &name,
Fetch1::FetchRequestPtr response) const
{
GEM5_VAR_USED const RequestPtr &request = response->request;
const RequestPtr &request = response->request;
if (response->packet && response->packet->isError()) {
MINORLINE(this, "id=F;%s vaddr=0x%x fault=\"error packet\"\n",
minorLine(*this, "id=F;%s vaddr=0x%x fault=\"error packet\"\n",
response->id, request->getVaddr());
} else if (response->fault != NoFault) {
MINORLINE(this, "id=F;%s vaddr=0x%x fault=\"%s\"\n",
minorLine(*this, "id=F;%s vaddr=0x%x fault=\"%s\"\n",
response->id, request->getVaddr(), response->fault->name());
} else {
MINORLINE(this, "id=%s size=%d vaddr=0x%x paddr=0x%x\n",
minorLine(*this, "id=%s size=%d vaddr=0x%x paddr=0x%x\n",
response->id, request->getSize(),
request->getVaddr(), request->getPaddr());
}
@@ -765,7 +765,7 @@ Fetch1::minorTrace() const
else
(*out.inputWire).reportData(data);
MINORTRACE("state=%s icacheState=%s in_tlb_mem=%s/%s"
Minor::minorTrace("state=%s icacheState=%s in_tlb_mem=%s/%s"
" streamSeqNum=%d lines=%s\n", thread.state, icacheState,
numFetchesInITLB, numFetchesInMemorySystem,
thread.streamSeqNum, data.str());

View File

@@ -644,8 +644,9 @@ Fetch2::minorTrace() const
else
(*out.inputWire).reportData(data);
MINORTRACE("inputIndex=%d havePC=%d predictionSeqNum=%d insts=%s\n",
fetchInfo[0].inputIndex, fetchInfo[0].havePC, fetchInfo[0].predictionSeqNum, data.str());
Minor::minorTrace("inputIndex=%d havePC=%d predictionSeqNum=%d insts=%s\n",
fetchInfo[0].inputIndex, fetchInfo[0].havePC,
fetchInfo[0].predictionSeqNum, data.str());
inputBuffer[0].minorTrace();
}

View File

@@ -950,7 +950,7 @@ LSQ::StoreBuffer::minorTrace() const
os << ',';
}
MINORTRACE("addr=%s num_unissued_stores=%d\n", os.str(),
Minor::minorTrace("addr=%s num_unissued_stores=%d\n", os.str(),
numUnissuedAccesses);
}
@@ -1665,7 +1665,7 @@ LSQ::pushFailedRequest(MinorDynInstPtr inst)
void
LSQ::minorTrace() const
{
MINORTRACE("state=%s in_tlb_mem=%d/%d stores_in_transfers=%d"
Minor::minorTrace("state=%s in_tlb_mem=%d/%d stores_in_transfers=%d"
" lastMemBarrier=%d\n",
state, numAccessesInDTLB, numAccessesInMemorySystem,
numStoresInTransfers, lastMemBarrier[0]);

View File

@@ -302,7 +302,7 @@ Scoreboard::minorTrace() const
i++;
}
MINORTRACE("busy=%s\n", result_stream.str());
Minor::minorTrace("busy=%s\n", result_stream.str());
}
}

View File

@@ -50,6 +50,7 @@
#include <string>
#include "base/named.hh"
#include "base/trace.hh"
#include "debug/MinorTrace.hh"
@@ -57,16 +58,30 @@ namespace Minor
{
/** DPRINTFN for MinorTrace reporting */
#define MINORTRACE(...) \
DPRINTF(MinorTrace, "MinorTrace: " __VA_ARGS__)
template <class ...Args>
inline void
minorTrace(const char *fmt, Args ...args)
{
DPRINTF(MinorTrace, (std::string("MinorTrace: ") + fmt).c_str(), args...);
}
/** DPRINTFN for MinorTrace MinorInst line reporting */
#define MINORINST(sim_object, ...) \
DPRINTFS(MinorTrace, (sim_object), "MinorInst: " __VA_ARGS__)
template <class ...Args>
inline void
minorInst(const Named &named, const char *fmt, Args ...args)
{
DPRINTFS(MinorTrace, &named, (std::string("MinorInst: ") + fmt).c_str(),
args...);
}
/** DPRINTFN for MinorTrace MinorLine line reporting */
#define MINORLINE(sim_object, ...) \
DPRINTFS(MinorTrace, (sim_object), "MinorLine: " __VA_ARGS__)
template <class ...Args>
inline void
minorLine(const Named &named, const char *fmt, Args ...args)
{
DPRINTFS(MinorTrace, &named, (std::string("MinorLine: ") + fmt).c_str(),
args...);
}
}