Merge pull request #11135 from AdmiralCurtiss/ppcanalyst-unused-stats

PPCAnalyst: Remove unused variables and methods in BlockStats and BlockRegStats.
This commit is contained in:
JosJuice 2022-10-23 21:22:54 +02:00 committed by GitHub
commit 063c2739b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 69 deletions

View File

@ -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<u32>(i));
SetInstructionStats(block, &code[i], opinfo);
bool follow = false;

View File

@ -81,56 +81,12 @@ struct CodeOp // 16B
struct BlockStats
{
bool isFirstBlockOfFunction;
bool isLastBlockOfFunction;
int numCycles;
};
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<CodeOp>;
@ -233,8 +189,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

View File

@ -182,12 +182,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