From: Gabe Black Date: Fri, 7 Aug 2020 09:15:09 +0000 (-0700) Subject: x86: Use default initializers to simplify the decoder constructor. X-Git-Tag: v20.1.0.0~246 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9154f23d2c2f0bd11d1a6710eaab56a3dcb4250c;p=gem5.git x86: Use default initializers to simplify the decoder constructor. Change-Id: I76f1fe9a58a26f26c204cb0b9bab050a22d289c9 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/32895 Reviewed-by: Nikos Nikoleris Maintainer: Gabe Black Tested-by: kokoro --- diff --git a/src/arch/x86/decoder.hh b/src/arch/x86/decoder.hh index b26241843..6b05324b8 100644 --- a/src/arch/x86/decoder.hh +++ b/src/arch/x86/decoder.hh @@ -83,24 +83,24 @@ class Decoder : public InstDecoder // The bytes to be predecoded. MachInst fetchChunk; - InstBytes *instBytes; + InstBytes *instBytes = &dummy; int chunkIdx; // The pc of the start of fetchChunk. - Addr basePC; + Addr basePC = 0; // The pc the current instruction started at. - Addr origPC; + Addr origPC = 0; // The offset into fetchChunk of current processing. - int offset; + int offset = 0; // The extended machine instruction being generated. ExtMachInst emi; // Predecoding state. - X86Mode mode; - X86SubMode submode; - uint8_t altOp; - uint8_t defOp; - uint8_t altAddr; - uint8_t defAddr; - uint8_t stack; + X86Mode mode = LongMode; + X86SubMode submode = SixtyFourBitMode; + uint8_t altOp = 0; + uint8_t defOp = 0; + uint8_t altAddr = 0; + uint8_t defAddr = 0; + uint8_t stack = 0; uint8_t getNextByte() @@ -167,9 +167,9 @@ class Decoder : public InstDecoder // State machine state. protected: // Whether or not we're out of bytes. - bool outOfBytes; + bool outOfBytes = true; // Whether we've completed generating an ExtMachInst. - bool instDone; + bool instDone = false; // The size of the displacement value. int displacementSize; // The size of the immediate value. @@ -198,7 +198,7 @@ class Decoder : public InstDecoder ErrorState }; - State state; + State state = ResetState; // Functions to handle each of the states State doResetState(); @@ -229,32 +229,21 @@ class Decoder : public InstDecoder typedef RegVal CacheKey; typedef DecodeCache::AddrMap DecodePages; - DecodePages *decodePages; + DecodePages *decodePages = nullptr; typedef std::unordered_map AddrCacheMap; AddrCacheMap addrCacheMap; - DecodeCache::InstMap *instMap; + DecodeCache::InstMap *instMap = nullptr; typedef std::unordered_map< CacheKey, DecodeCache::InstMap *> InstCacheMap; static InstCacheMap instCacheMap; public: - Decoder(ISA* isa = nullptr) : basePC(0), origPC(0), offset(0), - outOfBytes(true), instDone(false), state(ResetState) + Decoder(ISA *isa=nullptr) { emi.reset(); - mode = LongMode; - submode = SixtyFourBitMode; emi.mode.mode = mode; emi.mode.submode = submode; - altOp = 0; - defOp = 0; - altAddr = 0; - defAddr = 0; - stack = 0; - instBytes = &dummy; - decodePages = NULL; - instMap = NULL; } void