From: Gabe Black Date: Thu, 27 Feb 2020 00:07:15 +0000 (-0800) Subject: arch,sim: Return whether or not a pseudo inst was recognized. X-Git-Tag: v20.0.0.0~258 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=268c9d836fb17cb35d4bc06f08659950fad33b0f;p=gem5.git arch,sim: Return whether or not a pseudo inst was recognized. Otherwise there's no way to distinguish whether return values are from the calls themselves, including what they mean in the context (success or failure?) or the pseudo inst dispatch function itself. Change-Id: I3e71c277f175c69af0d1adeb3299d88d095dfa84 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25948 Tested-by: Gem5 Cloud Project GCB service account <345032938727@cloudbuild.gserviceaccount.com> Tested-by: kokoro Maintainer: Jason Lowe-Power Reviewed-by: Jason Lowe-Power Reviewed-by: Alexandru Duțu --- diff --git a/src/arch/arm/tlb.cc b/src/arch/arm/tlb.cc index 5a92a0c33..84160bba8 100644 --- a/src/arch/arm/tlb.cc +++ b/src/arch/arm/tlb.cc @@ -141,7 +141,8 @@ TLB::finalizePhysical(const RequestPtr &req, req->setLocalAccessor( [func, mode](ThreadContext *tc, PacketPtr pkt) -> Cycles { - uint64_t ret = PseudoInst::pseudoInst(tc, func); + uint64_t ret; + PseudoInst::pseudoInst(tc, func, ret); if (mode == Read) pkt->setLE(ret); return Cycles(1); diff --git a/src/arch/x86/tlb.cc b/src/arch/x86/tlb.cc index 46bab4815..53492b033 100644 --- a/src/arch/x86/tlb.cc +++ b/src/arch/x86/tlb.cc @@ -265,8 +265,8 @@ TLB::finalizePhysical(const RequestPtr &req, req->setLocalAccessor( [func, mode](ThreadContext *tc, PacketPtr pkt) -> Cycles { - uint64_t ret = - PseudoInst::pseudoInst(tc, func); + uint64_t ret; + PseudoInst::pseudoInst(tc, func, ret); if (mode == Read) pkt->setLE(ret); return Cycles(1); diff --git a/src/sim/pseudo_inst.hh b/src/sim/pseudo_inst.hh index fbf997a9c..be9e5bb63 100644 --- a/src/sim/pseudo_inst.hh +++ b/src/sim/pseudo_inst.hh @@ -130,100 +130,109 @@ void togglesync(ThreadContext *tc); * manner using the ISA-specific getArguments functions. * * @param func M5 pseudo op major function number (see utility/m5/m5ops.h) + * @param result A reference to a uint64_t to store a result in. + * @return Whether the pseudo instruction was recognized/handled. */ template -uint64_t -pseudoInst(ThreadContext *tc, uint8_t func) +bool +pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result) { DPRINTF(PseudoInst, "PseudoInst::pseudoInst(%i)\n", func); + result = 0; + switch (func) { case M5OP_ARM: invokeSimcall(tc, arm); - break; + return true; case M5OP_QUIESCE: invokeSimcall(tc, quiesce); - break; + return true; case M5OP_QUIESCE_NS: invokeSimcall(tc, quiesceNs); - break; + return true; case M5OP_QUIESCE_CYCLE: invokeSimcall(tc, quiesceCycles); - break; + return true; case M5OP_QUIESCE_TIME: - return invokeSimcall(tc, quiesceTime); + result = invokeSimcall(tc, quiesceTime); + return true; case M5OP_RPNS: - return invokeSimcall(tc, rpns); + result = invokeSimcall(tc, rpns); + return true; case M5OP_WAKE_CPU: invokeSimcall(tc, wakeCPU); - break; + return true; case M5OP_EXIT: invokeSimcall(tc, m5exit); - break; + return true; case M5OP_FAIL: invokeSimcall(tc, m5fail); - break; + return true; case M5OP_INIT_PARAM: - return invokeSimcall(tc, initParam); + result = invokeSimcall(tc, initParam); + return true; case M5OP_LOAD_SYMBOL: invokeSimcall(tc, loadsymbol); - break; + return true; case M5OP_RESET_STATS: invokeSimcall(tc, resetstats); - break; + return true; case M5OP_DUMP_STATS: invokeSimcall(tc, dumpstats); - break; + return true; case M5OP_DUMP_RESET_STATS: invokeSimcall(tc, dumpresetstats); - break; + return true; case M5OP_CHECKPOINT: invokeSimcall(tc, m5checkpoint); - break; + return true; case M5OP_WRITE_FILE: - return invokeSimcall(tc, writefile); + result = invokeSimcall(tc, writefile); + return true; case M5OP_READ_FILE: - return invokeSimcall(tc, readfile); + result = invokeSimcall(tc, readfile); + return true; case M5OP_DEBUG_BREAK: invokeSimcall(tc, debugbreak); - break; + return true; case M5OP_SWITCH_CPU: invokeSimcall(tc, switchcpu); - break; + return true; case M5OP_ADD_SYMBOL: invokeSimcall(tc, addsymbol); - break; + return true; case M5OP_PANIC: panic("M5 panic instruction called at %s\n", tc->pcState()); case M5OP_WORK_BEGIN: invokeSimcall(tc, workbegin); - break; + return true; case M5OP_WORK_END: invokeSimcall(tc, workend); - break; + return true; case M5OP_ANNOTATE: case M5OP_RESERVED2: @@ -231,28 +240,26 @@ pseudoInst(ThreadContext *tc, uint8_t func) case M5OP_RESERVED4: case M5OP_RESERVED5: warn("Unimplemented m5 op (%#x)\n", func); - break; + return false; /* SE mode functions */ case M5OP_SE_SYSCALL: invokeSimcall(tc, m5Syscall); - break; + return true; case M5OP_SE_PAGE_FAULT: invokeSimcall(tc, TheISA::m5PageFault); - break; + return true; /* dist-gem5 functions */ case M5OP_DIST_TOGGLE_SYNC: invokeSimcall(tc, togglesync); - break; + return true; default: warn("Unhandled m5 op: %#x\n", func); - break; + return false; } - - return 0; } } // namespace PseudoInst