Small TLB cleanup

This commit is contained in:
irisz64
2025-09-01 12:05:25 +02:00
parent 5444df993c
commit bd4a692899

View File

@@ -294,37 +294,41 @@ static FORCE_INLINE u64 getVPN(const u64 addr, const u64 pageMask) {
TLBEntry *Cop0::TLBTryMatch(const u64 vaddr, int &index) {
for (int i = 0; i < 32; i++) {
if (TLBEntry *entry = &tlb[i]; entry->initialized) {
TLBEntry *entry = &tlb[i];
if (!entry->initialized)
continue;
const u64 entry_vpn = getVPN(entry->entryHi.raw, entry->pageMask.raw);
const u64 vaddr_vpn = getVPN(vaddr, entry->pageMask.raw);
const bool vpn_match = entry_vpn == vaddr_vpn;
const bool asid_match = entry->global || entryHi.asid == entry->entryHi.asid;
if(!vpn_match || !asid_match)
continue;
if (const bool asid_match = entry->global || entryHi.asid == entry->entryHi.asid;
vpn_match && asid_match) {
index = i;
return entry;
}
}
}
return nullptr;
}
TLBEntry *Cop0::TLBTryMatch(const u64 vaddr) {
for (auto &i : tlb) {
if (TLBEntry *entry = &i; entry->initialized) {
for (auto &t : tlb) {
TLBEntry *entry = &t;
if (!entry->initialized)
continue;
const u64 entry_vpn = getVPN(entry->entryHi.raw, entry->pageMask.raw);
const u64 vaddr_vpn = getVPN(vaddr, entry->pageMask.raw);
const bool vpn_match = entry_vpn == vaddr_vpn;
const bool asid_match = entry->global || entryHi.asid == entry->entryHi.asid;
if (const bool asid_match = entry->global || entryHi.asid == entry->entryHi.asid;
vpn_match && asid_match) {
if (vpn_match && asid_match)
return entry;
}
}
}
return nullptr;
}