[PATCH] D146188: [Clang][DOC] Add documentation in for __builtin_flt_rounds and __builtin_set_flt_rounds

xiongji90 via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 19 20:51:30 PDT 2023


xiongji90 updated this revision to Diff 506460.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146188/new/

https://reviews.llvm.org/D146188

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===================================================================
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -3246,7 +3246,7 @@
 
    double __builtin_canonicalize(double);
    float __builtin_canonicalizef(float);
-   long double__builtin_canonicalizel(long double);
+   long double __builtin_canonicalizel(long double);
 
 Returns the platform specific canonical encoding of a floating point
 number. This canonicalization is useful for implementing certain
@@ -3254,6 +3254,39 @@
 <https://llvm.org/docs/LangRef.html#llvm-canonicalize-intrinsic>`_ for
 more information on the semantics.
 
+``__builtin_flt_rounds``
+--------------------------
+
+.. code-block:: c
+
+   int __builtin_flt_rounds();
+
+Returns the current rounding mode. Encoding of the returned values is
+same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+The effect of passing some other value to this builtin is implementation-defined.
+
+``__builtin_set_flt_rounds``
+--------------------------
+
+.. code-block:: c
+
+   void __builtin_set_flt_rounds(int);
+
+Sets the current rounding mode. Encoding of the returned values is
+same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+This builtin is restrcted to work on x86 and arm targets currently. When support
+for the builtin is added for new targets, the manual should be updated accordingly.
+
 String builtins
 ---------------
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146188.506460.patch
Type: text/x-patch
Size: 1753 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230320/14139da1/attachment.bin>


More information about the cfe-commits mailing list