JitArm64: Implement mtfsb0x

Part 3 of implementing the FPSCR system register instructions.
This commit is contained in:
JosJuice 2021-07-12 16:26:03 +02:00
parent 46f7074bf7
commit b2d87c49b6
3 changed files with 37 additions and 2 deletions

View File

@ -119,6 +119,7 @@ public:
void mtcrf(UGeckoInstruction inst);
void mcrfs(UGeckoInstruction inst);
void mffsx(UGeckoInstruction inst);
void mtfsb0x(UGeckoInstruction inst);
// LoadStore
void lXX(UGeckoInstruction inst);
@ -261,8 +262,9 @@ protected:
void FakeLKExit(u32 exit_address_after_return);
void WriteBLRExit(Arm64Gen::ARM64Reg dest);
void FixGTBeforeSettingCRFieldBit(Arm64Gen::ARM64Reg reg);
Arm64Gen::FixupBranch JumpIfCRFieldBit(int field, int bit, bool jump_if_set);
void FixGTBeforeSettingCRFieldBit(Arm64Gen::ARM64Reg reg);
void UpdateRoundingMode();
void ComputeRC0(Arm64Gen::ARM64Reg reg);
void ComputeRC0(u64 imm);

View File

@ -48,6 +48,19 @@ void JitArm64::FixGTBeforeSettingCRFieldBit(Arm64Gen::ARM64Reg reg)
gpr.Unlock(WA);
}
void JitArm64::UpdateRoundingMode()
{
const BitSet32 gprs_to_save = gpr.GetCallerSavedUsed();
const BitSet32 fprs_to_save = fpr.GetCallerSavedUsed();
ABI_PushRegisters(gprs_to_save);
m_float_emit.ABI_PushRegisters(fprs_to_save, ARM64Reg::X8);
MOVP2R(ARM64Reg::X8, &PowerPC::RoundingModeUpdated);
BLR(ARM64Reg::X8);
m_float_emit.ABI_PopRegisters(fprs_to_save, ARM64Reg::X8);
ABI_PopRegisters(gprs_to_save);
}
void JitArm64::mtmsr(UGeckoInstruction inst)
{
INSTRUCTION_START
@ -754,3 +767,23 @@ void JitArm64::mffsx(UGeckoInstruction inst)
gpr.Unlock(WA);
gpr.Unlock(WB);
}
void JitArm64::mtfsb0x(UGeckoInstruction inst)
{
INSTRUCTION_START
JITDISABLE(bJITSystemRegistersOff);
FALLBACK_IF(inst.Rc);
u32 mask = ~(0x80000000 >> inst.CRBD);
ARM64Reg WA = gpr.GetReg();
LDR(IndexType::Unsigned, WA, PPC_REG, PPCSTATE_OFF(fpscr));
AND(WA, WA, LogicalImm(mask, 32));
STR(IndexType::Unsigned, WA, PPC_REG, PPCSTATE_OFF(fpscr));
gpr.Unlock(WA);
if (inst.CRBD >= 29)
UpdateRoundingMode();
}

View File

@ -316,7 +316,7 @@ constexpr std::array<GekkoOPTemplate, 15> table63{{
{64, &JitArm64::mcrfs}, // mcrfs
{583, &JitArm64::mffsx}, // mffsx
{70, &JitArm64::FallBackToInterpreter}, // mtfsb0x
{70, &JitArm64::mtfsb0x}, // mtfsb0x
{38, &JitArm64::FallBackToInterpreter}, // mtfsb1x
{134, &JitArm64::FallBackToInterpreter}, // mtfsfix
{711, &JitArm64::FallBackToInterpreter}, // mtfsfx