CPU: Implement instruction cache simulation
Implemented for all execution modes. Disabled by default in the cached interpreter and recompiler, always enabled in the pure interpreter.
This commit is contained in:
@ -34,8 +34,38 @@ ALWAYS_INLINE static void DispatchInterrupt()
|
||||
g_state.regs.pc);
|
||||
}
|
||||
|
||||
// icache stuff
|
||||
ALWAYS_INLINE bool IsCachedAddress(VirtualMemoryAddress address)
|
||||
{
|
||||
// KUSEG, KSEG0
|
||||
return (address >> 29) <= 4;
|
||||
}
|
||||
ALWAYS_INLINE u32 GetICacheLine(VirtualMemoryAddress address)
|
||||
{
|
||||
return ((address >> 4) & 0xFFu);
|
||||
}
|
||||
ALWAYS_INLINE u32 GetICacheLineOffset(VirtualMemoryAddress address)
|
||||
{
|
||||
return (address & (ICACHE_LINE_SIZE - 1));
|
||||
}
|
||||
ALWAYS_INLINE u32 GetICacheTagForAddress(VirtualMemoryAddress address)
|
||||
{
|
||||
return (address & ICACHE_TAG_ADDRESS_MASK);
|
||||
}
|
||||
ALWAYS_INLINE bool CompareICacheTag(VirtualMemoryAddress address)
|
||||
{
|
||||
const u32 line = GetICacheLine(address);
|
||||
return (g_state.icache_tags[line] == GetICacheTagForAddress(address));
|
||||
}
|
||||
|
||||
TickCount GetInstructionReadTicks(VirtualMemoryAddress address);
|
||||
TickCount GetICacheFillTicks(VirtualMemoryAddress address);
|
||||
u32 FillICache(VirtualMemoryAddress address);
|
||||
void CheckAndUpdateICacheTags(u32 line_count, TickCount uncached_ticks);
|
||||
|
||||
// defined in cpu_memory.cpp - memory access functions which return false if an exception was thrown.
|
||||
bool FetchInstruction();
|
||||
bool SafeReadInstruction(VirtualMemoryAddress addr, u32* value);
|
||||
bool ReadMemoryByte(VirtualMemoryAddress addr, u8* value);
|
||||
bool ReadMemoryHalfWord(VirtualMemoryAddress addr, u16* value);
|
||||
bool ReadMemoryWord(VirtualMemoryAddress addr, u32* value);
|
||||
|
||||
Reference in New Issue
Block a user