[libc-commits] [libc] remaining basic operations (PR #101576)

via libc-commits libc-commits at lists.llvm.org
Thu Aug 1 15:56:17 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: None (aaryanshukla)

<details>
<summary>Changes</summary>

- **script**
- **finished generic and headers**
- **going to add to header spec**
- **[libc][math][c23]:**


---

Patch is 20.67 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/101576.diff


26 Files Affected:

- (modified) libc/config/darwin/arm/entrypoints.txt (+2) 
- (modified) libc/config/darwin/x86_64/entrypoints.txt (+2) 
- (modified) libc/config/linux/aarch64/entrypoints.txt (+4) 
- (modified) libc/config/linux/arm/entrypoints.txt (+2) 
- (modified) libc/config/linux/riscv/entrypoints.txt (+3) 
- (modified) libc/config/linux/x86_64/entrypoints.txt (+4) 
- (modified) libc/config/windows/entrypoints.txt (+2) 
- (modified) libc/newhdrgen/yaml/math.yaml (+30) 
- (modified) libc/src/math/CMakeLists.txt (+5) 
- (added) libc/src/math/fsub.h (+20) 
- (added) libc/src/math/fsubf128.h (+21) 
- (added) libc/src/math/fsubl.h (+20) 
- (modified) libc/src/math/generic/CMakeLists.txt (+50) 
- (added) libc/src/math/generic/fsub.cpp (+20) 
- (added) libc/src/math/generic/fsubf128.cpp (+20) 
- (added) libc/src/math/generic/fsubl.cpp (+20) 
- (added) libc/src/math/generic/remainderf128.cpp (+21) 
- (added) libc/src/math/remainderf128.h (+21) 
- (modified) libc/test/src/math/CMakeLists.txt (+39) 
- (added) libc/test/src/math/fsub_test.cpp (+13) 
- (added) libc/test/src/math/fsubf128_test.cpp (+13) 
- (added) libc/test/src/math/fsubl_test.cpp (+13) 
- (modified) libc/test/src/math/smoke/CMakeLists.txt (+36) 
- (added) libc/test/src/math/smoke/fsub_test.cpp (+13) 
- (added) libc/test/src/math/smoke/fsubf128_test.cpp (+13) 
- (added) libc/test/src/math/smoke/fsubl_test.cpp (+13) 


``````````diff
diff --git a/libc/config/darwin/arm/entrypoints.txt b/libc/config/darwin/arm/entrypoints.txt
index d09b4e34b951c..6aaf5d46678d0 100644
--- a/libc/config/darwin/arm/entrypoints.txt
+++ b/libc/config/darwin/arm/entrypoints.txt
@@ -180,6 +180,8 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.frexp
     libc.src.math.frexpf
     libc.src.math.frexpl
+    libc.src.math.fsub 
+    libc.src.math.fsubl 
     libc.src.math.hypot
     libc.src.math.hypotf
     libc.src.math.ilogb
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 1cff157c629df..e7a33761e5cbb 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -147,6 +147,8 @@ set(TARGET_LIBM_ENTRYPOINTS
     #libc.src.math.frexp
     #libc.src.math.frexpf
     #libc.src.math.frexpl
+    #libc.src.math.fsub 
+    #libc.src.math.fsubl 
     #libc.src.math.hypot
     #libc.src.math.hypotf
     #libc.src.math.ilogb
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index ff0bf0ea345d3..57e92ecdbb014 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -435,6 +435,8 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fromfpxl
     libc.src.math.fsqrt
     libc.src.math.fsqrtl
+    libc.src.math.fsub 
+    libc.src.math.fsubl 
     libc.src.math.getpayload
     libc.src.math.getpayloadf
     libc.src.math.hypot
@@ -638,6 +640,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.frexpf128
     libc.src.math.fromfpf128
     libc.src.math.fromfpxf128
+    libc.src.math.fsubf128
     libc.src.math.getpayloadf128
     libc.src.math.ilogbf128
     libc.src.math.ldexpf128
@@ -653,6 +656,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.nextafterf128
     libc.src.math.nextdownf128
     libc.src.math.nextupf128
+    libc.src.math.remainderf128
     libc.src.math.remquof128
     libc.src.math.rintf128
     libc.src.math.roundf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 90aae962080cd..71d75960a03d8 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -293,6 +293,8 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fromfpx
     libc.src.math.fromfpxf
     libc.src.math.fromfpxl
+    libc.src.math.fsub 
+    libc.src.math.fsubl 
     libc.src.math.getpayload
     libc.src.math.getpayloadf
     libc.src.math.hypot
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 8443ef417b479..a3fbd7494b100 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -458,6 +458,8 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fromfpxl
     libc.src.math.fsqrt
     libc.src.math.fsqrtl
+    libc.src.math.fsub 
+    libc.src.math.fsubl 
     libc.src.math.getpayload
     libc.src.math.getpayloadf
     libc.src.math.hypot
@@ -594,6 +596,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.fromfpf128
     libc.src.math.fromfpxf128
     libc.src.math.fsqrtf128
+    libc.src.math.fsubf128
     libc.src.math.getpayloadf128
     libc.src.math.ilogbf128
     libc.src.math.ldexpf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index f737cca7f15b6..eee6a0c756d89 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -458,6 +458,8 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fromfpxl
     libc.src.math.fsqrt
     libc.src.math.fsqrtl
+    libc.src.math.fsub 
+    libc.src.math.fsubl 
     libc.src.math.getpayload
     libc.src.math.getpayloadf
     libc.src.math.hypot
@@ -683,6 +685,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.fromfpf128
     libc.src.math.fromfpxf128
     libc.src.math.fsqrtf128
+    libc.src.math.fsubf128
     libc.src.math.getpayloadf128
     libc.src.math.ilogbf128
     libc.src.math.ldexpf128
@@ -698,6 +701,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.nextafterf128
     libc.src.math.nextdownf128
     libc.src.math.nextupf128
+    libc.src.math.remainderf128
     libc.src.math.remquof128
     libc.src.math.rintf128
     libc.src.math.roundevenf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index e45219a9070e3..c611e4ae7e11b 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -193,6 +193,8 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.frexp
     libc.src.math.frexpf
     libc.src.math.frexpl
+    libc.src.math.fsub 
+    libc.src.math.fsubl 
     libc.src.math.hypot
     libc.src.math.hypotf
     libc.src.math.ilogb
diff --git a/libc/newhdrgen/yaml/math.yaml b/libc/newhdrgen/yaml/math.yaml
index ce562c653a6d2..cdd90e994c94c 100644
--- a/libc/newhdrgen/yaml/math.yaml
+++ b/libc/newhdrgen/yaml/math.yaml
@@ -794,6 +794,14 @@ functions:
     arguments:
       - type: long double
       - type: long double
+  - name: remainderf128
+    standards:
+      - llvm_libc_ext
+    return_type: float128
+    arguments:
+      - type: float128
+      - type: float128
+    guard: LIBC_TYPES_HAS_FLOAT128
   - name: remquo
     standards: 
       - stdc
@@ -1540,6 +1548,28 @@ functions:
       - type: int
       - type: unsigned int
     guard: LIBC_TYPES_HAS_FLOAT16
+  - name: fsub
+    standards: 
+      - stdc
+    return_type: float
+    arguments: 
+      - type: double
+      - type: double
+  - name: fsubl
+    standards: 
+      - stdc
+    return_type: float
+    arguments: 
+      - type: long double
+      - type: long double
+  - name: fsubf128
+    standards: 
+      - llvm_libc_ext
+    return_type: float
+    arguments: 
+      - type: float128
+      - type: float128
+    guard: LIBC_TYPES_HAS_FLOAT128
   - name: getpayloadf16
     standards: 
       - stdc
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index bd022ad88d884..92eb20e5e61fe 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -260,6 +260,10 @@ add_math_entrypoint_object(fromfpxl)
 add_math_entrypoint_object(fromfpxf16)
 add_math_entrypoint_object(fromfpxf128)
 
+add_math_entrypoint_object(fsub)
+add_math_entrypoint_object(fsubl)
+add_math_entrypoint_object(fsubf128)
+
 add_math_entrypoint_object(getpayload)
 add_math_entrypoint_object(getpayloadf)
 add_math_entrypoint_object(getpayloadf16)
@@ -382,6 +386,7 @@ add_math_entrypoint_object(remainder)
 add_math_entrypoint_object(remainderf)
 add_math_entrypoint_object(remainderl)
 add_math_entrypoint_object(remainderf16)
+add_math_entrypoint_object(remainderf128)
 
 add_math_entrypoint_object(remquo)
 add_math_entrypoint_object(remquof)
diff --git a/libc/src/math/fsub.h b/libc/src/math/fsub.h
new file mode 100644
index 0000000000000..f17f0fd3ec307
--- /dev/null
+++ b/libc/src/math/fsub.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for fsub --------------------------*- 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_FSUB_H
+#define LLVM_LIBC_SRC_MATH_FSUB_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float fsub(double x, double y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FSUB_H
diff --git a/libc/src/math/fsubf128.h b/libc/src/math/fsubf128.h
new file mode 100644
index 0000000000000..4f41c7d8bb04d
--- /dev/null
+++ b/libc/src/math/fsubf128.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for fsubf128 ----------------------*- 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_FSUBF128_H
+#define LLVM_LIBC_SRC_MATH_FSUBF128_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float fsubf128(float128 x, float128 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FSUBF128_H
diff --git a/libc/src/math/fsubl.h b/libc/src/math/fsubl.h
new file mode 100644
index 0000000000000..32570ca3dc0f7
--- /dev/null
+++ b/libc/src/math/fsubl.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for fsubl -------------------------*- 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_FSUBL_H
+#define LLVM_LIBC_SRC_MATH_FSUBL_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float fsubl(long double x, long double y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FSUBL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 927d97578316e..4c312b7360af7 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2823,6 +2823,43 @@ add_entrypoint_object(
     -O3
 )
 
+add_entrypoint_object(
+  fsub
+  SRCS
+    fsub.cpp
+  HDRS
+    ../fsub.h
+  DEPENDS
+   libc.src.__support.FPUtil.generic.add_sub
+  COMPILE_OPTIONS
+    -O3
+)
+
+add_entrypoint_object(
+  fsubl
+  SRCS
+    fsubl.cpp
+  HDRS
+    ../fsubl.h
+  DEPENDS
+   libc.src.__support.FPUtil.generic.add_sub
+  COMPILE_OPTIONS
+    -O3
+)
+
+add_entrypoint_object(
+  fsubf128
+  SRCS
+    fsubf128.cpp
+  HDRS
+    ../fsubf128.h
+  DEPENDS
+   libc.src.__support.macros.properties.types
+   libc.src.__support.FPUtil.generic.add_sub
+  COMPILE_OPTIONS
+    -O3
+)
+
 add_entrypoint_object(
   sqrt
   SRCS
@@ -2983,6 +3020,19 @@ add_entrypoint_object(
     -O3
 )
 
+add_entrypoint_object(
+  remainderf128
+  SRCS
+    remainderf128.cpp
+  HDRS
+    ../remainderf128.h
+  DEPENDS
+    libc.src.__support.macros.properties.types
+    libc.src.__support.FPUtil.division_and_remainder_operations
+  COMPILE_OPTIONS
+    -O3
+)
+
 add_entrypoint_object(
   hypotf
   SRCS
diff --git a/libc/src/math/generic/fsub.cpp b/libc/src/math/generic/fsub.cpp
new file mode 100644
index 0000000000000..97e28015c0487
--- /dev/null
+++ b/libc/src/math/generic/fsub.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of fsub 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/fsub.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fsub, (double x, double y)) {
+  return fputil::generic::sub<float>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fsubf128.cpp b/libc/src/math/generic/fsubf128.cpp
new file mode 100644
index 0000000000000..3efb34992b748
--- /dev/null
+++ b/libc/src/math/generic/fsubf128.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of fsubf128 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/fsubf128.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fsubf128, (float128 x, float128 y)) {
+  return fputil::generic::sub<float>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fsubl.cpp b/libc/src/math/generic/fsubl.cpp
new file mode 100644
index 0000000000000..cad5a2d5d452a
--- /dev/null
+++ b/libc/src/math/generic/fsubl.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of fsubl 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/fsubl.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fsubl, (long double x, long double y)) {
+  return fputil::generic::sub<float>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remainderf128.cpp b/libc/src/math/generic/remainderf128.cpp
new file mode 100644
index 0000000000000..52b6c5149fdcf
--- /dev/null
+++ b/libc/src/math/generic/remainderf128.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of remainderf128 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/remainderf128.h"
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float128, remainderf128, (float128 x, float128 y)) {
+  int quotient;
+  return fputil::remquo(x, y, quotient);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/remainderf128.h b/libc/src/math/remainderf128.h
new file mode 100644
index 0000000000000..57f770a853d68
--- /dev/null
+++ b/libc/src/math/remainderf128.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for remainderf128 -----------------*- 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_REMAINDERF128_H
+#define LLVM_LIBC_SRC_MATH_REMAINDERF128_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float128 remainderf128(float128 x, float128 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_REMAINDERF128_H
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index cc5955903b20d..644b74a0ac0a9 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2294,6 +2294,45 @@ add_fp_unittest(
     libc.src.math.fsqrtl
 )
 
+add_fp_unittest(
+  fsub_test
+  NEED_MPFR
+  SUITE
+    libc-math-unittests
+  SRCS
+    fsub_test.cpp
+  HDRS
+  SubTest.h
+  DEPENDS
+    libc.src.math.fsub
+)
+
+add_fp_unittest(
+  fsubl_test
+  NEED_MPFR
+  SUITE
+    libc-math-unittests
+  SRCS
+    fsubl_test.cpp
+  HDRS
+  SubTest.h
+  DEPENDS
+    libc.src.math.fsubl
+)
+
+add_fp_unittest(
+  fsubf128_test
+  NEED_MPFR
+  SUITE
+    libc-math-unittests
+  SRCS
+    fsubf128_test.cpp
+  HDRS
+  SubTest.h
+  DEPENDS
+    libc.src.math.fsubf128
+)
+
 add_fp_unittest(
   dsqrtl_test
   NEED_MPFR
diff --git a/libc/test/src/math/fsub_test.cpp b/libc/test/src/math/fsub_test.cpp
new file mode 100644
index 0000000000000..3c825f7f28af4
--- /dev/null
+++ b/libc/test/src/math/fsub_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for fsub ------------------------------------------------===//
+//
+// 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 "SubTest.h"
+
+#include "src/math/fsub.h"
+
+LIST_SUB_TESTS(float, double, LIBC_NAMESPACE::fsub)
diff --git a/libc/test/src/math/fsubf128_test.cpp b/libc/test/src/math/fsubf128_test.cpp
new file mode 100644
index 0000000000000..8f46d91116bde
--- /dev/null
+++ b/libc/test/src/math/fsubf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for fsubf128 --------------------------------------------===//
+//
+// 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 "SubTest.h"
+
+#include "src/math/fsubf128.h"
+
+LIST_SUB_TESTS(float, float128, LIBC_NAMESPACE::fsubf128)
diff --git a/libc/test/src/math/fsubl_test.cpp b/libc/test/src/math/fsubl_test.cpp
new file mode 100644
index 0000000000000..8723432603b00
--- /dev/null
+++ b/libc/test/src/math/fsubl_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for fsubl -----------------------------------------------===//
+//
+// 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 "SubTest.h"
+
+#include "src/math/fsubl.h"
+
+LIST_SUB_TESTS(float, long double, LIBC_NAMESPACE::fsubl)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index faca71b8b5bc4..622dc1ee50d86 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4227,6 +4227,42 @@ add_fp_unittest(
     libc.src.math.fsqrtf128
 )
 
+add_fp_unittest(
+  fsub_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    fsub_test.cpp
+  HDRS
+    SubTest.h
+  DEPENDS
+    libc.src.math.fsub
+)
+
+add_fp_unittest(
+  fsubl_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    fsubl_test.cpp
+  HDRS
+    SubTest.h
+  DEPENDS
+    libc.src.math.fsubl
+)
+
+add_fp_unittest(
+  fsubf128_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    fsubf128_test.cpp
+  HDRS
+    SubTest.h
+  DEPENDS
+    libc.src.math.fsubf128
+)
+
 add_fp_unittest(
   dsqrtl_test
   SUITE
diff --git a/libc/test/src/math/smoke/fsub_test.cpp b/libc/test/src/math/smoke/fsub_test.cpp
new file mode 100644
index 0000000000000..3c825f7f28af4
--- /dev/null
+++ b/libc/test/src/math/smoke/fsub_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for fsub ------------------------------------------------===//
+//
+// 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 "SubTest.h"
+
+#include "src/math/fsub.h"
+
+LIST_SUB_TESTS(float, double, LIBC_NAMESPACE::fsub)
diff --git a/libc/test/src/math/smoke/fsubf128_test.cpp b/libc/test/src/math/smoke/fsubf128_test.cpp
new file mode 100644
index 0000000000000..8f46d91116bde
--- /dev/null
+++ b/libc/test/src/math/smoke/fsubf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for fsubf128 --------------------------------------------===//
+//
+// 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 "SubTest.h"
+
+#include "src/math/fsubf128.h"
+
+LIST_SUB_TESTS(float, float128, LIBC_NAMESPACE::fsubf128)
diff --git a/libc/test/src/math/smo...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/101576


More information about the libc-commits mailing list