-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[libc][math] Adds entrypoint and tests for nearbyintf128,scalbnf128 #88443
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
Changes from 5 commits
4edc439
0a4d680
36c032e
6f45b69
c05a6fd
ce7f526
8cb168a
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,19 @@ | ||
//===-- Implementation of nearbyintf128 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/nearbyintf128.h" | ||
#include "src/__support/FPUtil/NearestIntegerOperations.h" | ||
#include "src/__support/common.h" | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
LLVM_LIBC_FUNCTION(float128, nearbyintf128, (float128 x)) { | ||
return fputil::round_using_current_rounding_mode(x); | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//===-- Implementation of scalbnf128 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/scalbnf128.h" | ||
#include "src/__support/FPUtil/ManipulationFunctions.h" | ||
#include "src/__support/common.h" | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
LLVM_LIBC_FUNCTION(float128, scalbnf128, (float128 x, int n)) { | ||
#if !defined(__FLT_RADIX__) | ||
Flandini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#error __FLT_RADIX__ undefined. | ||
#elif __FLT_RADIX__ != 2 | ||
#error __FLT_RADIX__!=2, unimplemented. | ||
#else | ||
return fputil::ldexp(x, n); | ||
#endif | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===-- Implementation header for nearbyintf128 -----------------*- 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_SRC_MATH_NEARBYINTF128_H | ||
#define LLVM_LIBC_SRC_MATH_NEARBYINTF128_H | ||
|
||
#include "src/__support/macros/properties/types.h" | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
float128 nearbyintf128(float128 x); | ||
|
||
} // namespace LIBC_NAMESPACE | ||
|
||
#endif // LLVM_LIBC_SRC_MATH_NEARBYINTF128_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===-- Implementation header for scalbnf128 --------------------*- 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_SRC_MATH_SCALBNF128_H | ||
#define LLVM_LIBC_SRC_MATH_SCALBNF128_H | ||
|
||
#include "src/__support/macros/properties/types.h" | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
float128 scalbnf128(float128 x, int n); | ||
|
||
} // namespace LIBC_NAMESPACE | ||
|
||
#endif // LLVM_LIBC_SRC_MATH_SCALBNF128_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//===-- Unittests for scalbnf128 ------------------------------------------===// | ||
// | ||
// 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 "ScalbnTest.h" | ||
|
||
#include "src/math/scalbnf128.h" | ||
|
||
LIST_SCALBN_TESTS(float128, LIBC_NAMESPACE::scalbnf128) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2188,6 +2188,58 @@ add_fp_unittest( | |
UNIT_TEST_ONLY | ||
) | ||
|
||
add_fp_unittest( | ||
nearbyint_test | ||
SUITE | ||
libc-math-smoke-tests | ||
SRCS | ||
nearbyint_test.cpp | ||
HDRS | ||
NearbyIntTest.h | ||
DEPENDS | ||
libc.hdr.fenv_macros | ||
libc.src.math.nearbyint | ||
) | ||
|
||
add_fp_unittest( | ||
nearbyintf_test | ||
SUITE | ||
libc-math-smoke-tests | ||
SRCS | ||
nearbyintf_test.cpp | ||
HDRS | ||
NearbyIntTest.h | ||
DEPENDS | ||
libc.hdr.fenv_macros | ||
libc.src.math.nearbyintf | ||
) | ||
|
||
add_fp_unittest( | ||
nearbyintl_test | ||
SUITE | ||
libc-math-smoke-tests | ||
SRCS | ||
nearbyintl_test.cpp | ||
HDRS | ||
NearbyIntTest.h | ||
DEPENDS | ||
libc.hdr.fenv_macros | ||
libc.src.math.nearbyintl | ||
) | ||
|
||
add_fp_unittest( | ||
nearbyintf128_test | ||
SUITE | ||
libc-math-smoke-tests | ||
SRCS | ||
nearbyintf128_test.cpp | ||
HDRS | ||
NearbyIntTest.h | ||
DEPENDS | ||
libc.hdr.fenv_macros | ||
libc.src.math.nearbyintf128 | ||
) | ||
|
||
add_fp_unittest( | ||
nextafter_test | ||
SUITE | ||
|
@@ -2770,6 +2822,20 @@ add_fp_unittest( | |
libc.src.__support.FPUtil.normal_float | ||
) | ||
|
||
add_fp_unittest( | ||
scalbnf128_test | ||
SUITE | ||
libc-math-smoke-tests | ||
SRCS | ||
scalbnf128_test.cpp | ||
HDRS | ||
ScalbnTest.h | ||
DEPENDS | ||
libc.src.math.scalbnf128 | ||
libc.src.__support.FPUtil.fp_bits | ||
libc.src.__support.FPUtil.normal_float | ||
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. Look like 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 removed the dependency from the other scalbn tests also. |
||
) | ||
|
||
add_fp_unittest( | ||
erff_test | ||
SUITE | ||
|
Uh oh!
There was an error while loading. Please reload this page.