CPU: Add targeted icache invalidation

This commit is contained in:
Stenzek
2026-06-24 21:22:53 +10:00
parent 17f54f1a25
commit b4834b982f
2 changed files with 27 additions and 0 deletions
+25
View File
@@ -2966,6 +2966,31 @@ void CPU::ClearICache()
g_state.icache_tags.fill(ICACHE_INVALID_BITS);
}
void CPU::InvalidateICacheAt(VirtualMemoryAddress address)
{
u32& tag = g_state.icache_tags[GetICacheLine(address)];
if ((tag & ICACHE_TAG_ADDRESS_MASK) == GetICacheTagForAddress(address))
tag = ICACHE_INVALID_BITS;
}
void CPU::InvalidICacheRange(VirtualMemoryAddress start, VirtualMemoryAddress end)
{
if (start >= end)
return;
const VirtualMemoryAddress first_word = Common::AlignDownPow2(start, 4);
const VirtualMemoryAddress last_word = Common::AlignDownPow2(end - 1u, 4);
for (VirtualMemoryAddress address = first_word;; address += sizeof(u32))
{
u32& tag = g_state.icache_tags[GetICacheLine(address)];
if ((tag & ICACHE_TAG_ADDRESS_MASK) == GetICacheTagForAddress(address))
tag = ICACHE_INVALID_BITS;
if (address == last_word)
break;
}
}
namespace CPU {
ALWAYS_INLINE_RELEASE static u32 ReadICache(VirtualMemoryAddress address)
{
+2
View File
@@ -135,6 +135,8 @@ void Shutdown();
void Reset();
bool DoState(StateWrapper& sw);
void ClearICache();
void InvalidateICacheAt(VirtualMemoryAddress address);
void InvalidICacheRange(VirtualMemoryAddress start, VirtualMemoryAddress end);
CPUExecutionMode GetCurrentExecutionMode();
bool UpdateDebugDispatcherFlag();
void UpdateMemoryPointers();