From dd5cc34951402264c022d234776b334d3198072c Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sat, 15 Aug 2015 07:25:14 +0200 Subject: [PATCH] Jit64: clean up GetAllocationOrder() --- Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp | 18 +++++++++--------- Source/Core/Core/PowerPC/Jit64/JitRegCache.h | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp index c546f84002..11ec44538b 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp +++ b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp @@ -131,10 +131,10 @@ float RegCache::ScoreRegister(X64Reg xr) X64Reg RegCache::GetFreeXReg() { size_t aCount; - const int* aOrder = GetAllocationOrder(aCount); + const X64Reg* aOrder = GetAllocationOrder(&aCount); for (size_t i = 0; i < aCount; i++) { - X64Reg xr = (X64Reg)aOrder[i]; + X64Reg xr = aOrder[i]; if (!xregs[xr].locked && xregs[xr].free) { return xr; @@ -226,9 +226,9 @@ void GPRRegCache::SetImmediate32(size_t preg, u32 immValue) regs[preg].location = Imm32(immValue); } -const int* GPRRegCache::GetAllocationOrder(size_t& count) +const X64Reg* GPRRegCache::GetAllocationOrder(size_t* count) { - static const int allocationOrder[] = + static const X64Reg allocationOrder[] = { // R12, when used as base register, for example in a LEA, can generate bad code! Need to look into this. #ifdef _WIN32 @@ -237,17 +237,17 @@ const int* GPRRegCache::GetAllocationOrder(size_t& count) R12, R13, R14, R15, RSI, RDI, R8, R9, R10, R11, RCX #endif }; - count = sizeof(allocationOrder) / sizeof(const int); + *count = sizeof(allocationOrder) / sizeof(X64Reg); return allocationOrder; } -const int* FPURegCache::GetAllocationOrder(size_t& count) +const X64Reg* FPURegCache::GetAllocationOrder(size_t* count) { - static const int allocationOrder[] = + static const X64Reg allocationOrder[] = { XMM6, XMM7, XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, XMM2, XMM3, XMM4, XMM5 }; - count = sizeof(allocationOrder) / sizeof(int); + *count = sizeof(allocationOrder) / sizeof(X64Reg); return allocationOrder; } @@ -395,7 +395,7 @@ int RegCache::NumFreeRegisters() { int count = 0; size_t aCount; - const int* aOrder = GetAllocationOrder(aCount); + const X64Reg* aOrder = GetAllocationOrder(&aCount); for (size_t i = 0; i < aCount; i++) if (!xregs[aOrder[i]].locked && xregs[aOrder[i]].free) count++; diff --git a/Source/Core/Core/PowerPC/Jit64/JitRegCache.h b/Source/Core/Core/PowerPC/Jit64/JitRegCache.h index ca2838dab3..4c7f280609 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitRegCache.h +++ b/Source/Core/Core/PowerPC/Jit64/JitRegCache.h @@ -42,7 +42,7 @@ protected: std::array regs; std::array xregs; - virtual const int *GetAllocationOrder(size_t& count) = 0; + virtual const Gen::X64Reg* GetAllocationOrder(size_t* count) = 0; virtual BitSet32 GetRegUtilization() = 0; virtual BitSet32 CountRegsIn(size_t preg, u32 lookahead) = 0; @@ -176,7 +176,7 @@ public: void StoreRegister(size_t preg, const Gen::OpArg& newLoc) override; void LoadRegister(size_t preg, Gen::X64Reg newLoc) override; Gen::OpArg GetDefaultLocation(size_t reg) const override; - const int* GetAllocationOrder(size_t& count) override; + const Gen::X64Reg* GetAllocationOrder(size_t* count) override; void SetImmediate32(size_t preg, u32 immValue); BitSet32 GetRegUtilization() override; BitSet32 CountRegsIn(size_t preg, u32 lookahead) override; @@ -188,7 +188,7 @@ class FPURegCache final : public RegCache public: void StoreRegister(size_t preg, const Gen::OpArg& newLoc) override; void LoadRegister(size_t preg, Gen::X64Reg newLoc) override; - const int* GetAllocationOrder(size_t& count) override; + const Gen::X64Reg* GetAllocationOrder(size_t* count) override; Gen::OpArg GetDefaultLocation(size_t reg) const override; BitSet32 GetRegUtilization() override; BitSet32 CountRegsIn(size_t preg, u32 lookahead) override;