Skip to content

[NFC][Docs] Documenting __builtin_cpu_supports. #84098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions clang/docs/LanguageExtensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2799,6 +2799,34 @@ counter's true frequency will need to be provided by the user.

Query for this feature with ``__has_builtin(__builtin_readsteadycounter)``.

``__builtin_cpu_supports``
--------------------------

**Syntax**:

.. code-block:: c++

int __builtin_cpu_supports(const char *features);

**Example of Use:**:

.. code-block:: c++

if (__builtin_cpu_supports("sve"))
sve_code();

**Description**:

The ``__builtin_cpu_supports`` function detects if the run-time CPU supports
features specified in string argument. It returns a positive integer if all
features are supported and 0 otherwise. Feature names are target specific. On
AArch64 features are combined using ``+`` like this
``__builtin_cpu_supports("flagm+sha3+lse+rcpc2+fcma+memtag+bti+sme2")``.
If a feature name is not supported, Clang will issue a warning and replace
builtin by the constant 0.

Query for this feature with ``__has_builtin(__builtin_cpu_supports)``.

``__builtin_dump_struct``
-------------------------

Expand Down