Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #9974 from JosJuice/jitarm64-mtfsfix
JitArm64: Implement mtfsfix
  • Loading branch information
lioncash committed Jul 31, 2021
2 parents b6bd3fc + 0e62dac commit bef1fdb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions Source/Core/Core/PowerPC/JitArm64/Jit.h
Expand Up @@ -121,6 +121,7 @@ class JitArm64 : public JitBase, public Arm64Gen::ARM64CodeBlock, public CommonA
void mffsx(UGeckoInstruction inst);
void mtfsb0x(UGeckoInstruction inst);
void mtfsb1x(UGeckoInstruction inst);
void mtfsfix(UGeckoInstruction inst);

// LoadStore
void lXX(UGeckoInstruction inst);
Expand Down
36 changes: 36 additions & 0 deletions Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp
Expand Up @@ -816,3 +816,39 @@ void JitArm64::mtfsb1x(UGeckoInstruction inst)
if (inst.CRBD >= 29)
UpdateRoundingMode();
}

void JitArm64::mtfsfix(UGeckoInstruction inst)
{
INSTRUCTION_START
JITDISABLE(bJITSystemRegistersOff);
FALLBACK_IF(inst.Rc);

u8 imm = (inst.hex >> (31 - 19)) & 0xF;
u8 shift = 28 - 4 * inst.CRFD;

ARM64Reg WA = gpr.GetReg();
LDR(IndexType::Unsigned, WA, PPC_REG, PPCSTATE_OFF(fpscr));

if (imm == 0xF)
{
ORR(WA, WA, LogicalImm(0xF << shift, 32));
}
else if (imm == 0x0)
{
BFI(WA, ARM64Reg::WZR, shift, 4);
}
else
{
ARM64Reg WB = gpr.GetReg();
MOVZ(WB, imm);
BFI(WA, WB, shift, 4);
gpr.Unlock(WB);
}

STR(IndexType::Unsigned, WA, PPC_REG, PPCSTATE_OFF(fpscr));
gpr.Unlock(WA);

// Field 7 contains NI and RN.
if (inst.CRFD == 7)
UpdateRoundingMode();
}
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp
Expand Up @@ -318,7 +318,7 @@ constexpr std::array<GekkoOPTemplate, 15> table63{{
{583, &JitArm64::mffsx}, // mffsx
{70, &JitArm64::mtfsb0x}, // mtfsb0x
{38, &JitArm64::mtfsb1x}, // mtfsb1x
{134, &JitArm64::FallBackToInterpreter}, // mtfsfix
{134, &JitArm64::mtfsfix}, // mtfsfix
{711, &JitArm64::FallBackToInterpreter}, // mtfsfx
}};

Expand Down

0 comments on commit bef1fdb

Please sign in to comment.