Skip to content

Commit ed12f80

Browse files
author
Job Henandez Lara
authored
[libc][math][c23] add entrypoints and tests for getpayload{,f,f128} (#101285)
1 parent 42c413b commit ed12f80

19 files changed

+253
-1
lines changed

libc/config/gpu/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ set(TARGET_LIBM_ENTRYPOINTS
283283
libc.src.math.fmodf
284284
libc.src.math.frexp
285285
libc.src.math.frexpf
286+
libc.src.math.getpayload
287+
libc.src.math.getpayloadf
286288
libc.src.math.hypot
287289
libc.src.math.hypotf
288290
libc.src.math.ilogb

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ set(TARGET_LIBM_ENTRYPOINTS
433433
libc.src.math.fromfpxl
434434
libc.src.math.fsqrt
435435
libc.src.math.fsqrtl
436+
libc.src.math.getpayload
437+
libc.src.math.getpayloadf
436438
libc.src.math.hypot
437439
libc.src.math.hypotf
438440
libc.src.math.ilogb
@@ -634,6 +636,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
634636
libc.src.math.frexpf128
635637
libc.src.math.fromfpf128
636638
libc.src.math.fromfpxf128
639+
libc.src.math.getpayloadf128
637640
libc.src.math.ilogbf128
638641
libc.src.math.ldexpf128
639642
libc.src.math.llogbf128

libc/config/linux/arm/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ set(TARGET_LIBM_ENTRYPOINTS
293293
libc.src.math.fromfpx
294294
libc.src.math.fromfpxf
295295
libc.src.math.fromfpxl
296+
libc.src.math.getpayload
297+
libc.src.math.getpayloadf
296298
libc.src.math.hypot
297299
libc.src.math.hypotf
298300
libc.src.math.ilogb

libc/config/linux/riscv/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ set(TARGET_LIBM_ENTRYPOINTS
456456
libc.src.math.fromfpxl
457457
libc.src.math.fsqrt
458458
libc.src.math.fsqrtl
459+
libc.src.math.getpayload
460+
libc.src.math.getpayloadf
459461
libc.src.math.hypot
460462
libc.src.math.hypotf
461463
libc.src.math.ilogb
@@ -590,6 +592,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
590592
libc.src.math.fromfpf128
591593
libc.src.math.fromfpxf128
592594
libc.src.math.fsqrtf128
595+
libc.src.math.getpayloadf128
593596
libc.src.math.ilogbf128
594597
libc.src.math.ldexpf128
595598
libc.src.math.llogbf128

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ set(TARGET_LIBM_ENTRYPOINTS
456456
libc.src.math.fromfpxl
457457
libc.src.math.fsqrt
458458
libc.src.math.fsqrtl
459+
libc.src.math.getpayload
460+
libc.src.math.getpayloadf
459461
libc.src.math.hypot
460462
libc.src.math.hypotf
461463
libc.src.math.ilogb
@@ -679,6 +681,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
679681
libc.src.math.fromfpf128
680682
libc.src.math.fromfpxf128
681683
libc.src.math.fsqrtf128
684+
libc.src.math.getpayloadf128
682685
libc.src.math.ilogbf128
683686
libc.src.math.ldexpf128
684687
libc.src.math.llogbf128

libc/docs/math/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Basic Operations
178178
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
179179
| fsub | N/A | | | N/A | | 7.12.14.2 | F.10.11 |
180180
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
181-
| getpayload | | | | |check| | | F.10.13.1 | N/A |
181+
| getpayload | |check| | |check| | | |check| | |check| | F.10.13.1 | N/A |
182182
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
183183
| ilogb | |check| | |check| | |check| | |check| | |check| | 7.12.6.8 | F.10.3.8 |
184184
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+

libc/spec/stdc.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,10 @@ def StdC : StandardSpec<"stdc"> {
736736
GuardedFunctionSpec<"totalordermagf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
737737
GuardedFunctionSpec<"totalordermagf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Ptr>], "LIBC_TYPES_HAS_FLOAT128">,
738738

739+
FunctionSpec<"getpayload", RetValSpec<DoubleType>, [ArgSpec<DoublePtr>]>,
740+
FunctionSpec<"getpayloadf", RetValSpec<FloatType>, [ArgSpec<FloatPtr>]>,
739741
GuardedFunctionSpec<"getpayloadf16", RetValSpec<Float16Type>, [ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
742+
GuardedFunctionSpec<"getpayloadf128", RetValSpec<Float128Type>, [ArgSpec<Float128Ptr>], "LIBC_TYPES_HAS_FLOAT128">,
740743

741744
FunctionSpec<"setpayload", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoubleType>]>,
742745
FunctionSpec<"setpayloadf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatType>]>,

libc/src/math/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,10 @@ add_math_entrypoint_object(fromfpxl)
260260
add_math_entrypoint_object(fromfpxf16)
261261
add_math_entrypoint_object(fromfpxf128)
262262

263+
add_math_entrypoint_object(getpayload)
264+
add_math_entrypoint_object(getpayloadf)
263265
add_math_entrypoint_object(getpayloadf16)
266+
add_math_entrypoint_object(getpayloadf128)
264267

265268
add_math_entrypoint_object(hypot)
266269
add_math_entrypoint_object(hypotf)

libc/src/math/generic/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4155,6 +4155,30 @@ add_entrypoint_object(
41554155
-O3
41564156
)
41574157

4158+
add_entrypoint_object(
4159+
getpayload
4160+
SRCS
4161+
getpayload.cpp
4162+
HDRS
4163+
../getpayload.h
4164+
DEPENDS
4165+
libc.src.__support.FPUtil.basic_operations
4166+
COMPILE_OPTIONS
4167+
-O3
4168+
)
4169+
4170+
add_entrypoint_object(
4171+
getpayloadf
4172+
SRCS
4173+
getpayloadf.cpp
4174+
HDRS
4175+
../getpayloadf.h
4176+
DEPENDS
4177+
libc.src.__support.FPUtil.basic_operations
4178+
COMPILE_OPTIONS
4179+
-O3
4180+
)
4181+
41584182
add_entrypoint_object(
41594183
getpayloadf16
41604184
SRCS
@@ -4168,6 +4192,19 @@ add_entrypoint_object(
41684192
-O3
41694193
)
41704194

4195+
add_entrypoint_object(
4196+
getpayloadf128
4197+
SRCS
4198+
getpayloadf128.cpp
4199+
HDRS
4200+
../getpayloadf128.h
4201+
DEPENDS
4202+
libc.src.__support.macros.properties.types
4203+
libc.src.__support.FPUtil.basic_operations
4204+
COMPILE_OPTIONS
4205+
-O3
4206+
)
4207+
41714208
add_entrypoint_object(
41724209
setpayload
41734210
SRCS

libc/src/math/generic/getpayload.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of getpayload function -----------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/math/getpayload.h"
10+
#include "src/__support/FPUtil/BasicOperations.h"
11+
#include "src/__support/common.h"
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
LLVM_LIBC_FUNCTION(double, getpayload, (const double *x)) {
17+
return fputil::getpayload(*x);
18+
}
19+
20+
} // namespace LIBC_NAMESPACE_DECL

libc/src/math/generic/getpayloadf.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of getpayloadf function ----------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/math/getpayloadf.h"
10+
#include "src/__support/FPUtil/BasicOperations.h"
11+
#include "src/__support/common.h"
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
LLVM_LIBC_FUNCTION(float, getpayloadf, (const float *x)) {
17+
return fputil::getpayload(*x);
18+
}
19+
20+
} // namespace LIBC_NAMESPACE_DECL
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of getpayloadf128 function -------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/math/getpayloadf128.h"
10+
#include "src/__support/FPUtil/BasicOperations.h"
11+
#include "src/__support/common.h"
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
LLVM_LIBC_FUNCTION(float128, getpayloadf128, (const float128 *x)) {
17+
return fputil::getpayload(*x);
18+
}
19+
20+
} // namespace LIBC_NAMESPACE_DECL

libc/src/math/getpayload.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for getpayload --------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_MATH_GETPAYLOAD_H
10+
#define LLVM_LIBC_SRC_MATH_GETPAYLOAD_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
double getpayload(const double *x);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_MATH_GETPAYLOAD_H

libc/src/math/getpayloadf.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for getpayloadf -------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_MATH_GETPAYLOADF_H
10+
#define LLVM_LIBC_SRC_MATH_GETPAYLOADF_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
float getpayloadf(const float *x);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_MATH_GETPAYLOADF_H

libc/src/math/getpayloadf128.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation header for getpayloadf128 ----------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_MATH_GETPAYLOADF128_H
10+
#define LLVM_LIBC_SRC_MATH_GETPAYLOADF128_H
11+
12+
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/types.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
17+
float128 getpayloadf128(const float128 *x);
18+
19+
} // namespace LIBC_NAMESPACE_DECL
20+
21+
#endif // LLVM_LIBC_SRC_MATH_GETPAYLOADF128_H

libc/test/src/math/smoke/CMakeLists.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,6 +3814,30 @@ add_fp_unittest(
38143814
libc.src.math.totalordermagf128
38153815
)
38163816

3817+
add_fp_unittest(
3818+
getpayload_test
3819+
SUITE
3820+
libc-math-smoke-tests
3821+
SRCS
3822+
getpayload_test.cpp
3823+
HDRS
3824+
GetPayloadTest.h
3825+
DEPENDS
3826+
libc.src.math.getpayload
3827+
)
3828+
3829+
add_fp_unittest(
3830+
getpayloadf_test
3831+
SUITE
3832+
libc-math-smoke-tests
3833+
SRCS
3834+
getpayloadf_test.cpp
3835+
HDRS
3836+
GetPayloadTest.h
3837+
DEPENDS
3838+
libc.src.math.getpayloadf
3839+
)
3840+
38173841
add_fp_unittest(
38183842
getpayloadf16_test
38193843
SUITE
@@ -3826,6 +3850,18 @@ add_fp_unittest(
38263850
libc.src.math.getpayloadf16
38273851
)
38283852

3853+
add_fp_unittest(
3854+
getpayloadf128_test
3855+
SUITE
3856+
libc-math-smoke-tests
3857+
SRCS
3858+
getpayloadf128_test.cpp
3859+
HDRS
3860+
GetPayloadTest.h
3861+
DEPENDS
3862+
libc.src.math.getpayloadf128
3863+
)
3864+
38293865
add_fp_unittest(
38303866
setpayload_test
38313867
SUITE
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===-- Unittests for getpayload ------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "GetPayloadTest.h"
10+
11+
#include "src/math/getpayload.h"
12+
13+
LIST_GETPAYLOAD_TESTS(double, LIBC_NAMESPACE::getpayload)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===-- Unittests for getpayloadf128 --------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "GetPayloadTest.h"
10+
11+
#include "src/math/getpayloadf128.h"
12+
13+
LIST_GETPAYLOAD_TESTS(float128, LIBC_NAMESPACE::getpayloadf128)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===-- Unittests for getpayloadf -----------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "GetPayloadTest.h"
10+
11+
#include "src/math/getpayloadf.h"
12+
13+
LIST_GETPAYLOAD_TESTS(float, LIBC_NAMESPACE::getpayloadf)

0 commit comments

Comments
 (0)