[clang] dcd08da - [NFC][Docs] Documenting __builtin_cpu_supports. (#84098)

via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 6 09:59:35 PST 2024


Author: Pavel Iliin
Date: 2024-03-06T17:59:31Z
New Revision: dcd08daed5fb9928fedb09c2a84d1e9d2ab59630

URL: https://github.com/llvm/llvm-project/commit/dcd08daed5fb9928fedb09c2a84d1e9d2ab59630
DIFF: https://github.com/llvm/llvm-project/commit/dcd08daed5fb9928fedb09c2a84d1e9d2ab59630.diff

LOG: [NFC][Docs] Documenting __builtin_cpu_supports. (#84098)

Co-authored-by: Jon Roelofs <jroelofs at gmail.com>

Added: 
    

Modified: 
    clang/docs/LanguageExtensions.rst

Removed: 
    


################################################################################
diff  --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index bcd69198eafdbe..2b54dffd058a35 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -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``
 -------------------------
 


        


More information about the cfe-commits mailing list