[PATCH] D46386: Adding __atomic_fetch_min/max intrinsics to clang

Elena Demikhovsky via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 11 22:07:59 PDT 2018


delena updated this revision to Diff 146462.
delena added a comment.

Added a line about *load-store* semantics of these two intrinsics.
Removed the common description of memory modeling.


Repository:
  rC Clang

https://reviews.llvm.org/D46386

Files:
  LanguageExtensions.rst


Index: LanguageExtensions.rst
===================================================================
--- LanguageExtensions.rst
+++ LanguageExtensions.rst
@@ -1975,6 +1975,32 @@
 Support for constant expression evaluation for the above builtins be detected
 with ``__has_feature(cxx_constexpr_string_builtins)``.
 
+Atomic Min/Max builtins with memory ordering
+--------------------------------------------
+
+There are two atomic builtins with min/max in-memory comparison and swap.
+The syntax and semantics are similar to GCC-compatible __atomic_* builtins.
+
+* ``__atomic_fetch_min`` 
+* ``__atomic_fetch_max`` 
+
+The builtins work with signed and unsigned integers and require to specify memory ordering.
+The return value is the original value that was stored in memory before comparison.
+
+Example:
+
+.. code-block:: c
+
+  unsigned int val = __atomic_fetch_min(unsigned int *pi, unsigned int ui, __ATOMIC_RELAXED);
+
+The third argument is one of the memory ordering specifiers ``__ATOMIC_RELAXED``,
+``__ATOMIC_CONSUME``, ``__ATOMIC_ACQUIRE``, ``__ATOMIC_RELEASE``,
+``__ATOMIC_ACQ_REL``, or ``__ATOMIC_SEQ_CST`` following C++11 memory model semantics.
+
+In terms or aquire-release ordering barriers these two operations are always
+considered as operations with *load-store* semantics, even when the original value
+is not actually modified after comparison.
+
 .. _langext-__c11_atomic:
 
 __c11_atomic builtins
@@ -2734,4 +2760,3 @@
 The ``#pragma comment(lib, ...)`` directive is supported on all ELF targets.
 The second parameter is the library name (without the traditional Unix prefix of
 ``lib``).  This allows you to provide an implicit link of dependent libraries.
-


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46386.146462.patch
Type: text/x-patch
Size: 1689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180512/1b945a64/attachment-0001.bin>


More information about the cfe-commits mailing list