-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang] Make __builtin_expf constexpr. #140841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ae2e336
034380c
0e09901
81f48d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s | ||
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -fexperimental-new-constant-interpreter %s | ||
// REQUIRES: llvm_integrate_libc | ||
// expected-no-diagnostics | ||
|
||
constexpr float Inf = __builtin_inff(); | ||
constexpr float NegInf = -__builtin_inff(); | ||
|
||
static_assert(Inf == __builtin_expf(Inf)); | ||
static_assert(0.0f == __builtin_expf(NegInf)); | ||
static_assert(1.0f == __builtin_expf(0.0f)); | ||
static_assert(0x1.5bf0a8p1f == __builtin_expf(1.0f)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,7 @@ test infrastructure itself can be affected. To avoid perturbing the unit test | |
infrastructure around the setting of ``errno``, the following rules are to be | ||
followed: | ||
|
||
#. A special macro named ``libc_errno`` defined in ``src/errno/libc_errno.h`` | ||
#. A special macro named ``libc_errno`` defined in ``src/__support/libc_errno.h`` | ||
should be used when setting ``errno`` from libc runtime code. For example, | ||
code to set ``errno`` to ``EINVAL`` should be: | ||
|
||
|
@@ -117,7 +117,7 @@ followed: | |
`ErrorOr <https://github.com/llvm/llvm-project/blob/main/libc/src/__support/error_or.h>`_ | ||
to return error values. | ||
|
||
#. The header file ``src/errno/libc_errno.h`` is shipped as part of the target | ||
#. The header file ``src/__support/libc_errno.h`` is shipped as part of the target | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this bullet point be revisited? I think that if we're using system errno, targets no longer need to depend on errno. For full-build, conversely, system errno shouldn't be feasible? |
||
corresponding to the ``errno`` entrypoint ``libc.src.errno.errno``. We do | ||
not in general allow dependencies between entrypoints. However, the ``errno`` | ||
entrypoint is the only exceptional entrypoint on which other entrypoints | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//===-- Floating point math functions ---------------------------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SHARED_MATH_H | ||
#define LLVM_LIBC_SHARED_MATH_H | ||
|
||
#include "src/__support/math/expf.h" | ||
|
||
namespace LIBC_NAMESPACE_DECL { | ||
namespace shared { | ||
|
||
using math::expf; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if there's any value in having a per-function (or per-function-group) header? E.g. |
||
|
||
} // namespace shared | ||
} // namespace LIBC_NAMESPACE_DECL | ||
|
||
#endif // LLVM_LIBC_SHARED_FP_BITS_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -381,3 +381,5 @@ add_subdirectory(HashTable) | |
add_subdirectory(fixed_point) | ||
|
||
add_subdirectory(time) | ||
|
||
add_subdirectory(math) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this reverts a landed fix to docs?