From 6aacd49094bc34e477af04c2806d20b47372205d Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Tue, 16 Jul 2013 09:47:53 +0000 Subject: ARM: implement low-level intrinsics for the atomic exclusive operations. This adds three overloaded intrinsics to Clang: T __builtin_arm_ldrex(const volatile T *addr) int __builtin_arm_strex(T val, volatile T *addr) void __builtin_arm_clrex() The intent is that these do what users would expect when given most sensible types. Currently, "sensible" translates to ints, floats and pointers. llvm-svn: 186394 --- clang/docs/LanguageExtensions.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'clang/docs') diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index bfc5feb30b8..65840c0c927 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -1656,6 +1656,36 @@ C11's ```` header. These builtins provide the semantics of the * ``__c11_atomic_fetch_or`` * ``__c11_atomic_fetch_xor`` +Low-level ARM exclusive memory builtins +--------------------------------------- + +Clang provides overloaded builtins giving direct access to the three key ARM +instructions for implementing atomic operations. + +.. code-block:: c + T __builtin_arm_ldrex(const volatile T *addr); + int __builtin_arm_strex(T val, volatile T *addr); + void __builtin_arm_clrex(void); + +The types ``T`` currently supported are: +* Integer types with width at most 64 bits. +* Floating-point types +* Pointer types. + +Note that the compiler does not guarantee it will not insert stores which clear +the exclusive monitor in between an ``ldrex`` and its paired ``strex``. In +practice this is only usually a risk when the extra store is on the same cache +line as the variable being modified and Clang will only insert stack stores on +its own, so it is best not to use these operations on variables with automatic +storage duration. + +Also, loads and stores may be implicit in code written between the ``ldrex`` and +``strex``. Clang will not necessarily mitigate the effects of these either, so +care should be exercised. + +For these reasons the higher level atomic primitives should be preferred where +possible. + Non-standard C++11 Attributes ============================= -- cgit v1.2.3