Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/9403

Change subject: arch: cpu: Make the ExtMachInst type a template argument in InstMap.
......................................................................

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
---
M src/arch/generic/decode_cache.cc
M src/arch/generic/decode_cache.hh
M src/arch/riscv/decoder.hh
M src/arch/x86/decoder.cc
M src/arch/x86/decoder.hh
M src/cpu/decode_cache.hh
6 files changed, 10 insertions(+), 8 deletions(-)



diff --git a/src/arch/generic/decode_cache.cc b/src/arch/generic/decode_cache.cc
index 782dfca..0f7a9d9 100644
--- a/src/arch/generic/decode_cache.cc
+++ b/src/arch/generic/decode_cache.cc
@@ -46,7 +46,7 @@
     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 c6bce72..ebfaa06 100644
--- a/src/arch/generic/decode_cache.hh
+++ b/src/arch/generic/decode_cache.hh
@@ -47,7 +47,7 @@
 class BasicDecodeCache
 {
   private:
-    DecodeCache::InstMap instMap;
+    DecodeCache::InstMap<TheISA::ExtMachInst> instMap;
     DecodeCache::AddrMap<StaticInstPtr> decodePages;

   public:
diff --git a/src/arch/riscv/decoder.hh b/src/arch/riscv/decoder.hh
index 91fe787..7503211 100644
--- a/src/arch/riscv/decoder.hh
+++ b/src/arch/riscv/decoder.hh
@@ -48,7 +48,7 @@
 class Decoder
 {
   private:
-    DecodeCache::InstMap instMap;
+    DecodeCache::InstMap<ExtMachInst> instMap;
     bool aligned;
     bool mid;
     bool more;
diff --git a/src/arch/x86/decoder.cc b/src/arch/x86/decoder.cc
index 835d5e2..54701bb 100644
--- a/src/arch/x86/decoder.cc
+++ b/src/arch/x86/decoder.cc
@@ -681,7 +681,7 @@
 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 a60aa46..3630ea8 100644
--- a/src/arch/x86/decoder.hh
+++ b/src/arch/x86/decoder.hh
@@ -229,8 +229,9 @@
     typedef std::unordered_map<CacheKey, DecodePages *> AddrCacheMap;
     AddrCacheMap addrCacheMap;

-    DecodeCache::InstMap *instMap;
- typedef std::unordered_map<CacheKey, DecodeCache::InstMap *> InstCacheMap;
+    DecodeCache::InstMap<ExtMachInst> *instMap;
+    typedef std::unordered_map<
+            CacheKey, DecodeCache::InstMap<ExtMachInst> *> InstCacheMap;
     static InstCacheMap instCacheMap;

   public:
@@ -277,7 +278,7 @@
         if (imIter != instCacheMap.end()) {
             instMap = imIter->second;
         } else {
-            instMap = new DecodeCache::InstMap;
+            instMap = new DecodeCache::InstMap<ExtMachInst>;
             instCacheMap[m5Reg] = instMap;
         }
     }
diff --git a/src/cpu/decode_cache.hh b/src/cpu/decode_cache.hh
index c451cbb..2d33455 100644
--- a/src/cpu/decode_cache.hh
+++ b/src/cpu/decode_cache.hh
@@ -47,7 +47,8 @@
 {

 /// Hash for decoded instructions.
-typedef std::unordered_map<TheISA::ExtMachInst, StaticInstPtr> InstMap;
+template <typename EMI>
+using InstMap = std::unordered_map<EMI, StaticInstPtr>;

 /// A sparse map from an Addr to a Value, stored in page chunks.
 template<class Value>

--
To view, visit https://gem5-review.googlesource.com/9403
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ic2188d59696530d7ecafdff0785d71867182701d
Gerrit-Change-Number: 9403
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to