diff options
author | RSDuck <rsduck@users.noreply.github.com> | 2020-07-08 23:08:25 +0200 |
---|---|---|
committer | RSDuck <rsduck@users.noreply.github.com> | 2020-07-08 23:08:25 +0200 |
commit | 3786660099e6517a9230ec6f76559b72aa1660fd (patch) | |
tree | e81c25213d2dad4af78492597f05692372de0b3f /src/ARMJIT_x64 | |
parent | 778623a8b7ded3a66fc838840ce85626f5feed05 (diff) |
misc JIT changes
Diffstat (limited to 'src/ARMJIT_x64')
-rw-r--r-- | src/ARMJIT_x64/ARMJIT_Compiler.cpp | 2 | ||||
-rw-r--r-- | src/ARMJIT_x64/ARMJIT_LoadStore.cpp | 147 |
2 files changed, 97 insertions, 52 deletions
diff --git a/src/ARMJIT_x64/ARMJIT_Compiler.cpp b/src/ARMJIT_x64/ARMJIT_Compiler.cpp index d8bdd56..6905010 100644 --- a/src/ARMJIT_x64/ARMJIT_Compiler.cpp +++ b/src/ARMJIT_x64/ARMJIT_Compiler.cpp @@ -633,7 +633,7 @@ void Compiler::Comp_SpecialBranchBehaviour(bool taken) JitBlockEntry Compiler::CompileBlock(ARM* cpu, bool thumb, FetchedInstr instrs[], int instrsCount) { - if (NearSize - (NearCode - NearStart) < 1024 * 32) // guess... + if (NearSize - (GetCodePtr() - NearStart) < 1024 * 32) // guess... { printf("near reset\n"); ResetBlockCache(); diff --git a/src/ARMJIT_x64/ARMJIT_LoadStore.cpp b/src/ARMJIT_x64/ARMJIT_LoadStore.cpp index ff15729..aa84105 100644 --- a/src/ARMJIT_x64/ARMJIT_LoadStore.cpp +++ b/src/ARMJIT_x64/ARMJIT_LoadStore.cpp @@ -216,9 +216,17 @@ void Compiler::Comp_MemAccess(int rd, int rn, const Op2& op2, int size, int flag if (size == 32) { - AND(32, R(RSCRATCH3), Imm8(0x3)); - SHL(32, R(RSCRATCH3), Imm8(3)); - ROR_(32, rdMapped, R(RSCRATCH3)); + if (addrIsStatic) + { + if (staticAddress & 0x3) + ROR_(32, rdMapped, Imm8((staticAddress & 0x3) * 8)); + } + else + { + AND(32, R(RSCRATCH3), Imm8(0x3)); + SHL(32, R(RSCRATCH3), Imm8(3)); + ROR_(32, rdMapped, R(RSCRATCH3)); + } } } @@ -233,78 +241,115 @@ void Compiler::Comp_MemAccess(int rd, int rn, const Op2& op2, int size, int flag { PushRegs(false); - if (Num == 0) + void* func = NULL; + if (addrIsStatic) + func = ARMJIT_Memory::GetFuncForAddr(CurCPU, staticAddress, flags & memop_Store, size); + + if (func) { - MOV(64, R(ABI_PARAM2), R(RCPU)); + AND(32, R(RSCRATCH3), Imm8(addressMask)); + if (ABI_PARAM1 != RSCRATCH3) MOV(32, R(ABI_PARAM1), R(RSCRATCH3)); if (flags & memop_Store) - { - MOV(32, R(ABI_PARAM3), rdMapped); + MOV(32, R(ABI_PARAM2), rdMapped); + + ABI_CallFunction((void (*)())func); + + PopRegs(false); - switch (size | NDS::ConsoleType) + if (!(flags & memop_Store)) + { + if (size == 32) { - case 32: CALL((void*)&SlowWrite9<u32, 0>); break; - case 16: CALL((void*)&SlowWrite9<u16, 0>); break; - case 8: CALL((void*)&SlowWrite9<u8, 0>); break; - case 33: CALL((void*)&SlowWrite9<u32, 1>); break; - case 17: CALL((void*)&SlowWrite9<u16, 1>); break; - case 9: CALL((void*)&SlowWrite9<u8, 1>); break; + MOV(32, rdMapped, R(RSCRATCH)); + if (staticAddress & 0x3) + ROR_(32, rdMapped, Imm8((staticAddress & 0x3) * 8)); } - } - else - { - switch (size | NDS::ConsoleType) + else { - case 32: CALL((void*)&SlowRead9<u32, 0>); break; - case 16: CALL((void*)&SlowRead9<u16, 0>); break; - case 8: CALL((void*)&SlowRead9<u8, 0>); break; - case 33: CALL((void*)&SlowRead9<u32, 1>); break; - case 17: CALL((void*)&SlowRead9<u16, 1>); break; - case 9: CALL((void*)&SlowRead9<u8, 1>); break; + if (flags & memop_SignExtend) + MOVSX(32, size, rdMapped.GetSimpleReg(), R(RSCRATCH)); + else + MOVZX(32, size, rdMapped.GetSimpleReg(), R(RSCRATCH)); } } } else { - if (ABI_PARAM1 != RSCRATCH3) - MOV(32, R(ABI_PARAM1), R(RSCRATCH3)); - if (flags & memop_Store) + if (Num == 0) { - MOV(32, R(ABI_PARAM2), rdMapped); + MOV(64, R(ABI_PARAM2), R(RCPU)); + if (ABI_PARAM1 != RSCRATCH3) + MOV(32, R(ABI_PARAM1), R(RSCRATCH3)); + if (flags & memop_Store) + { + MOV(32, R(ABI_PARAM3), rdMapped); - switch (size | NDS::ConsoleType) + switch (size | NDS::ConsoleType) + { + case 32: CALL((void*)&SlowWrite9<u32, 0>); break; + case 16: CALL((void*)&SlowWrite9<u16, 0>); break; + case 8: CALL((void*)&SlowWrite9<u8, 0>); break; + case 33: CALL((void*)&SlowWrite9<u32, 1>); break; + case 17: CALL((void*)&SlowWrite9<u16, 1>); break; + case 9: CALL((void*)&SlowWrite9<u8, 1>); break; + } + } + else { - case 32: CALL((void*)&SlowWrite7<u32, 0>); break; - case 16: CALL((void*)&SlowWrite7<u16, 0>); break; - case 8: CALL((void*)&SlowWrite7<u8, 0>); break; - case 33: CALL((void*)&SlowWrite7<u32, 1>); break; - case 17: CALL((void*)&SlowWrite7<u16, 1>); break; - case 9: CALL((void*)&SlowWrite7<u8, 1>); break; + switch (size | NDS::ConsoleType) + { + case 32: CALL((void*)&SlowRead9<u32, 0>); break; + case 16: CALL((void*)&SlowRead9<u16, 0>); break; + case 8: CALL((void*)&SlowRead9<u8, 0>); break; + case 33: CALL((void*)&SlowRead9<u32, 1>); break; + case 17: CALL((void*)&SlowRead9<u16, 1>); break; + case 9: CALL((void*)&SlowRead9<u8, 1>); break; + } } } else { - switch (size | NDS::ConsoleType) + if (ABI_PARAM1 != RSCRATCH3) + MOV(32, R(ABI_PARAM1), R(RSCRATCH3)); + if (flags & memop_Store) { - case 32: CALL((void*)&SlowRead7<u32, 0>); break; - case 16: CALL((void*)&SlowRead7<u16, 0>); break; - case 8: CALL((void*)&SlowRead7<u8, 0>); break; - case 33: CALL((void*)&SlowRead7<u32, 1>); break; - case 17: CALL((void*)&SlowRead7<u16, 1>); break; - case 9: CALL((void*)&SlowRead7<u8, 1>); break; + MOV(32, R(ABI_PARAM2), rdMapped); + + switch (size | NDS::ConsoleType) + { + case 32: CALL((void*)&SlowWrite7<u32, 0>); break; + case 16: CALL((void*)&SlowWrite7<u16, 0>); break; + case 8: CALL((void*)&SlowWrite7<u8, 0>); break; + case 33: CALL((void*)&SlowWrite7<u32, 1>); break; + case 17: CALL((void*)&SlowWrite7<u16, 1>); break; + case 9: CALL((void*)&SlowWrite7<u8, 1>); break; + } + } + else + { + switch (size | NDS::ConsoleType) + { + case 32: CALL((void*)&SlowRead7<u32, 0>); break; + case 16: CALL((void*)&SlowRead7<u16, 0>); break; + case 8: CALL((void*)&SlowRead7<u8, 0>); break; + case 33: CALL((void*)&SlowRead7<u32, 1>); break; + case 17: CALL((void*)&SlowRead7<u16, 1>); break; + case 9: CALL((void*)&SlowRead7<u8, 1>); break; + } } } - } - PopRegs(false); - - if (!(flags & memop_Store)) - { - if (flags & memop_SignExtend) - MOVSX(32, size, rdMapped.GetSimpleReg(), R(RSCRATCH)); - else - MOVZX(32, size, rdMapped.GetSimpleReg(), R(RSCRATCH)); + PopRegs(false); + + if (!(flags & memop_Store)) + { + if (flags & memop_SignExtend) + MOVSX(32, size, rdMapped.GetSimpleReg(), R(RSCRATCH)); + else + MOVZX(32, size, rdMapped.GetSimpleReg(), R(RSCRATCH)); + } } } |