PPCAnalyzer: Most member functions can be const.

This commit is contained in:
Admiral H. Curtiss 2021-12-31 17:46:45 +01:00
parent d6331c1e71
commit b3a3ecd2b4
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
2 changed files with 15 additions and 12 deletions

View File

@ -192,7 +192,7 @@ static void AnalyzeFunction2(Common::Symbol* func)
func->flags = flags;
}
bool PPCAnalyzer::CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b)
bool PPCAnalyzer::CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b) const
{
const GekkoOPInfo* a_info = a.opinfo;
const GekkoOPInfo* b_info = b.opinfo;
@ -451,7 +451,7 @@ static bool isCror(const CodeOp& a)
}
void PPCAnalyzer::ReorderInstructionsCore(u32 instructions, CodeOp* code, bool reverse,
ReorderType type)
ReorderType type) const
{
// Bubbling an instruction sometimes reveals another opportunity to bubble an instruction, so do
// multiple passes.
@ -502,7 +502,7 @@ void PPCAnalyzer::ReorderInstructionsCore(u32 instructions, CodeOp* code, bool r
}
}
void PPCAnalyzer::ReorderInstructions(u32 instructions, CodeOp* code)
void PPCAnalyzer::ReorderInstructions(u32 instructions, CodeOp* code) const
{
// Reorder cror instructions upwards (e.g. towards an fcmp). Technically we should be more
// picky about this, but cror seems to almost solely be used for this purpose in real code.
@ -521,7 +521,7 @@ void PPCAnalyzer::ReorderInstructions(u32 instructions, CodeOp* code)
}
void PPCAnalyzer::SetInstructionStats(CodeBlock* block, CodeOp* code, const GekkoOPInfo* opinfo,
u32 index)
u32 index) const
{
code->wantsCR0 = false;
code->wantsCR1 = false;
@ -684,7 +684,7 @@ void PPCAnalyzer::SetInstructionStats(CodeBlock* block, CodeOp* code, const Gekk
}
}
bool PPCAnalyzer::IsBusyWaitLoop(CodeBlock* block, CodeOp* code, size_t instructions)
bool PPCAnalyzer::IsBusyWaitLoop(CodeBlock* block, CodeOp* code, size_t instructions) const
{
// Very basic algorithm to detect busy wait loops:
// * It loops to itself and does not contain any other branches.
@ -737,7 +737,8 @@ bool PPCAnalyzer::IsBusyWaitLoop(CodeBlock* block, CodeOp* code, size_t instruct
return false;
}
u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, std::size_t block_size)
u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer,
std::size_t block_size) const
{
// Clear block stats
*block->m_stats = {};

View File

@ -216,7 +216,7 @@ public:
void ClearOption(AnalystOption option) { m_options &= ~(option); }
bool HasOption(AnalystOption option) const { return !!(m_options & option); }
void SetDebuggingEnabled(bool enabled) { m_is_debugging_enabled = enabled; }
u32 Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, std::size_t block_size);
u32 Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, std::size_t block_size) const;
private:
enum class ReorderType
@ -226,11 +226,13 @@ private:
CROR
};
bool CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b);
void ReorderInstructionsCore(u32 instructions, CodeOp* code, bool reverse, ReorderType type);
void ReorderInstructions(u32 instructions, CodeOp* code);
void SetInstructionStats(CodeBlock* block, CodeOp* code, const GekkoOPInfo* opinfo, u32 index);
bool IsBusyWaitLoop(CodeBlock* block, CodeOp* code, size_t instructions);
bool CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b) const;
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;
bool IsBusyWaitLoop(CodeBlock* block, CodeOp* code, size_t instructions) const;
// Options
u32 m_options = 0;