mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-05 04:03:49 +01:00
x86jit: Flip cc in stl* to avoid reg loads.
Unfortunately, this zero thing is now concerning me...
This commit is contained in:
1 parent
59f491eddb
commit
d0a2ced2f9
3 files changed
+77
-11
No files matched your search
+48
-10
@@ -463,18 +463,37 @@ namespace MIPSComp
|
||||
gpr.SetImm(rd, 0);
|
||||
} else {
|
||||
gpr.Lock(rd, rs, rt);
|
||||
gpr.MapReg(rs, true, false);
|
||||
gpr.MapReg(rd, rd == rt || rd == rs, true);
|
||||
|
||||
// Let's try to avoid loading rs or if it's an imm, flushing it.
|
||||
MIPSGPReg lhs = rs;
|
||||
MIPSGPReg rhs = rt;
|
||||
CCFlags cc = CC_L;
|
||||
if (gpr.IsImm(lhs)) {
|
||||
// Hmm. This is a bit confusing. lhs may be ZERO, but its location may be memory.
|
||||
// TODO: That's probably not a good thing, but changing it breaks more...
|
||||
gpr.SetImm(lhs, gpr.GetImm(lhs));
|
||||
// rhs is guaranteed not to be an imm (handled above.)
|
||||
std::swap(lhs, rhs);
|
||||
cc = SwapCCFlag(cc);
|
||||
} else if (!gpr.R(lhs).CanDoOpWith(gpr.R(rhs))) {
|
||||
// Let's try to pick which makes more sense to load.
|
||||
if (MIPSAnalyst::IsRegisterUsed(rhs, js.compilerPC + 4, 3)) {
|
||||
std::swap(lhs, rhs);
|
||||
cc = SwapCCFlag(cc);
|
||||
}
|
||||
gpr.MapReg(lhs, true, false);
|
||||
}
|
||||
|
||||
bool needsTemp = NeedsTempForSETcc(gpr.RX(rd)) || rd == rt || rd == rs;
|
||||
if (needsTemp) {
|
||||
CMP(32, gpr.R(rs), gpr.R(rt));
|
||||
SETcc(CC_L, R(EAX));
|
||||
CMP(32, gpr.R(lhs), gpr.R(rhs));
|
||||
SETcc(cc, R(EAX));
|
||||
MOVZX(32, 8, gpr.RX(rd), R(EAX));
|
||||
} else {
|
||||
XOR(32, gpr.R(rd), gpr.R(rd));
|
||||
CMP(32, gpr.R(rs), gpr.R(rt));
|
||||
SETcc(CC_L, gpr.R(rd));
|
||||
CMP(32, gpr.R(lhs), gpr.R(rhs));
|
||||
SETcc(cc, gpr.R(rd));
|
||||
}
|
||||
gpr.UnlockAll();
|
||||
}
|
||||
@@ -487,18 +506,37 @@ namespace MIPSComp
|
||||
gpr.SetImm(rd, 0);
|
||||
} else {
|
||||
gpr.Lock(rd, rs, rt);
|
||||
gpr.MapReg(rs, true, false);
|
||||
gpr.MapReg(rd, rd == rt || rd == rs, true);
|
||||
|
||||
// Let's try to avoid loading rs or if it's an imm, flushing it.
|
||||
MIPSGPReg lhs = rs;
|
||||
MIPSGPReg rhs = rt;
|
||||
CCFlags cc = CC_B;
|
||||
if (gpr.IsImm(lhs)) {
|
||||
// Hmm. This is a bit confusing. lhs may be ZERO, but its location may be memory.
|
||||
// TODO: That's probably not a good thing, but changing it breaks more...
|
||||
gpr.SetImm(lhs, gpr.GetImm(lhs));
|
||||
// rhs is guaranteed not to be an imm (handled above.)
|
||||
std::swap(lhs, rhs);
|
||||
cc = SwapCCFlag(cc);
|
||||
} else if (!gpr.R(lhs).CanDoOpWith(gpr.R(rhs))) {
|
||||
// Let's try to pick which makes more sense to load.
|
||||
if (MIPSAnalyst::IsRegisterUsed(rhs, js.compilerPC + 4, 3)) {
|
||||
std::swap(lhs, rhs);
|
||||
cc = SwapCCFlag(cc);
|
||||
}
|
||||
gpr.MapReg(lhs, true, false);
|
||||
}
|
||||
|
||||
bool needsTemp = NeedsTempForSETcc(gpr.RX(rd)) || rd == rt || rd == rs;
|
||||
if (needsTemp) {
|
||||
CMP(32, gpr.R(rs), gpr.R(rt));
|
||||
SETcc(CC_B, R(EAX));
|
||||
CMP(32, gpr.R(lhs), gpr.R(rhs));
|
||||
SETcc(cc, R(EAX));
|
||||
MOVZX(32, 8, gpr.RX(rd), R(EAX));
|
||||
} else {
|
||||
XOR(32, gpr.R(rd), gpr.R(rd));
|
||||
CMP(32, gpr.R(rs), gpr.R(rt));
|
||||
SETcc(CC_B, gpr.R(rd));
|
||||
CMP(32, gpr.R(lhs), gpr.R(rhs));
|
||||
SETcc(cc, gpr.R(rd));
|
||||
}
|
||||
gpr.UnlockAll();
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ void Jit::BranchLogExit(MIPSOpcode op, u32 dest, bool useEAX)
|
||||
SetJumpTarget(skip);
|
||||
}
|
||||
|
||||
static CCFlags FlipCCFlag(CCFlags flag)
|
||||
CCFlags Jit::FlipCCFlag(CCFlags flag)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
@@ -155,6 +155,32 @@ static CCFlags FlipCCFlag(CCFlags flag)
|
||||
return CC_O;
|
||||
}
|
||||
|
||||
CCFlags Jit::SwapCCFlag(CCFlags flag)
|
||||
{
|
||||
// This swaps the comparison for an lhs/rhs swap, but doesn't flip/invert the logic.
|
||||
switch (flag)
|
||||
{
|
||||
case CC_O: return CC_O;
|
||||
case CC_NO: return CC_NO;
|
||||
case CC_B: return CC_A;
|
||||
case CC_NB: return CC_NA;
|
||||
case CC_Z: return CC_Z;
|
||||
case CC_NZ: return CC_NZ;
|
||||
case CC_BE: return CC_AE;
|
||||
case CC_NBE: return CC_NAE;
|
||||
case CC_S: return CC_S;
|
||||
case CC_NS: return CC_NS;
|
||||
case CC_P: return CC_P;
|
||||
case CC_NP: return CC_NP;
|
||||
case CC_L: return CC_G;
|
||||
case CC_NL: return CC_NG;
|
||||
case CC_LE: return CC_GE;
|
||||
case CC_NLE: return CC_NGE;
|
||||
}
|
||||
ERROR_LOG_REPORT(JIT, "SwapCCFlag: Unexpected CC flag: %d", flag);
|
||||
return CC_O;
|
||||
}
|
||||
|
||||
bool Jit::PredictTakeBranch(u32 targetAddr, bool likely) {
|
||||
// If it's likely, it's... probably likely, right?
|
||||
if (likely)
|
||||
|
||||
@@ -230,6 +230,8 @@ private:
|
||||
void CompITypeMemUnpairedLRInner(MIPSOpcode op, X64Reg shiftReg);
|
||||
void CompBranchExits(CCFlags cc, u32 targetAddr, u32 notTakenAddr, bool delaySlotIsNice, bool likely, bool andLink);
|
||||
void CompBranchExit(bool taken, u32 targetAddr, u32 notTakenAddr, bool delaySlotIsNice, bool likely, bool andLink);
|
||||
static CCFlags FlipCCFlag(CCFlags flag);
|
||||
static CCFlags SwapCCFlag(CCFlags flag);
|
||||
|
||||
void CompFPTriArith(MIPSOpcode op, void (XEmitter::*arith)(X64Reg reg, OpArg), bool orderMatters);
|
||||
void CompFPComp(int lhs, int rhs, u8 compare, bool allowNaN = false);
|
||||
|
||||
Reference in new issue
Block a user