Permalink
Browse files

Jit: Add preg_t variant of ComputeRC

  • Loading branch information...
MerryMage committed Oct 15, 2018
1 parent 5e46c16 commit 33812319acf7ab560176ace81b4b7a4e2ab621dd
Showing with 50 additions and 0 deletions.
  1. +1 −0 Source/Core/Core/PowerPC/Jit64/Jit.h
  2. +49 −0 Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp
@@ -88,6 +88,7 @@ class Jit64 : public Jitx86Base
void FinalizeCarryOverflow(bool oe, bool inv = false);
void FinalizeCarry(Gen::CCFlags cond);
void FinalizeCarry(bool ca);
void ComputeRC(preg_t preg, bool needs_test = true, bool needs_sext = true);
void ComputeRC(const Gen::OpArg& arg, bool needs_test = true, bool needs_sext = true);

// Use to extract bytes from a register using the regcache. offset is in bytes.
@@ -141,6 +141,55 @@ void Jit64::FinalizeCarryOverflow(bool oe, bool inv)
// branches, only EQ.
// The flags from any instruction that may set OF (such as ADD/SUB) can not be used for
// LT/GT either.
void Jit64::ComputeRC(preg_t preg, bool needs_test, bool needs_sext)
{
RCOpArg arg = gpr.Use(preg, RCMode::Read);
RegCache::Realize(arg);

if (arg.IsImm())
{
MOV(64, PPCSTATE(cr_val[0]), Imm32(arg.SImm32()));
}
else if (needs_sext)
{
MOVSX(64, 32, RSCRATCH, arg);
MOV(64, PPCSTATE(cr_val[0]), R(RSCRATCH));
}
else
{
MOV(64, PPCSTATE(cr_val[0]), arg);
}

if (CheckMergedBranch(0))
{
if (arg.IsImm())
{
s32 offset = arg.SImm32();
arg.Unlock();
DoMergedBranchImmediate(offset);
}
else
{
if (needs_test)
{
TEST(32, arg, arg);
}
else
{
// If an operand to the cmp/rc op we're merging with the branch isn't used anymore, it'd be
// better to flush it here so that we don't have to flush it on both sides of the branch.
// We don't want to do this if a test is needed though, because it would interrupt macro-op
// fusion.
for (int j : ~js.op->gprInUse)
gpr.StoreFromRegister(j);
}

arg.Unlock();
DoMergedBranchCondition();
}
}
}

void Jit64::ComputeRC(const OpArg& arg, bool needs_test, bool needs_sext)
{
ASSERT_MSG(DYNA_REC, arg.IsSimpleReg() || arg.IsImm(), "Invalid ComputeRC operand");

0 comments on commit 3381231

Please sign in to comment.