Merge pull request #419 from magumagu/jit-load-store-cleanup

Jit load store cleanup
This commit is contained in:
shuffle2 2014-05-29 15:25:00 -07:00
commit e9975cdd63
3 changed files with 33 additions and 67 deletions

View File

@ -176,14 +176,14 @@ void Jit64::lXXx(UGeckoInstruction inst)
{ {
u32 val = (u32)gpr.R(a).offset + (s32)inst.SIMM_16; u32 val = (u32)gpr.R(a).offset + (s32)inst.SIMM_16;
opAddress = Imm32(val); opAddress = Imm32(val);
if (update && !js.memcheck) if (update)
gpr.SetImmediate32(a, val); gpr.SetImmediate32(a, val);
} }
else if ((inst.OPCD == 31) && gpr.R(a).IsImm() && gpr.R(b).IsImm() && !js.memcheck) else if ((inst.OPCD == 31) && gpr.R(a).IsImm() && gpr.R(b).IsImm() && !js.memcheck)
{ {
u32 val = (u32)gpr.R(a).offset + (u32)gpr.R(b).offset; u32 val = (u32)gpr.R(a).offset + (u32)gpr.R(b).offset;
opAddress = Imm32(val); opAddress = Imm32(val);
if (update && !js.memcheck) if (update)
gpr.SetImmediate32(a, val); gpr.SetImmediate32(a, val);
} }
else else

View File

@ -324,12 +324,8 @@ void Jit64::lfsx(UGeckoInstruction inst)
#else #else
MOVD_xmm(XMM0, MComplex(RBX, EAX, SCALE_1, 0)); MOVD_xmm(XMM0, MComplex(RBX, EAX, SCALE_1, 0));
#endif #endif
MEMCHECK_START
PSHUFB(XMM0, M((void *)bswapShuffle1x4)); PSHUFB(XMM0, M((void *)bswapShuffle1x4));
ConvertSingleToDouble(s, XMM0); ConvertSingleToDouble(s, XMM0);
MEMCHECK_END
} else { } else {
SafeLoadToReg(EAX, R(EAX), 32, 0, RegistersInUse(), false); SafeLoadToReg(EAX, R(EAX), 32, 0, RegistersInUse(), false);

View File

@ -358,74 +358,44 @@ void EmuCodeBlock::SafeLoadToReg(X64Reg reg_value, const Gen::OpArg & opAddress,
} }
else else
{ {
OpArg addr_loc = opAddress;
if (offset) if (offset)
{ {
addr_loc = R(EAX);
MOV(32, R(EAX), opAddress); MOV(32, R(EAX), opAddress);
ADD(32, R(EAX), Imm32(offset)); ADD(32, R(EAX), Imm32(offset));
TEST(32, R(EAX), Imm32(mem_mask));
FixupBranch fast = J_CC(CC_Z, true);
ABI_PushRegistersAndAdjustStack(registersInUse, false);
switch (accessSize)
{
case 32: ABI_CallFunctionR((void *)&Memory::Read_U32, EAX); break;
case 16: ABI_CallFunctionR((void *)&Memory::Read_U16_ZX, EAX); break;
case 8: ABI_CallFunctionR((void *)&Memory::Read_U8_ZX, EAX); break;
}
ABI_PopRegistersAndAdjustStack(registersInUse, false);
MEMCHECK_START
if (signExtend && accessSize < 32)
{
// Need to sign extend values coming from the Read_U* functions.
MOVSX(32, accessSize, reg_value, R(EAX));
}
else if (reg_value != EAX)
{
MOVZX(32, accessSize, reg_value, R(EAX));
}
MEMCHECK_END
FixupBranch exit = J();
SetJumpTarget(fast);
UnsafeLoadToReg(reg_value, R(EAX), accessSize, 0, signExtend);
SetJumpTarget(exit);
} }
else TEST(32, addr_loc, Imm32(mem_mask));
FixupBranch fast = J_CC(CC_Z, true);
ABI_PushRegistersAndAdjustStack(registersInUse, false);
switch (accessSize)
{ {
TEST(32, opAddress, Imm32(mem_mask)); case 32: ABI_CallFunctionA((void *)&Memory::Read_U32, addr_loc); break;
FixupBranch fast = J_CC(CC_Z, true); case 16: ABI_CallFunctionA((void *)&Memory::Read_U16_ZX, addr_loc); break;
case 8: ABI_CallFunctionA((void *)&Memory::Read_U8_ZX, addr_loc); break;
ABI_PushRegistersAndAdjustStack(registersInUse, false);
switch (accessSize)
{
case 32: ABI_CallFunctionA((void *)&Memory::Read_U32, opAddress); break;
case 16: ABI_CallFunctionA((void *)&Memory::Read_U16_ZX, opAddress); break;
case 8: ABI_CallFunctionA((void *)&Memory::Read_U8_ZX, opAddress); break;
}
ABI_PopRegistersAndAdjustStack(registersInUse, false);
MEMCHECK_START
if (signExtend && accessSize < 32)
{
// Need to sign extend values coming from the Read_U* functions.
MOVSX(32, accessSize, reg_value, R(EAX));
}
else if (reg_value != EAX)
{
MOVZX(32, accessSize, reg_value, R(EAX));
}
MEMCHECK_END
FixupBranch exit = J();
SetJumpTarget(fast);
UnsafeLoadToReg(reg_value, opAddress, accessSize, offset, signExtend);
SetJumpTarget(exit);
} }
ABI_PopRegistersAndAdjustStack(registersInUse, false);
MEMCHECK_START
if (signExtend && accessSize < 32)
{
// Need to sign extend values coming from the Read_U* functions.
MOVSX(32, accessSize, reg_value, R(EAX));
}
else if (reg_value != EAX)
{
MOVZX(32, accessSize, reg_value, R(EAX));
}
MEMCHECK_END
FixupBranch exit = J();
SetJumpTarget(fast);
UnsafeLoadToReg(reg_value, addr_loc, accessSize, 0, signExtend);
SetJumpTarget(exit);
} }
} }
} }