diff --git a/Utilities/BEType.h b/Utilities/BEType.h index ba2cb3a0da..06388052f4 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -383,19 +383,28 @@ template struct se_storage { using type = u16; - [[deprecated]] static constexpr u16 swap(u16 src) // for reference + [[deprecated]] static constexpr u16 _swap(u16 src) // for reference { return (src >> 8) | (src << 8); } + static inline u16 swap(u16 src) + { +#if defined(__GNUG__) + return __builtin_bswap16(src); +#else + return _byteswap_ushort(src); +#endif + } + static inline u16 to(const T& src) { - return _byteswap_ushort(reinterpret_cast(src)); + return swap(reinterpret_cast(src)); } static inline T from(u16 src) { - const u16 result = _byteswap_ushort(src); + const u16 result = swap(src); return reinterpret_cast(result); } }; @@ -404,19 +413,28 @@ template struct se_storage { using type = u32; - [[deprecated]] static constexpr u32 swap(u32 src) // for reference + [[deprecated]] static constexpr u32 _swap(u32 src) // for reference { return (src >> 24) | (src << 24) | ((src >> 8) & 0x0000ff00) | ((src << 8) & 0x00ff0000); } + static inline u32 swap(u32 src) + { +#if defined(__GNUG__) + return __builtin_bswap32(src); +#else + return _byteswap_ulong(src); +#endif + } + static inline u32 to(const T& src) { - return _byteswap_ulong(reinterpret_cast(src)); + return swap(reinterpret_cast(src)); } static inline T from(u32 src) { - const u32 result = _byteswap_ulong(src); + const u32 result = swap(src); return reinterpret_cast(result); } }; @@ -425,7 +443,7 @@ template struct se_storage { using type = u64; - [[deprecated]] static constexpr u64 swap(u64 src) // for reference + [[deprecated]] static constexpr u64 _swap(u64 src) // for reference { return (src >> 56) | (src << 56) | ((src >> 40) & 0x000000000000ff00) | @@ -436,14 +454,23 @@ template struct se_storage ((src << 40) & 0x00ff000000000000); } + static inline u64 swap(u64 src) + { +#if defined(__GNUG__) + return __builtin_bswap64(src); +#else + return _byteswap_uint64(src); +#endif + } + static inline u64 to(const T& src) { - return _byteswap_uint64(reinterpret_cast(src)); + return swap(reinterpret_cast(src)); } static inline T from(u64 src) { - const u64 result = _byteswap_uint64(src); + const u64 result = swap(src); return reinterpret_cast(result); } }; diff --git a/Utilities/GNU.h b/Utilities/GNU.h index a54ac15a4f..5836d1b636 100644 --- a/Utilities/GNU.h +++ b/Utilities/GNU.h @@ -40,20 +40,8 @@ #endif #define _fpclass(x) std::fpclassify(x) -#define _byteswap_ushort(x) __builtin_bswap16(x) -#define _byteswap_uint64(x) __builtin_bswap64(x) #define INFINITE 0xFFFFFFFF -#if !defined(__MINGW32__) -#define _byteswap_ulong(x) __builtin_bswap32(x) -#else -inline std::uint32_t _byteswap_ulong(std::uint32_t value) -{ - __asm__("bswap %0" : "+r"(value)); - return value; -} -#endif - #ifdef __APPLE__ // XXX only supports a single timer diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 8afac01586..9d19e679ae 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -868,7 +868,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) case X64OP_LOAD: { u32 value; - if (is_writing || !thread->read_reg(addr, value) || !put_x64_reg_value(context, reg, d_size, _byteswap_ulong(value))) + if (is_writing || !thread->read_reg(addr, value) || !put_x64_reg_value(context, reg, d_size, se_storage::swap(value))) { return false; } @@ -878,7 +878,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) case X64OP_STORE: { u64 reg_value; - if (!is_writing || !get_x64_reg_value(context, reg, d_size, i_size, reg_value) || !thread->write_reg(addr, _byteswap_ulong((u32)reg_value))) + if (!is_writing || !get_x64_reg_value(context, reg, d_size, i_size, reg_value) || !thread->write_reg(addr, se_storage::swap((u32)reg_value))) { return false; } diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 75d853731e..85337df632 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -30,7 +30,7 @@ if(NOT MSVC) if($ENV{CI}) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O1") # fix for travis gcc OoM crash. Might be fixed with the move to containers. endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fexceptions -w") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fexceptions") add_compile_options(-msse -msse2 -mcx16 -mssse3) if(WIN32) add_compile_options(-municode -static -mwindows) @@ -118,7 +118,11 @@ if(WIN32) include_directories(BEFORE "${RPCS3_SRC_DIR}/../minidx12/Include") endif() -if(LLVM_FOUND) +if(NOT LLVM_FOUND) + Message("LLVM not found! LLVM 3.6 is required. RPCS3 will be compiled without LLVM support.") +elseif(${LLVM_PACKAGE_VERSION} VERSION_LESS "3.6" OR ${LLVM_PACKAGE_VERSION} VERSION_EQUAL "3.7" OR ${LLVM_PACKAGE_VERSION} VERSION_GREATER "3.7") + Message("LLVM ${LLVM_PACKAGE_VERSION} is not supported! LLVM 3.6 is required. RPCS3 will be compiled without LLVM support.") +else() add_definitions(${LLVM_DEFINITIONS}) add_definitions(-DLLVM_AVAILABLE) if (CMAKE_BUILD_TYPE STREQUAL "Release") diff --git a/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp b/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp index 3d8f6bc77e..076239720d 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp @@ -3690,7 +3690,7 @@ void ARMv7_instrs::REV(ARMv7Context& context, const ARMv7Code code, const ARMv7_ if (ConditionPassed(context, cond)) { - context.write_gpr(d, _byteswap_ulong(context.read_gpr(m)), type == T1 ? 2 : 4); + context.write_gpr(d, se_storage::swap(context.read_gpr(m)), type == T1 ? 2 : 4); } } diff --git a/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp b/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp index 94c4903c8a..1bfabf207c 100644 --- a/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp @@ -227,7 +227,7 @@ void CgBinaryDisasm::TaskFP() assert((m_buffer_size - m_offset) % sizeof(u32) == 0); for (u32 i = 0; i < (m_buffer_size - m_offset) / sizeof(u32); i++) { - data[i] = _byteswap_ulong(data[i]); // WTF, cannot use be_t<> there? + data[i] = se_storage::swap(data[i]); // WTF, cannot use be_t<> there? } enum diff --git a/rpcs3/Emu/RSX/CgBinaryProgram.h b/rpcs3/Emu/RSX/CgBinaryProgram.h index 10e2ac4fad..80c2a92dd2 100644 --- a/rpcs3/Emu/RSX/CgBinaryProgram.h +++ b/rpcs3/Emu/RSX/CgBinaryProgram.h @@ -365,7 +365,7 @@ public: assert((m_buffer_size - m_offset) % sizeof(u32) == 0); for (u32 i = 0; i < (m_buffer_size - m_offset) / sizeof(u32); i++) { - vdata[i] = _byteswap_ulong(vdata[i]); // WTF, cannot use be_t<> there? + vdata[i] = se_storage::swap(vdata[i]); // WTF, cannot use be_t<> there? } for (u32 i = 0; i < prog.ucodeSize / sizeof(u32); i++) diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp index 3269f41c63..8636c5dca6 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp @@ -405,7 +405,7 @@ namespace u32 *casted_dest = (u32*)((char*)dest + row * dst_pitch); u32 *casted_src = (u32*)((char*)mapped_buffer + row * src_pitch); for (unsigned col = 0; col < src_pitch / 4; col++) - *casted_dest++ = _byteswap_ulong(*casted_src++); + *casted_dest++ = se_storage::swap(*casted_src++); } readback_heap.m_heap->Unmap(0, nullptr); } diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 5bc710b9a7..768fb22d75 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -784,7 +784,8 @@ namespace rsx bind_cpu_only(); //NV308A - bind_range(); + bind_range(); + bind_range(); //NV3089 bind(); diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 12799ecd8a..9b3dea4c2a 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -7,6 +7,7 @@ #endif #define NOMINMAX +#define __STDC_CONSTANT_MACROS #if defined(MSVC_CRT_MEMLEAK_DETECTION) && defined(_DEBUG) && !defined(DBG_NEW) #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )