summaryrefslogtreecommitdiffstats
path: root/clang/docs
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2013-07-16 09:47:53 +0000
committerTim Northover <tnorthover@apple.com>2013-07-16 09:47:53 +0000
commit6aacd49094bc34e477af04c2806d20b47372205d (patch)
treefa4f832c4b6572696ab8b0d208c1401a25912dfe /clang/docs
parent4245f78fdd992e0f96c4c88ef7f31912803ad634 (diff)
downloadbcm5719-llvm-6aacd49094bc34e477af04c2806d20b47372205d.tar.gz
bcm5719-llvm-6aacd49094bc34e477af04c2806d20b47372205d.zip
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
Diffstat (limited to 'clang/docs')
-rw-r--r--clang/docs/LanguageExtensions.rst30
1 files changed, 30 insertions, 0 deletions
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 ``<stdatomic.h>`` 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
=============================
OpenPOWER on IntegriCloud