From f47e3c5c9ecbea85b4f802e07feebab113c837cd Mon Sep 17 00:00:00 2001 From: Dimo Markov Date: Sun, 21 Jul 2024 13:27:38 +0300 Subject: [PATCH] msvc: add simde_MemoryBarrier to avoid including --- simde/x86/sse.h | 57 +++++++++++++++++++++++++++++++++++++++++++----- simde/x86/sse2.h | 2 +- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/simde/x86/sse.h b/simde/x86/sse.h index a8855f540..a2de5d140 100644 --- a/simde/x86/sse.h +++ b/simde/x86/sse.h @@ -33,15 +33,60 @@ #include "mmx.h" #include "../simde-f16.h" -#if defined(_WIN32) && !defined(SIMDE_X86_SSE_NATIVE) && defined(_MSC_VER) - #define NOMINMAX - #include -#endif - #if defined(__ARM_ACLE) #include #endif +#ifdef _MSC_VER + #if defined(SIMDE_ARCH_AARCH64) + #include + + typedef enum simde_tag_ARM64INTR_BARRIER_TYPE + { + SIMDE_ARM64_BARRIER_SY = 0xF, + } + SIMDE_ARM64INTR_BARRIER_TYPE; + + HEDLEY_ALWAYS_INLINE + void simde_MemoryBarrier(void) { + __dmb(SIMDE_ARM64_BARRIER_SY); + } + #elif defined(SIMDE_ARCH_ARM) + #include + + typedef enum simde_tag_ARMINTR_BARRIER_TYPE + { + SIMDE_ARM_BARRIER_SY = 0xF, + } + SIMDE_ARMINTR_BARRIER_TYPE; + + HEDLEY_ALWAYS_INLINE + void simde_MemoryBarrier(void) { + __dmb(SIMDE_ARM_BARRIER_SY); + } + #elif defined(SIMDE_ARCH_X86) || defined(SIMDE_ARCH_AMD64) || defined(SIMDE_ARCH_E2K) + #if !defined(SIMDE_X86_SSE_NO_NATIVE) + #include + #endif + + HEDLEY_ALWAYS_INLINE + void simde_MemoryBarrier(void) { + #if defined(SIMDE_X86_SSE_NO_NATIVE) + ((void)0); // intentionally no-op + #elif defined(SIMDE_ARCH_AMD64) + __faststorefence(); + #elif defined(SIMDE_ARCH_IA64) + __mf(); + #else + long Barrier; + __asm { xchg Barrier, eax } + #endif + } + #else + #error "Missing implementation" + #endif +#endif + HEDLEY_DIAGNOSTIC_PUSH SIMDE_DISABLE_UNWANTED_DIAGNOSTICS SIMDE_BEGIN_DECLS_ @@ -4007,7 +4052,7 @@ simde_mm_sfence (void) { atomic_thread_fence(memory_order_seq_cst); #endif #elif defined(_MSC_VER) - MemoryBarrier(); + simde_MemoryBarrier(); #elif HEDLEY_HAS_EXTENSION(c_atomic) __c11_atomic_thread_fence(__ATOMIC_SEQ_CST); #elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) diff --git a/simde/x86/sse2.h b/simde/x86/sse2.h index 50364544c..a97b30904 100644 --- a/simde/x86/sse2.h +++ b/simde/x86/sse2.h @@ -4776,7 +4776,7 @@ simde_mm_pause (void) { #endif #elif defined(SIMDE_ARCH_ARM_NEON) #if defined(_MSC_VER) - __isb(_ARM64_BARRIER_SY); + __isb(SIMDE_ARM64_BARRIER_SY); #else __asm__ __volatile__("isb\n"); #endif