Compare commits

...

3 commits

Author SHA1 Message Date
Yohann MARTEL
257c34d7a3
Merge 32c2f49bec into 5a945705de 2025-07-20 10:11:39 +02:00
squidbus
5a945705de
mffs instruction should load to floating-point register. (#158) 2025-07-19 12:57:04 +03:00
Yohann Martel
32c2f49bec Fix bswap with MSVC compiler 2025-03-07 14:24:17 -05:00
2 changed files with 17 additions and 4 deletions

View file

@ -1241,7 +1241,7 @@ bool Recompiler::Recompile(
break;
case PPC_INST_MFFS:
println("\t{}.u64 = ctx.fpscr.loadFromHost();", r(insn.operands[0]));
println("\t{}.u64 = ctx.fpscr.loadFromHost();", f(insn.operands[0]));
break;
case PPC_INST_MFLR:

View file

@ -2,17 +2,30 @@
#include <cassert>
#if defined(_MSC_VER) // MSVC
#include <intrin.h>
#define BSWAP16(x) _byteswap_ushort(x)
#define BSWAP32(x) _byteswap_ulong(x)
#define BSWAP64(x) _byteswap_uint64(x)
#elif defined(__GNUC__) || defined(__clang__) // GCC or Clang
#define BSWAP16(x) __builtin_bswap16(x)
#define BSWAP32(x) __builtin_bswap32(x)
#define BSWAP64(x) __builtin_bswap64(x)
#else
#error "Unsupported compiler"
#endif
template<typename T>
inline T ByteSwap(T value)
{
if constexpr (sizeof(T) == 1)
return value;
else if constexpr (sizeof(T) == 2)
return static_cast<T>(__builtin_bswap16(static_cast<uint16_t>(value)));
return static_cast<T>(BSWAP16(static_cast<uint16_t>(value)));
else if constexpr (sizeof(T) == 4)
return static_cast<T>(__builtin_bswap32(static_cast<uint32_t>(value)));
return static_cast<T>(BSWAP32(static_cast<uint32_t>(value)));
else if constexpr (sizeof(T) == 8)
return static_cast<T>(__builtin_bswap64(static_cast<uint64_t>(value)));
return static_cast<T>(BSWAP64(static_cast<uint64_t>(value)));
assert(false && "Unexpected byte size.");
return value;