IR_X86: Use std::array instead of raw C arrays in RegInfo

This commit is contained in:
Lioncash 2017-01-16 15:55:14 -05:00
parent 45f7883ed8
commit bc7374a5e1
1 changed files with 8 additions and 6 deletions

View File

@ -26,6 +26,8 @@ The register allocation is linear scan allocation.
#endif #endif
#include <algorithm> #include <algorithm>
#include <array>
#include <cstddef>
#include <vector> #include <vector>
#include "Common/BitSet.h" #include "Common/BitSet.h"
@ -47,10 +49,10 @@ The register allocation is linear scan allocation.
using namespace IREmitter; using namespace IREmitter;
using namespace Gen; using namespace Gen;
static const unsigned int MAX_NUMBER_OF_REGS = 16;
struct RegInfo final : private NonCopyable struct RegInfo final : private NonCopyable
{ {
static constexpr size_t MAX_NUMBER_OF_REGS = 16;
JitIL* Jit; JitIL* Jit;
IRBuilder* Build; IRBuilder* Build;
InstLoc FirstI; InstLoc FirstI;
@ -69,8 +71,8 @@ struct RegInfo final : private NonCopyable
// The last instruction which uses the result of this instruction. Used by the register allocator. // The last instruction which uses the result of this instruction. Used by the register allocator.
std::vector<InstLoc> lastUsed; std::vector<InstLoc> lastUsed;
InstLoc regs[MAX_NUMBER_OF_REGS]; std::array<InstLoc, MAX_NUMBER_OF_REGS> regs;
InstLoc fregs[MAX_NUMBER_OF_REGS]; std::array<InstLoc, MAX_NUMBER_OF_REGS> fregs;
unsigned numSpills; unsigned numSpills;
unsigned numFSpills; unsigned numFSpills;
unsigned exitNumber; unsigned exitNumber;
@ -85,7 +87,7 @@ struct RegInfo final : private NonCopyable
static BitSet32 regsInUse(RegInfo& R) static BitSet32 regsInUse(RegInfo& R)
{ {
BitSet32 result; BitSet32 result;
for (unsigned i = 0; i < MAX_NUMBER_OF_REGS; i++) for (size_t i = 0; i < RegInfo::MAX_NUMBER_OF_REGS; i++)
{ {
if (R.regs[i] != nullptr) if (R.regs[i] != nullptr)
result[i] = true; result[i] = true;
@ -2328,7 +2330,7 @@ static void DoWriteCode(IRBuilder* ibuild, JitIL* Jit, u32 exitAddress)
} }
} }
for (unsigned i = 0; i < MAX_NUMBER_OF_REGS; i++) for (size_t i = 0; i < RegInfo::MAX_NUMBER_OF_REGS; i++)
{ {
if (RI.regs[i]) if (RI.regs[i])
{ {