[PATCH] [clang-cl] Added _InterlockedCompareExchangePointer to Intrin.h

David Ziman kumquats.a.pair at gmail.com
Thu Jan 23 03:47:35 PST 2014


  Updated patch to include an implementation of __faststorefence based on cl assembly output.

http://llvm-reviews.chandlerc.com/D2600

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2600?vs=6595&id=6599#toc

Files:
  lib/Headers/Intrin.h

Index: lib/Headers/Intrin.h
===================================================================
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -201,6 +201,9 @@
 static __inline__
 char _InterlockedCompareExchange8(char volatile *_Destination, char _Exchange,
                                   char _Comparand);
+static __inline__
+void *_InterlockedCompareExchangePointer(void *volatile *, void *,
+                                         void *);
 void *_InterlockedCompareExchangePointer_HLEAcquire(void *volatile *, void *,
                                                     void *);
 void *_InterlockedCompareExchangePointer_HLERelease(void *volatile *, void *,
@@ -741,6 +744,14 @@
   return _Comparand;
 }
 #ifdef __x86_64__
+static __inline__ void* __attribute__((__always_inline__, __nodebug__))
+_InterlockedCompareExchangePointer(void *volatile *_Destination,
+                              void *_Exchange, void *_Comparand) {
+  __atomic_compare_exchange(_Destination, &_Comparand, &_Exchange, 0, 0, 0);
+  return _Comparand;
+}
+#endif
+#ifdef __x86_64__
 static __inline__ __int64 __attribute__((__always_inline__, __nodebug__))
 _InterlockedCompareExchange64(__int64 volatile *_Destination,
                               __int64 _Exchange, __int64 _Comparand) {
@@ -766,6 +777,12 @@
 _WriteBarrier(void) {
   __asm__ volatile ("" : : : "memory");
 }
+#ifdef __X86_64__
+static __inline__ void __attribute__((__always_inline__, __nodebug__))
+__faststorefence(void) {
+	__asm__ volatile ("lock orq $0,(%rsp)");
+}
+#endif
 /*----------------------------------------------------------------------------*\
 |* Misc
 \*----------------------------------------------------------------------------*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2600.2.patch
Type: text/x-patch
Size: 1720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140123/4e5e90df/attachment.bin>


More information about the cfe-commits mailing list