[PATCH] D25576: Add 64-bit MS _Interlocked functions as builtins again
mstorsjo added a comment. > (should they be also on AArch64? I had problems with testing it for AArch64, > so I left it) Technically, I think they should be on AArch64 as well. But clang/LLVM probably doesn't support AArch64/Windows yet (I guess?), so testing it probably is impossible. When/if support later gets added for that, it's easy to complete these. AArch64/Windows in general isn't available yet; the Windows 10 SDK contains some arm64 tools, and the Windows 10 SDK and MSVC 2015 headers have got ifdefs using _M_ARM64, but other than that, there's no public version of Visual Studio even having a compiler for it. So until then, and when someone tries to get clang/LLVM to support it, it's probably ok to just ignore it. https://reviews.llvm.org/D25576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25576: Add 64-bit MS _Interlocked functions as builtins again
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm https://reviews.llvm.org/D25576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25576: Add 64-bit MS _Interlocked functions as builtins again
agutowski updated this revision to Diff 74586. agutowski added a comment. make target-independent Interlocked builtins use EmitMSVCBuiltinExpr https://reviews.llvm.org/D25576 Files: include/clang/Basic/BuiltinsARM.def include/clang/Basic/BuiltinsX86_64.def lib/CodeGen/CGBuiltin.cpp lib/Headers/intrin.h test/CodeGen/ms-intrinsics.c Index: lib/Headers/intrin.h === --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -387,25 +387,13 @@ void *_Exchange, void *_Comparand); void *_InterlockedCompareExchangePointer_np(void *volatile *_Destination, void *_Exchange, void *_Comparand); -static __inline__ -__int64 _InterlockedDecrement64(__int64 volatile *_Addend); -static __inline__ -__int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value); -static __inline__ -__int64 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value); void *_InterlockedExchangePointer(void *volatile *_Target, void *_Value); -static __inline__ -__int64 _InterlockedIncrement64(__int64 volatile *_Addend); long _InterlockedOr_np(long volatile *_Value, long _Mask); short _InterlockedOr16_np(short volatile *_Value, short _Mask); -static __inline__ -__int64 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask); __int64 _InterlockedOr64_np(__int64 volatile *_Value, __int64 _Mask); char _InterlockedOr8_np(char volatile *_Value, char _Mask); long _InterlockedXor_np(long volatile *_Value, long _Mask); short _InterlockedXor16_np(short volatile *_Value, short _Mask); -static __inline__ -__int64 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask); __int64 _InterlockedXor64_np(__int64 volatile *_Value, __int64 _Mask); char _InterlockedXor8_np(char volatile *_Value, char _Mask); unsigned __int64 _rorx_u64(unsigned __int64, const unsigned int); @@ -428,6 +416,27 @@ #endif /* __x86_64__ */ +#if defined(__x86_64__) || defined(__arm__) + +static __inline__ +__int64 _InterlockedDecrement64(__int64 volatile *_Addend); +static __inline__ +__int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value); +static __inline__ +__int64 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value); +static __inline__ +__int64 _InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value); +static __inline__ +__int64 _InterlockedIncrement64(__int64 volatile *_Addend); +static __inline__ +__int64 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask); +static __inline__ +__int64 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask); +static __inline__ +__int64 _InterlockedAnd64(__int64 volatile *_Value, __int64 _Mask); + +#endif + /**\ |* Bit Counting and Testing \**/ @@ -545,15 +554,7 @@ _InterlockedExchangeAdd_rel(long volatile *_Addend, long _Value) { return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELEASE); } -#endif -#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value) { - return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST); -} -#endif -#if defined(__arm__) || defined(__aarch64__) -static __inline__ __int64 __DEFAULT_FN_ATTRS _InterlockedExchangeAdd64_acq(__int64 volatile *_Addend, __int64 _Value) { return __atomic_fetch_add(_Addend, _Value, __ATOMIC_ACQUIRE); } @@ -567,15 +568,6 @@ } #endif /**\ -|* Interlocked Exchange Sub -\**/ -#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) -static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value) { - return __atomic_fetch_sub(_Subend, _Value, __ATOMIC_SEQ_CST); -} -#endif -/**\ |* Interlocked Increment \**/ #if defined(__arm__) || defined(__aarch64__) @@ -603,15 +595,7 @@ _InterlockedIncrement_rel(long volatile *_Value) { return __atomic_add_fetch(_Value, 1, __ATOMIC_RELEASE); } -#endif -#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedIncrement64(__int64 volatile *_Value) { - return __atomic_add_fetch(_Value, 1, __ATOMIC_SEQ_CST); -} -#endif -#if defined(__arm__) || defined(__aarch64__) -static __inline__ __int64 __DEFAULT_FN_ATTRS _InterlockedIncrement64_acq(__int64 volatile *_Value) { return __atomic_add_fetch(_Value, 1, __ATOMIC_ACQUIRE); } @@ -652,15 +636,7 @@ _InterlockedDecrement_rel(long volatile *_V
[PATCH] D25576: Add 64-bit MS _Interlocked functions as builtins again
rnk added inline comments. Comment at: lib/CodeGen/CGBuiltin.cpp:2730 +llvm::AtomicOrdering::SequentiallyConsistent); +return Builder.CreateSub(RMWI, ConstantInt::get(IntTy, 1)); } agutowski wrote: > rnk wrote: > > Can you make a helper similar to MakeBinaryAtomicValue for inc/dec and > > share this code with the 16 and 32-bit atomic increment implementations? > > You can do something like `Builder.CreateBinOp(Inc ? Instruction::Add : > > Instruction::Sub, ...)` > I thought about putting all the _Interlocked intrinsics here. Or do we want > all the others to remain target-independent? Sure, having the target-independent builtins call EmitMSVCBuiltinExpr seems reasonable. https://reviews.llvm.org/D25576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25576: Add 64-bit MS _Interlocked functions as builtins again
agutowski added inline comments. Comment at: lib/CodeGen/CGBuiltin.cpp:2730 +llvm::AtomicOrdering::SequentiallyConsistent); +return Builder.CreateSub(RMWI, ConstantInt::get(IntTy, 1)); } rnk wrote: > Can you make a helper similar to MakeBinaryAtomicValue for inc/dec and share > this code with the 16 and 32-bit atomic increment implementations? You can do > something like `Builder.CreateBinOp(Inc ? Instruction::Add : > Instruction::Sub, ...)` I thought about putting all the _Interlocked intrinsics here. Or do we want all the others to remain target-independent? https://reviews.llvm.org/D25576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25576: Add 64-bit MS _Interlocked functions as builtins again
rnk added inline comments. Comment at: lib/CodeGen/CGBuiltin.cpp:2730 +llvm::AtomicOrdering::SequentiallyConsistent); +return Builder.CreateSub(RMWI, ConstantInt::get(IntTy, 1)); } Can you make a helper similar to MakeBinaryAtomicValue for inc/dec and share this code with the 16 and 32-bit atomic increment implementations? You can do something like `Builder.CreateBinOp(Inc ? Instruction::Add : Instruction::Sub, ...)` https://reviews.llvm.org/D25576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25576: Add 64-bit MS _Interlocked functions as builtins again
agutowski created this revision. agutowski added reviewers: rnk, hans, majnemer, mstorsjo. agutowski added a subscriber: cfe-commits. Herald added a subscriber: aemerson. Previously global 64-bit versions of _Interlocked functions broke buildbots on i386, so now I'm adding them as builtins for x86-64 and ARM only (should they be also on AArch64? I had problems with testing it for AArch64, so I left it) https://reviews.llvm.org/D25576 Files: include/clang/Basic/BuiltinsARM.def include/clang/Basic/BuiltinsX86_64.def lib/CodeGen/CGBuiltin.cpp lib/Headers/intrin.h test/CodeGen/ms-intrinsics.c Index: lib/Headers/intrin.h === --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -387,25 +387,13 @@ void *_Exchange, void *_Comparand); void *_InterlockedCompareExchangePointer_np(void *volatile *_Destination, void *_Exchange, void *_Comparand); -static __inline__ -__int64 _InterlockedDecrement64(__int64 volatile *_Addend); -static __inline__ -__int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value); -static __inline__ -__int64 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value); void *_InterlockedExchangePointer(void *volatile *_Target, void *_Value); -static __inline__ -__int64 _InterlockedIncrement64(__int64 volatile *_Addend); long _InterlockedOr_np(long volatile *_Value, long _Mask); short _InterlockedOr16_np(short volatile *_Value, short _Mask); -static __inline__ -__int64 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask); __int64 _InterlockedOr64_np(__int64 volatile *_Value, __int64 _Mask); char _InterlockedOr8_np(char volatile *_Value, char _Mask); long _InterlockedXor_np(long volatile *_Value, long _Mask); short _InterlockedXor16_np(short volatile *_Value, short _Mask); -static __inline__ -__int64 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask); __int64 _InterlockedXor64_np(__int64 volatile *_Value, __int64 _Mask); char _InterlockedXor8_np(char volatile *_Value, char _Mask); unsigned __int64 _rorx_u64(unsigned __int64, const unsigned int); @@ -428,6 +416,27 @@ #endif /* __x86_64__ */ +#if defined(__x86_64__) || defined(__arm__) + +static __inline__ +__int64 _InterlockedDecrement64(__int64 volatile *_Addend); +static __inline__ +__int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value); +static __inline__ +__int64 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value); +static __inline__ +__int64 _InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value); +static __inline__ +__int64 _InterlockedIncrement64(__int64 volatile *_Addend); +static __inline__ +__int64 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask); +static __inline__ +__int64 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask); +static __inline__ +__int64 _InterlockedAnd64(__int64 volatile *_Value, __int64 _Mask); + +#endif + /**\ |* Bit Counting and Testing \**/ @@ -545,15 +554,7 @@ _InterlockedExchangeAdd_rel(long volatile *_Addend, long _Value) { return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELEASE); } -#endif -#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value) { - return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST); -} -#endif -#if defined(__arm__) || defined(__aarch64__) -static __inline__ __int64 __DEFAULT_FN_ATTRS _InterlockedExchangeAdd64_acq(__int64 volatile *_Addend, __int64 _Value) { return __atomic_fetch_add(_Addend, _Value, __ATOMIC_ACQUIRE); } @@ -567,15 +568,6 @@ } #endif /**\ -|* Interlocked Exchange Sub -\**/ -#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) -static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value) { - return __atomic_fetch_sub(_Subend, _Value, __ATOMIC_SEQ_CST); -} -#endif -/**\ |* Interlocked Increment \**/ #if defined(__arm__) || defined(__aarch64__) @@ -603,15 +595,7 @@ _InterlockedIncrement_rel(long volatile *_Value) { return __atomic_add_fetch(_Value, 1, __ATOMIC_RELEASE); } -#endif -#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedIncrement64(__int64 volatile *_Value) { - return __atomic_add_fetch(_Value, 1, __ATOMIC_SEQ_CST); -} -#endif -#if define