From 1d48a33aed06bd02c5c7796bbec8e1f7b88186ce Mon Sep 17 00:00:00 2001 From: Sepalani Date: Mon, 7 Jun 2021 13:42:39 +0400 Subject: [PATCH] MMIOHandlers: Move method definitions to MMIO.cpp --- Source/Core/Core/HW/MMIO.cpp | 36 ++++++++++++++++++++++++++++++ Source/Core/Core/HW/MMIOHandlers.h | 26 ++++----------------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/Source/Core/Core/HW/MMIO.cpp b/Source/Core/Core/HW/MMIO.cpp index 41a378990c..ed6ae9c4b1 100644 --- a/Source/Core/Core/HW/MMIO.cpp +++ b/Source/Core/Core/HW/MMIO.cpp @@ -290,6 +290,18 @@ void ReadHandler::Visit(ReadHandlingMethodVisitor& visitor) m_Method->AcceptReadVisitor(visitor); } +template +T ReadHandler::Read(u32 addr) +{ + // Check if the handler has already been initialized. For real + // handlers, this will always be the case, so this branch should be + // easily predictable. + if (!m_Method) + InitializeInvalid(); + + return m_ReadFunc(addr); +} + template void ReadHandler::ResetMethod(ReadHandlingMethod* method) { @@ -319,6 +331,12 @@ void ReadHandler::ResetMethod(ReadHandlingMethod* method) m_ReadFunc = v.ret; } +template +void ReadHandler::InitializeInvalid() +{ + ResetMethod(InvalidRead()); +} + template WriteHandler::WriteHandler() { @@ -344,6 +362,18 @@ void WriteHandler::Visit(WriteHandlingMethodVisitor& visitor) m_Method->AcceptWriteVisitor(visitor); } +template +void WriteHandler::Write(u32 addr, T val) +{ + // Check if the handler has already been initialized. For real + // handlers, this will always be the case, so this branch should be + // easily predictable. + if (!m_Method) + InitializeInvalid(); + + m_WriteFunc(addr, val); +} + template void WriteHandler::ResetMethod(WriteHandlingMethod* method) { @@ -373,6 +403,12 @@ void WriteHandler::ResetMethod(WriteHandlingMethod* method) m_WriteFunc = v.ret; } +template +void WriteHandler::InitializeInvalid() +{ + ResetMethod(InvalidWrite()); +} + // Define all the public specializations that are exported in MMIOHandlers.h. #define MaybeExtern MMIO_PUBLIC_SPECIALIZATIONS() diff --git a/Source/Core/Core/HW/MMIOHandlers.h b/Source/Core/Core/HW/MMIOHandlers.h index 300ed2909b..dfe1a3cc0e 100644 --- a/Source/Core/Core/HW/MMIOHandlers.h +++ b/Source/Core/Core/HW/MMIOHandlers.h @@ -127,16 +127,7 @@ public: // Entry point for read handling method visitors. void Visit(ReadHandlingMethodVisitor& visitor); - T Read(u32 addr) - { - // Check if the handler has already been initialized. For real - // handlers, this will always be the case, so this branch should be - // easily predictable. - if (!m_Method) - InitializeInvalid(); - - return m_ReadFunc(addr); - } + T Read(u32 addr); // Internal method called when changing the internal method object. Its // main role is to make sure the read function is updated at the same time. @@ -145,7 +136,7 @@ public: private: // Initialize this handler to an invalid handler. Done lazily to avoid // useless initialization of thousands of unused handler objects. - void InitializeInvalid() { ResetMethod(InvalidRead()); } + void InitializeInvalid(); std::unique_ptr> m_Method; std::function m_ReadFunc; }; @@ -163,16 +154,7 @@ public: // Entry point for write handling method visitors. void Visit(WriteHandlingMethodVisitor& visitor); - void Write(u32 addr, T val) - { - // Check if the handler has already been initialized. For real - // handlers, this will always be the case, so this branch should be - // easily predictable. - if (!m_Method) - InitializeInvalid(); - - m_WriteFunc(addr, val); - } + void Write(u32 addr, T val); // Internal method called when changing the internal method object. Its // main role is to make sure the write function is updated at the same @@ -182,7 +164,7 @@ public: private: // Initialize this handler to an invalid handler. Done lazily to avoid // useless initialization of thousands of unused handler objects. - void InitializeInvalid() { ResetMethod(InvalidWrite()); } + void InitializeInvalid(); std::unique_ptr> m_Method; std::function m_WriteFunc; };