From 81fcb4e5373ed9223a30c06f126fa1583b2071c9 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sat, 4 Apr 2020 00:59:27 +0100 Subject: [PATCH] mp: Migrate to shared version of mp library --- externals/CMakeLists.txt | 4 + src/CMakeLists.txt | 14 +-- src/backend/x64/devirtualize.h | 11 +- src/backend/x64/emit_x64_floating_point.cpp | 58 +++++----- src/backend/x64/emit_x64_saturation.cpp | 4 +- src/backend/x64/emit_x64_vector.cpp | 12 +-- .../x64/emit_x64_vector_floating_point.cpp | 66 ++++++------ src/common/{mp/lut.h => lut_from_list.h} | 9 +- src/common/mp/append.h | 27 ----- src/common/mp/bind.h | 18 ---- src/common/mp/cartesian_product.h | 51 --------- src/common/mp/concat.h | 57 ---------- src/common/mp/fapply.h | 27 ----- src/common/mp/fmap.h | 27 ----- src/common/mp/function_info.h | 102 ------------------ src/common/mp/integer.h | 51 --------- src/common/mp/list.h | 15 --- src/common/mp/to_tuple.h | 29 ----- src/common/mp/vlift.h | 17 --- src/common/mp/vllift.h | 31 ------ src/frontend/decoder/decoder_detail.h | 5 +- tests/CMakeLists.txt | 5 +- tests/mp.cpp | 27 ----- 23 files changed, 92 insertions(+), 575 deletions(-) rename src/common/{mp/lut.h => lut_from_list.h} (73%) delete mode 100644 src/common/mp/append.h delete mode 100644 src/common/mp/bind.h delete mode 100644 src/common/mp/cartesian_product.h delete mode 100644 src/common/mp/concat.h delete mode 100644 src/common/mp/fapply.h delete mode 100644 src/common/mp/fmap.h delete mode 100644 src/common/mp/function_info.h delete mode 100644 src/common/mp/integer.h delete mode 100644 src/common/mp/list.h delete mode 100644 src/common/mp/to_tuple.h delete mode 100644 src/common/mp/vlift.h delete mode 100644 src/common/mp/vllift.h delete mode 100644 tests/mp.cpp diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index db846225..def524b1 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -18,3 +18,7 @@ endif() add_library(catch INTERFACE) target_include_directories(catch INTERFACE $) + +add_library(mp INTERFACE) +target_include_directories(mp INTERFACE + $) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e55c25ee..22f14652 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,23 +57,12 @@ add_library(dynarmic common/iterator_util.h common/llvm_disassemble.cpp common/llvm_disassemble.h + common/lut_from_list.h common/macro_util.h common/math_util.cpp common/math_util.h common/memory_pool.cpp common/memory_pool.h - common/mp/append.h - common/mp/bind.h - common/mp/cartesian_product.h - common/mp/concat.h - common/mp/fapply.h - common/mp/fmap.h - common/mp/function_info.h - common/mp/list.h - common/mp/lut.h - common/mp/to_tuple.h - common/mp/vlift.h - common/mp/vllift.h common/safe_ops.h common/scope_exit.h common/string_util.h @@ -289,6 +278,7 @@ target_link_libraries(dynarmic PRIVATE boost fmt::fmt + mp xbyak $<$:${llvm_libs}> ) diff --git a/src/backend/x64/devirtualize.h b/src/backend/x64/devirtualize.h index 11d9c46a..70ab12af 100644 --- a/src/backend/x64/devirtualize.h +++ b/src/backend/x64/devirtualize.h @@ -9,10 +9,11 @@ #include #include +#include + #include "backend/x64/callback.h" #include "common/cast_util.h" #include "common/common_types.h" -#include "common/mp/function_info.h" namespace Dynarmic { namespace BackendX64 { @@ -32,18 +33,18 @@ struct ThunkBuilder { } // namespace impl template -ArgCallback DevirtualizeGeneric(Common::mp::class_type_t* this_) { +ArgCallback DevirtualizeGeneric(mp::class_type* this_) { return ArgCallback{&impl::ThunkBuilder::Thunk, reinterpret_cast(this_)}; } template -ArgCallback DevirtualizeWindows(Common::mp::class_type_t* this_) { +ArgCallback DevirtualizeWindows(mp::class_type* this_) { static_assert(sizeof(mfp) == 8); return ArgCallback{Common::BitCast(mfp), reinterpret_cast(this_)}; } template -ArgCallback DevirtualizeItanium(Common::mp::class_type_t* this_) { +ArgCallback DevirtualizeItanium(mp::class_type* this_) { struct MemberFunctionPointer { /// For a non-virtual function, this is a simple function pointer. /// For a virtual function, it is (1 + virtual table offset in bytes). @@ -65,7 +66,7 @@ ArgCallback DevirtualizeItanium(Common::mp::class_type_t* this_) } template -ArgCallback Devirtualize(Common::mp::class_type_t* this_) { +ArgCallback Devirtualize(mp::class_type* this_) { #if defined(__APPLE__) || defined(linux) || defined(__linux) || defined(__linux__) return DevirtualizeItanium(this_); #elif defined(__MINGW64__) diff --git a/src/backend/x64/emit_x64_floating_point.cpp b/src/backend/x64/emit_x64_floating_point.cpp index 7062cf49..8f515849 100644 --- a/src/backend/x64/emit_x64_floating_point.cpp +++ b/src/backend/x64/emit_x64_floating_point.cpp @@ -8,6 +8,13 @@ #include #include +#include +#include +#include +#include +#include +#include + #include "backend/x64/abi.h" #include "backend/x64/block_of_code.h" #include "backend/x64/emit_x64.h" @@ -18,20 +25,13 @@ #include "common/fp/info.h" #include "common/fp/op.h" #include "common/fp/rounding_mode.h" -#include "common/mp/cartesian_product.h" -#include "common/mp/integer.h" -#include "common/mp/list.h" -#include "common/mp/lut.h" -#include "common/mp/to_tuple.h" -#include "common/mp/vlift.h" -#include "common/mp/vllift.h" +#include "common/lut_from_list.h" #include "frontend/ir/basic_block.h" #include "frontend/ir/microinstruction.h" namespace Dynarmic::BackendX64 { using namespace Xbyak::util; -namespace mp = Dynarmic::Common::mp; namespace { @@ -845,28 +845,28 @@ static void EmitFPRound(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, siz return; } - using fsize_list = mp::list, - mp::vlift, - mp::vlift>; + using fsize_list = mp::list, + mp::lift_value, + mp::lift_value>; using rounding_list = mp::list< - std::integral_constant, - std::integral_constant, - std::integral_constant, - std::integral_constant, - std::integral_constant + mp::lift_value, + mp::lift_value, + mp::lift_value, + mp::lift_value, + mp::lift_value >; - using exact_list = mp::list, mp::vlift>; + using exact_list = mp::list; using key_type = std::tuple; using value_type = u64(*)(u64, FP::FPSR&, FP::FPCR); - static const auto lut = mp::GenerateLookupTableFromList( + static const auto lut = Common::GenerateLookupTableFromList( [](auto args) { return std::pair{ - mp::to_tuple, + mp::lower_to_tuple_v, static_cast( [](u64 input, FP::FPSR& fpsr, FP::FPCR fpcr) { - constexpr auto t = mp::to_tuple; + constexpr auto t = mp::lower_to_tuple_v; constexpr size_t fsize = std::get<0>(t); constexpr FP::RoundingMode rounding_mode = std::get<1>(t); constexpr bool exact = std::get<2>(t); @@ -1279,25 +1279,25 @@ static void EmitFPToFixed(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { } } - using fbits_list = mp::vllift>; + using fbits_list = mp::lift_sequence>; using rounding_list = mp::list< - std::integral_constant, - std::integral_constant, - std::integral_constant, - std::integral_constant, - std::integral_constant + mp::lift_value, + mp::lift_value, + mp::lift_value, + mp::lift_value, + mp::lift_value >; using key_type = std::tuple; using value_type = u64(*)(u64, FP::FPSR&, FP::FPCR); - static const auto lut = mp::GenerateLookupTableFromList( + static const auto lut = Common::GenerateLookupTableFromList( [](auto args) { return std::pair{ - mp::to_tuple, + mp::lower_to_tuple_v, static_cast( [](u64 input, FP::FPSR& fpsr, FP::FPCR fpcr) { - constexpr auto t = mp::to_tuple; + constexpr auto t = mp::lower_to_tuple_v; constexpr size_t fbits = std::get<0>(t); constexpr FP::RoundingMode rounding_mode = std::get<1>(t); using FPT = mp::unsigned_integer_of_size; diff --git a/src/backend/x64/emit_x64_saturation.cpp b/src/backend/x64/emit_x64_saturation.cpp index 1293da99..0658b763 100644 --- a/src/backend/x64/emit_x64_saturation.cpp +++ b/src/backend/x64/emit_x64_saturation.cpp @@ -6,12 +6,13 @@ #include +#include + #include "backend/x64/block_of_code.h" #include "backend/x64/emit_x64.h" #include "common/assert.h" #include "common/bit_util.h" #include "common/common_types.h" -#include "common/mp/integer.h" #include "frontend/ir/basic_block.h" #include "frontend/ir/microinstruction.h" #include "frontend/ir/opcodes.h" @@ -19,7 +20,6 @@ namespace Dynarmic::BackendX64 { using namespace Xbyak::util; -namespace mp = Dynarmic::Common::mp; namespace { diff --git a/src/backend/x64/emit_x64_vector.cpp b/src/backend/x64/emit_x64_vector.cpp index 4eceefbd..f92a1597 100644 --- a/src/backend/x64/emit_x64_vector.cpp +++ b/src/backend/x64/emit_x64_vector.cpp @@ -9,6 +9,8 @@ #include #include +#include + #include "backend/x64/abi.h" #include "backend/x64/block_of_code.h" #include "backend/x64/emit_x64.h" @@ -16,7 +18,6 @@ #include "common/bit_util.h" #include "common/common_types.h" #include "common/math_util.h" -#include "common/mp/function_info.h" #include "frontend/ir/basic_block.h" #include "frontend/ir/microinstruction.h" #include "frontend/ir/opcodes.h" @@ -24,7 +25,6 @@ namespace Dynarmic::BackendX64 { using namespace Xbyak::util; -namespace mp = Common::mp; template static void EmitVectorOperation(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, Function fn) { @@ -52,7 +52,7 @@ static void EmitAVXVectorOperation(BlockOfCode& code, EmitContext& ctx, IR::Inst template static void EmitOneArgumentFallback(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, Lambda lambda) { - const auto fn = static_cast*>(lambda); + const auto fn = static_cast*>(lambda); constexpr u32 stack_space = 2 * 16; auto args = ctx.reg_alloc.GetArgumentInfo(inst); const Xbyak::Xmm arg1 = ctx.reg_alloc.UseXmm(args[0]); @@ -75,7 +75,7 @@ static void EmitOneArgumentFallback(BlockOfCode& code, EmitContext& ctx, IR::Ins template static void EmitOneArgumentFallbackWithSaturation(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, Lambda lambda) { - const auto fn = static_cast*>(lambda); + const auto fn = static_cast*>(lambda); constexpr u32 stack_space = 2 * 16; auto args = ctx.reg_alloc.GetArgumentInfo(inst); const Xbyak::Xmm arg1 = ctx.reg_alloc.UseXmm(args[0]); @@ -100,7 +100,7 @@ static void EmitOneArgumentFallbackWithSaturation(BlockOfCode& code, EmitContext template static void EmitTwoArgumentFallbackWithSaturation(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, Lambda lambda) { - const auto fn = static_cast*>(lambda); + const auto fn = static_cast*>(lambda); constexpr u32 stack_space = 3 * 16; auto args = ctx.reg_alloc.GetArgumentInfo(inst); const Xbyak::Xmm arg1 = ctx.reg_alloc.UseXmm(args[0]); @@ -128,7 +128,7 @@ static void EmitTwoArgumentFallbackWithSaturation(BlockOfCode& code, EmitContext template static void EmitTwoArgumentFallback(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, Lambda lambda) { - const auto fn = static_cast*>(lambda); + const auto fn = static_cast*>(lambda); constexpr u32 stack_space = 3 * 16; auto args = ctx.reg_alloc.GetArgumentInfo(inst); const Xbyak::Xmm arg1 = ctx.reg_alloc.UseXmm(args[0]); diff --git a/src/backend/x64/emit_x64_vector_floating_point.cpp b/src/backend/x64/emit_x64_vector_floating_point.cpp index 2e5f2b0d..4af99cf9 100644 --- a/src/backend/x64/emit_x64_vector_floating_point.cpp +++ b/src/backend/x64/emit_x64_vector_floating_point.cpp @@ -10,6 +10,14 @@ #include #include +#include +#include +#include +#include +#include +#include +#include + #include "backend/x64/abi.h" #include "backend/x64/block_of_code.h" #include "backend/x64/emit_x64.h" @@ -18,21 +26,13 @@ #include "common/fp/info.h" #include "common/fp/op.h" #include "common/fp/util.h" -#include "common/mp/cartesian_product.h" -#include "common/mp/function_info.h" -#include "common/mp/integer.h" -#include "common/mp/list.h" -#include "common/mp/lut.h" -#include "common/mp/to_tuple.h" -#include "common/mp/vlift.h" -#include "common/mp/vllift.h" +#include "common/lut_from_list.h" #include "frontend/ir/basic_block.h" #include "frontend/ir/microinstruction.h" namespace Dynarmic::BackendX64 { using namespace Xbyak::util; -namespace mp = Common::mp; namespace { @@ -361,7 +361,7 @@ void EmitThreeOpVectorOperation(BlockOfCode& code, EmitContext& ctx, IR::Inst* i template void EmitTwoOpFallback(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, Lambda lambda) { - const auto fn = static_cast*>(lambda); + const auto fn = static_cast*>(lambda); auto args = ctx.reg_alloc.GetArgumentInfo(inst); const Xbyak::Xmm arg1 = ctx.reg_alloc.UseXmm(args[0]); @@ -387,7 +387,7 @@ void EmitTwoOpFallback(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, Lamb template void EmitThreeOpFallbackWithoutRegAlloc(BlockOfCode& code, EmitContext& ctx, Xbyak::Xmm result, Xbyak::Xmm arg1, Xbyak::Xmm arg2, Lambda lambda) { - const auto fn = static_cast*>(lambda); + const auto fn = static_cast*>(lambda); #ifdef _WIN32 constexpr u32 stack_space = 4 * 16; @@ -437,7 +437,7 @@ void EmitThreeOpFallback(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, La template void EmitFourOpFallbackWithoutRegAlloc(BlockOfCode& code, EmitContext& ctx, Xbyak::Xmm result, Xbyak::Xmm arg1, Xbyak::Xmm arg2, Xbyak::Xmm arg3, Lambda lambda) { - const auto fn = static_cast*>(lambda); + const auto fn = static_cast*>(lambda); #ifdef _WIN32 constexpr u32 stack_space = 5 * 16; @@ -1205,25 +1205,26 @@ void EmitFPVectorRoundInt(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { } using rounding_list = mp::list< - std::integral_constant, - std::integral_constant, - std::integral_constant, - std::integral_constant, - std::integral_constant + mp::lift_value, + mp::lift_value, + mp::lift_value, + mp::lift_value, + mp::lift_value >; - using exact_list = mp::list, mp::vlift>; + using exact_list = mp::list; using key_type = std::tuple; using value_type = void(*)(VectorArray&, const VectorArray&, FP::FPCR, FP::FPSR&); - static const auto lut = mp::GenerateLookupTableFromList( + static const auto lut = Common::GenerateLookupTableFromList( [](auto arg) { return std::pair{ - mp::to_tuple, + mp::lower_to_tuple_v, static_cast( [](VectorArray& output, const VectorArray& input, FP::FPCR fpcr, FP::FPSR& fpsr) { - constexpr FP::RoundingMode rounding_mode = std::get<0>(mp::to_tuple); - constexpr bool exact = std::get<1>(mp::to_tuple); + constexpr auto t = mp::lower_to_tuple_v; + constexpr FP::RoundingMode rounding_mode = std::get<0>(t); + constexpr bool exact = std::get<1>(t); for (size_t i = 0; i < output.size(); ++i) { output[i] = static_cast(FP::FPRoundInt(input[i], fpcr, rounding_mode, exact, fpsr)); @@ -1465,26 +1466,27 @@ void EmitFPVectorToFixed(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { } } - using fbits_list = mp::vllift>; + using fbits_list = mp::lift_sequence>; using rounding_list = mp::list< - std::integral_constant, - std::integral_constant, - std::integral_constant, - std::integral_constant, - std::integral_constant + mp::lift_value, + mp::lift_value, + mp::lift_value, + mp::lift_value, + mp::lift_value >; using key_type = std::tuple; using value_type = void(*)(VectorArray&, const VectorArray&, FP::FPCR, FP::FPSR&); - static const auto lut = mp::GenerateLookupTableFromList( + static const auto lut = Common::GenerateLookupTableFromList( [](auto arg) { return std::pair{ - mp::to_tuple, + mp::lower_to_tuple_v, static_cast( [](VectorArray& output, const VectorArray& input, FP::FPCR fpcr, FP::FPSR& fpsr) { - constexpr size_t fbits = std::get<0>(mp::to_tuple); - constexpr FP::RoundingMode rounding_mode = std::get<1>(mp::to_tuple); + constexpr auto t = mp::lower_to_tuple_v; + constexpr size_t fbits = std::get<0>(t); + constexpr FP::RoundingMode rounding_mode = std::get<1>(t); for (size_t i = 0; i < output.size(); ++i) { output[i] = static_cast(FP::FPToFixed(fsize, input[i], fbits, unsigned_, fpcr, rounding_mode, fpsr)); diff --git a/src/common/mp/lut.h b/src/common/lut_from_list.h similarity index 73% rename from src/common/mp/lut.h rename to src/common/lut_from_list.h index 5d644197..845a7f38 100644 --- a/src/common/mp/lut.h +++ b/src/common/lut_from_list.h @@ -8,16 +8,15 @@ #include #include -#include -#include "common/mp/list.h" +#include -namespace Dynarmic::Common::mp { +namespace Dynarmic::Common { template -inline auto GenerateLookupTableFromList(Function f, list) { +inline auto GenerateLookupTableFromList(Function f, mp::list) { static const std::array, sizeof...(Values)> pair_array{f(Values{})...}; return std::map(pair_array.begin(), pair_array.end()); } -} // namespace Dynarmic::Common::mp +} // namespace Dynarmic::Common diff --git a/src/common/mp/append.h b/src/common/mp/append.h deleted file mode 100644 index e6ad75ed..00000000 --- a/src/common/mp/append.h +++ /dev/null @@ -1,27 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -namespace Dynarmic::Common::mp { - -namespace detail { - -template -struct append_impl; - -template class LT, class... T1, class... T2> -struct append_impl, T2...> { - using type = LT; -}; - -} // namespace detail - -/// Append items T to list L -template -using append = typename detail::append_impl::type; - -} // namespace Dynarmic::Common::mp diff --git a/src/common/mp/bind.h b/src/common/mp/bind.h deleted file mode 100644 index 3666ea5b..00000000 --- a/src/common/mp/bind.h +++ /dev/null @@ -1,18 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -namespace Dynarmic::Common::mp { - -/// Binds the first sizeof...(A) arguments of metafunction F with arguments A -template class F, class... A> -struct bind { - template - using type = F; -}; - -} // namespace Dynarmic::Common::mp diff --git a/src/common/mp/cartesian_product.h b/src/common/mp/cartesian_product.h deleted file mode 100644 index 2ff42db1..00000000 --- a/src/common/mp/cartesian_product.h +++ /dev/null @@ -1,51 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -#include "common/mp/append.h" -#include "common/mp/bind.h" -#include "common/mp/concat.h" -#include "common/mp/fmap.h" -#include "common/mp/list.h" - -namespace Dynarmic::Common::mp { - -namespace detail { - -template -struct cartesian_product_impl{}; - -template -struct cartesian_product_impl { - using type = RL; -}; - -template class LT, class... RT, class... T1> -struct cartesian_product_impl, LT> { - using type = concat< - fmap::template type, list>... - >; -}; - -template -struct cartesian_product_impl { - using type = typename cartesian_product_impl< - typename cartesian_product_impl::type, - L2, - Ls... - >::type; -}; - -} // namespace detail - -/// Produces the cartesian product of a set of lists -/// For example: -/// cartesian_product, list> == list, list, list, list -template -using cartesian_product = typename detail::cartesian_product_impl, Ls...>::type; - -} // namespace Dynarmic::Common::mp diff --git a/src/common/mp/concat.h b/src/common/mp/concat.h deleted file mode 100644 index e41dd9e6..00000000 --- a/src/common/mp/concat.h +++ /dev/null @@ -1,57 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -#include "common/mp/list.h" - -namespace Dynarmic::Common::mp { - -namespace detail { - -template -struct concat_impl; - -template<> -struct concat_impl<> { - using type = list<>; -}; - -template -struct concat_impl { - using type = L; -}; - -template class LT, class... T1, class... T2, class... Ls> -struct concat_impl, LT, Ls...> { - using type = typename concat_impl, Ls...>::type; -}; - -template class LT, - class... T1, class... T2, class... T3, class... T4, class... T5, class... T6, class... T7, class... T8, - class... T9, class... T10, class... T11, class... T12, class... T13, class... T14, class... T15, class... T16, - class... Ls> -struct concat_impl< - LT, LT, LT, LT, LT, LT, LT, LT, - LT, LT, LT, LT, LT, LT, LT, LT, - Ls...> -{ - using type = typename concat_impl< - LT< - T1..., T2..., T3..., T4..., T5..., T6..., T7..., T8..., - T9..., T10..., T11..., T12..., T13..., T14..., T15..., T16... - >, - Ls... - >::type; -}; - -} // namespace detail - -/// Concatenate lists together -template -using concat = typename detail::concat_impl::type; - -} // namespace Dynarmic::Common::mp diff --git a/src/common/mp/fapply.h b/src/common/mp/fapply.h deleted file mode 100644 index 1b84efc4..00000000 --- a/src/common/mp/fapply.h +++ /dev/null @@ -1,27 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -namespace Dynarmic::Common::mp { - -namespace detail { - -template class F, class L> -struct fapply_impl; - -template class F, template class LT, class... T> -struct fapply_impl> { - using type = F; -}; - -} // namespace detail - -/// Invokes metafunction F where the arguments are all the members of list L -template class F, class L> -using fapply = typename detail::fapply_impl::type; - -} // namespace Dynarmic::Common::mp diff --git a/src/common/mp/fmap.h b/src/common/mp/fmap.h deleted file mode 100644 index d05766a6..00000000 --- a/src/common/mp/fmap.h +++ /dev/null @@ -1,27 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -namespace Dynarmic::Common::mp { - -namespace detail { - -template class F, class L> -struct fmap_impl; - -template class F, template class LT, class... T> -struct fmap_impl> { - using type = LT...>; -}; - -} // namespace detail - -/// Metafunction that applies each element of list L to metafunction F -template class F, class L> -using fmap = typename detail::fmap_impl::type; - -} // namespace Dynarmic::Common::mp diff --git a/src/common/mp/function_info.h b/src/common/mp/function_info.h deleted file mode 100644 index 8f8bae14..00000000 --- a/src/common/mp/function_info.h +++ /dev/null @@ -1,102 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2016 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -#include -#include - -namespace Dynarmic::Common::mp { - -/// Used to provide information about an arbitrary function. -template -struct FunctionInfo : public FunctionInfo -{ -}; - -/** - * Partial specialization for function types. - * - * This is used as the supporting base for all other specializations. - */ -template -struct FunctionInfo -{ - using return_type = R; - static constexpr size_t args_count = sizeof...(Args); - - template - struct Parameter - { - static_assert(args_count != 0 && ParameterIndex < args_count, "Non-existent function parameter index"); - using type = std::tuple_element_t>; - }; - - using equivalent_function_type = R(Args...); -}; - -/// Partial specialization for function pointers -template -struct FunctionInfo : public FunctionInfo -{ -}; - -/// Partial specialization for member function pointers. -template -struct FunctionInfo : public FunctionInfo -{ - using class_type = C; -}; - -/// Partial specialization for const member function pointers. -template -struct FunctionInfo : public FunctionInfo -{ - using class_type = C; -}; - -/** - * Helper template for retrieving the number of function parameters. - * - * @tparam Function An arbitrary function type. - */ -template -constexpr size_t parameter_count_v = FunctionInfo::args_count; - -/** - * Helper template for retrieving the type of a function parameter. - * - * @tparam Function An arbitrary function type. - * @tparam ParameterIndex Zero-based index indicating which parameter to get the type of. - */ -template -using parameter_type_t = typename FunctionInfo::template Parameter::type; - -/** - * Helper template for retrieving the return type of a function. - * - * @tparam Function The function type to get the return type of. - */ -template -using return_type_t = typename FunctionInfo::return_type; - -/** - * Helper template for retrieving the class type of a member function. - * - * @tparam Function The function type to get the return type of. - */ -template -using class_type_t = typename FunctionInfo::class_type; - -/** - * Helper template for retrieving the equivalent function type of a member function or functor. - * - * @tparam Function The function type to get the return type of. - */ -template -using equivalent_function_type_t = typename FunctionInfo::equivalent_function_type; - -} // namespace Dynarmic::Common::mp diff --git a/src/common/mp/integer.h b/src/common/mp/integer.h deleted file mode 100644 index ee9f6201..00000000 --- a/src/common/mp/integer.h +++ /dev/null @@ -1,51 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -#include -#include - -namespace Dynarmic::Common::mp { - -namespace detail { - -template -struct integer_of_size_impl{}; - -template<> -struct integer_of_size_impl<8> { - using unsigned_type = std::uint8_t; - using signed_type = std::int8_t; -}; - -template<> -struct integer_of_size_impl<16> { - using unsigned_type = std::uint16_t; - using signed_type = std::int16_t; -}; - -template<> -struct integer_of_size_impl<32> { - using unsigned_type = std::uint32_t; - using signed_type = std::int32_t; -}; - -template<> -struct integer_of_size_impl<64> { - using unsigned_type = std::uint64_t; - using signed_type = std::int64_t; -}; - -} // namespace detail - -template -using unsigned_integer_of_size = typename detail::integer_of_size_impl::unsigned_type; - -template -using signed_integer_of_size = typename detail::integer_of_size_impl::signed_type; - -} // namespace Dynarmic::Common::mp diff --git a/src/common/mp/list.h b/src/common/mp/list.h deleted file mode 100644 index 96c00697..00000000 --- a/src/common/mp/list.h +++ /dev/null @@ -1,15 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -namespace Dynarmic::Common::mp { - -/// Contains a list of types -template -struct list {}; - -} // namespace Dynarmic::Common::mp diff --git a/src/common/mp/to_tuple.h b/src/common/mp/to_tuple.h deleted file mode 100644 index 1e782a1d..00000000 --- a/src/common/mp/to_tuple.h +++ /dev/null @@ -1,29 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -#include - -namespace Dynarmic::Common::mp { - -namespace detail { - -template -struct to_tuple_impl; - -template class LT, class... T> -struct to_tuple_impl> { - static constexpr auto value = std::make_tuple(static_cast(T::value)...); -}; - -} // namespace detail - -/// Metafunction that converts a list of metavalues to a tuple value. -template -constexpr auto to_tuple = detail::to_tuple_impl::value; - -} // namespace Dynarmic::Common::mp diff --git a/src/common/mp/vlift.h b/src/common/mp/vlift.h deleted file mode 100644 index c46874d3..00000000 --- a/src/common/mp/vlift.h +++ /dev/null @@ -1,17 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -#include - -namespace Dynarmic::Common::mp { - -/// Lifts a value into a type -template -using vlift = std::integral_constant; - -} // namespace Dynarmic::Common::mp diff --git a/src/common/mp/vllift.h b/src/common/mp/vllift.h deleted file mode 100644 index 25eb323d..00000000 --- a/src/common/mp/vllift.h +++ /dev/null @@ -1,31 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#pragma once - -#include - -#include "common/mp/list.h" - -namespace Dynarmic::Common::mp { - -namespace detail { - -template -struct vllift_impl{}; - -template -struct vllift_impl> { - using type = list...>; -}; - -} // namespace detail - -/// Lifts values in value list VL to create a type list. -template -using vllift = typename detail::vllift_impl::type; - -} // namespace Dynarmic::Common::mp diff --git a/src/frontend/decoder/decoder_detail.h b/src/frontend/decoder/decoder_detail.h index dcba0fb8..17cc85b4 100644 --- a/src/frontend/decoder/decoder_detail.h +++ b/src/frontend/decoder/decoder_detail.h @@ -10,9 +10,10 @@ #include #include +#include + #include "common/assert.h" #include "common/bit_util.h" -#include "common/mp/function_info.h" namespace Dynarmic::Decoder { namespace detail { @@ -152,7 +153,7 @@ public: */ template static auto GetMatcher(FnT fn, const char* const name, const char* const bitstring) { - constexpr size_t args_count = Common::mp::FunctionInfo::args_count; + constexpr size_t args_count = mp::parameter_count_v; using Iota = std::make_index_sequence; const auto [mask, expect] = GetMaskAndExpect(bitstring); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7dded099..29026bee 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,7 +11,6 @@ add_executable(dynarmic_tests fp/mantissa_util_tests.cpp fp/unpacked_tests.cpp main.cpp - mp.cpp rand_int.h ) @@ -40,12 +39,12 @@ include(CreateDirectoryGroups) create_target_directory_groups(dynarmic_tests) create_target_directory_groups(dynarmic_print_info) -target_link_libraries(dynarmic_tests PRIVATE dynarmic boost catch fmt xbyak) +target_link_libraries(dynarmic_tests PRIVATE dynarmic boost catch fmt mp xbyak) target_include_directories(dynarmic_tests PRIVATE . ../src) target_compile_options(dynarmic_tests PRIVATE ${DYNARMIC_CXX_FLAGS}) target_compile_definitions(dynarmic_tests PRIVATE FMT_USE_USER_DEFINED_LITERALS=0) -target_link_libraries(dynarmic_print_info PRIVATE dynarmic boost catch fmt) +target_link_libraries(dynarmic_print_info PRIVATE dynarmic boost catch fmt mp) target_include_directories(dynarmic_print_info PRIVATE . ../src) target_compile_options(dynarmic_print_info PRIVATE ${DYNARMIC_CXX_FLAGS}) target_compile_definitions(dynarmic_print_info PRIVATE FMT_USE_USER_DEFINED_LITERALS=0) diff --git a/tests/mp.cpp b/tests/mp.cpp deleted file mode 100644 index 7f34a525..00000000 --- a/tests/mp.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2018 MerryMage - * This software may be used and distributed according to the terms of the GNU - * General Public License version 2 or any later version. - */ - -#include - -#include "common/mp/cartesian_product.h" - -using namespace Dynarmic::Common::mp; - -static_assert( - std::is_same_v< - cartesian_product, list, list>, - list< - list, - list, - list, - list, - list, - list, - list, - list - > - > -);