]> granicus.if.org Git - libvpx/blobdiff - vpx_util/endian_inl.h
Merge "Optimize vp9_highbd_block_error_8bit assembly."
[libvpx] / vpx_util / endian_inl.h
index 91753a67f6980bcb9a1d4c348fe61efa0b18facc..37bdce1ccd96e558caa76e739a85ae3b3623c546 100644 (file)
 # define LOCAL_GCC_PREREQ(maj, min) 0
 #endif
 
-#ifdef __clang__
-# define LOCAL_CLANG_VERSION ((__clang_major__ << 8) | __clang_minor__)
-# define LOCAL_CLANG_PREREQ(maj, min) \
-    (LOCAL_CLANG_VERSION >= (((maj) << 8) | (min)))
-#else
-# define LOCAL_CLANG_VERSION 0
-# define LOCAL_CLANG_PREREQ(maj, min) 0
-#endif  // __clang__
+// handle clang compatibility
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
 
 // some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__)
 #if !defined(WORDS_BIGENDIAN) && \
 #if defined(WORDS_BIGENDIAN)
 #define HToLE32 BSwap32
 #define HToLE16 BSwap16
+#define HToBE64(x) (x)
+#define HToBE32(x) (x)
 #else
 #define HToLE32(x) (x)
 #define HToLE16(x) (x)
+#define HToBE64(X) BSwap64(X)
+#define HToBE32(X) BSwap32(X)
+#endif
+
+#if LOCAL_GCC_PREREQ(4, 8) || __has_builtin(__builtin_bswap16)
+#define HAVE_BUILTIN_BSWAP16
 #endif
 
-// clang-3.3 and gcc-4.3 have builtin functions for swap32/swap64
-#if LOCAL_GCC_PREREQ(4, 3) || LOCAL_CLANG_PREREQ(3, 3)
+#if LOCAL_GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap32)
 #define HAVE_BUILTIN_BSWAP32
+#endif
+
+#if LOCAL_GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap64)
 #define HAVE_BUILTIN_BSWAP64
 #endif
-// clang-3.3 and gcc-4.8 have a builtin function for swap16
-#if LOCAL_GCC_PREREQ(4, 8) || LOCAL_CLANG_PREREQ(3, 3)
-#define HAVE_BUILTIN_BSWAP16
+
+#if HAVE_MIPS32 && defined(__mips__) && !defined(__mips64) && \
+    defined(__mips_isa_rev) && (__mips_isa_rev >= 2) && (__mips_isa_rev < 6)
+#define VPX_USE_MIPS32_R2
 #endif
 
 static INLINE uint16_t BSwap16(uint16_t x) {
@@ -71,7 +78,7 @@ static INLINE uint16_t BSwap16(uint16_t x) {
 }
 
 static INLINE uint32_t BSwap32(uint32_t x) {
-#if HAVE_MIPS32
+#if defined(VPX_USE_MIPS32_R2)
   uint32_t ret;
   __asm__ volatile (
     "wsbh   %[ret], %[x]          \n\t"