Merge pull request #13959 from Sintendo/jitarm64-subfx-merge

JitArm64_Integer: Merge subfx and subfcx
This commit is contained in:
JMC47
2025-12-22 13:27:38 -05:00
committed by GitHub
3 changed files with 22 additions and 32 deletions

View File

@@ -6,13 +6,11 @@
#include <cstddef>
#include <map>
#include <optional>
#include <tuple>
#include <rangeset/rangesizeset.h>
#include "Common/Arm64Emitter.h"
#include "Core/PowerPC/CPUCoreBase.h"
#include "Core/PowerPC/JitArm64/JitArm64Cache.h"
#include "Core/PowerPC/JitArm64/JitArm64_RegCache.h"
#include "Core/PowerPC/JitArmCommon/BackPatch.h"
@@ -114,7 +112,6 @@ public:
void rlwimix(UGeckoInstruction inst);
void subfex(UGeckoInstruction inst);
void subfzex(UGeckoInstruction inst);
void subfcx(UGeckoInstruction inst);
void subfic(UGeckoInstruction inst);
void addex(UGeckoInstruction inst);
void divwux(UGeckoInstruction inst);

View File

@@ -18,15 +18,18 @@
using namespace Arm64Gen;
using namespace JitCommon;
#define CARRY_IF_NEEDED(inst_without_carry, inst_with_carry, ...) \
#define CARRY_IF_NEEDED_COND(carry, inst_without_carry, inst_with_carry, ...) \
do \
{ \
if (js.op->wantsCA) \
if ((carry) && js.op->wantsCA) \
inst_with_carry(__VA_ARGS__); \
else \
inst_without_carry(__VA_ARGS__); \
} while (0)
#define CARRY_IF_NEEDED(inst_without_carry, inst_with_carry, ...) \
CARRY_IF_NEEDED_COND(true, inst_without_carry, inst_with_carry, __VA_ARGS__)
void JitArm64::ComputeRC0(ARM64Reg reg)
{
gpr.BindCRToRegister(0, false);
@@ -1114,20 +1117,6 @@ void JitArm64::addzex(UGeckoInstruction inst)
ComputeRC0(gpr.R(d));
}
void JitArm64::subfx(UGeckoInstruction inst)
{
INSTRUCTION_START
JITDISABLE(bJITIntegerOff);
FALLBACK_IF(inst.OE);
int a = inst.RA, b = inst.RB, d = inst.RD;
gpr.BindToRegister(d, d == a || d == b);
SUB(gpr.R(d), gpr.R(b), gpr.R(a));
if (inst.Rc)
ComputeRC0(gpr.R(d));
}
void JitArm64::subfex(UGeckoInstruction inst)
{
INSTRUCTION_START
@@ -1259,13 +1248,14 @@ void JitArm64::subfex(UGeckoInstruction inst)
ComputeRC0(gpr.R(d));
}
void JitArm64::subfcx(UGeckoInstruction inst)
void JitArm64::subfx(UGeckoInstruction inst)
{
INSTRUCTION_START
JITDISABLE(bJITIntegerOff);
FALLBACK_IF(inst.OE);
int a = inst.RA, b = inst.RB, d = inst.RD;
const int a = inst.RA, b = inst.RB, d = inst.RD;
const bool carry = !(inst.SUBOP10 & (1 << 5));
if (gpr.IsImm(a))
{
@@ -1278,7 +1268,8 @@ void JitArm64::subfcx(UGeckoInstruction inst)
gpr.BindToRegister(d, false);
MOV(gpr.R(d), gpr.R(b));
}
ComputeCarry(true);
if (carry)
ComputeCarry(true);
if (inst.Rc)
ComputeRC0(gpr.R(d));
return;
@@ -1289,8 +1280,10 @@ void JitArm64::subfcx(UGeckoInstruction inst)
if (low_12 || high_12)
{
gpr.BindToRegister(d, d == b);
CARRY_IF_NEEDED(SUB, SUBS, gpr.R(d), gpr.R(b), high_12 ? imm >> 12 : imm, high_12);
ComputeCarry();
CARRY_IF_NEEDED_COND(carry, SUB, SUBS, gpr.R(d), gpr.R(b), high_12 ? imm >> 12 : imm,
high_12);
if (carry)
ComputeCarry();
if (inst.Rc)
ComputeRC0(gpr.R(d));
return;
@@ -1300,8 +1293,9 @@ void JitArm64::subfcx(UGeckoInstruction inst)
if (gpr.IsImm(b, 0))
{
gpr.BindToRegister(d, d == a);
CARRY_IF_NEEDED(NEG, NEGS, gpr.R(d), gpr.R(a));
ComputeCarry();
CARRY_IF_NEEDED_COND(carry, NEG, NEGS, gpr.R(d), gpr.R(a));
if (carry)
ComputeCarry();
if (inst.Rc)
ComputeRC0(gpr.R(d));
return;
@@ -1310,10 +1304,9 @@ void JitArm64::subfcx(UGeckoInstruction inst)
gpr.BindToRegister(d, d == a || d == b);
// d = b - a
CARRY_IF_NEEDED(SUB, SUBS, gpr.R(d), gpr.R(b), gpr.R(a));
ComputeCarry();
CARRY_IF_NEEDED_COND(carry, SUB, SUBS, gpr.R(d), gpr.R(b), gpr.R(a));
if (carry)
ComputeCarry();
if (inst.Rc)
ComputeRC0(gpr.R(d));
}

View File

@@ -172,8 +172,8 @@ constexpr std::array<JitArm64OpTemplate, 107> s_table31{{
{616, &JitArm64::negx}, // negox
{40, &JitArm64::subfx}, // subfx
{552, &JitArm64::subfx}, // subfox
{8, &JitArm64::subfcx}, // subfcx
{520, &JitArm64::subfcx}, // subfcox
{8, &JitArm64::subfx}, // subfcx
{520, &JitArm64::subfx}, // subfcox
{136, &JitArm64::subfex}, // subfex
{648, &JitArm64::subfex}, // subfeox
{232, &JitArm64::subfex}, // subfmex