Merge pull request #457 from Tilka/jcc

x64Emitter: J_CC: use 32 bit offset automatically
This commit is contained in:
Ryan Houdek 2014-06-06 20:53:50 -05:00
commit b6db0d0ab8
4 changed files with 13 additions and 15 deletions

View File

@ -447,20 +447,13 @@ FixupBranch XEmitter::J_CC(CCFlags conditionCode, bool force5bytes)
return branch; return branch;
} }
void XEmitter::J_CC(CCFlags conditionCode, const u8 * addr, bool force5Bytes) void XEmitter::J_CC(CCFlags conditionCode, const u8* addr)
{ {
u64 fn = (u64)addr; u64 fn = (u64)addr;
if (!force5Bytes)
{
s64 distance = (s64)(fn - ((u64)code + 2)); s64 distance = (s64)(fn - ((u64)code + 2));
_assert_msg_(DYNA_REC, distance >= -0x80 && distance < 0x80, "Jump target too far away, needs force5Bytes = true"); if (distance < -0x80 || distance >= 0x80)
//8 bits will do
Write8(0x70 + conditionCode);
Write8((u8)(s8)distance);
}
else
{ {
s64 distance = (s64)(fn - ((u64)code + 6)); distance = (s64)(fn - ((u64)code + 6));
_assert_msg_(DYNA_REC, _assert_msg_(DYNA_REC,
distance >= -0x80000000LL && distance < 0x80000000LL, distance >= -0x80000000LL && distance < 0x80000000LL,
"Jump target too far away, needs indirect register"); "Jump target too far away, needs indirect register");
@ -468,6 +461,11 @@ void XEmitter::J_CC(CCFlags conditionCode, const u8 * addr, bool force5Bytes)
Write8(0x80 + conditionCode); Write8(0x80 + conditionCode);
Write32((u32)(s32)distance); Write32((u32)(s32)distance);
} }
else
{
Write8(0x70 + conditionCode);
Write8((u8)(s8)distance);
}
} }
void XEmitter::SetJumpTarget(const FixupBranch &branch) void XEmitter::SetJumpTarget(const FixupBranch &branch)

View File

@ -331,7 +331,7 @@ public:
FixupBranch J_CC(CCFlags conditionCode, bool force5bytes = false); FixupBranch J_CC(CCFlags conditionCode, bool force5bytes = false);
//void J_CC(CCFlags conditionCode, JumpTarget target); //void J_CC(CCFlags conditionCode, JumpTarget target);
void J_CC(CCFlags conditionCode, const u8 * addr, bool force5Bytes = false); void J_CC(CCFlags conditionCode, const u8* addr);
void SetJumpTarget(const FixupBranch &branch); void SetJumpTarget(const FixupBranch &branch);

View File

@ -168,7 +168,7 @@ void Jit64AsmRoutineManager::Generate()
SetJumpTarget(noExtException); SetJumpTarget(noExtException);
TEST(32, M((void*)PowerPC::GetStatePtr()), Imm32(0xFFFFFFFF)); TEST(32, M((void*)PowerPC::GetStatePtr()), Imm32(0xFFFFFFFF));
J_CC(CC_Z, outerLoop, true); J_CC(CC_Z, outerLoop);
//Landing pad for drec space //Landing pad for drec space
ABI_PopAllCalleeSavedRegsAndAdjustStack(); ABI_PopAllCalleeSavedRegsAndAdjustStack();

View File

@ -769,7 +769,7 @@ void VertexLoader::CompileVertexTranslator()
SUB(32, M(&loop_counter), Imm8(1)); SUB(32, M(&loop_counter), Imm8(1));
#endif #endif
J_CC(CC_NZ, loop_start, true); J_CC(CC_NZ, loop_start);
ABI_PopAllCalleeSavedRegsAndAdjustStack(); ABI_PopAllCalleeSavedRegsAndAdjustStack();
RET(); RET();
#endif #endif