From f2b2f5b4c726bc1651ebcdc7a5d769d6d0c83729 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 8 Apr 2018 21:38:16 -0400 Subject: [PATCH] PPCAnalyst: Make ReorderType an enum class Makes the values strongly typed and doesn't dump them into the class itself. --- Source/Core/Core/PowerPC/PPCAnalyst.cpp | 15 ++++++++------- Source/Core/Core/PowerPC/PPCAnalyst.h | 8 ++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/PowerPC/PPCAnalyst.cpp index bd6cf88014..ba75fe5ab9 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/PowerPC/PPCAnalyst.cpp @@ -479,11 +479,12 @@ void PPCAnalyzer::ReorderInstructionsCore(u32 instructions, CodeOp* code, bool r CodeOp& b = code[i + increment]; // Reorder integer compares, rlwinm., and carry-affecting ops // (if we add more merged branch instructions, add them here!) - if ((type == REORDER_CROR && isCror(a)) || (type == REORDER_CARRY && isCarryOp(a)) || - (type == REORDER_CMP && (isCmp(a) || a.outputCR0))) + if ((type == ReorderType::CROR && isCror(a)) || + (type == ReorderType::Carry && isCarryOp(a)) || + (type == ReorderType::CMP && (isCmp(a) || a.outputCR0))) { // once we're next to a carry instruction, don't move away! - if (type == REORDER_CARRY && i != start) + if (type == ReorderType::Carry && i != start) { // if we read the CA flag, and the previous instruction sets it, don't move away. if (!reverse && (a.opinfo->flags & FL_READ_CA) && @@ -514,16 +515,16 @@ void PPCAnalyzer::ReorderInstructions(u32 instructions, CodeOp* code) // picky about this, but cror seems to almost solely be used for this purpose in real code. // Additionally, the other boolean ops seem to almost never be used. if (HasOption(OPTION_CROR_MERGE)) - ReorderInstructionsCore(instructions, code, true, REORDER_CROR); + ReorderInstructionsCore(instructions, code, true, ReorderType::CROR); // For carry, bubble instructions *towards* each other; one direction often isn't enough // to get pairs like addc/adde next to each other. if (HasOption(OPTION_CARRY_MERGE)) { - ReorderInstructionsCore(instructions, code, false, REORDER_CARRY); - ReorderInstructionsCore(instructions, code, true, REORDER_CARRY); + ReorderInstructionsCore(instructions, code, false, ReorderType::Carry); + ReorderInstructionsCore(instructions, code, true, ReorderType::Carry); } if (HasOption(OPTION_BRANCH_MERGE)) - ReorderInstructionsCore(instructions, code, false, REORDER_CMP); + ReorderInstructionsCore(instructions, code, false, ReorderType::CMP); } void PPCAnalyzer::SetInstructionStats(CodeBlock* block, CodeOp* code, const GekkoOPInfo* opinfo, diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.h b/Source/Core/Core/PowerPC/PPCAnalyst.h index c625e80097..e5e84a69f6 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.h +++ b/Source/Core/Core/PowerPC/PPCAnalyst.h @@ -208,11 +208,11 @@ public: u32 Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, u32 blockSize); private: - enum ReorderType + enum class ReorderType { - REORDER_CARRY, - REORDER_CMP, - REORDER_CROR + Carry, + CMP, + CROR }; void ReorderInstructionsCore(u32 instructions, CodeOp* code, bool reverse, ReorderType type);