arm,x86,sim: Use the new return value suppression in GuestABI.
authorGabe Black <gabeblack@google.com>
Wed, 29 Apr 2020 09:39:45 +0000 (02:39 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 12 May 2020 16:32:09 +0000 (16:32 +0000)
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 <gabeblack@google.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/arm/semihosting.cc
src/arch/x86/tlb.cc
src/sim/pseudo_inst.hh

index 7711a86c0a458ef08e2c994c9cd860696cc280a0..61a049d594cce998c0852579ee87543cc21d230d 100644 (file)
@@ -696,18 +696,6 @@ struct SemiPseudoAbi64 : public ArmSemihosting::Abi64
 namespace GuestABI
 {
 
-// Ignore return values since those will be handled by semihosting.
-template <typename T>
-struct Result<SemiPseudoAbi32, T>
-{
-    static void store(ThreadContext *tc, const T &ret) {}
-};
-template <typename T>
-struct Result<SemiPseudoAbi64, T>
-{
-    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 <typename T>
index ceccba892f4beb663942996752d82c6ae7a2e0a8..4464702dd03288b0391e70576a5b54e9e4cbf73b 100644 (file)
@@ -266,7 +266,7 @@ TLB::finalizePhysical(const RequestPtr &req,
             [func, mode](ThreadContext *tc, PacketPtr pkt) -> Cycles
             {
                 uint64_t ret;
-                PseudoInst::pseudoInst<X86PseudoInstABI>(tc, func, ret);
+                PseudoInst::pseudoInst<X86PseudoInstABI, true>(tc, func, ret);
                 if (mode == Read)
                     pkt->setLE(ret);
                 return Cycles(1);
index 6a63812dc70a137f69f406777a88ae8d64e9c3dc..982d6c86b2666b37b4629fddd11b9121f6573737 100644 (file)
@@ -59,16 +59,6 @@ struct PseudoInstABI
 namespace GuestABI
 {
 
-template <typename T>
-struct Result<PseudoInstABI, T>
-{
-    static void
-    store(ThreadContext *tc, const T &ret)
-    {
-        // Don't do anything with the pseudo inst results by default.
-    }
-};
-
 template <>
 struct Argument<PseudoInstABI, uint64_t>
 {
@@ -134,9 +124,9 @@ void togglesync(ThreadContext *tc);
  * @return Whether the pseudo instruction was recognized/handled.
  */
 
-template <typename ABI>
+template <typename ABI, bool store_ret>
 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<ABI>(tc, quiesceTime);
+        result = invokeSimcall<ABI, store_ret>(tc, quiesceTime);
         return true;
 
       case M5OP_RPNS:
-        result = invokeSimcall<ABI>(tc, rpns);
+        result = invokeSimcall<ABI, store_ret>(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<ABI>(tc, initParam);
+        result = invokeSimcall<ABI, store_ret>(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<ABI>(tc, writefile);
+        result = invokeSimcall<ABI, store_ret>(tc, writefile);
         return true;
 
       case M5OP_READ_FILE:
-        result = invokeSimcall<ABI>(tc, readfile);
+        result = invokeSimcall<ABI, store_ret>(tc, readfile);
         return true;
 
       case M5OP_DEBUG_BREAK:
@@ -262,6 +252,21 @@ pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result)
     }
 }
 
+template <typename ABI, bool store_ret=false>
+bool
+pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result)
+{
+    return pseudoInstWork<ABI, store_ret>(tc, func, result);
+}
+
+template <typename ABI, bool store_ret=true>
+bool
+pseudoInst(ThreadContext *tc, uint8_t func)
+{
+    uint64_t result;
+    return pseudoInstWork<ABI, store_ret>(tc, func, result);
+}
+
 } // namespace PseudoInst
 
 #endif // __SIM_PSEUDO_INST_HH__