1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-23 19:22:48 +01:00

Well, vector argument support in SC_FUNC

This commit is contained in:
Nekotekina 2014-09-06 21:30:50 +04:00
parent 82433d946e
commit 6c01854fec
2 changed files with 21 additions and 7 deletions

View File

@ -52,9 +52,11 @@ u32 _sys_heap_memalign(u32 heap_id, u32 align, u32 size)
return (u32)Memory.Alloc(size, align);
}
void sys_initialize_tls()
u128 sys_initialize_tls(u128 arg)
{
sysPrxForUser->Log("sys_initialize_tls()");
return arg;
}
s64 _sys_process_atexitspawn()

View File

@ -46,11 +46,11 @@ namespace detail
template<typename T, int g_count, int f_count, int v_count>
struct bind_arg<T, ARG_VECTOR, g_count, f_count, v_count>
{
static_assert(sizeof(T) == 16, "Wrong argument type for ARG_VECTOR");
static_assert(std::is_same<T, u128>::value, "Wrong argument type for ARG_VECTOR");
static __forceinline T func(PPUThread& CPU)
{
return (T&)CPU.VPR[v_count + 1]._u128;
return (T&)CPU.VPR[v_count + 1];
}
};
@ -69,9 +69,11 @@ namespace detail
template<typename T>
struct bind_result
{
static_assert(!std::is_pointer<T>::value, "Invalid function result type: pointer");
static_assert(sizeof(T) <= 8, "Invalid function result type");
static __forceinline void func(PPUThread& CPU, T value)
{
static_assert(!std::is_pointer<T>::value, "Invalid function result type: pointer");
if (std::is_floating_point<T>::value)
{
CPU.FPR[1] = (double)value;
@ -83,6 +85,15 @@ namespace detail
}
};
template<>
struct bind_result<u128>
{
static __forceinline void func(PPUThread& CPU, u128 value)
{
CPU.VPR[2] = value;
}
};
template <typename RT, typename F, typename Tuple, bool Done, int Total, int... N>
struct call_impl
{
@ -120,12 +131,13 @@ namespace detail
static_assert(!std::is_pointer<T>::value, "Invalid function argument type: pointer");
// TODO: check calculations
const bool is_float = std::is_floating_point<T>::value;
const bool is_vector = std::is_same<T, u128>::value;
const bind_arg_type t = is_float
? ((f_count >= 12) ? ARG_STACK : ARG_FLOAT)
: ((g_count >= 8) ? ARG_STACK : ARG_GENERAL);
const int g = g_count + (is_float ? 0 : 1);
: (is_vector ? ((v_count >= 12) ? ARG_STACK : ARG_VECTOR) : ((g_count >= 8) ? ARG_STACK : ARG_GENERAL));
const int g = g_count + (is_float || is_vector ? 0 : 1);
const int f = f_count + (is_float ? 1 : 0);
const int v = v_count; // TODO: vector argument support (if possible)
const int v = v_count + (is_vector ? 1 : 0);
return std::tuple_cat(std::tuple<T>(bind_arg<T, t, g, f, v>::func(CPU)), iterate<g, f, v, A...>(CPU));
}