Skip to content

Commit 0813260

Browse files
author
Job Henandez Lara
authored
[libc][math][c23] Add entrypoints and tests for totalorder{,f,f128} (#100593)
1 parent c3f7f28 commit 0813260

18 files changed

+252
-2
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ set(TARGET_LIBM_ENTRYPOINTS
520520
libc.src.math.tan
521521
libc.src.math.tanf
522522
libc.src.math.tanhf
523+
libc.src.math.totalorder
524+
libc.src.math.totalorderf
523525
libc.src.math.totalordermag
524526
libc.src.math.totalordermagf
525527
libc.src.math.totalordermagl
@@ -646,6 +648,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
646648
libc.src.math.roundevenf128
647649
libc.src.math.scalbnf128
648650
libc.src.math.sqrtf128
651+
libc.src.math.totalorderf128
649652
libc.src.math.totalordermagf128
650653
libc.src.math.truncf128
651654
libc.src.math.ufromfpf128

libc/config/linux/arm/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ set(TARGET_LIBM_ENTRYPOINTS
374374
libc.src.math.tan
375375
libc.src.math.tanf
376376
libc.src.math.tanhf
377+
libc.src.math.totalorder
378+
libc.src.math.totalorderf
377379
libc.src.math.totalordermag
378380
libc.src.math.totalordermagf
379381
libc.src.math.totalordermagl

libc/config/linux/riscv/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@ set(TARGET_LIBM_ENTRYPOINTS
542542
libc.src.math.tan
543543
libc.src.math.tanf
544544
libc.src.math.tanhf
545+
libc.src.math.totalorder
546+
libc.src.math.totalorderf
545547
libc.src.math.totalordermag
546548
libc.src.math.totalordermagf
547549
libc.src.math.totalordermagl
@@ -603,6 +605,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
603605
libc.src.math.roundf128
604606
libc.src.math.scalbnf128
605607
libc.src.math.sqrtf128
608+
libc.src.math.totalorderf128
606609
libc.src.math.totalordermagf128
607610
libc.src.math.truncf128
608611
libc.src.math.ufromfpf128

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@ set(TARGET_LIBM_ENTRYPOINTS
542542
libc.src.math.tan
543543
libc.src.math.tanf
544544
libc.src.math.tanhf
545+
libc.src.math.totalorder
546+
libc.src.math.totalorderf
545547
libc.src.math.totalordermag
546548
libc.src.math.totalordermagf
547549
libc.src.math.totalordermagl
@@ -690,6 +692,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
690692
libc.src.math.roundf128
691693
libc.src.math.scalbnf128
692694
libc.src.math.sqrtf128
695+
libc.src.math.totalorderf128
693696
libc.src.math.totalordermagf128
694697
libc.src.math.truncf128
695698
libc.src.math.ufromfpf128

libc/docs/math/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ Basic Operations
228228
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
229229
| setpayloadsig | | | | |check| | | F.10.13.3 | N/A |
230230
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
231-
| totalorder | | | | |check| | | F.10.12.1 | N/A |
231+
| totalorder | |check| | |check| | | |check| | |check| | F.10.12.1 | N/A |
232232
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
233233
| totalordermag | |check| | |check| | |check| | |check| | |check| | F.10.12.2 | N/A |
234234
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+

libc/spec/stdc.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,11 @@ def StdC : StandardSpec<"stdc"> {
721721
GuardedFunctionSpec<"canonicalizef128", RetValSpec<IntType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
722722

723723
FunctionSpec<"dsqrtl", RetValSpec<DoubleType>, [ArgSpec<LongDoubleType>]>,
724-
724+
725+
FunctionSpec<"totalorder", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoublePtr>]>,
726+
FunctionSpec<"totalorderf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatPtr>]>,
725727
GuardedFunctionSpec<"totalorderf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
728+
GuardedFunctionSpec<"totalorderf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Ptr>], "LIBC_TYPES_HAS_FLOAT128">,
726729

727730
FunctionSpec<"totalordermag", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoublePtr>]>,
728731
FunctionSpec<"totalordermagf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatPtr>]>,

libc/src/math/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,10 @@ add_math_entrypoint_object(tanhf)
434434
add_math_entrypoint_object(tgamma)
435435
add_math_entrypoint_object(tgammaf)
436436

437+
add_math_entrypoint_object(totalorder)
438+
add_math_entrypoint_object(totalorderf)
437439
add_math_entrypoint_object(totalorderf16)
440+
add_math_entrypoint_object(totalorderf128)
438441

439442
add_math_entrypoint_object(totalordermag)
440443
add_math_entrypoint_object(totalordermagf)

libc/src/math/generic/CMakeLists.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3994,6 +3994,30 @@ add_entrypoint_object(
39943994
-O3
39953995
)
39963996

3997+
add_entrypoint_object(
3998+
totalorder
3999+
SRCS
4000+
totalorder.cpp
4001+
HDRS
4002+
../totalorder.h
4003+
DEPENDS
4004+
libc.src.__support.FPUtil.basic_operations
4005+
COMPILE_OPTIONS
4006+
-O3
4007+
)
4008+
4009+
add_entrypoint_object(
4010+
totalorderf
4011+
SRCS
4012+
totalorderf.cpp
4013+
HDRS
4014+
../totalorderf.h
4015+
DEPENDS
4016+
libc.src.__support.FPUtil.basic_operations
4017+
COMPILE_OPTIONS
4018+
-O3
4019+
)
4020+
39974021
add_entrypoint_object(
39984022
totalorderf16
39994023
SRCS
@@ -4006,6 +4030,18 @@ add_entrypoint_object(
40064030
-O3
40074031
)
40084032

4033+
add_entrypoint_object(
4034+
totalorderf128
4035+
SRCS
4036+
totalorderf128.cpp
4037+
HDRS
4038+
../totalorderf128.h
4039+
DEPENDS
4040+
libc.src.__support.FPUtil.basic_operations
4041+
libc.src.__support.macros.properties.types
4042+
COMPILE_OPTIONS
4043+
-O3
4044+
)
40094045
add_entrypoint_object(
40104046
totalordermag
40114047
SRCS

libc/src/math/generic/totalorder.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of totalorder 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/totalorder.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, totalorder, (const double *x, const double *y)) {
17+
return static_cast<int>(fputil::totalorder(*x, *y));
18+
}
19+
20+
} // namespace LIBC_NAMESPACE_DECL

libc/src/math/generic/totalorderf.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of totalorderf 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/totalorderf.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, totalorderf, (const float *x, const float *y)) {
17+
return static_cast<int>(fputil::totalorder(*x, *y));
18+
}
19+
20+
} // namespace LIBC_NAMESPACE_DECL
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation of totalorderf128 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/totalorderf128.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, totalorderf128,
17+
(const float128 *x, const float128 *y)) {
18+
return static_cast<int>(fputil::totalorder(*x, *y));
19+
}
20+
21+
} // namespace LIBC_NAMESPACE_DECL

libc/src/math/totalorder.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for totalorder --------------------*- 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_TOTALORDER_H
10+
#define LLVM_LIBC_SRC_MATH_TOTALORDER_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
int totalorder(const double *x, const double *y);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_MATH_TOTALORDER_H

libc/src/math/totalorderf.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for totalorderf -------------------*- 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_TOTALORDERF_H
10+
#define LLVM_LIBC_SRC_MATH_TOTALORDERF_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
int totalorderf(const float *x, const float *y);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_MATH_TOTALORDERF_H

libc/src/math/totalorderf128.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation header for totalorderf128 ----------------*- 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_TOTALORDERF128_H
10+
#define LLVM_LIBC_SRC_MATH_TOTALORDERF128_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+
int totalorderf128(const float128 *x, const float128 *y);
18+
19+
} // namespace LIBC_NAMESPACE_DECL
20+
21+
#endif // LLVM_LIBC_SRC_MATH_TOTALORDERF128_H

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,6 +3654,30 @@ add_fp_unittest(
36543654
libc.src.__support.FPUtil.fp_bits
36553655
)
36563656

3657+
add_fp_unittest(
3658+
totalorder_test
3659+
SUITE
3660+
libc-math-smoke-tests
3661+
SRCS
3662+
totalorder_test.cpp
3663+
HDRS
3664+
TotalOrderTest.h
3665+
DEPENDS
3666+
libc.src.math.totalorder
3667+
)
3668+
3669+
add_fp_unittest(
3670+
totalorderf_test
3671+
SUITE
3672+
libc-math-smoke-tests
3673+
SRCS
3674+
totalorderf_test.cpp
3675+
HDRS
3676+
TotalOrderTest.h
3677+
DEPENDS
3678+
libc.src.math.totalorderf
3679+
)
3680+
36573681
add_fp_unittest(
36583682
totalorderf16_test
36593683
SUITE
@@ -3666,6 +3690,18 @@ add_fp_unittest(
36663690
libc.src.math.totalorderf16
36673691
)
36683692

3693+
add_fp_unittest(
3694+
totalorderf128_test
3695+
SUITE
3696+
libc-math-smoke-tests
3697+
SRCS
3698+
totalorderf128_test.cpp
3699+
HDRS
3700+
TotalOrderTest.h
3701+
DEPENDS
3702+
libc.src.math.totalorderf128
3703+
)
3704+
36693705
add_fp_unittest(
36703706
totalordermag_test
36713707
SUITE
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===-- Unittests for totalorder ------------------------------------------===//
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 "TotalOrderTest.h"
10+
11+
#include "src/math/totalorder.h"
12+
13+
LIST_TOTALORDER_TESTS(double, LIBC_NAMESPACE::totalorder)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===-- Unittests for totalorderf128 --------------------------------------===//
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 "TotalOrderTest.h"
10+
11+
#include "src/math/totalorderf128.h"
12+
13+
LIST_TOTALORDER_TESTS(float128, LIBC_NAMESPACE::totalorderf128)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===-- Unittests for totalorderf -----------------------------------------===//
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 "TotalOrderTest.h"
10+
11+
#include "src/math/totalorderf.h"
12+
13+
LIST_TOTALORDER_TESTS(float, LIBC_NAMESPACE::totalorderf)

0 commit comments

Comments
 (0)