34a35
> #include <vector>
60a62,74
> struct InstBytes
> {
> StaticInstPtr si;
> std::vector<MachInst> chunks;
> std::vector<MachInst> masks;
> int lastOffset;
>
> InstBytes() : lastOffset(0)
> {}
> };
>
> static InstBytes dummy;
>
63a78,79
> InstBytes *instBytes;
> int chunkIdx;
72c88,95
< HandyM5Reg m5Reg;
---
> //Predecoding state
> X86Mode mode;
> X86SubMode submode;
> uint8_t altOp;
> uint8_t defOp;
> uint8_t altAddr;
> uint8_t defAddr;
> uint8_t stack;
74c97
< inline uint8_t getNextByte()
---
> uint8_t getNextByte()
102c125
< inline void consumeByte()
---
> void updateOffsetState()
104d126
< offset++;
106,107c128,139
< if(offset == sizeof(MachInst))
< outOfBytes = true;
---
> if (offset == sizeof(MachInst)) {
> DPRINTF(Decoder, "At the end of a chunk, idx = %d, chunks = %d.\n",
> chunkIdx, instBytes->chunks.size());
> chunkIdx++;
> if (chunkIdx == instBytes->chunks.size()) {
> outOfBytes = true;
> } else {
> offset = 0;
> fetchChunk = instBytes->chunks[chunkIdx];
> basePC += sizeof(MachInst);
> }
> }
110c142
< inline void consumeBytes(int numBytes)
---
> void consumeByte()
111a144,149
> offset++;
> updateOffsetState();
> }
>
> void consumeBytes(int numBytes)
> {
113,115c151
< assert(offset <= sizeof(MachInst));
< if(offset == sizeof(MachInst))
< outOfBytes = true;
---
> updateOffsetState();
118,119d153
< void doReset();
<
135a170
> FromCacheState,
148a184,185
> State doResetState();
> State doFromCacheState();
155a193,206
> protected:
> /// Caching for decoded instruction objects.
>
> typedef MiscReg CacheKey;
>
> typedef DecodeCache::AddrMap<Decoder::InstBytes> DecodePages;
> DecodePages *decodePages;
> typedef m5::hash_map<CacheKey, DecodePages *> AddrCacheMap;
> AddrCacheMap addrCacheMap;
>
> DecodeCache::InstMap *instMap;
> typedef m5::hash_map<CacheKey, DecodeCache::InstMap *> InstCacheMap;
> static InstCacheMap instCacheMap;
>
163,165c214,225
< emi.mode.mode = LongMode;
< emi.mode.submode = SixtyFourBitMode;
< m5Reg = 0;
---
> 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;
167a228,256
> void setM5Reg(HandyM5Reg m5Reg)
> {
> mode = (X86Mode)(uint64_t)m5Reg.mode;
> submode = (X86SubMode)(uint64_t)m5Reg.submode;
> emi.mode.mode = mode;
> emi.mode.submode = submode;
> altOp = m5Reg.altOp;
> defOp = m5Reg.defOp;
> altAddr = m5Reg.altAddr;
> defAddr = m5Reg.defAddr;
> stack = m5Reg.stack;
>
> AddrCacheMap::iterator amIter = addrCacheMap.find(m5Reg);
> if (amIter != addrCacheMap.end()) {
> decodePages = amIter->second;
> } else {
> decodePages = new DecodePages;
> addrCacheMap[m5Reg] = decodePages;
> }
>
> InstCacheMap::iterator imIter = instCacheMap.find(m5Reg);
> if (imIter != instCacheMap.end()) {
> instMap = imIter->second;
> } else {
> instMap = new DecodeCache::InstMap;
> instCacheMap[m5Reg] = instMap;
> }
> }
>
221,225d309
< protected:
< /// Caching for decoded instruction objects.
< static DecodeCache::InstMap instMap;
< static DecodeCache::AddrMap<StaticInstPtr> decodePages;
<
233,242c317
<
< StaticInstPtr
< decode(X86ISA::PCState &nextPC)
< {
< if (!instDone)
< return NULL;
< instDone = false;
< updateNPC(nextPC);
< return decode(emi, origPC);
< }
---
> StaticInstPtr decode(X86ISA::PCState &nextPC);