diff --git a/Utilities/File.cpp b/Utilities/File.cpp index 8cddd416dd..92ddcb82ce 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -1,7 +1,6 @@ #include "File.h" #include "mutex.h" #include "StrFmt.h" -#include "BEType.h" #include "Crypto/sha1.h" #include diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index b31695df81..05bb310fa7 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -1,8 +1,9 @@ #include "StrFmt.h" -#include "BEType.h" #include "StrUtil.h" #include "cfmt.h" +#include "util/endian.hpp" #include "util/logs.hpp" +#include "util/v128.hpp" #include #include diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 3b274c934c..0fbf2b6316 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -119,6 +119,17 @@ struct fmt_unveil } }; +template +struct fmt_unveil, void> +{ + using type = typename fmt_unveil::type; + + static inline auto get(const se_t& arg) + { + return fmt_unveil::get(arg); + } +}; + // String type format provider, also type classifier (format() called if an argument is formatted as "%s") template struct fmt_class_string diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index cb9e073587..0c65698760 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1296,7 +1296,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no if (op != X64OP_LOAD_BE) { - value = se_storage::swap(value); + value = stx::se_storage::swap(value); } if (op == X64OP_LOAD_CMP) @@ -1338,7 +1338,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no } u32 val32 = static_cast(reg_value); - if (!thread->write_reg(addr, op == X64OP_STORE ? se_storage::swap(val32) : val32)) + if (!thread->write_reg(addr, op == X64OP_STORE ? stx::se_storage::swap(val32) : val32)) { return false; } diff --git a/Utilities/bin_patch.cpp b/Utilities/bin_patch.cpp index da11d9bf4d..e6705d44ac 100644 --- a/Utilities/bin_patch.cpp +++ b/Utilities/bin_patch.cpp @@ -4,6 +4,9 @@ #include "version.h" #include "Emu/System.h" +#include "util/types.hpp" +#include "util/endian.hpp" + LOG_CHANNEL(patch_log, "PAT"); namespace config_key diff --git a/Utilities/bin_patch.h b/Utilities/bin_patch.h index 688bdf31b5..12f384eea1 100644 --- a/Utilities/bin_patch.h +++ b/Utilities/bin_patch.h @@ -1,10 +1,10 @@ #pragma once -#include "BEType.h" #include #include #include +#include "util/types.hpp" #include "util/yaml.hpp" namespace patch_key @@ -53,7 +53,7 @@ public: f64 double_value; } value { 0 }; }; - + using patch_app_versions = std::unordered_map; using patch_serials = std::unordered_map; using patch_titles = std::unordered_map; diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp index 513ef7102e..1e6cd89eb6 100644 --- a/rpcs3/Crypto/unedat.cpp +++ b/rpcs3/Crypto/unedat.cpp @@ -5,6 +5,8 @@ #include "Utilities/mutex.h" #include +#include "util/v128.hpp" + LOG_CHANNEL(edat_log, "EDAT"); // Static variables are being modified concurrently in ec.cpp, for now use a mutex diff --git a/rpcs3/Crypto/unedat.h b/rpcs3/Crypto/unedat.h index cb98db0c69..e4e9a5a91d 100644 --- a/rpcs3/Crypto/unedat.h +++ b/rpcs3/Crypto/unedat.h @@ -4,9 +4,10 @@ #include "utils.h" -#include "Utilities/BEType.h" #include "Utilities/File.h" +#include "util/v128.hpp" + constexpr u32 SDAT_FLAG = 0x01000000; constexpr u32 EDAT_COMPRESSED_FLAG = 0x00000001; constexpr u32 EDAT_FLAG_0x02 = 0x00000002; diff --git a/rpcs3/Crypto/unpkg.h b/rpcs3/Crypto/unpkg.h index 933e65bc72..91b4dc5f98 100644 --- a/rpcs3/Crypto/unpkg.h +++ b/rpcs3/Crypto/unpkg.h @@ -1,6 +1,5 @@ #pragma once -#include "Utilities/BEType.h" #include #include @@ -96,7 +95,7 @@ struct PKGExtHeader be_t ext_hdr_size; // Extended header size. ex: 0x40 be_t ext_data_size; // ex: 0x180 be_t main_and_ext_headers_hmac_offset; // ex: 0x100 - be_t metadata_header_hmac_offset; // ex: 0x360, 0x390, 0x490 + be_t metadata_header_hmac_offset; // ex: 0x360, 0x390, 0x490 be_t tail_offset; // tail size seams to be always 0x1A0 be_t padding1; be_t pkg_key_id; // Id of the AES key used for decryption. PSP = 0x1, PSVita = 0xC0000002, PSM = 0xC0000004 diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index 7807fb253e..ec54710210 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -3,13 +3,14 @@ #include "sha1.h" #include "utils.h" #include "unself.h" -#include "Utilities/BEType.h" #include "Emu/VFS.h" #include "Emu/System.h" #include #include +#include "util/v128.hpp" + inline u8 Read8(const fs::file& f) { u8 ret; diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index abfa0089b4..9cc878b31e 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -26,7 +26,6 @@ #include "util/types.hpp" #include "Utilities/StrFmt.h" -#include "Utilities/BEType.h" #include "Utilities/BitField.h" #include "util/logs.hpp" #include "Utilities/JIT.h" @@ -38,6 +37,8 @@ #include #include +#include "util/v128.hpp" + enum class i2 : char { }; diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.h b/rpcs3/Emu/Cell/Modules/cellAudio.h index bfe5786769..b515151591 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.h +++ b/rpcs3/Emu/Cell/Modules/cellAudio.h @@ -174,7 +174,7 @@ struct audio_port return addr.addr() + position(offset) * buf_size(); } - to_be_t* get_vm_ptr(s32 offset = 0) const + be_t* get_vm_ptr(s32 offset = 0) const { return vm::_ptr(buf_addr(offset)); } diff --git a/rpcs3/Emu/Cell/Modules/cellAudioIn.h b/rpcs3/Emu/Cell/Modules/cellAudioIn.h index 14b858ed35..2dfc77bf16 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudioIn.h +++ b/rpcs3/Emu/Cell/Modules/cellAudioIn.h @@ -1,6 +1,7 @@ #pragma once -#include "Utilities/BEType.h" +#include "util/types.hpp" +#include "util/endian.hpp" // Error codes enum CellAudioInError diff --git a/rpcs3/Emu/Cell/Modules/cellGem.h b/rpcs3/Emu/Cell/Modules/cellGem.h index 4ab64d95d9..34fd3005cb 100644 --- a/rpcs3/Emu/Cell/Modules/cellGem.h +++ b/rpcs3/Emu/Cell/Modules/cellGem.h @@ -1,7 +1,5 @@ #pragma once -#include "Utilities/BEType.h" - static const float CELL_GEM_SPHERE_RADIUS_MM = 22.5f; // Error codes diff --git a/rpcs3/Emu/Cell/Modules/cellJpgDec.h b/rpcs3/Emu/Cell/Modules/cellJpgDec.h index ca7dc1f6a5..f00b181d03 100644 --- a/rpcs3/Emu/Cell/Modules/cellJpgDec.h +++ b/rpcs3/Emu/Cell/Modules/cellJpgDec.h @@ -1,7 +1,5 @@ #pragma once -#include "Utilities/BEType.h" - //Return Codes enum CellJpgDecError : u32 { diff --git a/rpcs3/Emu/Cell/Modules/cellKb.h b/rpcs3/Emu/Cell/Modules/cellKb.h index adf42148ad..b2911edfdc 100644 --- a/rpcs3/Emu/Cell/Modules/cellKb.h +++ b/rpcs3/Emu/Cell/Modules/cellKb.h @@ -1,6 +1,5 @@ #pragma once -#include "Utilities/BEType.h" #include "Emu/Io/Keyboard.h" enum CellKbError : u32 diff --git a/rpcs3/Emu/Cell/Modules/cellMic.h b/rpcs3/Emu/Cell/Modules/cellMic.h index 92d0e50a43..f3a2cd918a 100644 --- a/rpcs3/Emu/Cell/Modules/cellMic.h +++ b/rpcs3/Emu/Cell/Modules/cellMic.h @@ -1,6 +1,5 @@ #pragma once -#include "Utilities/BEType.h" #include "Utilities/Thread.h" #include "3rdparty/OpenAL/include/alext.h" diff --git a/rpcs3/Emu/Cell/Modules/cellMouse.h b/rpcs3/Emu/Cell/Modules/cellMouse.h index f17cadb4d1..253b4eba7e 100644 --- a/rpcs3/Emu/Cell/Modules/cellMouse.h +++ b/rpcs3/Emu/Cell/Modules/cellMouse.h @@ -1,7 +1,5 @@ #pragma once -#include "Utilities/BEType.h" - enum CellMouseError : u32 { CELL_MOUSE_ERROR_FATAL = 0x80121201, diff --git a/rpcs3/Emu/Cell/Modules/cellPad.h b/rpcs3/Emu/Cell/Modules/cellPad.h index 5b81670696..f477b46c15 100644 --- a/rpcs3/Emu/Cell/Modules/cellPad.h +++ b/rpcs3/Emu/Cell/Modules/cellPad.h @@ -1,6 +1,5 @@ #pragma once -#include "Utilities/BEType.h" #include enum CellPadError : u32 diff --git a/rpcs3/Emu/Cell/Modules/cellResc.h b/rpcs3/Emu/Cell/Modules/cellResc.h index 1b3559a624..99e3ec4260 100644 --- a/rpcs3/Emu/Cell/Modules/cellResc.h +++ b/rpcs3/Emu/Cell/Modules/cellResc.h @@ -1,7 +1,5 @@ #pragma once -#include "Utilities/BEType.h" - enum CellRescError : u32 { CELL_RESC_ERROR_NOT_INITIALIZED = 0x80210301, diff --git a/rpcs3/Emu/Cell/Modules/cellRtc.h b/rpcs3/Emu/Cell/Modules/cellRtc.h index d40af85cfb..39539e643c 100644 --- a/rpcs3/Emu/Cell/Modules/cellRtc.h +++ b/rpcs3/Emu/Cell/Modules/cellRtc.h @@ -1,6 +1,5 @@ #pragma once -#include "Utilities/BEType.h" #include "Emu/Memory/vm_ptr.h" #include "Emu/Cell/ErrorCodes.h" diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.h b/rpcs3/Emu/Cell/Modules/cellSaveData.h index 6c4e772019..2cddfc43ae 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.h +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.h @@ -3,6 +3,8 @@ #include "stdafx.h" #include +#include "util/v128.hpp" + // Return codes enum CellSaveDataError : u32 { diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp index 846b284211..f79e8f0bec 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp @@ -15,6 +15,8 @@ #include "sysPrxForUser.h" #include "cellSpurs.h" +#include "util/v128.hpp" + LOG_CHANNEL(cellSpurs); template <> diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.h b/rpcs3/Emu/Cell/Modules/cellSpurs.h index ecc3d1d219..051042103c 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.h +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.h @@ -2,7 +2,7 @@ #include "cellSync.h" - +#include "util/v128.hpp" struct CellSpurs; struct CellSpursTaskset; diff --git a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp index 234fc039c9..7e5f43afc6 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp @@ -13,6 +13,8 @@ #include #include +#include "util/v128.hpp" + LOG_CHANNEL(cellSpurs); //---------------------------------------------------------------------------- diff --git a/rpcs3/Emu/Cell/Modules/cellSubDisplay.h b/rpcs3/Emu/Cell/Modules/cellSubDisplay.h index 182ed31690..feff510f77 100644 --- a/rpcs3/Emu/Cell/Modules/cellSubDisplay.h +++ b/rpcs3/Emu/Cell/Modules/cellSubDisplay.h @@ -1,7 +1,5 @@ #pragma once -#include "Utilities/BEType.h" - // Return Codes enum CellSubDisplayError : u32 { diff --git a/rpcs3/Emu/Cell/Modules/cellVdec.h b/rpcs3/Emu/Cell/Modules/cellVdec.h index 0a2780e4d7..5f00f83ead 100644 --- a/rpcs3/Emu/Cell/Modules/cellVdec.h +++ b/rpcs3/Emu/Cell/Modules/cellVdec.h @@ -1,7 +1,5 @@ #pragma once -#include "Utilities/BEType.h" - // Error Codes enum CellVdecError : u32 { diff --git a/rpcs3/Emu/Cell/Modules/cellVpost.h b/rpcs3/Emu/Cell/Modules/cellVpost.h index 4d331cdc98..00b14adeb8 100644 --- a/rpcs3/Emu/Cell/Modules/cellVpost.h +++ b/rpcs3/Emu/Cell/Modules/cellVpost.h @@ -18,8 +18,6 @@ extern "C" #pragma GCC diagnostic pop #endif -#include "Utilities/BEType.h" - // Error Codes enum CellVpostError : u32 { diff --git a/rpcs3/Emu/Cell/Modules/libsynth2.h b/rpcs3/Emu/Cell/Modules/libsynth2.h index 3867bbc6dd..573beff6e3 100644 --- a/rpcs3/Emu/Cell/Modules/libsynth2.h +++ b/rpcs3/Emu/Cell/Modules/libsynth2.h @@ -1,7 +1,5 @@ #pragma once -#include "Utilities/BEType.h" - // Error Codes enum CellSoundSynth2Error : u32 { diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index 47778c9062..b7b1c9bd99 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -15,6 +15,8 @@ #include "Emu/NP/np_handler.h" #include "Emu/NP/np_contexts.h" +#include "util/v128.hpp" + LOG_CHANNEL(sceNp); template <> diff --git a/rpcs3/Emu/Cell/Modules/sceNp.h b/rpcs3/Emu/Cell/Modules/sceNp.h index cca520bd00..6006e3f82f 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.h +++ b/rpcs3/Emu/Cell/Modules/sceNp.h @@ -3,8 +3,6 @@ #include "cellRtc.h" #include "Emu/Cell/ErrorCodes.h" -#include "Utilities/BEType.h" - error_code sceNpInit(u32 poolsize, vm::ptr poolptr); error_code sceNpTerm(); diff --git a/rpcs3/Emu/Cell/Modules/sceNpClans.h b/rpcs3/Emu/Cell/Modules/sceNpClans.h index 02ad1f693e..9e5c56c054 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpClans.h +++ b/rpcs3/Emu/Cell/Modules/sceNpClans.h @@ -2,8 +2,6 @@ #include "sceNp.h" -#include "Utilities/BEType.h" - // Return codes enum SceNpClansError : u32 { diff --git a/rpcs3/Emu/Cell/Modules/sceNpCommerce2.h b/rpcs3/Emu/Cell/Modules/sceNpCommerce2.h index 69bba37044..5975667748 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpCommerce2.h +++ b/rpcs3/Emu/Cell/Modules/sceNpCommerce2.h @@ -2,8 +2,6 @@ #include "cellRtc.h" -#include "Utilities/BEType.h" - // Return codes enum SceNpCommerce2Error { diff --git a/rpcs3/Emu/Cell/Modules/sceNpTus.h b/rpcs3/Emu/Cell/Modules/sceNpTus.h index 67ca89babf..5bf95057c2 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTus.h +++ b/rpcs3/Emu/Cell/Modules/sceNpTus.h @@ -1,7 +1,5 @@ #pragma once -#include "Utilities/BEType.h" - #include "cellRtc.h" #include "sceNp.h" diff --git a/rpcs3/Emu/Cell/PPUAnalyser.h b/rpcs3/Emu/Cell/PPUAnalyser.h index 2025743910..5801220d55 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.h +++ b/rpcs3/Emu/Cell/PPUAnalyser.h @@ -3,9 +3,10 @@ #include #include #include +#include "util/types.hpp" +#include "util/endian.hpp" #include "Utilities/bit_set.h" -#include "Utilities/BEType.h" #include "PPUOpcodes.h" // PPU Function Attributes diff --git a/rpcs3/Emu/Cell/PPUCallback.h b/rpcs3/Emu/Cell/PPUCallback.h index 63bedab5af..e9919bca56 100644 --- a/rpcs3/Emu/Cell/PPUCallback.h +++ b/rpcs3/Emu/Cell/PPUCallback.h @@ -2,6 +2,8 @@ #include "Emu/Cell/PPUThread.h" +#include "util/v128.hpp" + struct ppu_func_opd_t; namespace ppu_cb_detail diff --git a/rpcs3/Emu/Cell/PPUFunction.h b/rpcs3/Emu/Cell/PPUFunction.h index 531f780071..b9d1afcd2f 100644 --- a/rpcs3/Emu/Cell/PPUFunction.h +++ b/rpcs3/Emu/Cell/PPUFunction.h @@ -2,6 +2,8 @@ #include "PPUThread.h" +#include "util/v128.hpp" + using ppu_function_t = bool(*)(ppu_thread&); // BIND_FUNC macro "converts" any appropriate HLE function to ppu_function_t, binding it to PPU thread context. diff --git a/rpcs3/Emu/Cell/PPUInterpreter.cpp b/rpcs3/Emu/Cell/PPUInterpreter.cpp index d578c140ec..41343c439d 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/PPUInterpreter.cpp @@ -11,6 +11,7 @@ #include #include "util/asm.hpp" +#include "util/v128.hpp" #if !defined(_MSC_VER) && defined(__clang__) #pragma GCC diagnostic push diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 83a2c42631..98b4de0ca5 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -66,6 +66,7 @@ #include #include "util/asm.hpp" #include "util/vm.hpp" +#include "util/v128.hpp" const bool s_use_ssse3 = utils::has_ssse3(); @@ -1240,8 +1241,8 @@ static T ppu_load_acquire_reservation(ppu_thread& ppu, u32 addr) const auto inst = vm::_ptr>(cia); // Search for STWCX or STDCX nearby (LDARX-STWCX and LWARX-STDCX loops will use accurate 128-byte reservations) - constexpr u32 store_cond = se_storage::swap(sizeof(T) == 8 ? 0x7C00012D : 0x7C0001AD); - constexpr u32 mask = se_storage::swap(0xFC0007FF); + constexpr u32 store_cond = stx::se_storage::swap(sizeof(T) == 8 ? 0x7C00012D : 0x7C0001AD); + constexpr u32 mask = stx::se_storage::swap(0xFC0007FF); const auto store_vec = v128::from32p(store_cond); const auto mask_vec = v128::from32p(mask); diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index e1d148c1a8..d25bba964c 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -4,6 +4,8 @@ #include "../Memory/vm_ptr.h" #include "Utilities/lockless.h" +#include "util/v128.hpp" + LOG_CHANNEL(ppu_log, "PPU"); enum class ppu_cmd : u32 diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index 6d5f581b3e..3576418ab0 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -5,7 +5,10 @@ #include "PPUThread.h" #include "PPUInterpreter.h" +#include "util/types.hpp" +#include "util/endian.hpp" #include "util/logs.hpp" +#include "util/v128.hpp" #include using namespace llvm; diff --git a/rpcs3/Emu/Cell/PPUTranslator.h b/rpcs3/Emu/Cell/PPUTranslator.h index 6c821787f4..6e0490f491 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.h +++ b/rpcs3/Emu/Cell/PPUTranslator.h @@ -6,6 +6,8 @@ #include "PPUOpcodes.h" #include "PPUAnalyser.h" +#include "util/types.hpp" + class PPUTranslator final : public cpu_translator { // PPU Module diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index 3e314edc32..41901313f0 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -12,6 +12,7 @@ #include "Crypto/sha1.h" #include "util/asm.hpp" +#include "util/v128.hpp" #include #include diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.h b/rpcs3/Emu/Cell/SPUASMJITRecompiler.h index 9f837b593c..1ed1278333 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.h +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.h @@ -5,6 +5,8 @@ #include +#include "util/v128.hpp" + // SPU ASMJIT Recompiler class spu_recompiler : public spu_recompiler_base { diff --git a/rpcs3/Emu/Cell/SPUDisAsm.cpp b/rpcs3/Emu/Cell/SPUDisAsm.cpp index 9413e0f20a..81a9532674 100644 --- a/rpcs3/Emu/Cell/SPUDisAsm.cpp +++ b/rpcs3/Emu/Cell/SPUDisAsm.cpp @@ -7,6 +7,8 @@ const spu_decoder s_spu_disasm; const spu_decoder s_spu_itype; const spu_decoder s_spu_iflag; +#include "util/v128.hpp" + u32 SPUDisAsm::disasm(u32 pc) { const u32 op = *reinterpret_cast*>(offset + pc); diff --git a/rpcs3/Emu/Cell/SPUDisAsm.h b/rpcs3/Emu/Cell/SPUDisAsm.h index 1ad1df42f4..5047bd7dbf 100644 --- a/rpcs3/Emu/Cell/SPUDisAsm.h +++ b/rpcs3/Emu/Cell/SPUDisAsm.h @@ -3,6 +3,8 @@ #include "PPCDisAsm.h" #include "SPUOpcodes.h" +#include "util/v128.hpp" + static constexpr const char* spu_reg_name[128] = { "lr", "sp", "r2", "r3", "r4", "r5", "r6", "r7", diff --git a/rpcs3/Emu/Cell/SPUInterpreter.cpp b/rpcs3/Emu/Cell/SPUInterpreter.cpp index 2345275076..8bc1ed1060 100644 --- a/rpcs3/Emu/Cell/SPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/SPUInterpreter.cpp @@ -7,6 +7,7 @@ #include "Emu/Cell/Common.h" #include "util/asm.hpp" +#include "util/v128.hpp" #include #include diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 17d64c9c77..a69c610094 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -18,6 +18,8 @@ #include #include +#include "util/v128.hpp" + extern atomic_t g_progr; extern atomic_t g_progr_ptotal; extern atomic_t g_progr_pdone; diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 3f3c4da698..bdf2d05aa2 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -31,6 +31,7 @@ #include #include "util/vm.hpp" #include "util/asm.hpp" +#include "util/v128.hpp" using spu_rdata_t = decltype(spu_thread::rdata); diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index c1aea8c324..97a5aa14b2 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -4,9 +4,10 @@ #include "Emu/Cell/SPUInterpreter.h" #include "Emu/Memory/vm.h" #include "MFC.h" -#include "Utilities/BEType.h" #include +#include "util/v128.hpp" +#include "util/to_endian.hpp" LOG_CHANNEL(spu_log, "SPU"); diff --git a/rpcs3/Emu/Memory/vm.h b/rpcs3/Emu/Memory/vm.h index c257fb0941..cd4ebcac37 100644 --- a/rpcs3/Emu/Memory/vm.h +++ b/rpcs3/Emu/Memory/vm.h @@ -4,7 +4,8 @@ #include #include "util/types.hpp" #include "Utilities/StrFmt.h" -#include "Utilities/BEType.h" + +#include "util/to_endian.hpp" namespace utils { diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index c9c49998de..6d0c08c68b 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -1,7 +1,7 @@ #pragma once #include "util/types.hpp" -#include "Utilities/BEType.h" +#include "util/to_endian.hpp" #include "vm.h" class ppu_thread; diff --git a/rpcs3/Emu/Memory/vm_ref.h b/rpcs3/Emu/Memory/vm_ref.h index 8d4a621a72..b60e2584c5 100644 --- a/rpcs3/Emu/Memory/vm_ref.h +++ b/rpcs3/Emu/Memory/vm_ref.h @@ -1,9 +1,10 @@ #pragma once #include -#include "Utilities/BEType.h" #include "vm.h" +#include "util/to_endian.hpp" + namespace vm { template diff --git a/rpcs3/Emu/Memory/vm_var.h b/rpcs3/Emu/Memory/vm_var.h index ab8e24a7a5..9dde20df2e 100644 --- a/rpcs3/Emu/Memory/vm_var.h +++ b/rpcs3/Emu/Memory/vm_var.h @@ -1,7 +1,8 @@ #pragma once #include "vm_ptr.h" -#include "Utilities/BEType.h" + +#include "util/to_endian.hpp" namespace vm { diff --git a/rpcs3/Emu/NP/rpcn_client.cpp b/rpcs3/Emu/NP/rpcn_client.cpp index 46e73fb6a6..332c57d0e9 100644 --- a/rpcs3/Emu/NP/rpcn_client.cpp +++ b/rpcs3/Emu/NP/rpcn_client.cpp @@ -7,7 +7,6 @@ #include "rpcn_client.h" #include "np_structs_extra.h" #include "Utilities/StrUtil.h" -#include "Utilities/BEType.h" #include "Utilities/Thread.h" #include "Emu/IdManager.h" #include "Emu/System.h" diff --git a/rpcs3/Emu/NP/signaling_handler.h b/rpcs3/Emu/NP/signaling_handler.h index 18a1f7e057..e05740c0f9 100644 --- a/rpcs3/Emu/NP/signaling_handler.h +++ b/rpcs3/Emu/NP/signaling_handler.h @@ -1,5 +1,4 @@ #pragma once -#include "Utilities/BEType.h" #include "Emu/Memory/vm.h" #include "Emu/Memory/vm_ptr.h" #include "Emu/Cell/Modules/sceNp.h" diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 8458a7148e..fa24fa3b91 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -4,7 +4,8 @@ #include "Utilities/sysinfo.h" #include "../RSXThread.h" -#include +#include "util/v128.hpp" +#include "util/to_endian.hpp" #define DEBUG_VERTEX_STREAMING 0 @@ -667,7 +668,7 @@ void write_vertex_array_data_to_buffer(gsl::span raw_dst_span, gsl::s u32 src_value; memcpy(&src_value, src_ptr.subspan(attribute_src_stride * i).data(), sizeof(u32)); - if (swap_endianness) src_value = se_storage::swap(src_value); + if (swap_endianness) src_value = stx::se_storage::swap(src_value); const auto& decoded_vector = decode_cmp_vector(src_value); dst_span[i * dst_stride / sizeof(u16)] = decoded_vector[0]; diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp b/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp index e60a1f2de1..3bb2a57e68 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp @@ -3,6 +3,7 @@ #include "Emu/system_config.h" #include +#include "util/v128.hpp" using namespace program_hash_util; diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index a02f1c4d93..736db5d9d6 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -519,7 +519,8 @@ - + + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index a5f9a2e3ea..0f45a6b4c8 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -1069,7 +1069,10 @@ Header Files - + + Utilities + + Utilities diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index c90ae774bc..68bead6a83 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -44,6 +44,8 @@ DYNAMIC_IMPORT("ntdll.dll", NtSetTimerResolution, NTSTATUS(ULONG DesiredResoluti #include #include +#include "util/v128.hpp" + inline std::string sstr(const QString& _in) { return _in.toStdString(); } static semaphore<> s_qt_init; diff --git a/rpcs3/rpcs3qt/cheat_manager.cpp b/rpcs3/rpcs3qt/cheat_manager.cpp index 4b36b3df6d..c6836a9585 100644 --- a/rpcs3/rpcs3qt/cheat_manager.cpp +++ b/rpcs3/rpcs3qt/cheat_manager.cpp @@ -18,6 +18,7 @@ #include "Emu/Cell/PPUFunction.h" #include "util/yaml.hpp" +#include "util/to_endian.hpp" #include "Utilities/StrUtil.h" #include "Utilities/bin_patch.h" // get_patches_path() diff --git a/rpcs3/rpcs3qt/register_editor_dialog.cpp b/rpcs3/rpcs3qt/register_editor_dialog.cpp index a46d8f8016..ecf4268579 100644 --- a/rpcs3/rpcs3qt/register_editor_dialog.cpp +++ b/rpcs3/rpcs3qt/register_editor_dialog.cpp @@ -14,6 +14,8 @@ #include #include +#include "util/v128.hpp" + constexpr auto qstr = QString::fromStdString; inline std::string sstr(const QString& _in) { return _in.toStdString(); } inline std::string sstr(const QVariant& _in) { return sstr(_in.toString()); } diff --git a/rpcs3/rpcs3qt/skylander_dialog.cpp b/rpcs3/rpcs3qt/skylander_dialog.cpp index 33eb05b378..55802a65dc 100644 --- a/rpcs3/rpcs3qt/skylander_dialog.cpp +++ b/rpcs3/rpcs3qt/skylander_dialog.cpp @@ -3,7 +3,6 @@ #include "Crypto/md5.h" #include "Crypto/aes.h" #include "skylander_dialog.h" -#include "Utilities/BEType.h" #include "Emu/Io/Skylander.h" #include diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 5f4b26c632..17e437cc32 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -14,8 +14,8 @@ #endif #include "util/types.hpp" -#include "Utilities/BEType.h" #include "util/atomic.hpp" +#include "util/endian.hpp" #include "Utilities/StrFmt.h" #include "Utilities/File.h" #include "util/logs.hpp" diff --git a/rpcs3/util/to_endian.hpp b/rpcs3/util/to_endian.hpp new file mode 100644 index 0000000000..28a8d3e397 --- /dev/null +++ b/rpcs3/util/to_endian.hpp @@ -0,0 +1,78 @@ +#pragma once + +#include "util/types.hpp" +#include "util/endian.hpp" + +union v128; + +// Type converter: converts native endianness arithmetic/enum types to appropriate se_t<> type +template +struct to_se +{ + template + struct to_se_ + { + using type = T2; + }; + + template + struct to_se_::value || std::is_enum::value>> + { + using type = std::conditional_t<(sizeof(T2) > 1), se_t, T2>; + }; + + // Convert arithmetic and enum types + using type = typename to_se_::type; +}; + +template +struct to_se +{ + using type = se_t; +}; + +template +struct to_se +{ + using type = se_t; +}; + +template +struct to_se +{ + using type = se_t; +}; + +template +struct to_se::value>> +{ + // Move const qualifier + using type = const typename to_se::type; +}; + +template +struct to_se::value && !std::is_const::value>> +{ + // Move volatile qualifier + using type = volatile typename to_se::type; +}; + +template +struct to_se +{ + // Move array qualifier + using type = typename to_se::type[]; +}; + +template +struct to_se +{ + // Move array qualifier + using type = typename to_se::type[N]; +}; + +// BE/LE aliases for to_se<> +template +using to_be_t = typename to_se::type; +template +using to_le_t = typename to_se::type; diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index d0c784cd04..9ddd2f265b 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -213,6 +213,28 @@ namespace fmt template class atomic_t; +namespace stx +{ + template + class se_t; +} + +using stx::se_t; + +// se_t<> with native endianness +template +using nse_t = se_t; + +template +using be_t = se_t; +template +using le_t = se_t; + +template +using atomic_be_t = atomic_t, Align>; +template +using atomic_le_t = atomic_t, Align>; + // Extract T::simple_type if available, remove cv qualifiers template struct simple_type_helper diff --git a/Utilities/BEType.h b/rpcs3/util/v128.hpp similarity index 74% rename from Utilities/BEType.h rename to rpcs3/util/v128.hpp index 226584f95f..6c7d5824a9 100644 --- a/Utilities/BEType.h +++ b/rpcs3/util/v128.hpp @@ -1,17 +1,9 @@ #pragma once // No BOM and only basic ASCII in this header, or a neko will die #include "util/types.hpp" -#include "util/endian.hpp" -#include #include -#if __has_include() -#include -#else -#include -#endif - -// 128-bit vector type and also se_storage<> storage type +// 128-bit vector type union alignas(16) v128 { uchar _bytes[16]; @@ -405,107 +397,3 @@ inline v128 operator~(const v128& other) { return other ^ v128::from32p(UINT32_MAX); // XOR with ones } - -using stx::se_t; -using stx::se_storage; - -// se_t<> with native endianness -template -using nse_t = se_t; - -template -using be_t = se_t; -template -using le_t = se_t; - -// Type converter: converts native endianness arithmetic/enum types to appropriate se_t<> type -template -struct to_se -{ - template - struct to_se_ - { - using type = T2; - }; - - template - struct to_se_::value || std::is_enum::value>> - { - using type = std::conditional_t<(sizeof(T2) > 1), se_t, T2>; - }; - - // Convert arithmetic and enum types - using type = typename to_se_::type; -}; - -template -struct to_se -{ - using type = se_t; -}; - -template -struct to_se -{ - using type = se_t; -}; - -template -struct to_se -{ - using type = se_t; -}; - -template -struct to_se::value>> -{ - // Move const qualifier - using type = const typename to_se::type; -}; - -template -struct to_se::value && !std::is_const::value>> -{ - // Move volatile qualifier - using type = volatile typename to_se::type; -}; - -template -struct to_se -{ - // Move array qualifier - using type = typename to_se::type[]; -}; - -template -struct to_se -{ - // Move array qualifier - using type = typename to_se::type[N]; -}; - -// BE/LE aliases for to_se<> -template -using to_be_t = typename to_se::type; -template -using to_le_t = typename to_se::type; - -// BE/LE aliases for atomic_t -template -using atomic_be_t = atomic_t, Align>; -template -using atomic_le_t = atomic_t, Align>; - -template -struct fmt_unveil, void> -{ - using type = typename fmt_unveil::type; - - static inline auto get(const se_t& arg) - { - return fmt_unveil::get(arg); - } -}; - -static_assert(be_t(1) + be_t(2) + be_t(3) == 6); -static_assert(le_t(1) + le_t(2) + le_t(3) == 6);