Commit f9651857 authored by Orvid King's avatar Orvid King Committed by facebook-github-bot-1

Normalize SSE support detection

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
parent 0c1113b9
......@@ -33,7 +33,7 @@
#include <folly/Range.h>
#include <glog/logging.h>
#ifdef __SSSE3__
#if FOLLY_SSE >= 3
#include <x86intrin.h>
namespace folly {
namespace detail {
......@@ -188,7 +188,7 @@ class GroupVarint<uint32_t> : public detail::GroupVarintBase<uint32_t> {
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.
......@@ -214,7 +214,7 @@ class GroupVarint<uint32_t> : public detail::GroupVarintBase<uint32_t> {
__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);
......
......@@ -261,6 +261,32 @@ typedef SSIZE_T ssize_t;
// 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
......
......@@ -130,7 +130,7 @@ pthread_rwlock_t Read 728698 24us 101ns 7.28ms 194us
#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_
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment