[libc-commits] [libc] [libc][math][c23] Add exp2m1f C23 math function (PR #86996)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Mon Apr 1 10:52:05 PDT 2024
================
@@ -0,0 +1,182 @@
+//===-- Implementation of exp2m1f function --------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/exp2m1f.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/rounding_mode.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/optimization.h"
+#include "src/__support/macros/properties/cpu_features.h"
+#include "src/errno/libc_errno.h"
+
+#include "explogxf.h"
+
+namespace LIBC_NAMESPACE {
+
+static constexpr size_t N_EXCEPTS_LO = 8;
+
+static constexpr fputil::ExceptValues<float, N_EXCEPTS_LO> EXP2M1F_EXCEPTS_LO =
+ {{
+ // (input, RZ output, RU offset, RD offset, RN offset)
+ // x = 0x1.36dc8ep-36, exp2m1f(x) = 0x1.aef212p-37 (RZ)
+ {0x2d9b'6e47U, 0x2d57'7909U, 1U, 0U, 0U},
----------------
nickdesaulniers wrote:
`U` suffix means the literal is unsigned. This is opposed to `unsigned x = 7;` where `7` is signed with an implicit cast inserted in front during AST parsing. Dumping the ast alludes to this, and makes it more understandable.
https://godbolt.org/z/7n5MT4xYM
Notice the declaration of `foo` has an ImplictCast node inserted in the AST; the declaration of `bar` does not.
https://github.com/llvm/llvm-project/pull/86996
More information about the libc-commits
mailing list