|
12 | 12 |
|
13 | 13 | #include <cstring> |
14 | 14 | #include <string> |
| 15 | +#include <type_traits> |
15 | 16 |
|
16 | 17 | #include "third_party/fmt/include/fmt/format.h" |
17 | 18 | #include "xenia/base/byte_order.h" |
@@ -531,52 +532,25 @@ xe::cpu::Export* RegisterExport(R (*fn)(Ps&...), const char* name, |
531 | 532 | cvars::log_high_frequency_kernel_calls)) { |
532 | 533 | PrintKernelCall(export_entry, params); |
533 | 534 | } |
534 | | - auto result = |
535 | | - KernelTrampoline(FN, std::forward<std::tuple<Ps...>>(params), |
536 | | - std::make_index_sequence<sizeof...(Ps)>()); |
537 | | - result.Store(ppc_context); |
538 | | - if (export_entry->tags & |
539 | | - (xe::cpu::ExportTag::kLog | xe::cpu::ExportTag::kLogResult)) { |
540 | | - // TODO(benvanik): log result. |
| 535 | + if constexpr (std::is_void<R>::value) { |
| 536 | + KernelTrampoline(FN, std::forward<std::tuple<Ps...>>(params), |
| 537 | + std::make_index_sequence<sizeof...(Ps)>()); |
| 538 | + } else { |
| 539 | + auto result = |
| 540 | + KernelTrampoline(FN, std::forward<std::tuple<Ps...>>(params), |
| 541 | + std::make_index_sequence<sizeof...(Ps)>()); |
| 542 | + result.Store(ppc_context); |
| 543 | + if (export_entry->tags & |
| 544 | + (xe::cpu::ExportTag::kLog | xe::cpu::ExportTag::kLogResult)) { |
| 545 | + // TODO(benvanik): log result. |
| 546 | + } |
541 | 547 | } |
542 | 548 | } |
543 | 549 | }; |
544 | 550 | export_entry->function_data.trampoline = &X::Trampoline; |
545 | 551 | return export_entry; |
546 | 552 | } |
547 | 553 |
|
548 | | -template <KernelModuleId MODULE, uint16_t ORDINAL, typename... Ps> |
549 | | -xe::cpu::Export* RegisterExport(void (*fn)(Ps&...), const char* name, |
550 | | - xe::cpu::ExportTag::type tags) { |
551 | | - static const auto export_entry = new cpu::Export( |
552 | | - ORDINAL, xe::cpu::Export::Type::kFunction, name, |
553 | | - tags | xe::cpu::ExportTag::kImplemented | xe::cpu::ExportTag::kLog); |
554 | | - static void (*FN)(Ps & ...) = fn; |
555 | | - struct X { |
556 | | - static void Trampoline(PPCContext* ppc_context) { |
557 | | - ++export_entry->function_data.call_count; |
558 | | - Param::Init init = { |
559 | | - ppc_context, |
560 | | - 0, |
561 | | - }; |
562 | | - // Using braces initializer instead of make_tuple because braces |
563 | | - // enforce execution order across compilers. |
564 | | - // The make_tuple order is undefined per the C++ standard and |
565 | | - // cause inconsitencies between msvc and clang. |
566 | | - std::tuple<Ps...> params = {Ps(init)...}; |
567 | | - if (export_entry->tags & xe::cpu::ExportTag::kLog && |
568 | | - (!(export_entry->tags & xe::cpu::ExportTag::kHighFrequency) || |
569 | | - cvars::log_high_frequency_kernel_calls)) { |
570 | | - PrintKernelCall(export_entry, params); |
571 | | - } |
572 | | - KernelTrampoline(FN, std::forward<std::tuple<Ps...>>(params), |
573 | | - std::make_index_sequence<sizeof...(Ps)>()); |
574 | | - } |
575 | | - }; |
576 | | - export_entry->function_data.trampoline = &X::Trampoline; |
577 | | - return export_entry; |
578 | | -} |
579 | | - |
580 | 554 | } // namespace shim |
581 | 555 |
|
582 | 556 | using xe::cpu::ExportTag; |
|
0 commit comments