[libc-commits] [libc] [llvm] [libc] Make totalorder functions use the emulated float128 type (PR #221085)
Muhammad Haris Awan via libc-commits
libc-commits at lists.llvm.org
Sat Sep 19 13:35:49 PDT 2026
https://github.com/harisawan-bit updated https://github.com/llvm/llvm-project/pull/221085
>From 08b8ef1cd6fdb39b062f95b68fa1b704311395e6 Mon Sep 17 00:00:00 2001
From: Muhammad Haris Awan <an25mbbs026.student at fui.edu.pk>
Date: Sun, 20 Sep 2026 01:35:38 +0500
Subject: [PATCH] [libc] Make totalorder functions use the emulated float128
type
Part of #216576.
Modify `totalorderf128` and `totalordermagf128` to work with emulated
Float128 by removing native float128 guards, updating the implementation
headers, generic wrappers, CMake dependencies, Bazel overlays, and
smoke/shared tests.
---
libc/config/baremetal/aarch64/entrypoints.txt | 4 ++--
libc/config/baremetal/arm/entrypoints.txt | 4 ++--
libc/config/baremetal/riscv/entrypoints.txt | 4 ++--
libc/config/darwin/aarch64/entrypoints.txt | 4 ++--
libc/config/darwin/x86_64/entrypoints.txt | 2 ++
libc/config/freebsd/x86_64/entrypoints.txt | 4 ++--
libc/config/gpu/amdgpu/entrypoints.txt | 2 ++
libc/config/gpu/nvptx/entrypoints.txt | 2 ++
libc/config/linux/aarch64/entrypoints.txt | 4 ++--
libc/config/linux/arm/entrypoints.txt | 2 ++
libc/config/linux/riscv/entrypoints.txt | 4 ++--
libc/config/linux/x86_64/entrypoints.txt | 4 ++--
libc/config/windows/entrypoints.txt | 2 ++
libc/shared/math/totalorderf128.h | 13 ++++++------
libc/shared/math/totalordermagf128.h | 13 ++++++------
libc/src/__support/math/CMakeLists.txt | 4 ++--
libc/src/__support/math/totalorderf128.h | 18 +++++++++--------
libc/src/__support/math/totalordermagf128.h | 20 ++++++++++---------
libc/src/math/generic/CMakeLists.txt | 2 ++
libc/src/math/generic/totalorderf128.cpp | 14 +++++++++++--
libc/src/math/generic/totalordermagf128.cpp | 14 +++++++++++--
libc/src/math/totalorderf128.h | 12 ++++++++++-
libc/src/math/totalordermagf128.h | 12 ++++++++++-
.../shared/shared_math_constexpr_test.cpp | 7 ++++++-
libc/test/shared/shared_math_test.cpp | 7 ++++++-
.../src/math/smoke/totalorderf128_test.cpp | 14 +++++++++++--
.../src/math/smoke/totalordermagf128_test.cpp | 15 +++++++++++---
.../llvm-project-overlay/libc/BUILD.bazel | 8 ++++++--
.../libc/test/src/math/smoke/BUILD.bazel | 6 ++++++
29 files changed, 157 insertions(+), 64 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 114534ce61ae6..28f3cfbfbe174 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -607,9 +607,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanhf
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderf128
libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
+ libc.src.math.totalordermagf128
libc.src.math.totalordermagl
libc.src.math.trunc
libc.src.math.truncf
@@ -798,8 +800,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
- libc.src.math.totalorderf128
- libc.src.math.totalordermagf128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index c8148815c34e3..1b80147b6aae2 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -619,9 +619,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanhf
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderf128
libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
+ libc.src.math.totalordermagf128
libc.src.math.totalordermagl
libc.src.math.trunc
libc.src.math.truncf
@@ -809,8 +811,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
- libc.src.math.totalorderf128
- libc.src.math.totalordermagf128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 622d6156cff11..415332a464521 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -610,9 +610,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanhf
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderf128
libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
+ libc.src.math.totalordermagf128
libc.src.math.totalordermagl
libc.src.math.trunc
libc.src.math.truncf
@@ -801,8 +803,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
- libc.src.math.totalorderf128
- libc.src.math.totalordermagf128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index d702b2c5a6549..8dce7c5893591 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -429,9 +429,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanpif
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderf128
libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
+ libc.src.math.totalordermagf128
libc.src.math.totalordermagl
libc.src.math.trunc
libc.src.math.truncf
@@ -620,8 +622,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
- libc.src.math.totalorderf128
- libc.src.math.totalordermagf128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 716ab572f8d3c..ee34771831885 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -253,8 +253,10 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.sqrtl
#libc.src.math.tanf
#libc.src.math.tanhf
+ #libc.src.math.totalorderf128
#libc.src.math.totalordermag
#libc.src.math.totalordermagf
+ #libc.src.math.totalordermagf128
#libc.src.math.totalordermagl
#libc.src.math.trunc
#libc.src.math.truncf
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 8f6c178301c2f..2fdf99c530a42 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -380,9 +380,11 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanpif
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderf128
libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
+ libc.src.math.totalordermagf128
libc.src.math.totalordermagl
libc.src.math.ufromfp
libc.src.math.ufromfpf
@@ -553,8 +555,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
- libc.src.math.totalorderf128
- libc.src.math.totalordermagf128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 5c5e5891da822..182adb81a7a6c 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -548,9 +548,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tgammaf
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderf128
libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
+ libc.src.math.totalordermagf128
libc.src.math.totalordermagl
libc.src.math.trunc
libc.src.math.truncf
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index afae725484a89..76c98deb60e14 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -545,9 +545,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tgammaf
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderf128
libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
+ libc.src.math.totalordermagf128
libc.src.math.totalordermagl
libc.src.math.trunc
libc.src.math.truncf
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index fe1c2965f778b..76e1361ebe36a 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -808,9 +808,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanpif
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderf128
libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
+ libc.src.math.totalordermagf128
libc.src.math.totalordermagl
libc.src.math.trunc
libc.src.math.truncf
@@ -992,8 +994,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
- libc.src.math.totalorderf128
- libc.src.math.totalordermagf128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index f4347331d0b31..724bd23b276f0 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -602,9 +602,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanpif
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderf128
libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
+ libc.src.math.totalordermagf128
libc.src.math.totalordermagl
libc.src.math.trunc
libc.src.math.truncf
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 51587056fb02d..9da108474ada0 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -870,9 +870,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanpif
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderf128
libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
+ libc.src.math.totalordermagf128
libc.src.math.totalordermagl
libc.src.math.trunc
libc.src.math.truncf
@@ -1071,8 +1073,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
- libc.src.math.totalorderf128
- libc.src.math.totalordermagf128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index f21d48d6ef9e7..74581af4f6007 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -886,9 +886,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanpif
libc.src.math.totalorder
libc.src.math.totalorderf
+ libc.src.math.totalorderf128
libc.src.math.totalorderl
libc.src.math.totalordermag
libc.src.math.totalordermagf
+ libc.src.math.totalordermagf128
libc.src.math.totalordermagl
libc.src.math.trunc
libc.src.math.truncf
@@ -1087,8 +1089,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
- libc.src.math.totalorderf128
- libc.src.math.totalordermagf128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 3a48b49e169b3..bfe582ac25264 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -347,6 +347,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanf
libc.src.math.tanhf
libc.src.math.tanpif
+ libc.src.math.totalorderf128
+ libc.src.math.totalordermagf128
libc.src.math.trunc
libc.src.math.truncf
libc.src.math.truncf128
diff --git a/libc/shared/math/totalorderf128.h b/libc/shared/math/totalorderf128.h
index 8427aa0df9889..35a0309b949eb 100644
--- a/libc/shared/math/totalorderf128.h
+++ b/libc/shared/math/totalorderf128.h
@@ -1,18 +1,19 @@
-//===-- Shared totalorderf128 function --------------------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the shared totalorderf128 function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SHARED_MATH_TOTALORDERF128_H
#define LLVM_LIBC_SHARED_MATH_TOTALORDERF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/totalorderf128.h"
@@ -24,6 +25,4 @@ using math::totalorderf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_TOTALORDERF128_H
diff --git a/libc/shared/math/totalordermagf128.h b/libc/shared/math/totalordermagf128.h
index 663a3c4dc9fb2..344944293705f 100644
--- a/libc/shared/math/totalordermagf128.h
+++ b/libc/shared/math/totalordermagf128.h
@@ -1,18 +1,19 @@
-//===-- Shared totalordermagf128 function -----------------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the shared totalordermagf128 function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SHARED_MATH_TOTALORDERMAGF128_H
#define LLVM_LIBC_SHARED_MATH_TOTALORDERMAGF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/totalordermagf128.h"
@@ -24,6 +25,4 @@ using math::totalordermagf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_TOTALORDERMAGF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 8d6a1495e1c11..2865e06b0fd7b 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -5756,8 +5756,8 @@ add_header_library(
HDRS
totalorderf128.h
DEPENDS
- libc.include.llvm-libc-types.float128
libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.float128
libc.src.__support.macros.config
)
@@ -5813,8 +5813,8 @@ add_header_library(
HDRS
totalordermagf128.h
DEPENDS
- libc.include.llvm-libc-types.float128
libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.float128
libc.src.__support.macros.config
)
diff --git a/libc/src/__support/math/totalorderf128.h b/libc/src/__support/math/totalorderf128.h
index 3af00e711fab9..0128b5ab73fad 100644
--- a/libc/src/__support/math/totalorderf128.h
+++ b/libc/src/__support/math/totalorderf128.h
@@ -1,31 +1,33 @@
-//===-- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation header for totalorderf128.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_TOTALORDERF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_TOTALORDERF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr int totalorderf128(const float128 *x, const float128 *y) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr int totalorderf128(const Float128 *x, const Float128 *y) {
return static_cast<int>(fputil::totalorder(*x, *y));
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_TOTALORDERF128_H
diff --git a/libc/src/__support/math/totalordermagf128.h b/libc/src/__support/math/totalordermagf128.h
index ea79011f8b047..675277e4af006 100644
--- a/libc/src/__support/math/totalordermagf128.h
+++ b/libc/src/__support/math/totalordermagf128.h
@@ -1,32 +1,34 @@
-//===-- Implementation header for totalordermagf128 -------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation header for totalordermagf128.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_TOTALORDERMAGF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_TOTALORDERMAGF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr int totalordermagf128(const float128 *x,
- const float128 *y) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr int totalordermagf128(const Float128 *x,
+ const Float128 *y) {
return static_cast<int>(fputil::totalordermag(*x, *y));
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_TOTALORDERMAGF128_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 28b8e954530dd..d58f4282e6b23 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -4289,6 +4289,7 @@ add_entrypoint_object(
HDRS
../totalorderf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.totalorderf128
)
@@ -4349,6 +4350,7 @@ add_entrypoint_object(
HDRS
../totalordermagf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.totalordermagf128
)
diff --git a/libc/src/math/generic/totalorderf128.cpp b/libc/src/math/generic/totalorderf128.cpp
index ca521291e4924..16424372b8416 100644
--- a/libc/src/math/generic/totalorderf128.cpp
+++ b/libc/src/math/generic/totalorderf128.cpp
@@ -1,19 +1,29 @@
-//===-- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation of totalorderf128 function.
+///
+//===----------------------------------------------------------------------===//
#include "src/math/totalorderf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/totalorderf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(int, totalorderf128,
(const float128 *x, const float128 *y)) {
- return math::totalorderf128(x, y);
+ Float128 x_f128 = cpp::bit_cast<Float128>(*x);
+ Float128 y_f128 = cpp::bit_cast<Float128>(*y);
+ return math::totalorderf128(&x_f128, &y_f128);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/totalordermagf128.cpp b/libc/src/math/generic/totalordermagf128.cpp
index dfb6c794b0f1d..a938c87f70135 100644
--- a/libc/src/math/generic/totalordermagf128.cpp
+++ b/libc/src/math/generic/totalordermagf128.cpp
@@ -1,19 +1,29 @@
-//===-- Implementation of totalordermagf128 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation of totalordermagf128 function.
+///
+//===----------------------------------------------------------------------===//
#include "src/math/totalordermagf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/totalordermagf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(int, totalordermagf128,
(const float128 *x, const float128 *y)) {
- return math::totalordermagf128(x, y);
+ Float128 x_f128 = cpp::bit_cast<Float128>(*x);
+ Float128 y_f128 = cpp::bit_cast<Float128>(*y);
+ return math::totalordermagf128(&x_f128, &y_f128);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/totalorderf128.h b/libc/src/math/totalorderf128.h
index 958714849da67..baa711bf69e86 100644
--- a/libc/src/math/totalorderf128.h
+++ b/libc/src/math/totalorderf128.h
@@ -1,19 +1,29 @@
-//===-- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation header for totalorderf128.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_TOTALORDERF128_H
#define LLVM_LIBC_SRC_MATH_TOTALORDERF128_H
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
int totalorderf128(const float128 *x, const float128 *y);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/totalordermagf128.h b/libc/src/math/totalordermagf128.h
index 389d0596b9d4b..bdf99c7404e42 100644
--- a/libc/src/math/totalordermagf128.h
+++ b/libc/src/math/totalordermagf128.h
@@ -1,19 +1,29 @@
-//===-- Implementation header for totalordermagf128 -------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation header for totalordermagf128.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_TOTALORDERMAGF128_H
#define LLVM_LIBC_SRC_MATH_TOTALORDERMAGF128_H
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
int totalordermagf128(const float128 *x, const float128 *y);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index 370c31e193f5e..1b16b57e94b78 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -1,10 +1,15 @@
-//===-- Unittests for shared math functions in constexpr context ----------===//
+//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains unittests for shared math functions in constexpr context.
+///
+//===----------------------------------------------------------------------===//
#define LIBC_ENABLE_CONSTEXPR 1
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 7b785331f36c6..9f8c5bb534bbb 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -1,10 +1,15 @@
-//===-- Unittests for shared math functions -------------------------------===//
+//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains unittests for shared math functions.
+///
+//===----------------------------------------------------------------------===//
#include "shared/math.h"
#include "src/__support/FPUtil/float128.h"
diff --git a/libc/test/src/math/smoke/totalorderf128_test.cpp b/libc/test/src/math/smoke/totalorderf128_test.cpp
index 3696b54114c5c..2a8e7634dbcfd 100644
--- a/libc/test/src/math/smoke/totalorderf128_test.cpp
+++ b/libc/test/src/math/smoke/totalorderf128_test.cpp
@@ -1,13 +1,23 @@
-//===-- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains tests for totalorderf128.
+///
+//===----------------------------------------------------------------------===//
#include "TotalOrderTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/totalorderf128.h"
-LIST_TOTALORDER_TESTS(Totalorderf128, float128, LIBC_NAMESPACE::totalorderf128)
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
+LIST_TOTALORDER_TESTS(float128, LIBC_NAMESPACE::totalorderf128)
diff --git a/libc/test/src/math/smoke/totalordermagf128_test.cpp b/libc/test/src/math/smoke/totalordermagf128_test.cpp
index 613ed57fc2223..183dc132010e6 100644
--- a/libc/test/src/math/smoke/totalordermagf128_test.cpp
+++ b/libc/test/src/math/smoke/totalordermagf128_test.cpp
@@ -1,14 +1,23 @@
-//===-- Unittests for totalordermagf128 -----------------------------------===//
+//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains tests for totalordermagf128.
+///
+//===----------------------------------------------------------------------===//
#include "TotalOrderMagTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/totalordermagf128.h"
-LIST_TOTALORDERMAG_TESTS(Totalordermagf128, float128,
- LIBC_NAMESPACE::totalordermagf128)
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
+LIST_TOTALORDERMAG_TESTS(float128, LIBC_NAMESPACE::totalordermagf128)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 7eaa588d1cc94..3c5791d391de0 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -10979,8 +10979,8 @@ libc_support_library(
hdrs = ["src/__support/math/totalorderf128.h"],
deps = [
":__support_fputil_basic_operations",
+ ":__support_fputil_float128",
":__support_macros_config",
- ":llvm_libc_types_float128",
],
)
@@ -11036,8 +11036,8 @@ libc_support_library(
hdrs = ["src/__support/math/totalordermagf128.h"],
deps = [
":__support_fputil_basic_operations",
+ ":__support_fputil_float128",
":__support_macros_config",
- ":llvm_libc_types_float128",
],
)
@@ -14813,6 +14813,8 @@ libc_math_function(
libc_math_function(
name = "totalorderf128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_totalorderf128",
],
)
@@ -14855,6 +14857,8 @@ libc_math_function(
libc_math_function(
name = "totalordermagf128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_totalordermagf128",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
index e1d9305617303..56673ab6b7d93 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
@@ -2142,6 +2142,9 @@ math_test(
math_test(
name = "totalorderf128",
hdrs = ["TotalOrderTest.h"],
+ deps = [
+ "//libc:__support_fputil_float128",
+ ],
)
math_test(
@@ -2175,6 +2178,9 @@ math_test(
math_test(
name = "totalordermagf128",
hdrs = ["TotalOrderMagTest.h"],
+ deps = [
+ "//libc:__support_fputil_float128",
+ ],
)
math_test(
More information about the libc-commits
mailing list