From b3a3ecd2b426084ca134c9e264457308ba9e0380 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 31 Dec 2021 17:46:45 +0100 Subject: [PATCH] PPCAnalyzer: Most member functions can be const. --- Source/Core/Core/PowerPC/PPCAnalyst.cpp | 13 +++++++------ Source/Core/Core/PowerPC/PPCAnalyst.h | 14 ++++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/PowerPC/PPCAnalyst.cpp index 6b4c6241e7..798baf3f70 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/PowerPC/PPCAnalyst.cpp @@ -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 = {}; diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.h b/Source/Core/Core/PowerPC/PPCAnalyst.h index 8c1dfc47ef..da8cfb99c8 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.h +++ b/Source/Core/Core/PowerPC/PPCAnalyst.h @@ -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;