Skip to content

[libc][math][c23] Add entrypoints and tests for setpayload{,f,f128} #101122

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

Merged
merged 3 commits into from Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libc/config/linux/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbn
libc.src.math.scalbnf
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
libc.src.math.sin
libc.src.math.sincos
libc.src.math.sincosf
Expand Down Expand Up @@ -645,6 +647,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.roundf128
libc.src.math.roundevenf128
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.sqrtf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
Expand Down
2 changes: 2 additions & 0 deletions libc/config/linux/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbn
libc.src.math.scalbnf
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
libc.src.math.sin
libc.src.math.sincos
libc.src.math.sincosf
Expand Down
2 changes: 2 additions & 0 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbn
libc.src.math.scalbnf
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
libc.src.math.sin
libc.src.math.sincos
libc.src.math.sincosf
Expand Down
3 changes: 3 additions & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbn
libc.src.math.scalbnf
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
libc.src.math.sin
libc.src.math.sincos
libc.src.math.sincosf
Expand Down Expand Up @@ -688,6 +690,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.roundevenf128
libc.src.math.roundf128
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.sqrtf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
Expand Down
2 changes: 1 addition & 1 deletion libc/docs/math/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| scalbn | |check| | |check| | |check| | |check| | |check| | 7.12.6.19 | F.10.3.19 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| setpayload | | | | |check| | | F.10.13.2 | N/A |
| setpayload | |check| | |check| | | |check| | |check| | F.10.13.2 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| setpayloadsig | | | | |check| | | F.10.13.3 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
Expand Down
5 changes: 4 additions & 1 deletion libc/spec/stdc.td
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,11 @@ def StdC : StandardSpec<"stdc"> {
GuardedFunctionSpec<"totalordermagf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Ptr>], "LIBC_TYPES_HAS_FLOAT128">,

GuardedFunctionSpec<"getpayloadf16", RetValSpec<Float16Type>, [ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,


FunctionSpec<"setpayload", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoubleType>],
FunctionSpec<"setpayloadf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatType>],
GuardedFunctionSpec<"setpayloadf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"setpayloadf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,

GuardedFunctionSpec<"setpayloadsigf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,

Expand Down
3 changes: 3 additions & 0 deletions libc/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,10 @@ add_math_entrypoint_object(scalbnl)
add_math_entrypoint_object(scalbnf16)
add_math_entrypoint_object(scalbnf128)

add_math_entrypoint_object(setpayload)
add_math_entrypoint_object(setpayloadf)
add_math_entrypoint_object(setpayloadf16)
add_math_entrypoint_object(setpayloadf128)

add_math_entrypoint_object(setpayloadsigf16)

Expand Down
37 changes: 37 additions & 0 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4059,6 +4059,30 @@ add_entrypoint_object(
-O3
)

add_entrypoint_object(
setpayload
SRCS
setpayload.cpp
HDRS
../setpayload.h
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
setpayloadf
SRCS
setpayloadf.cpp
HDRS
../setpayloadf.h
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
setpayloadf16
SRCS
Expand All @@ -4072,6 +4096,19 @@ add_entrypoint_object(
-O3
)

add_entrypoint_object(
setpayloadf128
SRCS
setpayloadf128.cpp
HDRS
../setpayloadf128.h
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
setpayloadsigf16
SRCS
Expand Down
20 changes: 20 additions & 0 deletions libc/src/math/generic/setpayload.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of setpayload 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/setpayload.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(int, setpayload, (double *res, double pl)) {
return static_cast<int>(fputil::setpayload</*IsSignaling=*/false>(*res, pl));
}

} // namespace LIBC_NAMESPACE_DECL
20 changes: 20 additions & 0 deletions libc/src/math/generic/setpayloadf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of setpayloadf 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/setpayloadf.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(int, setpayloadf, (float *res, float pl)) {
return static_cast<int>(fputil::setpayload</*IsSignaling=*/false>(*res, pl));
}

} // namespace LIBC_NAMESPACE_DECL
20 changes: 20 additions & 0 deletions libc/src/math/generic/setpayloadf128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of setpayloadf128 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/setpayloadf128.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(int, setpayloadf128, (float128 * res, float128 pl)) {
return static_cast<int>(fputil::setpayload</*IsSignaling=*/false>(*res, pl));
}

} // namespace LIBC_NAMESPACE_DECL
20 changes: 20 additions & 0 deletions libc/src/math/setpayload.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for setpayload --------------------*- 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_SETPAYLOAD_H
#define LLVM_LIBC_SRC_MATH_SETPAYLOAD_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

int setpayload(double *res, double pl);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_SETPAYLOAD_H
20 changes: 20 additions & 0 deletions libc/src/math/setpayloadf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for setpayloadf -------------------*- 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_SETPAYLOADF_H
#define LLVM_LIBC_SRC_MATH_SETPAYLOADF_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

int setpayloadf(float *res, float pl);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_SETPAYLOADF_H
21 changes: 21 additions & 0 deletions libc/src/math/setpayloadf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for setpayloadf128 ----------------*- 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_SETPAYLOADF128_H
#define LLVM_LIBC_SRC_MATH_SETPAYLOADF128_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE_DECL {

int setpayloadf128(float128 *res, float128 pl);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_SETPAYLOADF128_H
36 changes: 36 additions & 0 deletions libc/test/src/math/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3725,6 +3725,30 @@ add_fp_unittest(
libc.src.math.getpayloadf16
)

add_fp_unittest(
setpayload_test
SUITE
libc-math-smoke-tests
SRCS
setpayload_test.cpp
HDRS
SetPayloadTest.h
DEPENDS
libc.src.math.setpayload
)

add_fp_unittest(
setpayloadf_test
SUITE
libc-math-smoke-tests
SRCS
setpayloadf_test.cpp
HDRS
SetPayloadTest.h
DEPENDS
libc.src.math.setpayloadf
)

add_fp_unittest(
setpayloadf16_test
SUITE
Expand All @@ -3737,6 +3761,18 @@ add_fp_unittest(
libc.src.math.setpayloadf16
)

add_fp_unittest(
setpayloadf128_test
SUITE
libc-math-smoke-tests
SRCS
setpayloadf128_test.cpp
HDRS
SetPayloadTest.h
DEPENDS
libc.src.math.setpayloadf128
)

add_fp_unittest(
setpayloadsigf16_test
SUITE
Expand Down
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/setpayload_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for setpayload ------------------------------------------===//
//
// 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 "SetPayloadTest.h"

#include "src/math/setpayload.h"

LIST_SETPAYLOAD_TESTS(double, LIBC_NAMESPACE::setpayload)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/setpayloadf128_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for setpayloadf128 --------------------------------------===//
//
// 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 "SetPayloadTest.h"

#include "src/math/setpayloadf128.h"

LIST_SETPAYLOAD_TESTS(float128, LIBC_NAMESPACE::setpayloadf128)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/setpayloadf_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for setpayloadf -----------------------------------------===//
//
// 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 "SetPayloadTest.h"

#include "src/math/setpayloadf.h"

LIST_SETPAYLOAD_TESTS(float, LIBC_NAMESPACE::setpayloadf)
Loading