Don't muck with currentMIPS->r in the slowmem jit.

This commit is contained in:
Unknown W. Brackets 2013-01-19 02:48:48 -08:00
parent f53ec2bef6
commit f1295f6262
3 changed files with 55 additions and 22 deletions

View File

@ -170,6 +170,16 @@ void XEmitter::ABI_CallFunctionACC(void *func, const Gen::OpArg &arg1, u32 param
ABI_RestoreStack(3 * 4);
}
void XEmitter::ABI_CallFunctionAAC(void *func, const Gen::OpArg &arg1, const Gen::OpArg &arg2, u32 param3)
{
ABI_AlignStack(3 * 4);
PUSH(32, Imm32(param3));
PUSH(32, arg2);
PUSH(32, arg1);
CALL(func);
ABI_RestoreStack(3 * 4);
}
void XEmitter::ABI_CallFunctionA(void *func, const Gen::OpArg &arg1)
{
ABI_AlignStack(1 * 4);
@ -430,6 +440,22 @@ void XEmitter::ABI_CallFunctionACC(void *func, const Gen::OpArg &arg1, u32 param
}
}
void XEmitter::ABI_CallFunctionAAC(void *func, const Gen::OpArg &arg1, const Gen::OpArg &arg2, u32 param3)
{
MOV(32, R(ABI_PARAM1), arg1);
MOV(32, R(ABI_PARAM2), arg2);
MOV(64, R(ABI_PARAM3), Imm64(param3));
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
}
}
void XEmitter::ABI_CallFunctionA(void *func, const Gen::OpArg &arg1)
{
if (!arg1.IsSimpleReg(ABI_PARAM1))

View File

@ -657,6 +657,7 @@ public:
void ABI_CallFunctionPPC(void *func, void *param1, void *param2,u32 param3);
void ABI_CallFunctionAC(void *func, const Gen::OpArg &arg1, u32 param2);
void ABI_CallFunctionACC(void *func, const Gen::OpArg &arg1, u32 param2, u32 param3);
void ABI_CallFunctionAAC(void *func, const Gen::OpArg &arg1, const Gen::OpArg &arg2, u32 param3);
void ABI_CallFunctionA(void *func, const Gen::OpArg &arg1);
// Pass a register as a paremeter.

View File

@ -41,24 +41,24 @@
namespace MIPSComp
{
static void ReadMemSafe32(u32 addr, int preg, u32 offset)
static u32 ReadMemSafe32(u32 addr, u32 offset)
{
currentMIPS->r[preg] = Memory::Read_U32(addr + offset);
return Memory::Read_U32(addr + offset);
}
static void ReadMemSafe16(u32 addr, int preg, u32 offset)
static u32 ReadMemSafe16(u32 addr, u32 offset)
{
currentMIPS->r[preg] = Memory::Read_U16(addr + offset);
return Memory::Read_U16(addr + offset);
}
static void WriteMemSafe32(u32 addr, int preg, u32 offset)
static void WriteMemSafe32(u32 addr, u32 value, u32 offset)
{
Memory::Write_U32(currentMIPS->r[preg], addr + offset);
Memory::Write_U32(value, addr + offset);
}
static void WriteMemSafe16(u32 addr, int preg, u32 offset)
static void WriteMemSafe16(u32 addr, u32 value, u32 offset)
{
Memory::Write_U16(currentMIPS->r[preg], addr + offset);
Memory::Write_U16(value, addr + offset);
}
void Jit::Comp_ITypeMem(u32 op)
@ -92,14 +92,16 @@ namespace MIPSComp
#else
MOVZX(32, 16, gpr.RX(rt), MComplex(RBX, EAX, SCALE_1, offset));
#endif
gpr.UnlockAll();
FlushAll();
FixupBranch skip = J();
SetJumpTarget(tooLow);
SetJumpTarget(tooHigh);
ABI_CallFunctionACC((void *) &ReadMemSafe16, gpr.R(rs), rt, offset);
ABI_CallFunctionAC((void *) &ReadMemSafe16, R(EAX), offset);
MOVZX(32, 16, gpr.RX(rt), R(EAX));
SetJumpTarget(skip);
gpr.UnlockAll();
}
else
{
@ -139,14 +141,16 @@ namespace MIPSComp
#else
MOV(32, gpr.R(rt), MComplex(RBX, EAX, SCALE_1, offset));
#endif
gpr.UnlockAll();
FlushAll();
FixupBranch skip = J();
SetJumpTarget(tooLow);
SetJumpTarget(tooHigh);
ABI_CallFunctionACC((void *) &ReadMemSafe32, gpr.R(rs), rt, offset);
ABI_CallFunctionAC((void *) &ReadMemSafe32, R(EAX), offset);
MOV(32, gpr.R(rt), R(EAX));
SetJumpTarget(skip);
gpr.UnlockAll();
}
else
{
@ -177,7 +181,7 @@ namespace MIPSComp
FlushAll();
gpr.Lock(rt, rs);
gpr.BindToRegister(rt, true, true);
gpr.BindToRegister(rt, true, false);
MOV(32, R(EAX), gpr.R(rs));
CMP(32, R(EAX), Imm32(0x08000000));
@ -189,14 +193,15 @@ namespace MIPSComp
#else
MOV(16, MComplex(RBX, EAX, SCALE_1, offset), gpr.R(rt));
#endif
gpr.UnlockAll();
FlushAll();
FixupBranch skip = J();
SetJumpTarget(tooLow);
SetJumpTarget(tooHigh);
ABI_CallFunctionACC((void *) &WriteMemSafe16, gpr.R(rs), rt, offset);
ABI_CallFunctionAAC((void *) &WriteMemSafe16, R(EAX), gpr.R(rt), offset);
SetJumpTarget(skip);
gpr.UnlockAll();
}
else
{
@ -220,7 +225,7 @@ namespace MIPSComp
FlushAll();
gpr.Lock(rt, rs);
gpr.BindToRegister(rt, true, true);
gpr.BindToRegister(rt, true, false);
MOV(32, R(EAX), gpr.R(rs));
CMP(32, R(EAX), Imm32(0x08000000));
@ -232,14 +237,15 @@ namespace MIPSComp
#else
MOV(32, MComplex(RBX, EAX, SCALE_1, offset), gpr.R(rt));
#endif
gpr.UnlockAll();
FlushAll();
FixupBranch skip = J();
SetJumpTarget(tooLow);
SetJumpTarget(tooHigh);
ABI_CallFunctionACC((void *) &WriteMemSafe32, gpr.R(rs), rt, offset);
ABI_CallFunctionAAC((void *) &WriteMemSafe32, R(EAX), gpr.R(rt), offset);
SetJumpTarget(skip);
gpr.UnlockAll();
}
else
{