From 563e19d1fd151fe222af2455536d8239f5c6d3dc Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 27 Mar 2018 01:20:05 -0700 Subject: [PATCH] arch: cpu: Make the ExtMachInst type a template argument in InstMap. This doesn't completely hide the ISA specific ExtMachInst type inside the ISAs since it still gets applied in arch/generic, but it at least pulls it into the arch directory. Change-Id: Ic2188d59696530d7ecafdff0785d71867182701d Reviewed-on: https://gem5-review.googlesource.com/9403 Reviewed-by: Andreas Sandberg Maintainer: Gabe Black --- src/arch/generic/decode_cache.cc | 2 +- src/arch/generic/decode_cache.hh | 2 +- src/arch/riscv/decoder.hh | 2 +- src/arch/x86/decoder.cc | 2 +- src/arch/x86/decoder.hh | 7 ++++--- src/cpu/decode_cache.hh | 3 ++- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/arch/generic/decode_cache.cc b/src/arch/generic/decode_cache.cc index 782dfca43..0f7a9d991 100644 --- a/src/arch/generic/decode_cache.cc +++ b/src/arch/generic/decode_cache.cc @@ -46,7 +46,7 @@ BasicDecodeCache::decode(TheISA::Decoder *decoder, if (si && (si->machInst == mach_inst)) return si; - DecodeCache::InstMap::iterator iter = instMap.find(mach_inst); + auto iter = instMap.find(mach_inst); if (iter != instMap.end()) { si = iter->second; return si; diff --git a/src/arch/generic/decode_cache.hh b/src/arch/generic/decode_cache.hh index c6bce7226..ebfaa0645 100644 --- a/src/arch/generic/decode_cache.hh +++ b/src/arch/generic/decode_cache.hh @@ -47,7 +47,7 @@ namespace GenericISA class BasicDecodeCache { private: - DecodeCache::InstMap instMap; + DecodeCache::InstMap instMap; DecodeCache::AddrMap decodePages; public: diff --git a/src/arch/riscv/decoder.hh b/src/arch/riscv/decoder.hh index 91fe7873e..750321167 100644 --- a/src/arch/riscv/decoder.hh +++ b/src/arch/riscv/decoder.hh @@ -48,7 +48,7 @@ class ISA; class Decoder { private: - DecodeCache::InstMap instMap; + DecodeCache::InstMap instMap; bool aligned; bool mid; bool more; diff --git a/src/arch/x86/decoder.cc b/src/arch/x86/decoder.cc index 835d5e25d..54701bb73 100644 --- a/src/arch/x86/decoder.cc +++ b/src/arch/x86/decoder.cc @@ -681,7 +681,7 @@ Decoder::InstCacheMap Decoder::instCacheMap; StaticInstPtr Decoder::decode(ExtMachInst mach_inst, Addr addr) { - DecodeCache::InstMap::iterator iter = instMap->find(mach_inst); + auto iter = instMap->find(mach_inst); if (iter != instMap->end()) return iter->second; diff --git a/src/arch/x86/decoder.hh b/src/arch/x86/decoder.hh index a60aa469a..3630ea8c8 100644 --- a/src/arch/x86/decoder.hh +++ b/src/arch/x86/decoder.hh @@ -229,8 +229,9 @@ class Decoder typedef std::unordered_map AddrCacheMap; AddrCacheMap addrCacheMap; - DecodeCache::InstMap *instMap; - typedef std::unordered_map InstCacheMap; + DecodeCache::InstMap *instMap; + typedef std::unordered_map< + CacheKey, DecodeCache::InstMap *> InstCacheMap; static InstCacheMap instCacheMap; public: @@ -277,7 +278,7 @@ class Decoder if (imIter != instCacheMap.end()) { instMap = imIter->second; } else { - instMap = new DecodeCache::InstMap; + instMap = new DecodeCache::InstMap; instCacheMap[m5Reg] = instMap; } } diff --git a/src/cpu/decode_cache.hh b/src/cpu/decode_cache.hh index c451cbb69..2d33455e0 100644 --- a/src/cpu/decode_cache.hh +++ b/src/cpu/decode_cache.hh @@ -47,7 +47,8 @@ namespace DecodeCache { /// Hash for decoded instructions. -typedef std::unordered_map InstMap; +template +using InstMap = std::unordered_map; /// A sparse map from an Addr to a Value, stored in page chunks. template -- 2.30.2