From 89473d59968de9510ef3e79e699f8dd13fb474ca Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 17 Jan 2017 20:03:42 -0500 Subject: [PATCH] IR: Clean up getNumberOfOperands - Use std::array - Make arrays constexpr where their contents aren't modified. --- Source/Core/Core/PowerPC/JitILCommon/IR.cpp | 31 +++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitILCommon/IR.cpp b/Source/Core/Core/PowerPC/JitILCommon/IR.cpp index f7348ba34e..33484da69a 100644 --- a/Source/Core/Core/PowerPC/JitILCommon/IR.cpp +++ b/Source/Core/Core/PowerPC/JitILCommon/IR.cpp @@ -121,6 +121,7 @@ TODO (in no particular order): #endif #include +#include #include #include #include @@ -1371,22 +1372,22 @@ unsigned IRBuilder::getComplexity(InstLoc I) const unsigned IRBuilder::getNumberOfOperands(InstLoc I) const { - static unsigned numberOfOperands[256]; + static std::array number_of_operands; static bool initialized = false; if (!initialized) { initialized = true; - std::fill_n(numberOfOperands, sizeof(numberOfOperands) / sizeof(numberOfOperands[0]), -1U); - numberOfOperands[Nop] = 0; - numberOfOperands[CInt16] = 0; - numberOfOperands[CInt32] = 0; + number_of_operands.fill(0xFFFFFFFF); + number_of_operands[Nop] = 0; + number_of_operands[CInt16] = 0; + number_of_operands[CInt32] = 0; - static unsigned ZeroOp[] = { + static constexpr std::array zero_op = { LoadCR, LoadLink, LoadMSR, LoadGReg, LoadCTR, InterpreterBranch, LoadCarry, RFIExit, LoadFReg, LoadFRegDENToZero, LoadGQR, Int3, }; - static unsigned UOp[] = { + static constexpr std::array unary_op = { StoreLink, BranchUncond, StoreCR, @@ -1427,7 +1428,7 @@ unsigned IRBuilder::getNumberOfOperands(InstLoc I) const FastCRGTSet, FastCRLTSet, }; - static unsigned BiOp[] = { + static constexpr std::array binary_op = { BranchCond, IdleBranch, And, @@ -1473,17 +1474,17 @@ unsigned IRBuilder::getNumberOfOperands(InstLoc I) const FPMerge11, FDCmpCR, }; - for (auto& op : ZeroOp) - numberOfOperands[op] = 0; + for (auto op : zero_op) + number_of_operands[op] = 0; - for (auto& op : UOp) - numberOfOperands[op] = 1; + for (auto op : unary_op) + number_of_operands[op] = 1; - for (auto& op : BiOp) - numberOfOperands[op] = 2; + for (auto op : binary_op) + number_of_operands[op] = 2; } - return numberOfOperands[getOpcode(*I)]; + return number_of_operands[getOpcode(*I)]; } // Performs a few simplifications for commutative operators