[Scummvm-git-logs] scummvm master -> 34057b773eef9969af7bc2b38aee645dc43e5f68
sev-
noreply at scummvm.org
Sat Jul 2 10:41:25 UTC 2022
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
56986e337c COMMON: Use compiler intrinsics in SWAP_BYTES_16 when available
34057b773e COMMON: Remove the MIPS byteswap functions
Commit: 56986e337c72fbee8d29b48e8643285076b275b3
https://github.com/scummvm/scummvm/commit/56986e337c72fbee8d29b48e8643285076b275b3
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-07-02T12:41:22+02:00
Commit Message:
COMMON: Use compiler intrinsics in SWAP_BYTES_16 when available
Changed paths:
common/endian.h
diff --git a/common/endian.h b/common/endian.h
index 0ad9b467ac3..d5f1543320c 100644
--- a/common/endian.h
+++ b/common/endian.h
@@ -106,6 +106,20 @@
return result;
}
}
+
+// Test for GCC-compatible
+#elif GCC_ATLEAST(4, 8) || defined(__clang__)
+
+ FORCEINLINE uint16 SWAP_BYTES_16(uint16 a) {
+ return __builtin_bswap16(a);
+ }
+
+#elif defined(_MSC_VER)
+
+ FORCEINLINE uint16 SWAP_BYTES_16(uint16 a) {
+ return _byteswap_ushort(a);
+ }
+
#else
inline uint16 SWAP_BYTES_16(const uint16 a) {
Commit: 34057b773eef9969af7bc2b38aee645dc43e5f68
https://github.com/scummvm/scummvm/commit/34057b773eef9969af7bc2b38aee645dc43e5f68
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-07-02T12:41:22+02:00
Commit Message:
COMMON: Remove the MIPS byteswap functions
Changed paths:
common/endian.h
diff --git a/common/endian.h b/common/endian.h
index d5f1543320c..9208fd0ce09 100644
--- a/common/endian.h
+++ b/common/endian.h
@@ -92,23 +92,8 @@
* and vice versa.
*/
-// compilerspecific variants come first, fallback last
-
-// Test for GCC and if the target has the MIPS rel.2 instructions (we know the psp does)
-#if defined(__GNUC__) && (defined(__psp__) || defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2))
-
- FORCEINLINE uint16 SWAP_BYTES_16(const uint16 a) {
- if (__builtin_constant_p(a)) {
- return SWAP_CONSTANT_16(a);
- } else {
- uint16 result;
- __asm__ ("wsbh %0,%1" : "=r" (result) : "r" (a));
- return result;
- }
- }
-
-// Test for GCC-compatible
-#elif GCC_ATLEAST(4, 8) || defined(__clang__)
+// compiler-specific variants come first, fallback last
+#if GCC_ATLEAST(4, 8) || defined(__clang__)
FORCEINLINE uint16 SWAP_BYTES_16(uint16 a) {
return __builtin_bswap16(a);
@@ -134,29 +119,8 @@
* and vice versa.
*/
-// machine/compiler-specific variants come first, fallback last
-
-// Test for GCC and if the target has the MIPS rel.2 instructions (we know the psp does)
-#if defined(__GNUC__) && (defined(__psp__) || defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2))
-
- FORCEINLINE uint32 SWAP_BYTES_32(const uint32 a) {
- if (__builtin_constant_p(a)) {
- return SWAP_CONSTANT_32(a);
- } else {
- uint32 result;
-# if defined(__psp__)
- // use special allegrex instruction
- __asm__ ("wsbw %0,%1" : "=r" (result) : "r" (a));
-# else
- __asm__ ("wsbh %0,%1\n"
- "rotr %0,%0,16" : "=r" (result) : "r" (a));
-# endif
- return result;
- }
- }
-
-// Test for GCC-compatible
-#elif defined(__GNUC__)
+// compiler-specific variants come first, fallback last
+#if defined(__GNUC__)
FORCEINLINE uint32 SWAP_BYTES_32(uint32 a) {
return __builtin_bswap32(a);
@@ -183,26 +147,8 @@
* and vice versa.
*/
-// machine/compiler-specific variants come first, fallback last
-
-// Test for GCC and if the target has the MIPS rel.2 instructions (we know the psp does)
-//
-#if defined(__GNUC__) && (defined(__psp__) || defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2))
-
- FORCEINLINE uint64 SWAP_BYTES_64(const uint64 a) {
- if (__builtin_constant_p(a)) {
- return SWAP_CONSTANT_64(a);
- } else {
- uint32 low = (uint32)a, high = (uint32)(a >> 32);
- low = SWAP_BYTES_32(low);
- high = SWAP_BYTES_32(high);
-
- return (((uint64)low) << 32) | high;
- }
- }
-
-// Test for GCC-compatible
-#elif defined(__GNUC__)
+// compiler-specific variants come first, fallback last
+#if defined(__GNUC__)
FORCEINLINE uint64 SWAP_BYTES_64(uint64 a) {
return __builtin_bswap64(a);
More information about the Scummvm-git-logs
mailing list