From f98211bfcf3473b7e57b108e0515c17bbdc58ba0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 21 Mar 2017 13:45:18 -0400 Subject: [PATCH 1/2] JitBase: Make MergeAllowedNextInstructions a const member function --- Source/Core/Core/PowerPC/JitCommon/JitBase.cpp | 2 +- Source/Core/Core/PowerPC/JitCommon/JitBase.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp b/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp index 9b0c837610..c00724795c 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp @@ -27,7 +27,7 @@ JitBase::JitBase() = default; JitBase::~JitBase() = default; -bool JitBase::MergeAllowedNextInstructions(int count) +bool JitBase::MergeAllowedNextInstructions(int count) const { if (CPU::GetState() == CPU::CPU_STEPPING || js.instructionsLeft < count) return false; diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.h b/Source/Core/Core/PowerPC/JitCommon/JitBase.h index f62776d6c3..0bd2044be5 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.h +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.h @@ -104,7 +104,7 @@ protected: PPCAnalyst::CodeBlock code_block; PPCAnalyst::PPCAnalyzer analyzer; - bool MergeAllowedNextInstructions(int count); + bool MergeAllowedNextInstructions(int count) const; void UpdateMemoryOptions(); From 0d1bc53e5570b5114260fa0f2529cc7728f45700 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 21 Mar 2017 13:49:56 -0400 Subject: [PATCH 2/2] JitBase: Rename MergeAllowedNextInstructions to CanMergeNextInstructions This is more indicative that it's checking for something --- Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp | 2 +- Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp | 6 +++--- Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp | 6 +++--- Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp | 2 +- Source/Core/Core/PowerPC/JitArm64/Jit.cpp | 2 +- Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp | 6 +++--- Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp | 4 ++-- .../Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp | 2 +- Source/Core/Core/PowerPC/JitCommon/JitBase.cpp | 2 +- Source/Core/Core/PowerPC/JitCommon/JitBase.h | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp index a331569470..659463e43e 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp @@ -492,7 +492,7 @@ void Jit64::FloatCompare(UGeckoInstruction inst, bool upper) // Merge neighboring fcmp and cror (the primary use of cror). UGeckoInstruction next = js.op[1].inst; if (analyzer.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CROR_MERGE) && - MergeAllowedNextInstructions(1) && next.OPCD == 19 && next.SUBOP10 == 449 && + CanMergeNextInstructions(1) && next.OPCD == 19 && next.SUBOP10 == 449 && (next.CRBA >> 2) == crf && (next.CRBB >> 2) == crf && (next.CRBD >> 2) == crf) { js.skipInstructions = 1; diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index 0d2722fa5a..4fdf8fab1a 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -66,7 +66,7 @@ void Jit64::FinalizeCarry(CCFlags cond) { // Not actually merging instructions, but the effect is equivalent (we can't have // breakpoints/etc in between). - if (MergeAllowedNextInstructions(1) && js.op[1].wantsCAInFlags) + if (CanMergeNextInstructions(1) && js.op[1].wantsCAInFlags) { if (cond == CC_C || cond == CC_NC) { @@ -95,7 +95,7 @@ void Jit64::FinalizeCarry(bool ca) js.carryFlagInverted = false; if (js.op->wantsCA) { - if (MergeAllowedNextInstructions(1) && js.op[1].wantsCAInFlags) + if (CanMergeNextInstructions(1) && js.op[1].wantsCAInFlags) { if (ca) STC(); @@ -343,7 +343,7 @@ bool Jit64::CheckMergedBranch(int crf) if (!analyzer.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_MERGE)) return false; - if (!MergeAllowedNextInstructions(1)) + if (!CanMergeNextInstructions(1)) return false; const UGeckoInstruction& next = js.op[1].inst; diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp index 9fa97ff09e..74d41076ba 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp @@ -110,7 +110,7 @@ void Jit64::lXXx(UGeckoInstruction inst) // PowerPC has no 8-bit sign extended load, but x86 does, so merge extsb with the load if we find // it. - if (MergeAllowedNextInstructions(1) && accessSize == 8 && js.op[1].inst.OPCD == 31 && + if (CanMergeNextInstructions(1) && accessSize == 8 && js.op[1].inst.OPCD == 31 && js.op[1].inst.SUBOP10 == 954 && js.op[1].inst.RS == inst.RD && js.op[1].inst.RA == inst.RD && !js.op[1].inst.Rc) { @@ -119,7 +119,7 @@ void Jit64::lXXx(UGeckoInstruction inst) signExtend = true; } - if (CPU::GetState() != CPU::CPU_STEPPING && inst.OPCD == 32 && MergeAllowedNextInstructions(2) && + if (CPU::GetState() != CPU::CPU_STEPPING && inst.OPCD == 32 && CanMergeNextInstructions(2) && (inst.hex & 0xFFFF0000) == 0x800D0000 && (js.op[1].inst.hex == 0x28000000 || (SConfig::GetInstance().bWii && js.op[1].inst.hex == 0x2C000000)) && @@ -318,7 +318,7 @@ void Jit64::dcbt(UGeckoInstruction inst) // This is important because invalidating the block cache when we don't // need to is terrible for performance. // (Invalidating the jit block cache on dcbst is a heuristic.) - if (MergeAllowedNextInstructions(1) && js.op[1].inst.OPCD == 31 && js.op[1].inst.SUBOP10 == 54 && + if (CanMergeNextInstructions(1) && js.op[1].inst.OPCD == 31 && js.op[1].inst.SUBOP10 == 54 && js.op[1].inst.RA == inst.RA && js.op[1].inst.RB == inst.RB) { js.skipInstructions = 1; diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp index f60b15488d..cf694f89bc 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp @@ -314,7 +314,7 @@ void Jit64::mfspr(UGeckoInstruction inst) ADD(64, R(RAX), R(RDX)); MOV(64, PPCSTATE(spr[SPR_TL]), R(RAX)); - if (MergeAllowedNextInstructions(1)) + if (CanMergeNextInstructions(1)) { const UGeckoInstruction& next = js.op[1].inst; // Two calls of TU/TL next to each other are extremely common in typical usage, so merge them diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index 5ff54ca819..a507485043 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -834,7 +834,7 @@ void JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBlock* } CompileInstruction(ops[i]); - if (!MergeAllowedNextInstructions(1) || js.op[1].opinfo->type != OPTYPE_INTEGER) + if (!CanMergeNextInstructions(1) || js.op[1].opinfo->type != OPTYPE_INTEGER) FlushCarry(); // If we have a register that will never be used again, flush it. diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index 6edf7baa89..0d94d1ac30 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -73,7 +73,7 @@ void JitArm64::ComputeCarry() return; js.carryFlagSet = true; - if (MergeAllowedNextInstructions(1) && js.op[1].opinfo->type == OPTYPE_INTEGER) + if (CanMergeNextInstructions(1) && js.op[1].opinfo->type == OPTYPE_INTEGER) { return; } @@ -575,7 +575,7 @@ void JitArm64::srawix(UGeckoInstruction inst) int a = inst.RA; int s = inst.RS; int amount = inst.SH; - bool inplace_carry = MergeAllowedNextInstructions(1) && js.op[1].wantsCAInFlags; + bool inplace_carry = CanMergeNextInstructions(1) && js.op[1].wantsCAInFlags; if (gpr.IsImm(s)) { @@ -1286,7 +1286,7 @@ void JitArm64::srawx(UGeckoInstruction inst) JITDISABLE(bJITIntegerOff); int a = inst.RA, b = inst.RB, s = inst.RS; - bool inplace_carry = MergeAllowedNextInstructions(1) && js.op[1].wantsCAInFlags; + bool inplace_carry = CanMergeNextInstructions(1) && js.op[1].wantsCAInFlags; if (gpr.IsImm(b) && gpr.IsImm(s)) { diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp index 61c11dd8c9..8e8bb6cf6b 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp @@ -374,7 +374,7 @@ void JitArm64::lXX(UGeckoInstruction inst) SafeLoadToReg(d, update ? a : (a ? a : -1), offsetReg, flags, offset, update); // LWZ idle skipping - if (inst.OPCD == 32 && MergeAllowedNextInstructions(2) && + if (inst.OPCD == 32 && CanMergeNextInstructions(2) && (inst.hex & 0xFFFF0000) == 0x800D0000 && // lwz r0, XXXX(r13) (js.op[1].inst.hex == 0x28000000 || (SConfig::GetInstance().bWii && js.op[1].inst.hex == 0x2C000000)) && // cmpXwi r0,0 @@ -645,7 +645,7 @@ void JitArm64::dcbt(UGeckoInstruction inst) // This is important because invalidating the block cache when we don't // need to is terrible for performance. // (Invalidating the jit block cache on dcbst is a heuristic.) - if (MergeAllowedNextInstructions(1) && js.op[1].inst.OPCD == 31 && js.op[1].inst.SUBOP10 == 54 && + if (CanMergeNextInstructions(1) && js.op[1].inst.OPCD == 31 && js.op[1].inst.SUBOP10 == 54 && js.op[1].inst.RA == inst.RA && js.op[1].inst.RB == inst.RB) { js.skipInstructions = 1; diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp index 1e2d3944b7..280f5e832d 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp @@ -283,7 +283,7 @@ void JitArm64::mfspr(UGeckoInstruction inst) ADD(XA, XB, XA, ArithOption(XA, ST_LSR, 3)); STR(INDEX_UNSIGNED, XA, PPC_REG, PPCSTATE_OFF(spr[SPR_TL])); - if (MergeAllowedNextInstructions(1)) + if (CanMergeNextInstructions(1)) { const UGeckoInstruction& next = js.op[1].inst; // Two calls of TU/TL next to each other are extremely common in typical usage, so merge them diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp b/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp index c00724795c..5965974165 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp @@ -27,7 +27,7 @@ JitBase::JitBase() = default; JitBase::~JitBase() = default; -bool JitBase::MergeAllowedNextInstructions(int count) const +bool JitBase::CanMergeNextInstructions(int count) const { if (CPU::GetState() == CPU::CPU_STEPPING || js.instructionsLeft < count) return false; diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.h b/Source/Core/Core/PowerPC/JitCommon/JitBase.h index 0bd2044be5..f82c4bab57 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.h +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.h @@ -104,7 +104,7 @@ protected: PPCAnalyst::CodeBlock code_block; PPCAnalyst::PPCAnalyzer analyzer; - bool MergeAllowedNextInstructions(int count) const; + bool CanMergeNextInstructions(int count) const; void UpdateMemoryOptions();