From a5217c07b8ae1cf3931cd20e1ee2bf62ab4b9724 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 8 Oct 2022 03:26:42 +0200 Subject: [PATCH 1/2] PPCAnalyst: Remove unused variables and methods in BlockRegStats. --- Source/Core/Core/PowerPC/PPCAnalyst.cpp | 20 ++--------- Source/Core/Core/PowerPC/PPCAnalyst.h | 45 +------------------------ 2 files changed, 4 insertions(+), 61 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/PowerPC/PPCAnalyst.cpp index 95553c9c27..ee15a21052 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/PowerPC/PPCAnalyst.cpp @@ -521,8 +521,8 @@ void PPCAnalyzer::ReorderInstructions(u32 instructions, CodeOp* code) const ReorderInstructionsCore(instructions, code, false, ReorderType::CMP); } -void PPCAnalyzer::SetInstructionStats(CodeBlock* block, CodeOp* code, const GekkoOPInfo* opinfo, - u32 index) const +void PPCAnalyzer::SetInstructionStats(CodeBlock* block, CodeOp* code, + const GekkoOPInfo* opinfo) const { code->wantsCR0 = false; code->wantsCR1 = false; @@ -534,9 +534,6 @@ void PPCAnalyzer::SetInstructionStats(CodeBlock* block, CodeOp* code, const Gekk block->m_fpa->any = true; } - if (opinfo->flags & FL_TIMER) - block->m_gpa->anyTimer = true; - // Does the instruction output CR0? if (opinfo->flags & FL_RC_BIT) code->outputCR0 = code->inst.hex & 1; // todo fix @@ -586,39 +583,32 @@ void PPCAnalyzer::SetInstructionStats(CodeBlock* block, CodeOp* code, const Gekk if (opinfo->flags & FL_OUT_A) { code->regsOut[code->inst.RA] = true; - block->m_gpa->SetOutputRegister(code->inst.RA, index); } if (opinfo->flags & FL_OUT_D) { code->regsOut[code->inst.RD] = true; - block->m_gpa->SetOutputRegister(code->inst.RD, index); } if ((opinfo->flags & FL_IN_A) || ((opinfo->flags & FL_IN_A0) && code->inst.RA != 0)) { code->regsIn[code->inst.RA] = true; - block->m_gpa->SetInputRegister(code->inst.RA, index); } if (opinfo->flags & FL_IN_B) { code->regsIn[code->inst.RB] = true; - block->m_gpa->SetInputRegister(code->inst.RB, index); } if (opinfo->flags & FL_IN_C) { code->regsIn[code->inst.RC] = true; - block->m_gpa->SetInputRegister(code->inst.RC, index); } if (opinfo->flags & FL_IN_S) { code->regsIn[code->inst.RS] = true; - block->m_gpa->SetInputRegister(code->inst.RS, index); } if (code->inst.OPCD == 46) // lmw { for (int iReg = code->inst.RD; iReg < 32; ++iReg) { code->regsOut[iReg] = true; - block->m_gpa->SetOutputRegister(iReg, index); } } else if (code->inst.OPCD == 47) // stmw @@ -626,7 +616,6 @@ void PPCAnalyzer::SetInstructionStats(CodeBlock* block, CodeOp* code, const Gekk for (int iReg = code->inst.RS; iReg < 32; ++iReg) { code->regsIn[iReg] = true; - block->m_gpa->SetInputRegister(iReg, index); } } @@ -741,9 +730,6 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, block->m_gpa->any = true; block->m_fpa->any = false; - block->m_gpa->Clear(); - block->m_fpa->Clear(); - // Set the blocks start address block->m_address = address; @@ -786,7 +772,7 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, block->m_stats->numCycles += opinfo->numCycles; block->m_physical_addresses.insert(result.physical_address); - SetInstructionStats(block, &code[i], opinfo, static_cast(i)); + SetInstructionStats(block, &code[i], opinfo); bool follow = false; diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.h b/Source/Core/Core/PowerPC/PPCAnalyst.h index 4ae41ccbae..49ace63de7 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.h +++ b/Source/Core/Core/PowerPC/PPCAnalyst.h @@ -88,49 +88,7 @@ struct BlockStats struct BlockRegStats { - short firstRead[32]; - short firstWrite[32]; - short lastRead[32]; - short lastWrite[32]; - short numReads[32]; - short numWrites[32]; - bool any; - bool anyTimer; - - int GetTotalNumAccesses(int reg) const { return numReads[reg] + numWrites[reg]; } - int GetUseRange(int reg) const - { - return std::max(lastRead[reg], lastWrite[reg]) - std::min(firstRead[reg], firstWrite[reg]); - } - - bool IsUsed(int reg) const { return (numReads[reg] + numWrites[reg]) > 0; } - void SetInputRegister(int reg, short opindex) - { - if (firstRead[reg] == -1) - firstRead[reg] = opindex; - lastRead[reg] = opindex; - numReads[reg]++; - } - - void SetOutputRegister(int reg, short opindex) - { - if (firstWrite[reg] == -1) - firstWrite[reg] = opindex; - lastWrite[reg] = opindex; - numWrites[reg]++; - } - - void Clear() - { - for (int i = 0; i < 32; ++i) - { - firstRead[i] = -1; - firstWrite[i] = -1; - numReads[i] = 0; - numWrites[i] = 0; - } - } }; using CodeBuffer = std::vector; @@ -233,8 +191,7 @@ private: void ReorderInstructionsCore(u32 instructions, CodeOp* code, bool reverse, ReorderType type) const; void ReorderInstructions(u32 instructions, CodeOp* code) const; - void SetInstructionStats(CodeBlock* block, CodeOp* code, const GekkoOPInfo* opinfo, - u32 index) const; + void SetInstructionStats(CodeBlock* block, CodeOp* code, const GekkoOPInfo* opinfo) const; bool IsBusyWaitLoop(CodeBlock* block, CodeOp* code, size_t instructions) const; // Options From 1abffc0b05368c199780d0c9e2d833351ecde02a Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 8 Oct 2022 03:28:27 +0200 Subject: [PATCH 2/2] PPCAnalyst: Remove unused variables in BlockStats. --- Source/Core/Core/PowerPC/PPCAnalyst.h | 2 -- Source/Core/DolphinQt/Debugger/JITWidget.cpp | 6 ------ 2 files changed, 8 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.h b/Source/Core/Core/PowerPC/PPCAnalyst.h index 49ace63de7..283706ebc1 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.h +++ b/Source/Core/Core/PowerPC/PPCAnalyst.h @@ -81,8 +81,6 @@ struct CodeOp // 16B struct BlockStats { - bool isFirstBlockOfFunction; - bool isLastBlockOfFunction; int numCycles; }; diff --git a/Source/Core/DolphinQt/Debugger/JITWidget.cpp b/Source/Core/DolphinQt/Debugger/JITWidget.cpp index fdf426acfc..46e0eebfe1 100644 --- a/Source/Core/DolphinQt/Debugger/JITWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/JITWidget.cpp @@ -181,12 +181,6 @@ void JITWidget::Update() // Add stats to the end of the ppc box since it's generally the shortest. ppc_disasm << std::dec << std::endl; - // Add some generic analysis - if (st.isFirstBlockOfFunction) - ppc_disasm << "(first block of function)" << std::endl; - if (st.isLastBlockOfFunction) - ppc_disasm << "(last block of function)" << std::endl; - ppc_disasm << st.numCycles << " estimated cycles" << std::endl; ppc_disasm << "Num instr: PPC: " << code_block.m_num_instructions