diff options
author | RSDuck <rsduck@users.noreply.github.com> | 2021-01-19 23:49:32 +0100 |
---|---|---|
committer | RSDuck <rsduck@users.noreply.github.com> | 2021-01-19 23:50:08 +0100 |
commit | 771dfaca2e3851217287aa73423eb6ec6d6b4360 (patch) | |
tree | e2917b8770e6cf9354bff9d89f3ae0455f4a15d4 /src/ARMJIT_A64 | |
parent | 31c9d116bd9a1e16fccc2e7a974d4a7410f7da90 (diff) |
JIT: handle STR post with rd == rn
fixes Zelda Four Swords
Diffstat (limited to 'src/ARMJIT_A64')
-rw-r--r-- | src/ARMJIT_A64/ARMJIT_Compiler.cpp | 22 | ||||
-rw-r--r-- | src/ARMJIT_A64/ARMJIT_Compiler.h | 18 | ||||
-rw-r--r-- | src/ARMJIT_A64/ARMJIT_LoadStore.cpp | 12 |
3 files changed, 34 insertions, 18 deletions
diff --git a/src/ARMJIT_A64/ARMJIT_Compiler.cpp b/src/ARMJIT_A64/ARMJIT_Compiler.cpp index 880a6fc..b5702bf 100644 --- a/src/ARMJIT_A64/ARMJIT_Compiler.cpp +++ b/src/ARMJIT_A64/ARMJIT_Compiler.cpp @@ -174,10 +174,13 @@ void Compiler::PopRegs(bool saveHiRegs) { if (saveHiRegs) { - BitSet16 hiRegsLoaded(RegCache.LoadedRegs & 0x7F00); + if (!Thumb && CurInstr.Cond() != 0xE) + { + BitSet16 hiRegsLoaded(RegCache.LoadedRegs & 0x7F00); - for (int reg : hiRegsLoaded) - LoadReg(reg, RegCache.Mapping[reg]); + for (int reg : hiRegsLoaded) + LoadReg(reg, RegCache.Mapping[reg]); + } } } @@ -326,9 +329,10 @@ Compiler::Compiler() { for (int size = 0; size < 3; size++) { - for (int reg = 0; reg < 8; reg++) + for (int reg = 0; reg < 32; reg++) { - ARM64Reg rdMapped = (ARM64Reg)(W19 + reg); + if (!(reg == W4 || (reg >= W19 && reg <= W26))) + continue; PatchedStoreFuncs[consoleType][num][size][reg] = GetRXPtr(); if (num == 0) { @@ -711,7 +715,9 @@ JitBlockEntry Compiler::CompileBlock(ARM* cpu, bool thumb, FetchedInstr instrs[] QuickCallFunction(X1, InterpretTHUMB[CurInstr.Info.Kind]); } else + { (this->*comp)(); + } } else { @@ -727,10 +733,12 @@ JitBlockEntry Compiler::CompileBlock(ARM* cpu, bool thumb, FetchedInstr instrs[] } } else if (cond == 0xF) + { Comp_AddCycles_C(); + } else { - IrregularCycles = false; + IrregularCycles = comp == NULL; FixupBranch skipExecute; if (cond < 0xE) @@ -763,7 +771,9 @@ JitBlockEntry Compiler::CompileBlock(ARM* cpu, bool thumb, FetchedInstr instrs[] SetJumpTarget(skipNop); } else + { SetJumpTarget(skipExecute); + } } } diff --git a/src/ARMJIT_A64/ARMJIT_Compiler.h b/src/ARMJIT_A64/ARMJIT_Compiler.h index a79e9da..0154175 100644 --- a/src/ARMJIT_A64/ARMJIT_Compiler.h +++ b/src/ARMJIT_A64/ARMJIT_Compiler.h @@ -241,17 +241,8 @@ public: u32 JitMemSecondarySize; u32 JitMemMainSize; - void* ReadBanked, *WriteBanked; - - void* JumpToFuncs9[3]; - void* JumpToFuncs7[3]; - std::unordered_map<ptrdiff_t, LoadStorePatch> LoadStorePatches; - // [Console Type][Num][Size][Sign Extend][Output register] - void* PatchedLoadFuncs[2][2][3][2][8]; - void* PatchedStoreFuncs[2][2][3][8]; - RegisterCache<Compiler, Arm64Gen::ARM64Reg> RegCache; bool CPSRDirty = false; @@ -263,6 +254,15 @@ public: void* JitRWStart; void* JitRXStart; #endif + + void* ReadBanked, *WriteBanked; + + void* JumpToFuncs9[3]; + void* JumpToFuncs7[3]; + + // [Console Type][Num][Size][Sign Extend][Output register] + void* PatchedLoadFuncs[2][2][3][2][32]; + void* PatchedStoreFuncs[2][2][3][32]; }; } diff --git a/src/ARMJIT_A64/ARMJIT_LoadStore.cpp b/src/ARMJIT_A64/ARMJIT_LoadStore.cpp index 3d30759..a622a92 100644 --- a/src/ARMJIT_A64/ARMJIT_LoadStore.cpp +++ b/src/ARMJIT_A64/ARMJIT_LoadStore.cpp @@ -116,6 +116,12 @@ void Compiler::Comp_MemAccess(int rd, int rn, Op2 offset, int size, int flags) rnMapped = W3; } + if (flags & memop_Store && flags & (memop_Post|memop_Writeback) && rd == rn) + { + MOV(W4, rdMapped); + rdMapped = W4; + } + ARM64Reg finalAddr = W0; if (flags & memop_Post) { @@ -170,10 +176,10 @@ void Compiler::Comp_MemAccess(int rd, int rn, Op2 offset, int size, int flags) ptrdiff_t memopStart = GetCodeOffset(); LoadStorePatch patch; + assert((rdMapped >= W19 && rdMapped <= W26) || rdMapped == W4); patch.PatchFunc = flags & memop_Store - ? PatchedStoreFuncs[NDS::ConsoleType][Num][__builtin_ctz(size) - 3][rdMapped - W19] - : PatchedLoadFuncs[NDS::ConsoleType][Num][__builtin_ctz(size) - 3][!!(flags & memop_SignExtend)][rdMapped - W19]; - assert(rdMapped - W19 >= 0 && rdMapped - W19 < 8); + ? PatchedStoreFuncs[NDS::ConsoleType][Num][__builtin_ctz(size) - 3][rdMapped] + : PatchedLoadFuncs[NDS::ConsoleType][Num][__builtin_ctz(size) - 3][!!(flags & memop_SignExtend)][rdMapped]; MOVP2R(X7, Num == 0 ? ARMJIT_Memory::FastMem9Start : ARMJIT_Memory::FastMem7Start); |