Skip to content

Commit

Permalink
Merge pull request #2661 from Sonicadvance1/aarch64_slwx
Browse files Browse the repository at this point in the history
[AArch64] Implement slwx in the recompiler.
  • Loading branch information
Sonicadvance1 committed Jun 26, 2015
2 parents da7ec75 + 63a2180 commit 6818f2e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions Source/Core/Core/PowerPC/JitArm64/Jit.h
Expand Up @@ -97,6 +97,7 @@ class JitArm64 : public JitBase, public Arm64Gen::ARM64CodeBlock
void addzex(UGeckoInstruction inst);
void subfx(UGeckoInstruction inst);
void addcx(UGeckoInstruction inst);
void slwx(UGeckoInstruction inst);

// System Registers
void mtmsr(UGeckoInstruction inst);
Expand Down
48 changes: 48 additions & 0 deletions Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp
Expand Up @@ -718,3 +718,51 @@ void JitArm64::addcx(UGeckoInstruction inst)
ComputeRC(gpr.R(d), 0);
}
}

void JitArm64::slwx(UGeckoInstruction inst)
{
INSTRUCTION_START
JITDISABLE(bJITIntegerOff);

int a = inst.RA, b = inst.RB, s = inst.RS;

if (gpr.IsImm(b) && gpr.IsImm(s))
{
u32 i = gpr.GetImm(s), j = gpr.GetImm(b);
gpr.SetImmediate(a, (j & 0x20) ? 0 : i << (j & 0x1F));

if (inst.Rc)
ComputeRC(gpr.GetImm(a), 0);
}
else if (gpr.IsImm(b))
{
u32 i = gpr.GetImm(b);
if (i & 0x20)
{
gpr.SetImmediate(a, 0);
if (inst.Rc)
ComputeRC(0, 0);
}
else
{
gpr.BindToRegister(a, a == s);
LSL(gpr.R(a), gpr.R(s), i & 0x1F);
if (inst.Rc)
ComputeRC(gpr.R(a), 0);
}
}
else
{
gpr.BindToRegister(a, a == b || a == s);

// PowerPC any shift in the 32-63 register range results in zero
// Since it has 32bit registers
// AArch64 it will use a mask of the register size for determining what shift amount
// So if we use a 64bit so the bits will end up in the high 32bits, and
// Later instructions will just eat high 32bits since it'll run 32bit operations for everything.
LSLV(EncodeRegTo64(gpr.R(a)), EncodeRegTo64(gpr.R(s)), EncodeRegTo64(gpr.R(b)));

if (inst.Rc)
ComputeRC(gpr.R(a), 0);
}
}
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp
Expand Up @@ -218,7 +218,7 @@ static GekkoOPTemplate table31[] =
{536, &JitArm64::FallBackToInterpreter}, // srwx
{792, &JitArm64::FallBackToInterpreter}, // srawx
{824, &JitArm64::srawix}, // srawix
{24, &JitArm64::FallBackToInterpreter}, // slwx
{24, &JitArm64::slwx}, // slwx

{54, &JitArm64::FallBackToInterpreter}, // dcbst
{86, &JitArm64::FallBackToInterpreter}, // dcbf
Expand Down

0 comments on commit 6818f2e

Please sign in to comment.