summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2017-01-17 20:03:42 -0500
committerLioncash <mathew1800@gmail.com>2017-01-17 20:22:38 -0500
commit89473d59968de9510ef3e79e699f8dd13fb474ca (patch)
tree3df37f3e4133366f0fd0782555bd9b5c565337ba /Source/Core
parentd3aed03563c631a2a23007f408614068461a69af (diff)
IR: Clean up getNumberOfOperands
- Use std::array - Make arrays constexpr where their contents aren't modified.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/PowerPC/JitILCommon/IR.cpp31
1 files 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 <algorithm>
+#include <array>
#include <cinttypes>
#include <ctime>
#include <memory>
@@ -1371,22 +1372,22 @@ unsigned IRBuilder::getComplexity(InstLoc I) const
unsigned IRBuilder::getNumberOfOperands(InstLoc I) const
{
- static unsigned numberOfOperands[256];
+ static std::array<u32, 256> 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<u32, 12> zero_op = {
LoadCR, LoadLink, LoadMSR, LoadGReg, LoadCTR, InterpreterBranch,
LoadCarry, RFIExit, LoadFReg, LoadFRegDENToZero, LoadGQR, Int3,
};
- static unsigned UOp[] = {
+ static constexpr std::array<u32, 39> unary_op = {
StoreLink,
BranchUncond,
StoreCR,
@@ -1427,7 +1428,7 @@ unsigned IRBuilder::getNumberOfOperands(InstLoc I) const
FastCRGTSet,
FastCRLTSet,
};
- static unsigned BiOp[] = {
+ static constexpr std::array<u32, 44> 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