Skip to content

Commit 546e4a2

Browse files
author
Job Henandez Lara
authored
[libc][math][c23] Add entrypoints and tests for setpayload{,f,f128} (#101122)
1 parent ebdcb76 commit 546e4a2

File tree

18 files changed

+251
-2
lines changed

18 files changed

+251
-2
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,8 @@ set(TARGET_LIBM_ENTRYPOINTS
508508
libc.src.math.scalbn
509509
libc.src.math.scalbnf
510510
libc.src.math.scalbnl
511+
libc.src.math.setpayload
512+
libc.src.math.setpayloadf
511513
libc.src.math.sin
512514
libc.src.math.sincos
513515
libc.src.math.sincosf
@@ -647,6 +649,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
647649
libc.src.math.roundf128
648650
libc.src.math.roundevenf128
649651
libc.src.math.scalbnf128
652+
libc.src.math.setpayloadf128
650653
libc.src.math.sqrtf128
651654
libc.src.math.totalorderf128
652655
libc.src.math.totalordermagf128

libc/config/linux/arm/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ set(TARGET_LIBM_ENTRYPOINTS
363363
libc.src.math.scalbn
364364
libc.src.math.scalbnf
365365
libc.src.math.scalbnl
366+
libc.src.math.setpayload
367+
libc.src.math.setpayloadf
366368
libc.src.math.sin
367369
libc.src.math.sincos
368370
libc.src.math.sincosf

libc/config/linux/riscv/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ set(TARGET_LIBM_ENTRYPOINTS
530530
libc.src.math.scalbn
531531
libc.src.math.scalbnf
532532
libc.src.math.scalbnl
533+
libc.src.math.setpayload
534+
libc.src.math.setpayloadf
533535
libc.src.math.sin
534536
libc.src.math.sincos
535537
libc.src.math.sincosf

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ set(TARGET_LIBM_ENTRYPOINTS
530530
libc.src.math.scalbn
531531
libc.src.math.scalbnf
532532
libc.src.math.scalbnl
533+
libc.src.math.setpayload
534+
libc.src.math.setpayloadf
533535
libc.src.math.sin
534536
libc.src.math.sincos
535537
libc.src.math.sincosf
@@ -691,6 +693,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
691693
libc.src.math.roundevenf128
692694
libc.src.math.roundf128
693695
libc.src.math.scalbnf128
696+
libc.src.math.setpayloadf128
694697
libc.src.math.sqrtf128
695698
libc.src.math.totalorderf128
696699
libc.src.math.totalordermagf128

libc/docs/math/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Basic Operations
224224
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
225225
| scalbn | |check| | |check| | |check| | |check| | |check| | 7.12.6.19 | F.10.3.19 |
226226
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
227-
| setpayload | | | | |check| | | F.10.13.2 | N/A |
227+
| setpayload | |check| | |check| | | |check| | |check| | F.10.13.2 | N/A |
228228
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
229229
| setpayloadsig | | | | |check| | | F.10.13.3 | N/A |
230230
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+

libc/spec/stdc.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,11 @@ def StdC : StandardSpec<"stdc"> {
734734
GuardedFunctionSpec<"totalordermagf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Ptr>], "LIBC_TYPES_HAS_FLOAT128">,
735735

736736
GuardedFunctionSpec<"getpayloadf16", RetValSpec<Float16Type>, [ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
737-
737+
738+
FunctionSpec<"setpayload", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoubleType>],
739+
FunctionSpec<"setpayloadf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatType>],
738740
GuardedFunctionSpec<"setpayloadf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
741+
GuardedFunctionSpec<"setpayloadf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
739742

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

libc/src/math/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,10 @@ add_math_entrypoint_object(scalbnl)
406406
add_math_entrypoint_object(scalbnf16)
407407
add_math_entrypoint_object(scalbnf128)
408408

409+
add_math_entrypoint_object(setpayload)
410+
add_math_entrypoint_object(setpayloadf)
409411
add_math_entrypoint_object(setpayloadf16)
412+
add_math_entrypoint_object(setpayloadf128)
410413

411414
add_math_entrypoint_object(setpayloadsigf16)
412415

libc/src/math/generic/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4116,6 +4116,30 @@ add_entrypoint_object(
41164116
-O3
41174117
)
41184118

4119+
add_entrypoint_object(
4120+
setpayload
4121+
SRCS
4122+
setpayload.cpp
4123+
HDRS
4124+
../setpayload.h
4125+
DEPENDS
4126+
libc.src.__support.FPUtil.basic_operations
4127+
COMPILE_OPTIONS
4128+
-O3
4129+
)
4130+
4131+
add_entrypoint_object(
4132+
setpayloadf
4133+
SRCS
4134+
setpayloadf.cpp
4135+
HDRS
4136+
../setpayloadf.h
4137+
DEPENDS
4138+
libc.src.__support.FPUtil.basic_operations
4139+
COMPILE_OPTIONS
4140+
-O3
4141+
)
4142+
41194143
add_entrypoint_object(
41204144
setpayloadf16
41214145
SRCS
@@ -4129,6 +4153,19 @@ add_entrypoint_object(
41294153
-O3
41304154
)
41314155

4156+
add_entrypoint_object(
4157+
setpayloadf128
4158+
SRCS
4159+
setpayloadf128.cpp
4160+
HDRS
4161+
../setpayloadf128.h
4162+
DEPENDS
4163+
libc.src.__support.macros.properties.types
4164+
libc.src.__support.FPUtil.basic_operations
4165+
COMPILE_OPTIONS
4166+
-O3
4167+
)
4168+
41324169
add_entrypoint_object(
41334170
setpayloadsigf16
41344171
SRCS
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of setpayload 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/setpayload.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(int, setpayload, (double *res, double pl)) {
17+
return static_cast<int>(fputil::setpayload</*IsSignaling=*/false>(*res, pl));
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 setpayloadf 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/setpayloadf.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(int, setpayloadf, (float *res, float pl)) {
17+
return static_cast<int>(fputil::setpayload</*IsSignaling=*/false>(*res, pl));
18+
}
19+
20+
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)