Skip to content

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

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 5 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 @@ -520,6 +520,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tan
libc.src.math.tanf
libc.src.math.tanhf
libc.src.math.totalorder
libc.src.math.totalorderf
libc.src.math.totalordermag
libc.src.math.totalordermagf
libc.src.math.totalordermagl
Expand Down Expand Up @@ -646,6 +648,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.roundevenf128
libc.src.math.scalbnf128
libc.src.math.sqrtf128
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
libc.src.math.ufromfpf128
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 @@ -374,6 +374,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tan
libc.src.math.tanf
libc.src.math.tanhf
libc.src.math.totalorder
libc.src.math.totalorderf
libc.src.math.totalordermag
libc.src.math.totalordermagf
libc.src.math.totalordermagl
Expand Down
3 changes: 3 additions & 0 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tan
libc.src.math.tanf
libc.src.math.tanhf
libc.src.math.totalorder
libc.src.math.totalorderf
libc.src.math.totalordermag
libc.src.math.totalordermagf
libc.src.math.totalordermagl
Expand Down Expand Up @@ -603,6 +605,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.roundf128
libc.src.math.scalbnf128
libc.src.math.sqrtf128
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
libc.src.math.ufromfpf128
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 @@ -542,6 +542,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tan
libc.src.math.tanf
libc.src.math.tanhf
libc.src.math.totalorder
libc.src.math.totalorderf
libc.src.math.totalordermag
libc.src.math.totalordermagf
libc.src.math.totalordermagl
Expand Down Expand Up @@ -689,6 +691,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.roundf128
libc.src.math.scalbnf128
libc.src.math.sqrtf128
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
libc.src.math.ufromfpf128
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 @@ -228,7 +228,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| setpayloadsig | | | | |check| | | F.10.13.3 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| totalorder | | | | |check| | | F.10.12.1 | N/A |
| totalorder | |check| | |check| | | |check| | |check| | F.10.12.1 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| totalordermag | |check| | |check| | |check| | |check| | |check| | F.10.12.2 | 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 @@ -720,8 +720,11 @@ def StdC : StandardSpec<"stdc"> {
GuardedFunctionSpec<"canonicalizef128", RetValSpec<IntType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,

FunctionSpec<"dsqrtl", RetValSpec<DoubleType>, [ArgSpec<LongDoubleType>]>,


FunctionSpec<"totalorder", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoublePtr>]>,
FunctionSpec<"totalorderf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatPtr>]>,
GuardedFunctionSpec<"totalorderf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"totalorderf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Ptr>], "LIBC_TYPES_HAS_FLOAT128">,

FunctionSpec<"totalordermag", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoublePtr>]>,
FunctionSpec<"totalordermagf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatPtr>]>,
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 @@ -433,7 +433,10 @@ add_math_entrypoint_object(tanhf)
add_math_entrypoint_object(tgamma)
add_math_entrypoint_object(tgammaf)

add_math_entrypoint_object(totalorder)
add_math_entrypoint_object(totalorderf)
add_math_entrypoint_object(totalorderf16)
add_math_entrypoint_object(totalorderf128)

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

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

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

add_entrypoint_object(
totalorderf16
SRCS
Expand All @@ -3985,6 +4009,18 @@ add_entrypoint_object(
-O3
)

add_entrypoint_object(
totalorderf128
SRCS
totalorderf128.cpp
HDRS
../totalorderf128.h
DEPENDS
libc.src.__support.FPUtil.basic_operations
libc.src.__support.macros.properties.types
COMPILE_OPTIONS
-O3
)
add_entrypoint_object(
totalordermag
SRCS
Expand Down
20 changes: 20 additions & 0 deletions libc/src/math/generic/totalorder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of totalorder 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/totalorder.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, totalorder, (const double *x, const double *y)) {
return static_cast<int>(fputil::totalorder(*x, *y));
}

} // namespace LIBC_NAMESPACE_DECL
20 changes: 20 additions & 0 deletions libc/src/math/generic/totalorderf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of totalorderf 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/totalorderf.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, totalorderf, (const float *x, const float *y)) {
return static_cast<int>(fputil::totalorder(*x, *y));
}

} // namespace LIBC_NAMESPACE_DECL
21 changes: 21 additions & 0 deletions libc/src/math/generic/totalorderf128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation of totalorderf128 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/totalorderf128.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, totalorderf128,
(const float128 *x, const float128 *y)) {
return static_cast<int>(fputil::totalorder(*x, *y));
}

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

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

namespace LIBC_NAMESPACE_DECL {

int totalorder(const double *x, const double *y);

} // namespace LIBC_NAMESPACE_DECL

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

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

namespace LIBC_NAMESPACE_DECL {

int totalorderf(const float *x, const float *y);

} // namespace LIBC_NAMESPACE_DECL

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

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

namespace LIBC_NAMESPACE_DECL {

int totalorderf128(const float128 *x, const float128 *y);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_TOTALORDERF128_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 @@ -3641,6 +3641,30 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
totalorder_test
SUITE
libc-math-smoke-tests
SRCS
totalorder_test.cpp
HDRS
TotalOrderTest.h
DEPENDS
libc.src.math.totalorder
)

add_fp_unittest(
totalorderf_test
SUITE
libc-math-smoke-tests
SRCS
totalorderf_test.cpp
HDRS
TotalOrderTest.h
DEPENDS
libc.src.math.totalorderf
)

add_fp_unittest(
totalorderf16_test
SUITE
Expand All @@ -3653,6 +3677,18 @@ add_fp_unittest(
libc.src.math.totalorderf16
)

add_fp_unittest(
totalorderf128_test
SUITE
libc-math-smoke-tests
SRCS
totalorderf128_test.cpp
HDRS
TotalOrderTest.h
DEPENDS
libc.src.math.totalorderf128
)

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

#include "src/math/totalorder.h"

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

#include "src/math/totalorderf128.h"

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

#include "src/math/totalorderf.h"

LIST_TOTALORDER_TESTS(float, LIBC_NAMESPACE::totalorderf)
Loading