[libc][math][c23] Add entrypoints and tests for dsqrt{l,f128} (#99815)
This commit is contained in:
parent
ffcd7e98d9
commit
c1562374c8
@ -135,6 +135,7 @@ set(TARGET_LIBM_ENTRYPOINTS
|
||||
libc.src.math.cos
|
||||
libc.src.math.cosf
|
||||
libc.src.math.cospif
|
||||
libc.src.math.dsqrtl
|
||||
libc.src.math.erff
|
||||
libc.src.math.exp
|
||||
libc.src.math.expf
|
||||
|
@ -119,6 +119,7 @@ set(TARGET_LIBM_ENTRYPOINTS
|
||||
#libc.src.math.ceill
|
||||
#libc.src.math.coshf
|
||||
#libc.src.math.cosf
|
||||
#libc.src.math.dsqrtl
|
||||
#libc.src.math.expf
|
||||
#libc.src.math.exp2f
|
||||
#libc.src.math.expm1f
|
||||
|
@ -359,6 +359,7 @@ set(TARGET_LIBM_ENTRYPOINTS
|
||||
libc.src.math.coshf
|
||||
libc.src.math.cospif
|
||||
libc.src.math.dmull
|
||||
libc.src.math.dsqrtl
|
||||
libc.src.math.erff
|
||||
libc.src.math.exp
|
||||
libc.src.math.exp10
|
||||
@ -598,6 +599,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
|
||||
# math.h C23 _Float128 entrypoints
|
||||
libc.src.math.ceilf128
|
||||
libc.src.math.copysignf128
|
||||
libc.src.math.dsqrtf128
|
||||
libc.src.math.fabsf128
|
||||
libc.src.math.fdimf128
|
||||
libc.src.math.floorf128
|
||||
|
@ -227,6 +227,7 @@ set(TARGET_LIBM_ENTRYPOINTS
|
||||
libc.src.math.cos
|
||||
libc.src.math.cosf
|
||||
libc.src.math.coshf
|
||||
libc.src.math.dsqrtl
|
||||
libc.src.math.erff
|
||||
libc.src.math.exp
|
||||
libc.src.math.exp10
|
||||
|
@ -377,6 +377,7 @@ set(TARGET_LIBM_ENTRYPOINTS
|
||||
libc.src.math.cosf
|
||||
libc.src.math.coshf
|
||||
libc.src.math.cospif
|
||||
libc.src.math.dsqrtl
|
||||
libc.src.math.erff
|
||||
libc.src.math.exp
|
||||
libc.src.math.exp10
|
||||
@ -549,6 +550,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
|
||||
libc.src.math.ceilf128
|
||||
libc.src.math.copysignf128
|
||||
libc.src.math.dmulf128
|
||||
libc.src.math.dsqrtf128
|
||||
libc.src.math.fabsf128
|
||||
libc.src.math.fdimf128
|
||||
libc.src.math.floorf128
|
||||
|
@ -382,6 +382,7 @@ set(TARGET_LIBM_ENTRYPOINTS
|
||||
libc.src.math.coshf
|
||||
libc.src.math.cospif
|
||||
libc.src.math.dmull
|
||||
libc.src.math.dsqrtl
|
||||
libc.src.math.erff
|
||||
libc.src.math.exp
|
||||
libc.src.math.exp10
|
||||
@ -643,6 +644,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
|
||||
libc.src.math.ceilf128
|
||||
libc.src.math.copysignf128
|
||||
libc.src.math.dmulf128
|
||||
libc.src.math.dsqrtf128
|
||||
libc.src.math.fabsf128
|
||||
libc.src.math.fdimf128
|
||||
libc.src.math.floorf128
|
||||
|
@ -278,7 +278,7 @@ Higher Math Functions
|
||||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
|
||||
| cospi | |check| | | | | | 7.12.4.12 | F.10.1.12 |
|
||||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
|
||||
| dsqrt | N/A | N/A | | N/A | | 7.12.14.6 | F.10.11 |
|
||||
| dsqrt | N/A | N/A | |check| | N/A | |check|\* | 7.12.14.6 | F.10.11 |
|
||||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
|
||||
| erf | |check| | | | | | 7.12.8.1 | F.10.5.1 |
|
||||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
|
||||
|
@ -57,6 +57,8 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> {
|
||||
[], // Types
|
||||
[], // Enumerations
|
||||
[
|
||||
GuardedFunctionSpec<"dsqrtf128", RetValSpec<DoubleType>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
|
||||
|
||||
GuardedFunctionSpec<"f16add", RetValSpec<Float16Type>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>], "LIBC_TYPES_HAS_FLOAT16">,
|
||||
GuardedFunctionSpec<"f16addf", RetValSpec<Float16Type>, [ArgSpec<FloatType>, ArgSpec<FloatType>], "LIBC_TYPES_HAS_FLOAT16">,
|
||||
GuardedFunctionSpec<"f16addl", RetValSpec<Float16Type>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>], "LIBC_TYPES_HAS_FLOAT16">,
|
||||
|
@ -717,6 +717,9 @@ def StdC : StandardSpec<"stdc"> {
|
||||
FunctionSpec<"canonicalizel", RetValSpec<IntType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
|
||||
GuardedFunctionSpec<"canonicalizef16", RetValSpec<IntType>, [ArgSpec<Float16Type>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
|
||||
GuardedFunctionSpec<"canonicalizef128", RetValSpec<IntType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
|
||||
|
||||
FunctionSpec<"dsqrtl", RetValSpec<DoubleType>, [ArgSpec<LongDoubleType>]>,
|
||||
|
||||
|
||||
GuardedFunctionSpec<"totalorderf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
|
||||
|
||||
|
@ -89,6 +89,9 @@ add_math_entrypoint_object(cospif)
|
||||
add_math_entrypoint_object(dmull)
|
||||
add_math_entrypoint_object(dmulf128)
|
||||
|
||||
add_math_entrypoint_object(dsqrtl)
|
||||
add_math_entrypoint_object(dsqrtf128)
|
||||
|
||||
add_math_entrypoint_object(erf)
|
||||
add_math_entrypoint_object(erff)
|
||||
|
||||
|
21
libc/src/math/dsqrtf128.h
Normal file
21
libc/src/math/dsqrtf128.h
Normal file
@ -0,0 +1,21 @@
|
||||
//===-- Implementation header for dsqrtf128 ---------------------*- 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_DSQRTF128_H
|
||||
#define LLVM_LIBC_SRC_MATH_DSQRTF128_H
|
||||
|
||||
#include "src/__support/macros/config.h"
|
||||
#include "src/__support/macros/properties/types.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
double dsqrtf128(float128 x);
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
|
||||
#endif // LLVM_LIBC_SRC_MATH_DSQRTF128_H
|
20
libc/src/math/dsqrtl.h
Normal file
20
libc/src/math/dsqrtl.h
Normal file
@ -0,0 +1,20 @@
|
||||
//===-- Implementation header for dsqrtl ------------------------*- 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_DSQRTL_H
|
||||
#define LLVM_LIBC_SRC_MATH_DSQRTL_H
|
||||
|
||||
#include "src/__support/macros/config.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
double dsqrtl(long double x);
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
|
||||
#endif // LLVM_LIBC_SRC_MATH_DSQRTL_H
|
@ -129,6 +129,31 @@ add_entrypoint_object(
|
||||
libc.src.__support.FPUtil.nearest_integer_operations
|
||||
)
|
||||
|
||||
add_entrypoint_object(
|
||||
dsqrtl
|
||||
SRCS
|
||||
dsqrtl.cpp
|
||||
HDRS
|
||||
../dsqrtl.h
|
||||
DEPENDS
|
||||
libc.src.__support.FPUtil.generic.sqrt
|
||||
COMPILE_OPTIONS
|
||||
-O3
|
||||
)
|
||||
|
||||
add_entrypoint_object(
|
||||
dsqrtf128
|
||||
SRCS
|
||||
dsqrtf128.cpp
|
||||
HDRS
|
||||
../dsqrtf128.h
|
||||
DEPENDS
|
||||
libc.src.__support.macros.properties.types
|
||||
libc.src.__support.FPUtil.generic.sqrt
|
||||
COMPILE_OPTIONS
|
||||
-O3
|
||||
)
|
||||
|
||||
add_header_library(
|
||||
range_reduction
|
||||
HDRS
|
||||
|
20
libc/src/math/generic/dsqrtf128.cpp
Normal file
20
libc/src/math/generic/dsqrtf128.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//===-- Implementation of dsqrtf128 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/dsqrtf128.h"
|
||||
#include "src/__support/FPUtil/generic/sqrt.h"
|
||||
#include "src/__support/common.h"
|
||||
#include "src/__support/macros/config.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
LLVM_LIBC_FUNCTION(double, dsqrtf128, (float128 x)) {
|
||||
return fputil::sqrt<double>(x);
|
||||
}
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
20
libc/src/math/generic/dsqrtl.cpp
Normal file
20
libc/src/math/generic/dsqrtl.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//===-- Implementation of dsqrtl 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/dsqrtl.h"
|
||||
#include "src/__support/FPUtil/generic/sqrt.h"
|
||||
#include "src/__support/common.h"
|
||||
#include "src/__support/macros/config.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
LLVM_LIBC_FUNCTION(double, dsqrtl, (long double x)) {
|
||||
return fputil::sqrt<double>(x);
|
||||
}
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
@ -2271,6 +2271,19 @@ add_fp_unittest(
|
||||
libc.src.math.fsqrtl
|
||||
)
|
||||
|
||||
add_fp_unittest(
|
||||
dsqrtl_test
|
||||
NEED_MPFR
|
||||
SUITE
|
||||
libc-math-unittests
|
||||
SRCS
|
||||
dsqrtl_test.cpp
|
||||
HDRS
|
||||
SqrtTest.h
|
||||
DEPENDS
|
||||
libc.src.math.dsqrtl
|
||||
)
|
||||
|
||||
add_fp_unittest(
|
||||
cbrtf_test
|
||||
NEED_MPFR
|
||||
|
13
libc/test/src/math/dsqrtl_test.cpp
Normal file
13
libc/test/src/math/dsqrtl_test.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
//===-- Unittests for dsqrtl ----------------------------------------------===//
|
||||
//
|
||||
// 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 "SqrtTest.h"
|
||||
|
||||
#include "src/math/dsqrtl.h"
|
||||
|
||||
LIST_NARROWING_SQRT_TESTS(double, long double, LIBC_NAMESPACE::dsqrtl)
|
@ -3996,6 +3996,30 @@ add_fp_unittest(
|
||||
libc.src.math.fsqrtf128
|
||||
)
|
||||
|
||||
add_fp_unittest(
|
||||
dsqrtl_test
|
||||
SUITE
|
||||
libc-math-smoke-tests
|
||||
SRCS
|
||||
dsqrtl_test.cpp
|
||||
HDRS
|
||||
SqrtTest.h
|
||||
DEPENDS
|
||||
libc.src.math.dsqrtl
|
||||
)
|
||||
|
||||
add_fp_unittest(
|
||||
dsqrtf128_test
|
||||
SUITE
|
||||
libc-math-smoke-tests
|
||||
SRCS
|
||||
dsqrtf128_test.cpp
|
||||
HDRS
|
||||
SqrtTest.h
|
||||
DEPENDS
|
||||
libc.src.math.dsqrtf128
|
||||
)
|
||||
|
||||
add_fp_unittest(
|
||||
sin_test
|
||||
SUITE
|
||||
|
13
libc/test/src/math/smoke/dsqrtf128_test.cpp
Normal file
13
libc/test/src/math/smoke/dsqrtf128_test.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
//===-- Unittests for dsqrtf128 -------------------------------------------===//
|
||||
//
|
||||
// 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 "SqrtTest.h"
|
||||
|
||||
#include "src/math/dsqrtf128.h"
|
||||
|
||||
LIST_NARROWING_SQRT_TESTS(double, float128, LIBC_NAMESPACE::dsqrtf128)
|
13
libc/test/src/math/smoke/dsqrtl_test.cpp
Normal file
13
libc/test/src/math/smoke/dsqrtl_test.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
//===-- Unittests for dsqrtl ----------------------------------------------===//
|
||||
//
|
||||
// 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 "SqrtTest.h"
|
||||
|
||||
#include "src/math/dsqrtl.h"
|
||||
|
||||
LIST_NARROWING_SQRT_TESTS(double, long double, LIBC_NAMESPACE::dsqrtl)
|
@ -893,6 +893,9 @@ template void explain_unary_operation_single_output_error(Operation op, double,
|
||||
template void explain_unary_operation_single_output_error(Operation op,
|
||||
long double, float,
|
||||
double, RoundingMode);
|
||||
template void explain_unary_operation_single_output_error(Operation op,
|
||||
long double, double,
|
||||
double, RoundingMode);
|
||||
|
||||
#ifdef LIBC_TYPES_HAS_FLOAT16
|
||||
template void explain_unary_operation_single_output_error(Operation op, float16,
|
||||
@ -1118,6 +1121,9 @@ template bool compare_unary_operation_single_output(Operation, double, float,
|
||||
template bool compare_unary_operation_single_output(Operation, long double,
|
||||
float, double,
|
||||
RoundingMode);
|
||||
template bool compare_unary_operation_single_output(Operation, long double,
|
||||
double, double,
|
||||
RoundingMode);
|
||||
#ifdef LIBC_TYPES_HAS_FLOAT16
|
||||
template bool compare_unary_operation_single_output(Operation, float16, float16,
|
||||
double, RoundingMode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user