From 1c776d8c1a9a181793aec245f4446fa2e49804f2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 31 Aug 2021 10:04:42 -0400 Subject: [PATCH] MMU: Move invalidation logic into the TLBEntry struct Puts the invalidation logic in one place and lets us tidy up InvalidateTLBEntry a little. --- Source/Core/Core/PowerPC/MMU.cpp | 9 ++------- Source/Core/Core/PowerPC/PowerPC.h | 11 ++++++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index abdcbf67c7..399f90b2a1 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -1295,13 +1295,8 @@ void InvalidateTLBEntry(u32 address) { const u32 entry_index = (address >> HW_PAGE_INDEX_SHIFT) & HW_PAGE_INDEX_MASK; - TLBEntry& tlbe = ppcState.tlb[0][entry_index]; - tlbe.tag[0] = TLBEntry::INVALID_TAG; - tlbe.tag[1] = TLBEntry::INVALID_TAG; - - TLBEntry& tlbe_i = ppcState.tlb[1][entry_index]; - tlbe_i.tag[0] = TLBEntry::INVALID_TAG; - tlbe_i.tag[1] = TLBEntry::INVALID_TAG; + ppcState.tlb[0][entry_index].Invalidate(); + ppcState.tlb[1][entry_index].Invalidate(); } // Page Address Translation diff --git a/Source/Core/Core/PowerPC/PowerPC.h b/Source/Core/Core/PowerPC/PowerPC.h index db1fc04de5..33566908b9 100644 --- a/Source/Core/Core/PowerPC/PowerPC.h +++ b/Source/Core/Core/PowerPC/PowerPC.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -49,12 +50,16 @@ constexpr size_t TLB_WAYS = 2; struct TLBEntry { + using WayArray = std::array; + static constexpr u32 INVALID_TAG = 0xffffffff; - u32 tag[TLB_WAYS] = {INVALID_TAG, INVALID_TAG}; - u32 paddr[TLB_WAYS] = {}; - u32 pte[TLB_WAYS] = {}; + WayArray tag{INVALID_TAG, INVALID_TAG}; + WayArray paddr{}; + WayArray pte{}; u32 recent = 0; + + void Invalidate() { tag.fill(INVALID_TAG); } }; struct PairedSingle