diff --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst --- a/libcxx/docs/UsingLibcxx.rst +++ b/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 ```` 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.