[JIT]: Respect Microsoft calling convention too
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -2,7 +2,12 @@
|
|||||||
*.ini
|
*.ini
|
||||||
*build*/
|
*build*/
|
||||||
.idea/
|
.idea/
|
||||||
roms/
|
*.z64
|
||||||
|
*.n64
|
||||||
|
*.v64
|
||||||
|
*.Z64
|
||||||
|
*.N64
|
||||||
|
*.V64
|
||||||
saves/
|
saves/
|
||||||
*.bin
|
*.bin
|
||||||
*.sh
|
*.sh
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <Mem.hpp>
|
#include <Mem.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <xbyak.h>
|
#include <xbyak.h>
|
||||||
|
#include <jit/helpers.hpp>
|
||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
struct Core;
|
struct Core;
|
||||||
@@ -35,7 +36,7 @@ struct JIT : BaseCPU {
|
|||||||
[[nodiscard]] Disassembler::DisassemblyResult Disassemble(u32, u32) const override { return {}; }
|
[[nodiscard]] Disassembler::DisassemblyResult Disassemble(u32, u32) const override { return {}; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Xbyak::CodeGenerator code{kCodeCacheSize};
|
Xbyak::CodeGenerator code{kCodeCacheAllocSize};
|
||||||
Registers regs;
|
Registers regs;
|
||||||
Mem mem;
|
Mem mem;
|
||||||
u64 cop2Latch{};
|
u64 cop2Latch{};
|
||||||
@@ -83,7 +84,7 @@ private:
|
|||||||
thisPtr += arr[1];
|
thisPtr += arr[1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
code.mov(code.rdi, thisPtr);
|
code.mov(code.ARG1, thisPtr);
|
||||||
code.mov(code.rax, functionPtr);
|
code.mov(code.rax, functionPtr);
|
||||||
code.sub(code.rsp, 8);
|
code.sub(code.rsp, 8);
|
||||||
code.call(code.rax);
|
code.call(code.rax);
|
||||||
|
|||||||
@@ -71,4 +71,18 @@ static bool IsBranchLikely(const u32 instr) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define ARG1 rcx
|
||||||
|
#define ARG2 rdx
|
||||||
|
#define ARG3 r8
|
||||||
|
#define ARG4 r9
|
||||||
|
#else
|
||||||
|
#define ARG1 rdi
|
||||||
|
#define ARG2 rsi
|
||||||
|
#define ARG3 rdx
|
||||||
|
#define ARG4 rcx
|
||||||
|
#define ARG5 r8
|
||||||
|
#define ARG6 r9
|
||||||
|
#endif
|
||||||
} // namespace n64
|
} // namespace n64
|
||||||
|
|||||||
@@ -899,8 +899,9 @@ void JIT::lbu(u32 instr) {
|
|||||||
// regs.cop0.FireException(Cop0::GetTLBExceptionCode(regs.cop0.tlbError, Cop0::LOAD), 0, regs.oldPC);
|
// regs.cop0.FireException(Cop0::GetTLBExceptionCode(regs.cop0.tlbError, Cop0::LOAD), 0, regs.oldPC);
|
||||||
Util::panic("[JIT]: Unhandled TLBL exception in LBU!");
|
Util::panic("[JIT]: Unhandled TLBL exception in LBU!");
|
||||||
} else {
|
} else {
|
||||||
code.mov(code.rsi, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
code.mov(code.ARG2,
|
||||||
code.mov(code.edx, paddr);
|
code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
||||||
|
code.mov(code.ARG3, paddr);
|
||||||
emitMemberFunctionCall(&Mem::Read<u8>, &mem);
|
emitMemberFunctionCall(&Mem::Read<u8>, &mem);
|
||||||
regs.Write<u8>(RT(instr), code.rax);
|
regs.Write<u8>(RT(instr), code.rax);
|
||||||
}
|
}
|
||||||
@@ -917,8 +918,9 @@ void JIT::lb(u32 instr) {
|
|||||||
// regs.cop0.FireException(Cop0::GetTLBExceptionCode(regs.cop0.tlbError, Cop0::LOAD), 0, regs.oldPC);
|
// regs.cop0.FireException(Cop0::GetTLBExceptionCode(regs.cop0.tlbError, Cop0::LOAD), 0, regs.oldPC);
|
||||||
Util::panic("[JIT]: Unhandled TLBL exception in LB!");
|
Util::panic("[JIT]: Unhandled TLBL exception in LB!");
|
||||||
} else {
|
} else {
|
||||||
code.mov(code.rsi, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
code.mov(code.ARG2,
|
||||||
code.mov(code.edx, paddr);
|
code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
||||||
|
code.mov(code.ARG3, paddr);
|
||||||
emitMemberFunctionCall(&Mem::Read<u8>, &mem);
|
emitMemberFunctionCall(&Mem::Read<u8>, &mem);
|
||||||
regs.Write<s8>(RT(instr), code.rax);
|
regs.Write<s8>(RT(instr), code.rax);
|
||||||
}
|
}
|
||||||
@@ -943,8 +945,9 @@ void JIT::ld(u32 instr) {
|
|||||||
// regs.cop0.FireException(Cop0::GetTLBExceptionCode(regs.cop0.tlbError, Cop0::LOAD), 0, regs.oldPC);
|
// regs.cop0.FireException(Cop0::GetTLBExceptionCode(regs.cop0.tlbError, Cop0::LOAD), 0, regs.oldPC);
|
||||||
Util::panic("[JIT]: Unhandled TLBL exception in LD!");
|
Util::panic("[JIT]: Unhandled TLBL exception in LD!");
|
||||||
} else {
|
} else {
|
||||||
code.mov(code.rsi, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
code.mov(code.ARG2,
|
||||||
code.mov(code.edx, paddr);
|
code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
||||||
|
code.mov(code.ARG3, paddr);
|
||||||
emitMemberFunctionCall(&Mem::Read<u64>, &mem);
|
emitMemberFunctionCall(&Mem::Read<u64>, &mem);
|
||||||
regs.Write<u64>(RT(instr), code.rax);
|
regs.Write<u64>(RT(instr), code.rax);
|
||||||
}
|
}
|
||||||
@@ -1032,8 +1035,8 @@ void JIT::lh(u32 instr) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
code.mov(code.rsi, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
code.mov(code.ARG2, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
||||||
code.mov(code.edx, paddr);
|
code.mov(code.ARG3, paddr);
|
||||||
emitMemberFunctionCall(&Mem::Read<u16>, &mem);
|
emitMemberFunctionCall(&Mem::Read<u16>, &mem);
|
||||||
regs.Write<s16>(RT(instr), code.rax);
|
regs.Write<s16>(RT(instr), code.rax);
|
||||||
return;
|
return;
|
||||||
@@ -1068,21 +1071,21 @@ void JIT::lw(u32 instr) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
code.mov(code.rsi, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
code.mov(code.ARG2, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
||||||
code.mov(code.edx, paddr);
|
code.mov(code.ARG3, paddr);
|
||||||
emitMemberFunctionCall(&Mem::Read<u32>, &mem);
|
emitMemberFunctionCall(&Mem::Read<u32>, &mem);
|
||||||
regs.Write<s32>(RT(instr), code.rax);
|
regs.Write<s32>(RT(instr), code.rax);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
code.mov(code.esi, Cop0::LOAD);
|
code.mov(code.ARG2, Cop0::LOAD);
|
||||||
regs.Read<s64>(RS(instr), code.rdx);
|
regs.Read<s64>(RS(instr), code.rdx);
|
||||||
code.add(code.rdx, offset);
|
code.add(code.ARG3, offset);
|
||||||
code.mov(code.rcx, reinterpret_cast<uintptr_t>(&paddr));
|
code.mov(code.ARG4, reinterpret_cast<uintptr_t>(&paddr));
|
||||||
emitMemberFunctionCall(&Cop0::MapVAddr, ®s.cop0);
|
emitMemberFunctionCall(&Cop0::MapVAddr, ®s.cop0);
|
||||||
|
|
||||||
code.mov(code.rsi, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
code.mov(code.ARG2, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
||||||
code.mov(code.edx, paddr);
|
code.mov(code.ARG3, paddr);
|
||||||
emitMemberFunctionCall(&Mem::Read<u32>, &mem);
|
emitMemberFunctionCall(&Mem::Read<u32>, &mem);
|
||||||
regs.Write<s32>(RT(instr), code.rax);
|
regs.Write<s32>(RT(instr), code.rax);
|
||||||
}
|
}
|
||||||
@@ -1305,9 +1308,10 @@ void JIT::sw(const u32 instr) {
|
|||||||
// regs.cop0.FireException(Cop0::GetTLBExceptionCode(regs.cop0.tlbError, Cop0::STORE), 0, regs.oldPC);
|
// regs.cop0.FireException(Cop0::GetTLBExceptionCode(regs.cop0.tlbError, Cop0::STORE), 0, regs.oldPC);
|
||||||
Util::panic("[JIT]: Unhandled TLBS exception in SW!");
|
Util::panic("[JIT]: Unhandled TLBS exception in SW!");
|
||||||
} else {
|
} else {
|
||||||
code.lea(code.rsi, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
code.lea(code.ARG2,
|
||||||
code.mov(code.edx, physical);
|
code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
||||||
code.mov(code.rcx, regs.Read<s64>(RT(instr)));
|
code.mov(code.ARG3, physical);
|
||||||
|
code.mov(code.ARG4, regs.Read<s64>(RT(instr)));
|
||||||
emitMemberFunctionCall(&Mem::WriteJIT<u32>, &mem);
|
emitMemberFunctionCall(&Mem::WriteJIT<u32>, &mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1329,8 +1333,9 @@ void JIT::sw(const u32 instr) {
|
|||||||
// regs.cop0.FireException(Cop0::GetTLBExceptionCode(regs.cop0.tlbError, Cop0::STORE), 0, regs.oldPC);
|
// regs.cop0.FireException(Cop0::GetTLBExceptionCode(regs.cop0.tlbError, Cop0::STORE), 0, regs.oldPC);
|
||||||
Util::panic("[JIT]: Unhandled TLBS exception in SW!");
|
Util::panic("[JIT]: Unhandled TLBS exception in SW!");
|
||||||
} else {
|
} else {
|
||||||
code.mov(code.rsi, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
code.mov(code.ARG2,
|
||||||
code.mov(code.edx, physical);
|
code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
||||||
|
code.mov(code.ARG3, physical);
|
||||||
regs.Read<s64>(RT(instr), code.rcx);
|
regs.Read<s64>(RT(instr), code.rcx);
|
||||||
emitMemberFunctionCall(&Mem::WriteJIT<u32>, &mem);
|
emitMemberFunctionCall(&Mem::WriteJIT<u32>, &mem);
|
||||||
}
|
}
|
||||||
@@ -1341,16 +1346,16 @@ void JIT::sw(const u32 instr) {
|
|||||||
if (regs.IsRegConstant(RT(instr))) {
|
if (regs.IsRegConstant(RT(instr))) {
|
||||||
const s16 offset = instr;
|
const s16 offset = instr;
|
||||||
regs.Read<s64>(RS(instr), code.rdx);
|
regs.Read<s64>(RS(instr), code.rdx);
|
||||||
code.add(code.rdx, offset);
|
code.add(code.ARG3, offset);
|
||||||
|
|
||||||
code.mov(code.esi, Cop0::STORE);
|
code.mov(code.ARG2, Cop0::STORE);
|
||||||
|
|
||||||
code.mov(code.rcx, reinterpret_cast<uintptr_t>(&physical));
|
code.mov(code.ARG4, reinterpret_cast<uintptr_t>(&physical));
|
||||||
emitMemberFunctionCall(&Cop0::MapVAddr, ®s.cop0);
|
emitMemberFunctionCall(&Cop0::MapVAddr, ®s.cop0);
|
||||||
|
|
||||||
code.mov(code.rsi, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
code.mov(code.ARG2, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
||||||
code.mov(code.edx, physical);
|
code.mov(code.ARG3, physical);
|
||||||
code.mov(code.rcx, regs.Read<s64>(RT(instr)));
|
code.mov(code.ARG4, regs.Read<s64>(RT(instr)));
|
||||||
emitMemberFunctionCall(&Mem::WriteJIT<u32>, &mem);
|
emitMemberFunctionCall(&Mem::WriteJIT<u32>, &mem);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -1358,16 +1363,16 @@ void JIT::sw(const u32 instr) {
|
|||||||
|
|
||||||
const s16 offset = instr;
|
const s16 offset = instr;
|
||||||
regs.Read<s64>(RS(instr), code.rdx);
|
regs.Read<s64>(RS(instr), code.rdx);
|
||||||
code.add(code.rdx, offset);
|
code.add(code.ARG3, offset);
|
||||||
|
|
||||||
code.mov(code.esi, Cop0::STORE);
|
code.mov(code.ARG2, Cop0::STORE);
|
||||||
|
|
||||||
code.mov(code.rcx, reinterpret_cast<uintptr_t>(&physical));
|
code.mov(code.ARG4, reinterpret_cast<uintptr_t>(&physical));
|
||||||
emitMemberFunctionCall(&Cop0::MapVAddr, ®s.cop0);
|
emitMemberFunctionCall(&Cop0::MapVAddr, ®s.cop0);
|
||||||
|
|
||||||
code.mov(code.rsi, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
code.mov(code.ARG2, code.ptr[code.rbp + (reinterpret_cast<uintptr_t>(®s) - reinterpret_cast<uintptr_t>(this))]);
|
||||||
code.mov(code.edx, physical);
|
code.mov(code.ARG3, physical);
|
||||||
regs.Read<s64>(RT(instr), code.rcx);
|
regs.Read<s64>(RT(instr), code.ARG4);
|
||||||
emitMemberFunctionCall(&Mem::WriteJIT<u32>, &mem);
|
emitMemberFunctionCall(&Mem::WriteJIT<u32>, &mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user