[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
Wed Mar 15 20:09:02 PDT 2023


xiongji90 created this revision.
xiongji90 added reviewers: rjmccall, sepavloff, aaron.ballman, andrew.w.kaylor.
Herald added a project: All.
xiongji90 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch aims to add necessary description for __builtin_flt_rounds and __builtins_set_flt_rounds in LanguageExtensions.rst


Repository:
  rG LLVM Github Monorepo

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,46 @@
 <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
+See `llvm.get.rounding
+<https://llvm.org/docs/LangRef.html#llvm-get-rounding-intrinsic>`_ for
+more information on the semantics.
+
+``__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
+See `llvm.set.rounding
+<https://llvm.org/docs/LangRef.html#llvm-set-rounding-intrinsic>`_ for
+more information on the semantics.
+This builtin is converted to llvm.set.rounding intrinsic in LLVM IR level
+and not all targets support this intrinsic, so only x86 and arm targets
+support this builtin. Since this builtin changes default floating-point
+environment, ``#pragma STDC FENV_ACCESS ON`` is required.
+
 String builtins
 ---------------
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146188.505686.patch
Type: text/x-patch
Size: 2047 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230316/1d59bdee/attachment-0001.bin>


More information about the cfe-commits mailing list