Skip to content

Commit dcd08da

Browse files
ilinpvjroelofs
andauthored
[NFC][Docs] Documenting __builtin_cpu_supports. (#84098)
Co-authored-by: Jon Roelofs <[email protected]>
1 parent fc9f1d4 commit dcd08da

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2799,6 +2799,34 @@ counter's true frequency will need to be provided by the user.
27992799
28002800
Query for this feature with ``__has_builtin(__builtin_readsteadycounter)``.
28012801
2802+
``__builtin_cpu_supports``
2803+
--------------------------
2804+
2805+
**Syntax**:
2806+
2807+
.. code-block:: c++
2808+
2809+
int __builtin_cpu_supports(const char *features);
2810+
2811+
**Example of Use:**:
2812+
2813+
.. code-block:: c++
2814+
2815+
if (__builtin_cpu_supports("sve"))
2816+
sve_code();
2817+
2818+
**Description**:
2819+
2820+
The ``__builtin_cpu_supports`` function detects if the run-time CPU supports
2821+
features specified in string argument. It returns a positive integer if all
2822+
features are supported and 0 otherwise. Feature names are target specific. On
2823+
AArch64 features are combined using ``+`` like this
2824+
``__builtin_cpu_supports("flagm+sha3+lse+rcpc2+fcma+memtag+bti+sme2")``.
2825+
If a feature name is not supported, Clang will issue a warning and replace
2826+
builtin by the constant 0.
2827+
2828+
Query for this feature with ``__has_builtin(__builtin_cpu_supports)``.
2829+
28022830
``__builtin_dump_struct``
28032831
-------------------------
28042832

0 commit comments

Comments
 (0)