From 56791f45fa1c4146e3f07f96ad80d8dbcc08ae95 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 28 Jan 2021 22:24:43 -0800 Subject: [PATCH] arch: Make some internal decode methods protected. These methods aren't used outside of the decoder and the decode cache, so they don't need to be public. Change-Id: Ifdaf318995f1bb0a75b390bd1c5fde1211c66e62 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40102 Tested-by: kokoro Reviewed-by: Daniel Carvalho Reviewed-by: Bobby R. Bruce Maintainer: Bobby R. Bruce --- src/arch/arm/decoder.hh | 65 ++++++++++++++++++++------------------- src/arch/mips/decoder.hh | 3 +- src/arch/power/decoder.hh | 3 +- src/arch/riscv/decoder.hh | 14 ++++----- src/arch/sparc/decoder.hh | 3 +- src/arch/x86/decoder.hh | 13 ++++---- 6 files changed, 53 insertions(+), 48 deletions(-) diff --git a/src/arch/arm/decoder.hh b/src/arch/arm/decoder.hh index 1f143287fa..53e3f76f6a 100644 --- a/src/arch/arm/decoder.hh +++ b/src/arch/arm/decoder.hh @@ -82,6 +82,7 @@ class Decoder : public InstDecoder /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; + friend class GenericISA::BasicDecodeCache; /** * Pre-decode an instruction from the current state of the @@ -95,6 +96,38 @@ class Decoder : public InstDecoder */ void consumeBytes(int numBytes); + /** + * Decode a machine instruction without calling the cache. + * + * @note The implementation of this method is generated by the ISA + * parser script. + * + * @warn This method takes a pre-decoded instruction as its + * argument. It should typically not be called directly. + * + * @param mach_inst The binary instruction to decode. + * @retval A pointer to the corresponding StaticInst object. + */ + StaticInstPtr decodeInst(ExtMachInst mach_inst); + + /** + * Decode a pre-decoded machine instruction. + * + * @warn This method takes a pre-decoded instruction as its + * argument. It should typically not be called directly. + * + * @param mach_inst A pre-decoded instruction + * @retval A pointer to the corresponding StaticInst object. + */ + StaticInstPtr + decode(ExtMachInst mach_inst, Addr addr) + { + StaticInstPtr si = defaultCache.decode(this, mach_inst, addr); + DPRINTF(Decode, "Decode: Decoded %s instruction: %#x\n", + si->getName(), mach_inst); + return si; + } + public: // Decoder API Decoder(ISA* isa = nullptr); @@ -161,38 +194,6 @@ class Decoder : public InstDecoder */ StaticInstPtr decode(ArmISA::PCState &pc); - /** - * Decode a pre-decoded machine instruction. - * - * @warn This method takes a pre-decoded instruction as its - * argument. It should typically not be called directly. - * - * @param mach_inst A pre-decoded instruction - * @retval A pointer to the corresponding StaticInst object. - */ - StaticInstPtr - decode(ExtMachInst mach_inst, Addr addr) - { - StaticInstPtr si = defaultCache.decode(this, mach_inst, addr); - DPRINTF(Decode, "Decode: Decoded %s instruction: %#x\n", - si->getName(), mach_inst); - return si; - } - - /** - * Decode a machine instruction without calling the cache. - * - * @note The implementation of this method is generated by the ISA - * parser script. - * - * @warn This method takes a pre-decoded instruction as its - * argument. It should typically not be called directly. - * - * @param mach_inst The binary instruction to decode. - * @retval A pointer to the corresponding StaticInst object. - */ - StaticInstPtr decodeInst(ExtMachInst mach_inst); - /** * Take over the state from an old decoder when switching CPUs. * diff --git a/src/arch/mips/decoder.hh b/src/arch/mips/decoder.hh index 6e00bc3731..969c15213b 100644 --- a/src/arch/mips/decoder.hh +++ b/src/arch/mips/decoder.hh @@ -89,8 +89,8 @@ class Decoder : public InstDecoder protected: /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; + friend class GenericISA::BasicDecodeCache; - public: StaticInstPtr decodeInst(ExtMachInst mach_inst); /// Decode a machine instruction. @@ -105,6 +105,7 @@ class Decoder : public InstDecoder return si; } + public: StaticInstPtr decode(MipsISA::PCState &nextPC) { diff --git a/src/arch/power/decoder.hh b/src/arch/power/decoder.hh index 4e02ef7bca..bd32614d9e 100644 --- a/src/arch/power/decoder.hh +++ b/src/arch/power/decoder.hh @@ -96,8 +96,8 @@ class Decoder : public InstDecoder protected: /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; + friend class GenericISA::BasicDecodeCache; - public: StaticInstPtr decodeInst(ExtMachInst mach_inst); /// Decode a machine instruction. @@ -112,6 +112,7 @@ class Decoder : public InstDecoder return si; } + public: StaticInstPtr decode(PowerISA::PCState &nextPC) { diff --git a/src/arch/riscv/decoder.hh b/src/arch/riscv/decoder.hh index 23c3c38462..173b4c7513 100644 --- a/src/arch/riscv/decoder.hh +++ b/src/arch/riscv/decoder.hh @@ -56,6 +56,13 @@ class Decoder : public InstDecoder ExtMachInst emi; bool instDone; + StaticInstPtr decodeInst(ExtMachInst mach_inst); + + /// Decode a machine instruction. + /// @param mach_inst The binary instruction to decode. + /// @retval A pointer to the corresponding StaticInst object. + StaticInstPtr decode(ExtMachInst mach_inst, Addr addr); + public: Decoder(ISA* isa=nullptr) { reset(); } @@ -72,13 +79,6 @@ class Decoder : public InstDecoder bool instReady() { return instDone; } void takeOverFrom(Decoder *old) {} - StaticInstPtr decodeInst(ExtMachInst mach_inst); - - /// Decode a machine instruction. - /// @param mach_inst The binary instruction to decode. - /// @retval A pointer to the corresponding StaticInst object. - StaticInstPtr decode(ExtMachInst mach_inst, Addr addr); - StaticInstPtr decode(RiscvISA::PCState &nextPC); }; diff --git a/src/arch/sparc/decoder.hh b/src/arch/sparc/decoder.hh index ece3b9c77d..340733db9b 100644 --- a/src/arch/sparc/decoder.hh +++ b/src/arch/sparc/decoder.hh @@ -103,8 +103,8 @@ class Decoder : public InstDecoder protected: /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; + friend class GenericISA::BasicDecodeCache; - public: StaticInstPtr decodeInst(ExtMachInst mach_inst); /// Decode a machine instruction. @@ -119,6 +119,7 @@ class Decoder : public InstDecoder return si; } + public: StaticInstPtr decode(SparcISA::PCState &nextPC) { diff --git a/src/arch/x86/decoder.hh b/src/arch/x86/decoder.hh index 94ebd0cf2f..c9ff3ce68f 100644 --- a/src/arch/x86/decoder.hh +++ b/src/arch/x86/decoder.hh @@ -241,6 +241,13 @@ class Decoder : public InstDecoder CacheKey, DecodeCache::InstMap *> InstCacheMap; static InstCacheMap instCacheMap; + StaticInstPtr decodeInst(ExtMachInst mach_inst); + + /// Decode a machine instruction. + /// @param mach_inst The binary instruction to decode. + /// @retval A pointer to the corresponding StaticInst object. + StaticInstPtr decode(ExtMachInst mach_inst, Addr addr); + public: Decoder(ISA *isa=nullptr) { @@ -328,12 +335,6 @@ class Decoder : public InstDecoder } public: - StaticInstPtr decodeInst(ExtMachInst mach_inst); - - /// Decode a machine instruction. - /// @param mach_inst The binary instruction to decode. - /// @retval A pointer to the corresponding StaticInst object. - StaticInstPtr decode(ExtMachInst mach_inst, Addr addr); StaticInstPtr decode(X86ISA::PCState &nextPC); StaticInstPtr fetchRomMicroop(