From e3d8b931420200679e8119f1affe7ad156f8c726 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 20 Oct 2020 19:53:47 -0700 Subject: [PATCH] base,sim: Move BitUnion serialization support to bitunion.hh. This keeps the BitUnion code centralized and out of the generic serialization code. Change-Id: I297638df4f8908096b7c439298fbaf03236f9011 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36283 Tested-by: kokoro Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg --- src/base/bitunion.hh | 27 +++++++++++++++++++++++++++ src/sim/serialize_handlers.hh | 27 --------------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/base/bitunion.hh b/src/base/bitunion.hh index bf183ae0e..aef6f6ec6 100644 --- a/src/base/bitunion.hh +++ b/src/base/bitunion.hh @@ -35,6 +35,7 @@ #include #include "base/bitfield.hh" +#include "sim/serialize_handlers.hh" // The following implements the BitUnion system of defining bitfields //on top of an underlying class. This is done through the pervasive use of @@ -505,4 +506,30 @@ operator << (std::ostream &os, const BitUnionType &bu) os, (BitUnionBaseType)bu); } +// Specialization for BitUnion types. +template +struct ParseParam> +{ + static bool + parse(const std::string &s, BitUnionType &value) + { + // Zero initialize storage to avoid leaking an uninitialized value + BitUnionBaseType storage = BitUnionBaseType(); + auto res = to_number(s, storage); + value = storage; + return res; + } +}; + +template +struct ShowParam> +{ + static void + show(std::ostream &os, const BitUnionType &value) + { + ShowParam>::show( + os, static_cast &>(value)); + } +}; + #endif // __BASE_BITUNION_HH__ diff --git a/src/sim/serialize_handlers.hh b/src/sim/serialize_handlers.hh index e09712140..8efd895ba 100644 --- a/src/sim/serialize_handlers.hh +++ b/src/sim/serialize_handlers.hh @@ -50,7 +50,6 @@ #include #include -#include "base/bitunion.hh" #include "base/str.hh" /** @@ -108,21 +107,6 @@ struct ParseParam } }; -// Specialization for BitUnion types. -template -struct ParseParam> -{ - static bool - parse(const std::string &s, BitUnionType &value) - { - // Zero initialize storage to avoid leaking an uninitialized value - BitUnionBaseType storage = BitUnionBaseType(); - auto res = to_number(s, storage); - value = storage; - return res; - } -}; - /* * A structure which should be specialized to contain a static method with the * signature: @@ -168,17 +152,6 @@ struct ShowParam } }; -template -struct ShowParam> -{ - static void - show(std::ostream &os, const BitUnionType &value) - { - ShowParam>::show( - os, static_cast &>(value)); - } -}; - /** @} */ #endif // __SERIALIZE_HANDLERS_HH__ -- 2.30.2