mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
Remove built_function
With today's branch prediction techniques, it's hardly useful.
This commit is contained in:
parent
d2897bc6a0
commit
12c83b340d
11 changed files with 17 additions and 112 deletions
|
@ -263,100 +263,6 @@ inline FT build_function_asm(std::string_view name, F&& builder)
|
|||
return reinterpret_cast<FT>(uptr(result));
|
||||
}
|
||||
|
||||
#if !defined(ARCH_X64) || defined(__APPLE__)
|
||||
template <typename FT, usz = 4096>
|
||||
class built_function
|
||||
{
|
||||
FT m_func;
|
||||
|
||||
public:
|
||||
built_function(const built_function&) = delete;
|
||||
|
||||
built_function& operator=(const built_function&) = delete;
|
||||
|
||||
template <typename F>
|
||||
built_function(std::string_view name, F&& builder,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION())
|
||||
: m_func(ensure(build_function_asm<FT>(name, std::forward<F>(builder)), const_str(), line, col, file, func))
|
||||
{
|
||||
}
|
||||
|
||||
operator FT() const noexcept
|
||||
{
|
||||
return m_func;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
auto operator()(Args&&... args) const noexcept
|
||||
{
|
||||
return m_func(std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
#else
|
||||
template <typename FT, usz Size = 4096>
|
||||
class built_function
|
||||
{
|
||||
alignas(4096) uchar m_data[Size];
|
||||
|
||||
public:
|
||||
built_function(const built_function&) = delete;
|
||||
|
||||
built_function& operator=(const built_function&) = delete;
|
||||
|
||||
template <typename F>
|
||||
built_function(std::string_view name, F&& builder)
|
||||
{
|
||||
using namespace asmjit;
|
||||
|
||||
inline_runtime rt(m_data, Size);
|
||||
|
||||
CodeHolder code;
|
||||
code.init(rt.environment());
|
||||
|
||||
#if defined(ARCH_X64)
|
||||
native_args args;
|
||||
#ifdef _WIN32
|
||||
args[0] = x86::rcx;
|
||||
args[1] = x86::rdx;
|
||||
args[2] = x86::r8;
|
||||
args[3] = x86::r9;
|
||||
#else
|
||||
args[0] = x86::rdi;
|
||||
args[1] = x86::rsi;
|
||||
args[2] = x86::rdx;
|
||||
args[3] = x86::rcx;
|
||||
#endif
|
||||
#elif defined(ARCH_ARM64)
|
||||
native_args args;
|
||||
args[0] = a64::x0;
|
||||
args[1] = a64::x1;
|
||||
args[2] = a64::x2;
|
||||
args[3] = a64::x3;
|
||||
#endif
|
||||
|
||||
native_asm compiler(&code);
|
||||
compiler.addEncodingOptions(EncodingOptions::kOptimizedAlign);
|
||||
builder(compiler, args);
|
||||
rt.dump_name = name;
|
||||
jit_announce(rt._add(&code), code.codeSize(), name);
|
||||
}
|
||||
|
||||
operator FT() const noexcept
|
||||
{
|
||||
return FT(+m_data);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
auto operator()(Args&&... args) const noexcept
|
||||
{
|
||||
return FT(+m_data)(std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LLVM_AVAILABLE
|
||||
|
||||
namespace llvm
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue