Flesh out ExecContext serialize/unserialize (including RegFile).
authorSteve Reinhardt <stever@eecs.umich.edu>
Wed, 29 Oct 2003 16:50:25 +0000 (08:50 -0800)
committerSteve Reinhardt <stever@eecs.umich.edu>
Wed, 29 Oct 2003 16:50:25 +0000 (08:50 -0800)
Add support for serializing enums.

arch/alpha/isa_traits.hh:
    Add serialize/unserialize functions for RegFile
    (defined in new isa_traits.cc).
cpu/exec_context.cc:
    Flesh out serialize/unserialize.
sim/serialize.hh:
    Add {UN}SERIALIZE_ENUM().

--HG--
extra : convert_revision : 9e30c7e7b3b290dc8ea0888ba3636fc93ee89052

arch/alpha/isa_traits.hh
cpu/exec_context.cc
sim/serialize.hh

index e27841c3c74a7873334a1c3704c886baccc4a973..fbdcffbcf1d2841e7b03eee8a53b5e4210ea73a0 100644 (file)
@@ -158,6 +158,9 @@ class AlphaISA
 #endif // FULL_SYSTEM
         // Are these architectural, or just for convenience?
         uint8_t opcode, ra;            // current instruction details (for intr's)
+
+        void serialize(std::ostream &os);
+        void unserialize(const IniFile *db, const std::string &section);
     };
 
     static StaticInstPtr<AlphaISA> decodeInst(MachInst);
index ed636064982f458001a6a380574291b7ba6996fd..b869a8c4d8b898e3b6bdfd09c61c356b2761840c 100644 (file)
@@ -100,16 +100,20 @@ ExecContext::takeOverFrom(ExecContext *oldContext)
 void
 ExecContext::serialize(ostream &os)
 {
-    SERIALIZE_ARRAY(regs.intRegFile, NumIntRegs);
-    SERIALIZE_ARRAY(regs.floatRegFile.q, NumFloatRegs);
+    SERIALIZE_ENUM(_status);
+    regs.serialize(os);
+    // thread_num and cpu_id are deterministic from the config
+    SERIALIZE_SCALAR(func_exe_insn);
 }
 
 
 void
 ExecContext::unserialize(const IniFile *db, const std::string &section)
 {
-    UNSERIALIZE_ARRAY(regs.intRegFile, NumIntRegs);
-    UNSERIALIZE_ARRAY(regs.floatRegFile.q, NumFloatRegs);
+    UNSERIALIZE_ENUM(_status);
+    regs.unserialize(db, section);
+    // thread_num and cpu_id are deterministic from the config
+    UNSERIALIZE_SCALAR(func_exe_insn);
 }
 
 
index 9c321b897da816af86e24399492cb7311c4b3696..d7842b47d25cc63ace6ab7eceb2d8762fddd1167 100644 (file)
@@ -66,6 +66,16 @@ void arrayParamIn(const IniFile *db, const std::string &section,
 
 #define UNSERIALIZE_SCALAR(scalar)     paramIn(db, section, #scalar, scalar)
 
+// ENUMs are like SCALARs, but we cast them to ints on the way out
+#define SERIALIZE_ENUM(scalar)         paramOut(os, #scalar, (int)scalar)
+
+#define UNSERIALIZE_ENUM(scalar)               \
+ do {                                          \
+    int tmp;                                   \
+    paramIn(db, section, #scalar, tmp);                \
+    scalar = (typeof(scalar))tmp;              \
+  } while (0)
+
 #define SERIALIZE_ARRAY(member, size)  \
         arrayParamOut(os, #member, member, size)