diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index cfc280da27f4b7..2630d8f3abaa8a 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -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 @@ -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 diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt index 8e77105fdb13e9..65e91897dad90f 100644 --- a/libc/config/linux/arm/entrypoints.txt +++ b/libc/config/linux/arm/entrypoints.txt @@ -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 diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index 04b8b3bc4ce391..cf8a79583f524d 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -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 @@ -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 diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 3922505f2ac372..0eb1690172a8ec 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -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 @@ -690,6 +692,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 diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst index e2062ab5fc6d8a..0448f8f36d2c20 100644 --- a/libc/docs/math/index.rst +++ b/libc/docs/math/index.rst @@ -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 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td index 3e5a0e0344e9f2..788b9581cb2ab3 100644 --- a/libc/spec/stdc.td +++ b/libc/spec/stdc.td @@ -721,8 +721,11 @@ def StdC : StandardSpec<"stdc"> { GuardedFunctionSpec<"canonicalizef128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"dsqrtl", RetValSpec, [ArgSpec]>, - + + FunctionSpec<"totalorder", RetValSpec, [ArgSpec, ArgSpec]>, + FunctionSpec<"totalorderf", RetValSpec, [ArgSpec, ArgSpec]>, GuardedFunctionSpec<"totalorderf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, + GuardedFunctionSpec<"totalorderf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"totalordermag", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"totalordermagf", RetValSpec, [ArgSpec, ArgSpec]>, diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt index 323ce988f86136..eb33532826ab80 100644 --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -434,7 +434,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) diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index 504c65bf91ba6e..f118742bddd680 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -3994,6 +3994,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 @@ -4006,6 +4030,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 diff --git a/libc/src/math/generic/totalorder.cpp b/libc/src/math/generic/totalorder.cpp new file mode 100644 index 00000000000000..f052c81c98fa99 --- /dev/null +++ b/libc/src/math/generic/totalorder.cpp @@ -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(fputil::totalorder(*x, *y)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/totalorderf.cpp b/libc/src/math/generic/totalorderf.cpp new file mode 100644 index 00000000000000..17c13040721758 --- /dev/null +++ b/libc/src/math/generic/totalorderf.cpp @@ -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(fputil::totalorder(*x, *y)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/totalorderf128.cpp b/libc/src/math/generic/totalorderf128.cpp new file mode 100644 index 00000000000000..83d77686d212a0 --- /dev/null +++ b/libc/src/math/generic/totalorderf128.cpp @@ -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(fputil::totalorder(*x, *y)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/totalorder.h b/libc/src/math/totalorder.h new file mode 100644 index 00000000000000..d8d0297c527976 --- /dev/null +++ b/libc/src/math/totalorder.h @@ -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 diff --git a/libc/src/math/totalorderf.h b/libc/src/math/totalorderf.h new file mode 100644 index 00000000000000..bade04ce6e68ac --- /dev/null +++ b/libc/src/math/totalorderf.h @@ -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 diff --git a/libc/src/math/totalorderf128.h b/libc/src/math/totalorderf128.h new file mode 100644 index 00000000000000..958714849da67d --- /dev/null +++ b/libc/src/math/totalorderf128.h @@ -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 diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index a1389765389950..a59af91d76736e 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -3654,6 +3654,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 @@ -3666,6 +3690,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 diff --git a/libc/test/src/math/smoke/totalorder_test.cpp b/libc/test/src/math/smoke/totalorder_test.cpp new file mode 100644 index 00000000000000..21f49c31f50fee --- /dev/null +++ b/libc/test/src/math/smoke/totalorder_test.cpp @@ -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) diff --git a/libc/test/src/math/smoke/totalorderf128_test.cpp b/libc/test/src/math/smoke/totalorderf128_test.cpp new file mode 100644 index 00000000000000..6f7fd6a94fcf99 --- /dev/null +++ b/libc/test/src/math/smoke/totalorderf128_test.cpp @@ -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) diff --git a/libc/test/src/math/smoke/totalorderf_test.cpp b/libc/test/src/math/smoke/totalorderf_test.cpp new file mode 100644 index 00000000000000..71db87c0c2415a --- /dev/null +++ b/libc/test/src/math/smoke/totalorderf_test.cpp @@ -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)