[libc-commits] [libc] [libc][math][c23] Add entrypoints and tests for totalorder{, f, f128} (PR #100593)

Job Henandez Lara via libc-commits libc-commits at lists.llvm.org
Tue Jul 30 09:37:47 PDT 2024


https://github.com/Jobhdez updated https://github.com/llvm/llvm-project/pull/100593

>From 1ab1ab1d76588ece26da35b46a34718202e9a901 Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Thu, 25 Jul 2024 09:34:15 -0700
Subject: [PATCH 1/5] [libc][math][c23] Add entrypoints for
 totalorder{f,l,f128}

---
 libc/config/linux/aarch64/entrypoints.txt     |  4 ++
 libc/config/linux/arm/entrypoints.txt         |  3 ++
 libc/config/linux/riscv/entrypoints.txt       |  4 ++
 libc/config/linux/x86_64/entrypoints.txt      |  4 ++
 libc/docs/math/index.rst                      |  2 +-
 libc/spec/stdc.td                             |  6 ++-
 libc/src/math/CMakeLists.txt                  |  4 ++
 libc/src/math/generic/CMakeLists.txt          | 48 +++++++++++++++++++
 libc/src/math/generic/totalorder.cpp          | 20 ++++++++
 libc/src/math/generic/totalorderf.cpp         | 20 ++++++++
 libc/src/math/generic/totalorderf128.cpp      | 20 ++++++++
 libc/src/math/generic/totalorderl.cpp         | 20 ++++++++
 libc/src/math/totalorder.h                    | 20 ++++++++
 libc/src/math/totalorderf.h                   | 20 ++++++++
 libc/src/math/totalorderf128.h                | 21 ++++++++
 libc/src/math/totalorderl.h                   | 20 ++++++++
 libc/test/src/math/smoke/CMakeLists.txt       | 48 +++++++++++++++++++
 libc/test/src/math/smoke/totalorder_test.cpp  | 13 +++++
 .../src/math/smoke/totalorderf128_test.cpp    | 13 +++++
 libc/test/src/math/smoke/totalorderf_test.cpp | 13 +++++
 libc/test/src/math/smoke/totalorderl_test.cpp | 13 +++++
 21 files changed, 334 insertions(+), 2 deletions(-)
 create mode 100644 libc/src/math/generic/totalorder.cpp
 create mode 100644 libc/src/math/generic/totalorderf.cpp
 create mode 100644 libc/src/math/generic/totalorderf128.cpp
 create mode 100644 libc/src/math/generic/totalorderl.cpp
 create mode 100644 libc/src/math/totalorder.h
 create mode 100644 libc/src/math/totalorderf.h
 create mode 100644 libc/src/math/totalorderf128.h
 create mode 100644 libc/src/math/totalorderl.h
 create mode 100644 libc/test/src/math/smoke/totalorder_test.cpp
 create mode 100644 libc/test/src/math/smoke/totalorderf128_test.cpp
 create mode 100644 libc/test/src/math/smoke/totalorderf_test.cpp
 create mode 100644 libc/test/src/math/smoke/totalorderl_test.cpp

diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index cfc280da27f4b..583cddf75a448 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -520,6 +520,9 @@ 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.totalorderl
     libc.src.math.totalordermag
     libc.src.math.totalordermagf
     libc.src.math.totalordermagl
@@ -646,6 +649,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 8e77105fdb13e..06a934d347f6f 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -374,6 +374,9 @@ 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.totalorderl
     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 04b8b3bc4ce39..f4bdef23148a1 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -542,6 +542,9 @@ 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.totalorderl
     libc.src.math.totalordermag
     libc.src.math.totalordermagf
     libc.src.math.totalordermagl
@@ -603,6 +606,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 fa656d946eceb..bd24e2dc7c635 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -542,6 +542,9 @@ 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.totalorderl
     libc.src.math.totalordermag
     libc.src.math.totalordermagf
     libc.src.math.totalordermagl
@@ -689,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 9f88b4d9a44b3..50133042a37ae 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|              | |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 9c84accd72cff..0b44c05224e56 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -720,8 +720,12 @@ 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>]>,
+	  FunctionSpec<"totalorderl", RetValSpec<IntType>, [ArgSpec<LongDoublePtr>, ArgSpec<LongDoublePtr>]>,
 	  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>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index d70af33522d2b..3dd41f694a27e 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -433,7 +433,11 @@ 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(totalorderl)
 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 27b5b945e278c..bf09e43ee752a 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3973,6 +3973,42 @@ 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(
+  totalorderl
+  SRCS
+    totalorderl.cpp
+  HDRS
+    ../totalorderl.h
+  DEPENDS
+    libc.src.__support.FPUtil.basic_operations
+  COMPILE_OPTIONS
+    -O3
+)
+
 add_entrypoint_object(
   totalorderf16
   SRCS
@@ -3985,6 +4021,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 0000000000000..f052c81c98fa9
--- /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<int>(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 0000000000000..17c1304072175
--- /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<int>(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 0000000000000..956f8c9e8c3bb
--- /dev/null
+++ b/libc/src/math/generic/totalorderf128.cpp
@@ -0,0 +1,20 @@
+//===-- 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
diff --git a/libc/src/math/generic/totalorderl.cpp b/libc/src/math/generic/totalorderl.cpp
new file mode 100644
index 0000000000000..f3fa2b2c01f6f
--- /dev/null
+++ b/libc/src/math/generic/totalorderl.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of totalorderl 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/totalorderl.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, totalorderl, (const long double *x, const long double *y)) {
+  return static_cast<int>(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 0000000000000..d8d0297c52797
--- /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 0000000000000..6806f4dc78c8e
--- /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 0000000000000..958714849da67
--- /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/src/math/totalorderl.h b/libc/src/math/totalorderl.h
new file mode 100644
index 0000000000000..064b2a514fa8e
--- /dev/null
+++ b/libc/src/math/totalorderl.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for totalorderl -------------------*- 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_TOTALORDERL_H
+#define LLVM_LIBC_SRC_MATH_TOTALORDERL_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int totalorderl(const long double *x, const long double *y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_TOTALORDERL_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 8b2942343409d..1329bbd3bc170 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -3641,6 +3641,42 @@ 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(
+  totalorderl_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    totalorderl_test.cpp
+  HDRS
+    TotalOrderTest.h
+  DEPENDS
+    libc.src.math.totalorderl
+)
+
 add_fp_unittest(
   totalorderf16_test
   SUITE
@@ -3653,6 +3689,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 0000000000000..21f49c31f50fe
--- /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 0000000000000..6f7fd6a94fcf9
--- /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 0000000000000..71db87c0c2415
--- /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)
diff --git a/libc/test/src/math/smoke/totalorderl_test.cpp b/libc/test/src/math/smoke/totalorderl_test.cpp
new file mode 100644
index 0000000000000..fc2353fce3859
--- /dev/null
+++ b/libc/test/src/math/smoke/totalorderl_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for totalorderl -----------------------------------------===//
+//
+// 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/totalorderl.h"
+
+LIST_TOTALORDER_TESTS(long double, LIBC_NAMESPACE::totalorderl)

>From d5d93230a881a499ad8aef6852beba4b344b2929 Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Mon, 29 Jul 2024 21:29:59 -0700
Subject: [PATCH 2/5] remove long double

---
 libc/src/math/generic/totalorderl.cpp         | 20 -------------------
 libc/src/math/totalorderl.h                   | 20 -------------------
 libc/test/src/math/smoke/totalorderl_test.cpp | 13 ------------
 3 files changed, 53 deletions(-)
 delete mode 100644 libc/src/math/generic/totalorderl.cpp
 delete mode 100644 libc/src/math/totalorderl.h
 delete mode 100644 libc/test/src/math/smoke/totalorderl_test.cpp

diff --git a/libc/src/math/generic/totalorderl.cpp b/libc/src/math/generic/totalorderl.cpp
deleted file mode 100644
index f3fa2b2c01f6f..0000000000000
--- a/libc/src/math/generic/totalorderl.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation of totalorderl 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/totalorderl.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, totalorderl, (const long double *x, const long double *y)) {
-  return static_cast<int>(fputil::totalorder(*x, *y));
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/totalorderl.h b/libc/src/math/totalorderl.h
deleted file mode 100644
index 064b2a514fa8e..0000000000000
--- a/libc/src/math/totalorderl.h
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- Implementation header for totalorderl -------------------*- 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_TOTALORDERL_H
-#define LLVM_LIBC_SRC_MATH_TOTALORDERL_H
-
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-int totalorderl(const long double *x, const long double *y);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_TOTALORDERL_H
diff --git a/libc/test/src/math/smoke/totalorderl_test.cpp b/libc/test/src/math/smoke/totalorderl_test.cpp
deleted file mode 100644
index fc2353fce3859..0000000000000
--- a/libc/test/src/math/smoke/totalorderl_test.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-//===-- Unittests for totalorderl -----------------------------------------===//
-//
-// 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/totalorderl.h"
-
-LIST_TOTALORDER_TESTS(long double, LIBC_NAMESPACE::totalorderl)

>From 4a2099b9fcc375a7f0543eca358baa9aac85c6aa Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Mon, 29 Jul 2024 21:30:24 -0700
Subject: [PATCH 3/5] update, remove long double entries

---
 libc/config/linux/aarch64/entrypoints.txt |  1 -
 libc/config/linux/arm/entrypoints.txt     |  1 -
 libc/config/linux/riscv/entrypoints.txt   |  1 -
 libc/config/linux/x86_64/entrypoints.txt  |  1 -
 libc/spec/stdc.td                         |  1 -
 libc/src/math/CMakeLists.txt              |  1 -
 libc/src/math/generic/CMakeLists.txt      | 12 ------------
 libc/test/src/math/smoke/CMakeLists.txt   | 12 ------------
 8 files changed, 30 deletions(-)

diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 583cddf75a448..2630d8f3abaa8 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -522,7 +522,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.tanhf
     libc.src.math.totalorder
     libc.src.math.totalorderf
-    libc.src.math.totalorderl
     libc.src.math.totalordermag
     libc.src.math.totalordermagf
     libc.src.math.totalordermagl
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 06a934d347f6f..65e91897dad90 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -376,7 +376,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.tanhf
     libc.src.math.totalorder
     libc.src.math.totalorderf
-    libc.src.math.totalorderl
     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 f4bdef23148a1..cf8a79583f524 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -544,7 +544,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.tanhf
     libc.src.math.totalorder
     libc.src.math.totalorderf
-    libc.src.math.totalorderl
     libc.src.math.totalordermag
     libc.src.math.totalordermagf
     libc.src.math.totalordermagl
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index bd24e2dc7c635..7b6947bf00140 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -544,7 +544,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.tanhf
     libc.src.math.totalorder
     libc.src.math.totalorderf
-    libc.src.math.totalorderl
     libc.src.math.totalordermag
     libc.src.math.totalordermagf
     libc.src.math.totalordermagl
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 0b44c05224e56..992d0c3b0396c 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -723,7 +723,6 @@ def StdC : StandardSpec<"stdc"> {
 
           FunctionSpec<"totalorder", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoublePtr>]>,
 	  FunctionSpec<"totalorderf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatPtr>]>,
-	  FunctionSpec<"totalorderl", RetValSpec<IntType>, [ArgSpec<LongDoublePtr>, ArgSpec<LongDoublePtr>]>,
 	  GuardedFunctionSpec<"totalorderf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Ptr>], "LIBC_TYPES_HAS_FLOAT16">,
 	  GuardedFunctionSpec<"totalorderf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Ptr>], "LIBC_TYPES_HAS_FLOAT128">,
 
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 3dd41f694a27e..54fb6cb4a3434 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -435,7 +435,6 @@ add_math_entrypoint_object(tgammaf)
 
 add_math_entrypoint_object(totalorder)
 add_math_entrypoint_object(totalorderf)
-add_math_entrypoint_object(totalorderl)
 add_math_entrypoint_object(totalorderf16)
 add_math_entrypoint_object(totalorderf128)
 
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index bf09e43ee752a..00313f30195ff 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3997,18 +3997,6 @@ add_entrypoint_object(
     -O3
 )
 
-add_entrypoint_object(
-  totalorderl
-  SRCS
-    totalorderl.cpp
-  HDRS
-    ../totalorderl.h
-  DEPENDS
-    libc.src.__support.FPUtil.basic_operations
-  COMPILE_OPTIONS
-    -O3
-)
-
 add_entrypoint_object(
   totalorderf16
   SRCS
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 1329bbd3bc170..d9e81cd9d32d9 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -3665,18 +3665,6 @@ add_fp_unittest(
     libc.src.math.totalorderf
 )
 
-add_fp_unittest(
-  totalorderl_test
-  SUITE
-    libc-math-smoke-tests
-  SRCS
-    totalorderl_test.cpp
-  HDRS
-    TotalOrderTest.h
-  DEPENDS
-    libc.src.math.totalorderl
-)
-
 add_fp_unittest(
   totalorderf16_test
   SUITE

>From 3d11d2f7066e9ae8e0a72b5166a95502ce092727 Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Mon, 29 Jul 2024 21:37:09 -0700
Subject: [PATCH 4/5] format code

---
 libc/src/math/generic/totalorderf128.cpp | 3 ++-
 libc/src/math/totalorderf.h              | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libc/src/math/generic/totalorderf128.cpp b/libc/src/math/generic/totalorderf128.cpp
index 956f8c9e8c3bb..83d77686d212a 100644
--- a/libc/src/math/generic/totalorderf128.cpp
+++ b/libc/src/math/generic/totalorderf128.cpp
@@ -13,7 +13,8 @@
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(int, totalorderf128, (const float128 *x, const float128 *y)) {
+LLVM_LIBC_FUNCTION(int, totalorderf128,
+                   (const float128 *x, const float128 *y)) {
   return static_cast<int>(fputil::totalorder(*x, *y));
 }
 
diff --git a/libc/src/math/totalorderf.h b/libc/src/math/totalorderf.h
index 6806f4dc78c8e..f649dc937e4c9 100644
--- a/libc/src/math/totalorderf.h
+++ b/libc/src/math/totalorderf.h
@@ -1,4 +1,5 @@
-//===-- Implementation header for totalorderf --------------------*- C++ -*-===//
+//===-- 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.

>From 60da1920634558b0926272c4160b89f0a2ea7638 Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Tue, 30 Jul 2024 09:37:28 -0700
Subject: [PATCH 5/5] address review

---
 libc/docs/math/index.rst    | 2 +-
 libc/src/math/totalorderf.h | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 50133042a37ae..2e541c7ad097c 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|          | |check|         | |check|                | |check|              | |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/src/math/totalorderf.h b/libc/src/math/totalorderf.h
index f649dc937e4c9..bade04ce6e68a 100644
--- a/libc/src/math/totalorderf.h
+++ b/libc/src/math/totalorderf.h
@@ -1,5 +1,4 @@
-//===-- Implementation header for totalorderf --------------------*- C++
-//-*-===//
+//===-- 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.



More information about the libc-commits mailing list