x86jit: Implement syscalls and some system.

This commit is contained in:
Unknown W. Brackets 2023-08-24 18:56:17 -07:00
parent 2fbdc42a5c
commit 004c35cf76
2 changed files with 45 additions and 4 deletions

View File

@ -54,7 +54,8 @@ void X64JitBackend::CompIR_Exit(IRInst inst) {
break; break;
case IROp::ExitToPC: case IROp::ExitToPC:
CompIR_Generic(inst); FlushAll();
JMP(dispatcherCheckCoreState_, true);
break; break;
default: default:

View File

@ -65,8 +65,13 @@ void X64JitBackend::CompIR_Basic(IRInst inst) {
break; break;
case IROp::SetPC: case IROp::SetPC:
regs_.Map(inst);
MovToPC(regs_.RX(inst.src1));
break;
case IROp::SetPCConst: case IROp::SetPCConst:
CompIR_Generic(inst); MOV(32, R(SCRATCH1), Imm32(inst.constant));
MovToPC(SCRATCH1);
break; break;
default: default:
@ -95,6 +100,29 @@ void X64JitBackend::CompIR_System(IRInst inst) {
switch (inst.op) { switch (inst.op) {
case IROp::Syscall: case IROp::Syscall:
FlushAll();
SaveStaticRegisters();
#ifdef USE_PROFILER
// When profiling, we can't skip CallSyscall, since it times syscalls.
ABI_CallFunctionC((const u8 *)&CallSyscall, inst.constant);
#else
// Skip the CallSyscall where possible.
{
MIPSOpcode op(inst.constant);
void *quickFunc = GetQuickSyscallFunc(op);
if (quickFunc) {
ABI_CallFunctionP((const u8 *)quickFunc, (void *)GetSyscallFuncPointer(op));
} else {
ABI_CallFunctionC((const u8 *)&CallSyscall, inst.constant);
}
}
#endif
LoadStaticRegisters();
// This is always followed by an ExitToPC, where we check coreState.
break;
case IROp::CallReplacement: case IROp::CallReplacement:
case IROp::Break: case IROp::Break:
CompIR_Generic(inst); CompIR_Generic(inst);
@ -111,9 +139,17 @@ void X64JitBackend::CompIR_Transfer(IRInst inst) {
switch (inst.op) { switch (inst.op) {
case IROp::SetCtrlVFPU: case IROp::SetCtrlVFPU:
regs_.SetGPRImm(IRREG_VFPU_CTRL_BASE + inst.dest, (int32_t)inst.constant);
break;
case IROp::SetCtrlVFPUReg: case IROp::SetCtrlVFPUReg:
regs_.Map(inst);
MOV(32, regs_.R(IRREG_VFPU_CTRL_BASE + inst.dest), regs_.R(inst.src1));
break;
case IROp::SetCtrlVFPUFReg: case IROp::SetCtrlVFPUFReg:
CompIR_Generic(inst); regs_.Map(inst);
MOVD_xmm(regs_.R(IRREG_VFPU_CTRL_BASE + inst.dest), regs_.FX(inst.src1));
break; break;
case IROp::FpCondFromReg: case IROp::FpCondFromReg:
@ -128,10 +164,14 @@ void X64JitBackend::CompIR_Transfer(IRInst inst) {
case IROp::FpCtrlFromReg: case IROp::FpCtrlFromReg:
case IROp::FpCtrlToReg: case IROp::FpCtrlToReg:
case IROp::VfpuCtrlToReg:
CompIR_Generic(inst); CompIR_Generic(inst);
break; break;
case IROp::VfpuCtrlToReg:
regs_.Map(inst);
MOV(32, regs_.R(inst.dest), regs_.R(IRREG_VFPU_CTRL_BASE + inst.src1));
break;
case IROp::FMovFromGPR: case IROp::FMovFromGPR:
if (regs_.IsGPRImm(inst.src1) && regs_.GetGPRImm(inst.src1) == 0) { if (regs_.IsGPRImm(inst.src1) && regs_.GetGPRImm(inst.src1) == 0) {
regs_.MapFPR(inst.dest, MIPSMap::NOINIT); regs_.MapFPR(inst.dest, MIPSMap::NOINIT);