Skip to content

Commit e8de23e

Browse files
committed
[NFC][Docs] Documenting __builtin_cpu_supports.
1 parent 44be5a7 commit e8de23e

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 at runtime if target CPU
2821+
supports features specified in string argument. It returns positive integer
2822+
if all features are supported and 0 otherwise. Names of features and format is
2823+
target specific. For example on AArch64 features are combined using ``+`` like
2824+
this ``__builtin_cpu_supports("flagm+sha3+lse+rcpc2+fcma+memtag+bti+sme2")``.
2825+
If feature name is not supported or format is wrong, compiler will issue a
2826+
warning and replace builtin by 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)