Skip to content

Commit

Permalink
ARM_BARRIERs used in multiple places - supplied equivalent SIMDe defi…
Browse files Browse the repository at this point in the history
…nitions
  • Loading branch information
Epixu committed Jul 21, 2024
1 parent acd6694 commit d84635f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
40 changes: 35 additions & 5 deletions simde/x86/sse.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,34 @@
#include <intrin.h>
#endif

#pragma intrinsic(_InterlockedOr)
long _InterlockedOr(long volatile*, long);

#ifdef __i386__
#pragma intrinsic(_InterlockedOr)
long _InterlockedOr(long volatile*, long);

static HEDLEY_ALWAYS_INLINE void simde_MemoryBarrier(void) {
long dummy;
InterlockedOr(&dummy, 0);
}
#elif defined(__aarch64__) || defined(__arm64ec__)
typedef enum simde_tag_ARM64INTR_BARRIER_TYPE
{
SIMDE_ARM64_BARRIER_SY = 0xF,
SIMDE_ARM64_BARRIER_ST = 0xE,
SIMDE_ARM64_BARRIER_LD = 0xD,
SIMDE_ARM64_BARRIER_ISH = 0xB,
SIMDE_ARM64_BARRIER_ISHST = 0xA,
SIMDE_ARM64_BARRIER_ISHLD = 0x9,
SIMDE_ARM64_BARRIER_NSH = 0x7,
SIMDE_ARM64_BARRIER_NSHST = 0x6,
SIMDE_ARM64_BARRIER_NSHLD = 0x5,
SIMDE_ARM64_BARRIER_OSH = 0x3,
SIMDE_ARM64_BARRIER_OSHST = 0x2,
SIMDE_ARM64_BARRIER_OSHLD = 0x1
}
SIMDE_ARM64INTR_BARRIER_TYPE;

static HEDLEY_ALWAYS_INLINE void simde_MemoryBarrier(void) {
__dmb(0xF/* _ARM64_BARRIER_SY defined in <arm64intr.h> */);
__dmb(SIMDE_ARM64_BARRIER_SY);
}
#elif defined(__x86_64__)
#pragma intrinsic(__faststorefence)
Expand All @@ -63,8 +80,21 @@
__faststorefence();
}
#elif defined(__arm__)
typedef enum simde_tag_ARMINTR_BARRIER_TYPE
{
SIMDE_ARM_BARRIER_SY = 0xF,
SIMDE_ARM_BARRIER_ST = 0xE,
SIMDE_ARM_BARRIER_ISH = 0xB,
SIMDE_ARM_BARRIER_ISHST = 0xA,
SIMDE_ARM_BARRIER_NSH = 0x7,
SIMDE_ARM_BARRIER_NSHST = 0x6,
SIMDE_ARM_BARRIER_OSH = 0x3,
SIMDE_ARM_BARRIER_OSHST = 0x2
}
SIMDE_ARMINTR_BARRIER_TYPE;

static HEDLEY_ALWAYS_INLINE void simde_MemoryBarrier(void) {
__dmb(0xF /* _ARM_BARRIER_SY defined in <armintr.h> */);
__dmb(SIMDE_ARM_BARRIER_SY);
}
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion simde/x86/sse2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d84635f

Please sign in to comment.