From aead66ccbff6aea8b195308b0e0577c3891f2eb9 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 21 Jan 2015 18:18:26 +0300 Subject: [PATCH] Some refactoring --- rpcs3/Emu/ARMv7/PSVFuncList.h | 63 +++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/rpcs3/Emu/ARMv7/PSVFuncList.h b/rpcs3/Emu/ARMv7/PSVFuncList.h index 0850a88ccf..cf34bf846e 100644 --- a/rpcs3/Emu/ARMv7/PSVFuncList.h +++ b/rpcs3/Emu/ARMv7/PSVFuncList.h @@ -550,6 +550,22 @@ namespace psv_func_detail static const bind_arg_type value = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); }; + template + struct arg_type + { + static_assert(!std::is_pointer::value, "Invalid function argument type (pointer)"); + static_assert(!std::is_reference::value, "Invalid function argument type (reference)"); + // TODO: check calculations + static const bool is_float = std::is_floating_point::value; + static const bool is_vector = std::is_same::value; + static const bind_arg_type value = is_float + ? ((f_count >= 4) ? ARG_STACK : ARG_FLOAT) + : (is_vector ? ((v_count >= 4) ? ARG_STACK : ARG_VECTOR) : ((g_count >= 4) ? ARG_STACK : ARG_GENERAL)); + static const int g_value = g_count + (is_float || is_vector ? 0 : 1); + static const int f_value = f_count + (is_float ? 1 : 0); + static const int v_value = v_count + (is_vector ? 1 : 0); + }; + template struct call_impl { @@ -576,28 +592,22 @@ namespace psv_func_detail } template - __forceinline std::tuple<> iterate(ARMv7Context& context) + __forceinline std::tuple<> get_func_args(ARMv7Context& context) { // terminator return std::tuple<>(); } template - __forceinline std::tuple iterate(ARMv7Context& context) + __forceinline std::tuple get_func_args(ARMv7Context& context) { - static_assert(!std::is_pointer::value, "Invalid function argument type (pointer)"); - static_assert(!std::is_reference::value, "Invalid function argument type (reference)"); - // TODO: check calculations - const bool is_float = std::is_floating_point::value; - const bool is_vector = std::is_same::value; - const bind_arg_type t = is_float - ? ((f_count >= 4) ? ARG_STACK : ARG_FLOAT) - : (is_vector ? ((v_count >= 4) ? ARG_STACK : ARG_VECTOR) : ((g_count >= 4) ? 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 + (is_vector ? 1 : 0); + typedef arg_type type; + const bind_arg_type t = type::value; + const int g = type::g_value; + const int f = type::f_value; + const int v = type::v_value; - return std::tuple_cat(std::tuple(bind_arg::get_arg(context)), iterate(context)); + return std::tuple_cat(std::tuple(bind_arg::get_arg(context)), get_func_args(context)); } template @@ -610,19 +620,14 @@ namespace psv_func_detail template __forceinline static bool put_func_args(ARMv7Context& context, T1 arg, T... args) { - static_assert(!std::is_pointer::value, "Invalid callback argument type (pointer)"); - static_assert(!std::is_reference::value, "Invalid callback argument type (reference)"); - // TODO: check calculations - const bool is_float = std::is_floating_point::value; - const bool is_vector = std::is_same::value; - const bind_arg_type t = is_float - ? ((f_count >= 4) ? ARG_STACK : ARG_FLOAT) - : (is_vector ? ((v_count >= 4) ? ARG_STACK : ARG_VECTOR) : ((g_count >= 4) ? 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 + (is_vector ? 1 : 0); + typedef arg_type type; + const bind_arg_type t = type::value; + const int g = type::g_value; + const int f = type::f_value; + const int v = type::v_value; bind_arg::put_arg(context, arg); + // return true if stack was used return put_func_args(context, args...) || (t == ARG_STACK); } @@ -645,7 +650,7 @@ namespace psv_func_detail virtual void operator()(ARMv7Context& context) { - call(m_call, iterate<0, 0, 0, T...>(context)); + call(m_call, get_func_args<0, 0, 0, T...>(context)); } }; @@ -664,7 +669,7 @@ namespace psv_func_detail virtual void operator()(ARMv7Context& context) { - call(m_call, std::tuple_cat(std::tuple(context), iterate<0, 0, 0, T...>(context))); + call(m_call, std::tuple_cat(std::tuple(context), get_func_args<0, 0, 0, T...>(context))); } }; @@ -683,7 +688,7 @@ namespace psv_func_detail virtual void operator()(ARMv7Context& context) { - bind_result::value>::put_result(context, call(m_call, iterate<0, 0, 0, T...>(context))); + bind_result::value>::put_result(context, call(m_call, get_func_args<0, 0, 0, T...>(context))); } }; @@ -702,7 +707,7 @@ namespace psv_func_detail virtual void operator()(ARMv7Context& context) { - bind_result::value>::put_result(context, call(m_call, std::tuple_cat(std::tuple(context), iterate<0, 0, 0, T...>(context)))); + bind_result::value>::put_result(context, call(m_call, std::tuple_cat(std::tuple(context), get_func_args<0, 0, 0, T...>(context)))); } };