Summary: This unifies ways of detecting SSE support into the FOLLY_SSE define which is a numeric value from 0 to 4.2 depending on detected level.
This also adds a `#define` for `__extension__` which is used in folly, but is GCC specific.
Closes #259
Reviewed By: @yfeldblum
Differential Revision:
D2283522
Pulled By: @sgolemon
#include <folly/Range.h>
#include <glog/logging.h>
-#ifdef __SSSE3__
+#if FOLLY_SSE >= 3
#include <x86intrin.h>
namespace folly {
namespace detail {
return decode_simple(p, dest, dest+1, dest+2, dest+3);
}
-#ifdef __SSSE3__
+#if FOLLY_SSE >= 3
/**
* Just like the non-SSSE3 decode below, but with the additional constraint
* that we must be able to read at least 17 bytes from the input pointer, p.
__m128i r = _mm_shuffle_epi8(val, mask);
// Extracting 32 bits at a time out of an XMM register is a SSE4 feature
-#ifdef __SSE4__
+#if FOLLY_SSE >= 4
*a = _mm_extract_epi32(r, 0);
*b = _mm_extract_epi32(r, 1);
*c = _mm_extract_epi32(r, 2);
// compiler specific to compiler specific
// nolint
# define __PRETTY_FUNCTION__ __FUNCSIG__
+
+// Hide a GCC specific thing that breaks MSVC if left alone.
+# define __extension__
+
+#ifdef _M_IX86_FP
+# define FOLLY_SSE _M_IX86_FP
+#endif
+
+#endif
+
+#ifndef FOLLY_SSE
+# if defined(__SSE4_2__)
+# define FOLLY_SSE 4.2
+# elif defined(__SSE4_1__)
+# define FOLLY_SSE 4.1
+# elif defined(__SSE4__)
+# define FOLLY_SSE 4
+# elif defined(__SSE3__)
+# define FOLLY_SSE 3
+# elif defined(__SSE2__)
+# define FOLLY_SSE 2
+# elif defined(__SSE__)
+# define FOLLY_SSE 1
+# else
+# define FOLLY_SSE 0
+# endif
#endif
#if FOLLY_UNUSUAL_GFLAGS_NAMESPACE
#endif
// iOS doesn't define _mm_cvtsi64_si128 and friends
-#if defined(__SSE2__) && !TARGET_OS_IPHONE
+#if (FOLLY_SSE >= 2) && !TARGET_OS_IPHONE
#define RW_SPINLOCK_USE_SSE_INSTRUCTIONS_
#else
#undef RW_SPINLOCK_USE_SSE_INSTRUCTIONS_