From 1e4a6b32b462a4d1d302724421b4b2b78f9c9bd8 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 29 Apr 2020 02:39:45 -0700 Subject: [PATCH] arm,x86,sim: Use the new return value suppression in GuestABI. This gets rid of some dummy Return structure definitions. Also augment the PseudoInst::pseudoInst dispatch function so it can store or not store results, depending on what's needed at each call sight. Change-Id: If4a53bc0a27e5214a26ef1a100c99948ca95418d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28289 Reviewed-by: Gabe Black Reviewed-by: Nikos Nikoleris Maintainer: Gabe Black Tested-by: kokoro --- src/arch/arm/semihosting.cc | 12 ------------ src/arch/x86/tlb.cc | 2 +- src/sim/pseudo_inst.hh | 39 +++++++++++++++++++++---------------- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/arch/arm/semihosting.cc b/src/arch/arm/semihosting.cc index 7711a86c0..61a049d59 100644 --- a/src/arch/arm/semihosting.cc +++ b/src/arch/arm/semihosting.cc @@ -696,18 +696,6 @@ struct SemiPseudoAbi64 : public ArmSemihosting::Abi64 namespace GuestABI { -// Ignore return values since those will be handled by semihosting. -template -struct Result -{ - static void store(ThreadContext *tc, const T &ret) {} -}; -template -struct Result -{ - static void store(ThreadContext *tc, const T &ret) {} -}; - // Handle arguments the same as for semihosting operations. Skipping the first // slot is handled internally by the State type. template diff --git a/src/arch/x86/tlb.cc b/src/arch/x86/tlb.cc index ceccba892..4464702dd 100644 --- a/src/arch/x86/tlb.cc +++ b/src/arch/x86/tlb.cc @@ -266,7 +266,7 @@ TLB::finalizePhysical(const RequestPtr &req, [func, mode](ThreadContext *tc, PacketPtr pkt) -> Cycles { uint64_t ret; - PseudoInst::pseudoInst(tc, func, 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 6a63812dc..982d6c86b 100644 --- a/src/sim/pseudo_inst.hh +++ b/src/sim/pseudo_inst.hh @@ -59,16 +59,6 @@ struct PseudoInstABI namespace GuestABI { -template -struct Result -{ - static void - store(ThreadContext *tc, const T &ret) - { - // Don't do anything with the pseudo inst results by default. - } -}; - template <> struct Argument { @@ -134,9 +124,9 @@ void togglesync(ThreadContext *tc); * @return Whether the pseudo instruction was recognized/handled. */ -template +template bool -pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result) +pseudoInstWork(ThreadContext *tc, uint8_t func, uint64_t &result) { DPRINTF(PseudoInst, "PseudoInst::pseudoInst(%i)\n", func); @@ -160,11 +150,11 @@ pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result) return true; case M5OP_QUIESCE_TIME: - result = invokeSimcall(tc, quiesceTime); + result = invokeSimcall(tc, quiesceTime); return true; case M5OP_RPNS: - result = invokeSimcall(tc, rpns); + result = invokeSimcall(tc, rpns); return true; case M5OP_WAKE_CPU: @@ -180,7 +170,7 @@ pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result) return true; case M5OP_INIT_PARAM: - result = invokeSimcall(tc, initParam); + result = invokeSimcall(tc, initParam); return true; case M5OP_LOAD_SYMBOL: @@ -204,11 +194,11 @@ pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result) return true; case M5OP_WRITE_FILE: - result = invokeSimcall(tc, writefile); + result = invokeSimcall(tc, writefile); return true; case M5OP_READ_FILE: - result = invokeSimcall(tc, readfile); + result = invokeSimcall(tc, readfile); return true; case M5OP_DEBUG_BREAK: @@ -262,6 +252,21 @@ pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result) } } +template +bool +pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result) +{ + return pseudoInstWork(tc, func, result); +} + +template +bool +pseudoInst(ThreadContext *tc, uint8_t func) +{ + uint64_t result; + return pseudoInstWork(tc, func, result); +} + } // namespace PseudoInst #endif // __SIM_PSEUDO_INST_HH__ -- 2.30.2