[libcxx-commits] [PATCH] D129310: [libc++][doc] Documents the header __bits.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 7 11:04:17 PDT 2022


Mordante created this revision.
Mordante added a reviewer: ldionne.
Herald added a project: All.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This addresses a request during the review of D128929 <https://reviews.llvm.org/D128929>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129310

Files:
  libcxx/docs/UsingLibcxx.rst


Index: libcxx/docs/UsingLibcxx.rst
===================================================================
--- libcxx/docs/UsingLibcxx.rst
+++ libcxx/docs/UsingLibcxx.rst
@@ -429,3 +429,39 @@
 * ``identity::operator()``
 * ``to_integer``
 * ``to_underlying``
+
+
+Compiler intrinsics wrappers
+----------------------------
+
+The header ``__bits`` contains several compiler intrinsics wrapper functions.
+Unless specified otherwise those function are available with the following
+overloads:
+
+* ``unsigned``
+* ``unsigned long``
+* ``unsigned long long``
+
+All those functions are ``constexpr`` and don't throw exceptions.
+
+Starting with C++20 the Standard header ``<bit>`` is available. This header
+contains all functions available in  ``<__bits>``` under a different name.
+
+
+``__libcpp_ctz``
+~~~~~~~~~~~~~~~~
+
+Returns the number of trailing zero bits in the input.
+
+
+``__libcpp_clz``
+~~~~~~~~~~~~~~~~
+
+Returns the number of leading zero bits in the input.
+When the platform supports 128-bit values the overload ``__uint128_t`` is
+available, but not purely as an interinsic.
+
+``__libcpp_popcount``
+~~~~~~~~~~~~~~~~~~~~~
+
+Returns the number of bits set in the input.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129310.442995.patch
Type: text/x-patch
Size: 1188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220707/2165569e/attachment.bin>


More information about the libcxx-commits mailing list