Skip to content

Commit

Permalink
fixup-always-define-sse
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed May 25, 2024
1 parent edee7c4 commit 8df5b5d
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions src/common/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,39 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define __x86_64__ 1
#endif

#if defined(_MSC_VER)
/* Detect MSVC providing SSE and SSE2.
MSVC doesn't set __SSE*__, and only sets _M_IX86_FP on i686.
We should look for _M_AMD64 or _M_X64 to know if SSE and SSE2
are enabled when building code for amd64. Beware that _M_AMD64
and _M_X64 are also enabled when building for ARM64EC:
> - _M_AMD64 Defined as the integer literal value 100 for compilations
> that target x64 processors or ARM64EC. Otherwise, undefined.
> - _M_X64 Defined as the integer literal value 100 for compilations
> that target x64 processors or ARM64EC. Otherwise, undefined.
> - _M_ARM64EC Defined as 1 for compilations that target ARM64EC.
> Otherwise, undefined.
> -- https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170
It is unclear if xmmintrin.h is available on ARM64EC. */

#if defined(_M_IX86_FP)
#if _M_IX86_FP >= 2
#define __SSE__ 1
#define __SSE2__ 1
#elif _M_IX86_FP == 1
#define __SSE__ 1
#endif
#elif defined(_M_AMD64) || defined(_M_X64)
#if !defined(_M_ARM64EC)
#define __SSE__ 1
#define __SSE2__ 1
#endif
#endif
#endif

/* The definition name syntax is: DAEMON_USE_ARCH_INTRINSICS_<architecture>[_extension]
Examples:
Expand All @@ -81,45 +114,12 @@ The definitions for the architecture itself are automatically set by CMake. */
#if defined(DAEMON_USE_ARCH_INTRINSICS)
// Set architecture extensions definitions.

#if defined(_MSC_VER)
/* Detect MSVC providing SSE and SSE2.
MSVC doesn't set __SSE*__, and only sets _M_IX86_FP on i686.
We should look for _M_AMD64 or _M_X64 to know if SSE and SSE2
are enabled when building code for amd64. Beware that _M_AMD64
and _M_X64 are also enabled when building for ARM64EC:
> - _M_AMD64 Defined as the integer literal value 100 for compilations
> that target x64 processors or ARM64EC. Otherwise, undefined.
> - _M_X64 Defined as the integer literal value 100 for compilations
> that target x64 processors or ARM64EC. Otherwise, undefined.
> - _M_ARM64EC Defined as 1 for compilations that target ARM64EC.
> Otherwise, undefined.
> -- https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170
It is unclear if xmmintrin.h is available on ARM64EC. */

#if defined(_M_IX86_FP)
#if _M_IX86_FP >= 2
#define DAEMON_USE_ARCH_INTRINSICS_i686_sse
#define DAEMON_USE_ARCH_INTRINSICS_i686_sse2
#elif _M_IX86_FP == 1
#define DAEMON_USE_ARCH_INTRINSICS_i686_sse
#endif
#elif defined(_M_AMD64) || defined(_M_X64)
#if !defined(_M_ARM64EC)
#define DAEMON_USE_ARCH_INTRINSICS_i686_sse
#define DAEMON_USE_ARCH_INTRINSICS_i686_sse2
#endif
#endif
#else
#if defined(__SSE__) || defined(MSVC_SSE)
#define DAEMON_USE_ARCH_INTRINSICS_i686_sse
#endif
#if defined(__SSE__)
#define DAEMON_USE_ARCH_INTRINSICS_i686_sse
#endif

#if defined(__SSE2__) || defined(MSVC_SSE2)
#define DAEMON_USE_ARCH_INTRINSICS_i686_sse2
#endif
#if defined(__SSE2__)
#define DAEMON_USE_ARCH_INTRINSICS_i686_sse2
#endif

// Include intrinsics-specific headers.
Expand Down

0 comments on commit 8df5b5d

Please sign in to comment.