Force inline a few simple functions that Clang is refusing to inline.

This commit is contained in:
Skyth 2024-10-18 16:30:35 +03:00
parent d29dd06dce
commit 64d9cfbd9b
5 changed files with 18 additions and 16 deletions

View file

@ -1,6 +1,11 @@
project("UnleashedRecomp") project("UnleashedRecomp")
set(TARGET_NAME "SWA") set(TARGET_NAME "SWA")
add_compile_options(
"/fp:strict"
"-march=sandybridge"
"-fno-strict-aliasing")
add_compile_definitions(SWA_IMPL) add_compile_definitions(SWA_IMPL)
add_compile_definitions(SDL_MAIN_HANDLED) add_compile_definitions(SDL_MAIN_HANDLED)

View file

@ -97,7 +97,7 @@ struct DirtyStates
static DirtyStates g_dirtyStates(true); static DirtyStates g_dirtyStates(true);
template<typename T> template<typename T>
static void SetDirtyValue(bool& dirtyState, T& dest, const T& src) static FORCEINLINE void SetDirtyValue(bool& dirtyState, T& dest, const T& src)
{ {
if (dest != src) if (dest != src)
{ {

View file

@ -157,13 +157,13 @@ struct arg_ordinal_t
}; };
template<auto Func, int I = 0, typename ...TArgs> template<auto Func, int I = 0, typename ...TArgs>
void _translate_args(PPCContext& ctx, uint8_t* base, std::tuple<TArgs...>&) noexcept FORCEINLINE void _translate_args(PPCContext& ctx, uint8_t* base, std::tuple<TArgs...>&) noexcept
requires (I >= sizeof...(TArgs)) requires (I >= sizeof...(TArgs))
{ {
} }
template <auto Func, int I = 0, typename ...TArgs> template <auto Func, int I = 0, typename ...TArgs>
std::enable_if_t<(I < sizeof...(TArgs)), void> _translate_args(PPCContext& ctx, uint8_t* base, std::tuple<TArgs...>& tpl) noexcept FORCEINLINE std::enable_if_t<(I < sizeof...(TArgs)), void> _translate_args(PPCContext& ctx, uint8_t* base, std::tuple<TArgs...>& tpl) noexcept
{ {
using T = std::tuple_element_t<I, std::remove_reference_t<decltype(tpl)>>; using T = std::tuple_element_t<I, std::remove_reference_t<decltype(tpl)>>;
std::get<I>(tpl) = ArgTranslator::GetValue<T>(ctx, base, arg_ordinal_t<Func, I>::value); std::get<I>(tpl) = ArgTranslator::GetValue<T>(ctx, base, arg_ordinal_t<Func, I>::value);
@ -172,7 +172,7 @@ std::enable_if_t<(I < sizeof...(TArgs)), void> _translate_args(PPCContext& ctx,
} }
template<auto Func> template<auto Func>
PPC_FUNC(GuestFunction) FORCEINLINE PPC_FUNC(GuestFunction)
{ {
using ret_t = decltype(std::apply(Func, function_args(Func))); using ret_t = decltype(std::apply(Func, function_args(Func)));

View file

@ -21,16 +21,6 @@ void* Memory::Reserve(size_t offset, size_t size)
return Alloc(offset, size, MEM_RESERVE); return Alloc(offset, size, MEM_RESERVE);
} }
void* Memory::Translate(size_t offset) const noexcept
{
return base + offset;
}
uint32_t Memory::MapVirtual(void* host) const noexcept
{
return static_cast<uint32_t>(static_cast<char*>(host) - base);
}
SWA_API void* MmGetHostAddress(uint32_t ptr) SWA_API void* MmGetHostAddress(uint32_t ptr)
{ {
return g_memory.Translate(ptr); return g_memory.Translate(ptr);

View file

@ -14,8 +14,15 @@ public:
void* Commit(size_t offset, size_t size); void* Commit(size_t offset, size_t size);
void* Reserve(size_t offset, size_t size); void* Reserve(size_t offset, size_t size);
void* Translate(size_t offset) const noexcept; void* Translate(size_t offset) const noexcept
uint32_t MapVirtual(void* host) const noexcept; {
return base + offset;
}
uint32_t MapVirtual(void* host) const noexcept
{
return static_cast<uint32_t>(static_cast<char*>(host) - base);
}
}; };
SWA_API void* MmGetHostAddress(uint32_t ptr); SWA_API void* MmGetHostAddress(uint32_t ptr);