Common: Move FPU-related helpers into Common namespace

Makes these utilities' namespace consistent with the majority of the
Common library.
This commit is contained in:
Lioncash 2023-03-21 10:49:35 -04:00
parent d41751c954
commit 0888c93d48
9 changed files with 17 additions and 17 deletions

View File

@ -11,6 +11,8 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
namespace Common::FPU
{
static u64 GetFPCR() static u64 GetFPCR()
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
@ -31,8 +33,6 @@ static void SetFPCR(u64 fpcr)
#endif #endif
} }
namespace FPURoundMode
{
static const u64 default_fpcr = GetFPCR(); static const u64 default_fpcr = GetFPCR();
static u64 saved_fpcr = default_fpcr; static u64 saved_fpcr = default_fpcr;
@ -87,4 +87,4 @@ void LoadDefaultSIMDState()
SetFPCR(default_fpcr); SetFPCR(default_fpcr);
} }
} // namespace FPURoundMode } // namespace Common::FPU

View File

@ -5,7 +5,7 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
namespace FPURoundMode namespace Common::FPU
{ {
enum RoundMode : u32 enum RoundMode : u32
{ {
@ -27,4 +27,4 @@ void SetSIMDMode(RoundMode rounding_mode, bool non_ieee_mode);
void SaveSIMDState(); void SaveSIMDState();
void LoadSIMDState(); void LoadSIMDState();
void LoadDefaultSIMDState(); void LoadDefaultSIMDState();
} // namespace FPURoundMode } // namespace Common::FPU

View File

@ -6,7 +6,7 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
// Generic, do nothing // Generic, do nothing
namespace FPURoundMode namespace Common::FPU
{ {
void SetSIMDMode(RoundMode rounding_mode, bool non_ieee_mode) void SetSIMDMode(RoundMode rounding_mode, bool non_ieee_mode)
{ {
@ -20,4 +20,4 @@ void LoadSIMDState()
void LoadDefaultSIMDState() void LoadDefaultSIMDState()
{ {
} }
} // namespace FPURoundMode } // namespace Common::FPU

View File

@ -9,7 +9,7 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Intrinsics.h" #include "Common/Intrinsics.h"
namespace FPURoundMode namespace Common::FPU
{ {
// Get the default SSE states here. // Get the default SSE states here.
static u32 saved_sse_state = _mm_getcsr(); static u32 saved_sse_state = _mm_getcsr();
@ -49,4 +49,4 @@ void LoadDefaultSIMDState()
{ {
_mm_setcsr(default_sse_state); _mm_setcsr(default_sse_state);
} }
} // namespace FPURoundMode } // namespace Common::FPU

View File

@ -644,7 +644,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
// thread, and then takes over and becomes the video thread // thread, and then takes over and becomes the video thread
Common::SetCurrentThreadName("Video thread"); Common::SetCurrentThreadName("Video thread");
UndeclareAsCPUThread(); UndeclareAsCPUThread();
FPURoundMode::LoadDefaultSIMDState(); Common::FPU::LoadDefaultSIMDState();
// Spawn the CPU thread. The CPU thread will signal the event that boot is complete. // Spawn the CPU thread. The CPU thread will signal the event that boot is complete.
s_cpu_thread = std::thread(cpuThreadFunc, savestate_path, delete_savestate); s_cpu_thread = std::thread(cpuThreadFunc, savestate_path, delete_savestate);

View File

@ -436,7 +436,7 @@ enum FPSCRExceptionFlag : u32
union UReg_FPSCR union UReg_FPSCR
{ {
// Rounding mode (towards: nearest, zero, +inf, -inf) // Rounding mode (towards: nearest, zero, +inf, -inf)
BitField<0, 2, FPURoundMode::RoundMode> RN; BitField<0, 2, Common::FPU::RoundMode> RN;
// Non-IEEE mode enable (aka flush-to-zero) // Non-IEEE mode enable (aka flush-to-zero)
BitField<2, 1, u32> NI; BitField<2, 1, u32> NI;
// Inexact exception enable // Inexact exception enable

View File

@ -686,7 +686,7 @@ void RoundingModeUpdated()
// The rounding mode is separate for each thread, so this must run on the CPU thread // The rounding mode is separate for each thread, so this must run on the CPU thread
ASSERT(Core::IsCPUThread()); ASSERT(Core::IsCPUThread());
FPURoundMode::SetSIMDMode(PowerPC::ppcState.fpscr.RN, PowerPC::ppcState.fpscr.NI); Common::FPU::SetSIMDMode(PowerPC::ppcState.fpscr.RN, PowerPC::ppcState.fpscr.NI);
} }
} // namespace PowerPC } // namespace PowerPC

View File

@ -455,8 +455,8 @@ int FifoManager::RunGpuOnCpu(Core::System& system, int ticks)
{ {
if (!reset_simd_state) if (!reset_simd_state)
{ {
FPURoundMode::SaveSIMDState(); Common::FPU::SaveSIMDState();
FPURoundMode::LoadDefaultSIMDState(); Common::FPU::LoadDefaultSIMDState();
reset_simd_state = true; reset_simd_state = true;
} }
ReadDataFromFifo(system, fifo.CPReadPointer.load(std::memory_order_relaxed)); ReadDataFromFifo(system, fifo.CPReadPointer.load(std::memory_order_relaxed));
@ -484,7 +484,7 @@ int FifoManager::RunGpuOnCpu(Core::System& system, int ticks)
if (reset_simd_state) if (reset_simd_state)
{ {
FPURoundMode::LoadSIMDState(); Common::FPU::LoadSIMDState();
} }
// Discard all available ticks as there is nothing to do any more. // Discard all available ticks as there is nothing to do any more.

View File

@ -84,12 +84,12 @@ public:
// Set the rounding mode to something that's as annoying as possible to handle // Set the rounding mode to something that's as annoying as possible to handle
// (flush-to-zero enabled, and rounding not symmetric about the origin) // (flush-to-zero enabled, and rounding not symmetric about the origin)
FPURoundMode::SetSIMDMode(FPURoundMode::RoundMode::ROUND_UP, true); Common::FPU::SetSIMDMode(Common::FPU::RoundMode::ROUND_UP, true);
} }
~TestConversion() override ~TestConversion() override
{ {
FPURoundMode::LoadDefaultSIMDState(); Common::FPU::LoadDefaultSIMDState();
FreeCodeSpace(); FreeCodeSpace();
} }