summaryrefslogtreecommitdiff
path: root/src/arch/x86
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2012-05-26 13:45:12 -0700
committerGabe Black <gblack@eecs.umich.edu>2012-05-26 13:45:12 -0700
commit19df4e94ee4f2323e5fe1b915f7e81a6034cfc56 (patch)
treeae0fbc2a53a90e022e91b00f028451759c2d270d /src/arch/x86
parent0cba96ba6a5d7a4dab2a63b14149c49dfbfbb3bc (diff)
downloadgem5-19df4e94ee4f2323e5fe1b915f7e81a6034cfc56.tar.xz
ISA,CPU: Generalize and split out the components of the decode cache.
This will allow it to be specialized by the ISAs. The existing caching scheme is provided by the BasicDecodeCache in the GenericISA namespace and is built from the generalized components. --HG-- rename : src/cpu/decode_cache.cc => src/arch/generic/decode_cache.cc
Diffstat (limited to 'src/arch/x86')
-rw-r--r--src/arch/x86/decoder.cc21
-rw-r--r--src/arch/x86/decoder.hh13
2 files changed, 25 insertions, 9 deletions
diff --git a/src/arch/x86/decoder.cc b/src/arch/x86/decoder.cc
index d7199fa82..5fb2dcaf4 100644
--- a/src/arch/x86/decoder.cc
+++ b/src/arch/x86/decoder.cc
@@ -408,6 +408,25 @@ Decoder::State Decoder::doImmediateState()
return nextState;
}
-DecodeCache Decoder::defaultCache;
+DecodeCache::InstMap Decoder::instMap;
+DecodeCache::AddrMap<StaticInstPtr> Decoder::decodePages;
+
+StaticInstPtr
+Decoder::decode(ExtMachInst mach_inst, Addr addr)
+{
+ StaticInstPtr &si = decodePages.lookup(addr);
+ if (si && (si->machInst == mach_inst))
+ return si;
+
+ DecodeCache::InstMap::iterator iter = instMap.find(mach_inst);
+ if (iter != instMap.end()) {
+ si = iter->second;
+ return si;
+ }
+
+ si = decodeInst(mach_inst);
+ instMap[mach_inst] = si;
+ return si;
+}
}
diff --git a/src/arch/x86/decoder.hh b/src/arch/x86/decoder.hh
index 300e2238c..725d443d6 100644
--- a/src/arch/x86/decoder.hh
+++ b/src/arch/x86/decoder.hh
@@ -40,7 +40,7 @@
#include "base/trace.hh"
#include "base/types.hh"
#include "cpu/decode_cache.hh"
-#include "cpu/static_inst_fwd.hh"
+#include "cpu/static_inst.hh"
#include "debug/Decoder.hh"
class ThreadContext;
@@ -218,8 +218,9 @@ class Decoder
}
protected:
- /// A cache of decoded instruction objects.
- static DecodeCache defaultCache;
+ /// Caching for decoded instruction objects.
+ static DecodeCache::InstMap instMap;
+ static DecodeCache::AddrMap<StaticInstPtr> decodePages;
public:
StaticInstPtr decodeInst(ExtMachInst mach_inst);
@@ -227,11 +228,7 @@ class Decoder
/// 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)
- {
- return defaultCache.decode(this, mach_inst, addr);
- }
+ StaticInstPtr decode(ExtMachInst mach_inst, Addr addr);
StaticInstPtr
decode(X86ISA::PCState &nextPC)