mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 05:45:38 +00:00
Cheats: Prevent inlining of memory functions
Clang is way too eager here and inlines the whole thing hundreds of times within CheatList::Apply().
This commit is contained in:
parent
66c7682c89
commit
56a14db113
|
@ -10,7 +10,6 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
// Force inline helper
|
// Force inline helper
|
||||||
#ifndef ALWAYS_INLINE
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#define ALWAYS_INLINE __forceinline
|
#define ALWAYS_INLINE __forceinline
|
||||||
#elif defined(__GNUC__) || defined(__clang__)
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
|
@ -18,7 +17,6 @@
|
||||||
#else
|
#else
|
||||||
#define ALWAYS_INLINE inline
|
#define ALWAYS_INLINE inline
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
// Force inline in non-debug helper
|
// Force inline in non-debug helper
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
@ -27,6 +25,15 @@
|
||||||
#define ALWAYS_INLINE_RELEASE ALWAYS_INLINE
|
#define ALWAYS_INLINE_RELEASE ALWAYS_INLINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Prevent inlining
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#define NEVER_INLINE __declspec(noinline)
|
||||||
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
|
#define NEVER_INLINE __attribute__((noinline))
|
||||||
|
#else
|
||||||
|
#define NEVER_INLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
// unreferenced parameter macro
|
// unreferenced parameter macro
|
||||||
#ifndef UNREFERENCED_VARIABLE
|
#ifndef UNREFERENCED_VARIABLE
|
||||||
#if defined(__GNUC__) || defined(__clang__) || defined(__EMSCRIPTEN__)
|
#if defined(__GNUC__) || defined(__clang__) || defined(__EMSCRIPTEN__)
|
||||||
|
|
|
@ -44,7 +44,7 @@ static bool IsValidScanAddress(PhysicalMemoryAddress address)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T DoMemoryRead(VirtualMemoryAddress address)
|
NEVER_INLINE static T DoMemoryRead(VirtualMemoryAddress address)
|
||||||
{
|
{
|
||||||
using UnsignedType = typename std::make_unsigned_t<T>;
|
using UnsignedType = typename std::make_unsigned_t<T>;
|
||||||
static_assert(std::is_same_v<UnsignedType, u8> || std::is_same_v<UnsignedType, u16> ||
|
static_assert(std::is_same_v<UnsignedType, u8> || std::is_same_v<UnsignedType, u16> ||
|
||||||
|
@ -60,7 +60,7 @@ static T DoMemoryRead(VirtualMemoryAddress address)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void DoMemoryWrite(PhysicalMemoryAddress address, T value)
|
NEVER_INLINE static void DoMemoryWrite(PhysicalMemoryAddress address, T value)
|
||||||
{
|
{
|
||||||
using UnsignedType = typename std::make_unsigned_t<T>;
|
using UnsignedType = typename std::make_unsigned_t<T>;
|
||||||
static_assert(std::is_same_v<UnsignedType, u8> || std::is_same_v<UnsignedType, u16> ||
|
static_assert(std::is_same_v<UnsignedType, u8> || std::is_same_v<UnsignedType, u16> ||
|
||||||
|
@ -74,7 +74,7 @@ static void DoMemoryWrite(PhysicalMemoryAddress address, T value)
|
||||||
CPU::SafeWriteMemoryWord(address, value);
|
CPU::SafeWriteMemoryWord(address, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 GetControllerButtonBits()
|
NEVER_INLINE static u32 GetControllerButtonBits()
|
||||||
{
|
{
|
||||||
static constexpr std::array<u16, 16> button_mapping = {{
|
static constexpr std::array<u16, 16> button_mapping = {{
|
||||||
0x0100, // Select
|
0x0100, // Select
|
||||||
|
@ -115,7 +115,7 @@ static u32 GetControllerButtonBits()
|
||||||
return translated_bits;
|
return translated_bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 GetControllerAnalogBits()
|
NEVER_INLINE static u32 GetControllerAnalogBits()
|
||||||
{
|
{
|
||||||
// 0x010000 - Right Thumb Up
|
// 0x010000 - Right Thumb Up
|
||||||
// 0x020000 - Right Thumb Right
|
// 0x020000 - Right Thumb Right
|
||||||
|
|
Loading…
Reference in a new issue