[libc-commits] [libc] 6ba9d29 - [libc][math] Add float128 rounding functions (ceilf128, floorf128, roundf128, truncf128). (#80634)

via libc-commits libc-commits at lists.llvm.org
Mon Feb 5 04:38:02 PST 2024


Author: lntue
Date: 2024-02-05T07:37:57-05:00
New Revision: 6ba9d2988ba471d3a1620da64d5a08f2edfe91ed

URL: https://github.com/llvm/llvm-project/commit/6ba9d2988ba471d3a1620da64d5a08f2edfe91ed
DIFF: https://github.com/llvm/llvm-project/commit/6ba9d2988ba471d3a1620da64d5a08f2edfe91ed.diff

LOG: [libc][math] Add float128 rounding functions (ceilf128, floorf128, roundf128, truncf128). (#80634)

Added: 
    libc/src/math/ceilf128.h
    libc/src/math/floorf128.h
    libc/src/math/generic/ceilf128.cpp
    libc/src/math/generic/floorf128.cpp
    libc/src/math/generic/roundf128.cpp
    libc/src/math/generic/truncf128.cpp
    libc/src/math/roundf128.h
    libc/src/math/truncf128.h
    libc/test/src/math/smoke/ceilf128_test.cpp
    libc/test/src/math/smoke/floorf128_test.cpp
    libc/test/src/math/smoke/roundf128_test.cpp
    libc/test/src/math/smoke/truncf128_test.cpp

Modified: 
    libc/config/linux/x86_64/entrypoints.txt
    libc/docs/math/index.rst
    libc/spec/stdc.td
    libc/src/math/CMakeLists.txt
    libc/src/math/generic/CMakeLists.txt
    libc/test/src/math/smoke/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 9946b93c346ce0..e3ed5db29a9a95 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -397,11 +397,15 @@ set(TARGET_LIBM_ENTRYPOINTS
 if(LIBC_COMPILER_HAS_FLOAT128)
   list(APPEND TARGET_LIBM_ENTRYPOINTS
     # math.h C23 _Float128 entrypoints
+    libc.src.math.ceilf128
     libc.src.math.copysignf128
     libc.src.math.fabsf128
-    libc.src.math.sqrtf128
+    libc.src.math.floorf128
     libc.src.math.fmaxf128
     libc.src.math.fminf128
+    libc.src.math.roundf128
+    libc.src.math.sqrtf128
+    libc.src.math.truncf128
   )
 endif()
 

diff  --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 748247bb85d79c..bf58f559c45141 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -114,6 +114,8 @@ Basic Operations
 +--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | ceill        | |check| | |check| | |check| | |check| | |check| |         |         | |check| | |check| | |check| |         |         |
 +--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ceilf128     | |check| |         |         |         |         |         |         |         |         |         |         |         |
++--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | copysign     | |check| | |check| | |check| | |check| | |check| |         |         | |check| | |check| | |check| |         |         |
 +--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | copysignf    | |check| | |check| | |check| | |check| | |check| |         |         | |check| | |check| | |check| |         |         |
@@ -142,6 +144,8 @@ Basic Operations
 +--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | floorl       | |check| | |check| | |check| | |check| | |check| |         |         | |check| | |check| | |check| |         |         |
 +--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| floorf128    | |check| |         |         |         |         |         |         |         |         |         |         |         |
++--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | fmax         | |check| | |check| | |check| | |check| | |check| |         |         | |check| | |check| | |check| |         |         |
 +--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | fmaxf        | |check| | |check| | |check| | |check| | |check| |         |         | |check| | |check| | |check| |         |         |
@@ -266,6 +270,8 @@ Basic Operations
 +--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | roundl       | |check| | |check| | |check| | |check| | |check| |         |         | |check| | |check| | |check| |         |         |
 +--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| roundf128    | |check| |         |         |         |         |         |         |         |         |         |         |         |
++--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | scalbn       | |check| | |check| | |check| | |check| | |check| |         |         | |check| | |check| | |check| |         |         |
 +--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | scalbnf      | |check| | |check| | |check| | |check| | |check| |         |         | |check| | |check| | |check| |         |         |
@@ -278,6 +284,8 @@ Basic Operations
 +--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | truncl       | |check| | |check| | |check| | |check| | |check| |         |         | |check| | |check| | |check| |         |         |
 +--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| truncf128    | |check| |         |         |         |         |         |         |         |         |         |         |         |
++--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 
 
 Higher Math Functions

diff  --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 6ff2c7c6136962..2723a2d39203b0 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -363,6 +363,7 @@ def StdC : StandardSpec<"stdc"> {
           FunctionSpec<"ceil", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
           FunctionSpec<"ceilf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
           FunctionSpec<"ceill", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
+          FunctionSpec<"ceilf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>]>,
 
           FunctionSpec<"fabs", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
           FunctionSpec<"fabsf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
@@ -376,6 +377,7 @@ def StdC : StandardSpec<"stdc"> {
           FunctionSpec<"floor", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
           FunctionSpec<"floorf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
           FunctionSpec<"floorl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
+          FunctionSpec<"floorf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>]>,
 
           FunctionSpec<"fmin", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
           FunctionSpec<"fminf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,
@@ -458,6 +460,7 @@ def StdC : StandardSpec<"stdc"> {
           FunctionSpec<"round", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
           FunctionSpec<"roundf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
           FunctionSpec<"roundl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
+          FunctionSpec<"roundf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>]>,
 
           FunctionSpec<"lround", RetValSpec<LongType>, [ArgSpec<DoubleType>]>,
           FunctionSpec<"lroundf", RetValSpec<LongType>, [ArgSpec<FloatType>]>,
@@ -487,6 +490,7 @@ def StdC : StandardSpec<"stdc"> {
           FunctionSpec<"trunc", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
           FunctionSpec<"truncf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
           FunctionSpec<"truncl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
+          FunctionSpec<"truncf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>]>,
 
           FunctionSpec<"nearbyint", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
           FunctionSpec<"nearbyintf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,

diff  --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 2b7eb3a05396b5..d4dbeebb7b2195 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -76,6 +76,7 @@ add_math_entrypoint_object(atanhf)
 add_math_entrypoint_object(ceil)
 add_math_entrypoint_object(ceilf)
 add_math_entrypoint_object(ceill)
+add_math_entrypoint_object(ceilf128)
 
 add_math_entrypoint_object(copysign)
 add_math_entrypoint_object(copysignf)
@@ -114,6 +115,7 @@ add_math_entrypoint_object(fdiml)
 add_math_entrypoint_object(floor)
 add_math_entrypoint_object(floorf)
 add_math_entrypoint_object(floorl)
+add_math_entrypoint_object(floorf128)
 
 add_math_entrypoint_object(fma)
 add_math_entrypoint_object(fmaf)
@@ -216,6 +218,7 @@ add_math_entrypoint_object(rintl)
 add_math_entrypoint_object(round)
 add_math_entrypoint_object(roundf)
 add_math_entrypoint_object(roundl)
+add_math_entrypoint_object(roundf128)
 
 add_math_entrypoint_object(scalbn)
 add_math_entrypoint_object(scalbnf)
@@ -247,3 +250,4 @@ add_math_entrypoint_object(tgammaf)
 add_math_entrypoint_object(trunc)
 add_math_entrypoint_object(truncf)
 add_math_entrypoint_object(truncl)
+add_math_entrypoint_object(truncf128)

diff  --git a/libc/src/math/ceilf128.h b/libc/src/math/ceilf128.h
new file mode 100644
index 00000000000000..db8feffc87ba2b
--- /dev/null
+++ b/libc/src/math/ceilf128.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for ceilf128 ----------------------*- 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_CEILF128_H
+#define LLVM_LIBC_SRC_MATH_CEILF128_H
+
+#include "src/__support/macros/properties/float.h"
+
+namespace LIBC_NAMESPACE {
+
+float128 ceilf128(float128 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_CEILF128_H

diff  --git a/libc/src/math/floorf128.h b/libc/src/math/floorf128.h
new file mode 100644
index 00000000000000..86b9a8e9265e11
--- /dev/null
+++ b/libc/src/math/floorf128.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for floorf128 ---------------------*- 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_FLOORF128_H
+#define LLVM_LIBC_SRC_MATH_FLOORF128_H
+
+#include "src/__support/macros/properties/float.h"
+
+namespace LIBC_NAMESPACE {
+
+float128 floorf128(float128 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_FLOORF128_H

diff  --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 2521435bffb4e9..05b70be7b7b9fd 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -4,10 +4,10 @@ add_entrypoint_object(
     ceil.cpp
   HDRS
     ../ceil.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
-  COMPILE_OPTIONS
-    -O2
 )
 
 add_entrypoint_object(
@@ -16,10 +16,10 @@ add_entrypoint_object(
     ceilf.cpp
   HDRS
     ../ceilf.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
-  COMPILE_OPTIONS
-    -O2
 )
 
 add_entrypoint_object(
@@ -28,10 +28,22 @@ add_entrypoint_object(
     ceill.cpp
   HDRS
     ../ceill.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
+)
+
+add_entrypoint_object(
+  ceilf128
+  SRCS
+    ceilf128.cpp
+  HDRS
+    ../ceilf128.h
   COMPILE_OPTIONS
-    -O2
+    -O3
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
 )
 
 add_object_library(
@@ -214,10 +226,10 @@ add_entrypoint_object(
     trunc.cpp
   HDRS
     ../trunc.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
-  COMPILE_OPTIONS
-    -O2
 )
 
 add_entrypoint_object(
@@ -226,10 +238,10 @@ add_entrypoint_object(
     truncf.cpp
   HDRS
     ../truncf.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
-  COMPILE_OPTIONS
-    -O2
 )
 
 add_entrypoint_object(
@@ -238,10 +250,22 @@ add_entrypoint_object(
     truncl.cpp
   HDRS
     ../truncl.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
+)
+
+add_entrypoint_object(
+  truncf128
+  SRCS
+    truncf128.cpp
+  HDRS
+    ../truncf128.h
   COMPILE_OPTIONS
-    -O2
+    -O3
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
 )
 
 add_entrypoint_object(
@@ -250,10 +274,10 @@ add_entrypoint_object(
     floor.cpp
   HDRS
     ../floor.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
-  COMPILE_OPTIONS
-    -O2
 )
 
 add_entrypoint_object(
@@ -262,10 +286,10 @@ add_entrypoint_object(
     floorf.cpp
   HDRS
     ../floorf.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
-  COMPILE_OPTIONS
-    -O2
 )
 
 add_entrypoint_object(
@@ -274,10 +298,22 @@ add_entrypoint_object(
     floorl.cpp
   HDRS
     ../floorl.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
+)
+
+add_entrypoint_object(
+  floorf128
+  SRCS
+    floorf128.cpp
+  HDRS
+    ../floorf128.h
   COMPILE_OPTIONS
-    -O2
+    -O3
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
 )
 
 add_entrypoint_object(
@@ -286,10 +322,10 @@ add_entrypoint_object(
     round.cpp
   HDRS
     ../round.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
-  COMPILE_OPTIONS
-    -O2
 )
 
 add_entrypoint_object(
@@ -298,10 +334,10 @@ add_entrypoint_object(
     roundf.cpp
   HDRS
     ../roundf.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
-  COMPILE_OPTIONS
-    -O2
 )
 
 add_entrypoint_object(
@@ -310,10 +346,22 @@ add_entrypoint_object(
     roundl.cpp
   HDRS
     ../roundl.h
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
     libc.src.__support.FPUtil.nearest_integer_operations
+)
+
+add_entrypoint_object(
+  roundf128
+  SRCS
+    roundf128.cpp
+  HDRS
+    ../roundf128.h
   COMPILE_OPTIONS
-    -O2
+    -O3
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
 )
 
 add_entrypoint_object(

diff  --git a/libc/src/math/generic/ceilf128.cpp b/libc/src/math/generic/ceilf128.cpp
new file mode 100644
index 00000000000000..af980429f87d88
--- /dev/null
+++ b/libc/src/math/generic/ceilf128.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of ceilf128 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/ceilf128.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float128, ceilf128, (float128 x)) { return fputil::ceil(x); }
+
+} // namespace LIBC_NAMESPACE

diff  --git a/libc/src/math/generic/floorf128.cpp b/libc/src/math/generic/floorf128.cpp
new file mode 100644
index 00000000000000..22a8eacb45ddbc
--- /dev/null
+++ b/libc/src/math/generic/floorf128.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of floorf128 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/floorf128.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float128, floorf128, (float128 x)) {
+  return fputil::floor(x);
+}
+
+} // namespace LIBC_NAMESPACE

diff  --git a/libc/src/math/generic/roundf128.cpp b/libc/src/math/generic/roundf128.cpp
new file mode 100644
index 00000000000000..5b35d746d4407b
--- /dev/null
+++ b/libc/src/math/generic/roundf128.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of roundf128 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/roundf128.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float128, roundf128, (float128 x)) {
+  return fputil::round(x);
+}
+
+} // namespace LIBC_NAMESPACE

diff  --git a/libc/src/math/generic/truncf128.cpp b/libc/src/math/generic/truncf128.cpp
new file mode 100644
index 00000000000000..ecf05fa73b35c4
--- /dev/null
+++ b/libc/src/math/generic/truncf128.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of truncf128 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/truncf128.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float128, truncf128, (float128 x)) {
+  return fputil::trunc(x);
+}
+
+} // namespace LIBC_NAMESPACE

diff  --git a/libc/src/math/roundf128.h b/libc/src/math/roundf128.h
new file mode 100644
index 00000000000000..c67c946cc5e8be
--- /dev/null
+++ b/libc/src/math/roundf128.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for roundf128 ---------------------*- 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_ROUNDF128_H
+#define LLVM_LIBC_SRC_MATH_ROUNDF128_H
+
+#include "src/__support/macros/properties/float.h"
+
+namespace LIBC_NAMESPACE {
+
+float128 roundf128(float128 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_ROUNDF128_H

diff  --git a/libc/src/math/truncf128.h b/libc/src/math/truncf128.h
new file mode 100644
index 00000000000000..c92c8202d4eef7
--- /dev/null
+++ b/libc/src/math/truncf128.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for truncf128 ---------------------*- 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_TRUNCF128_H
+#define LLVM_LIBC_SRC_MATH_TRUNCF128_H
+
+#include "src/__support/macros/properties/float.h"
+
+namespace LIBC_NAMESPACE {
+
+float128 truncf128(float128 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_TRUNCF128_H

diff  --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index eff97e9f1a34b4..4ee81ec1cccf6e 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -165,6 +165,22 @@ add_fp_unittest(
   UNIT_TEST_ONLY
 )
 
+add_fp_unittest(
+  truncf128_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    truncf128_test.cpp
+  HDRS
+    TruncTest.h
+  DEPENDS
+    libc.include.math
+    libc.src.math.truncf128
+    libc.src.__support.FPUtil.fp_bits
+  # FIXME: Currently fails on the GPU build.
+  UNIT_TEST_ONLY
+)
+
 add_fp_unittest(
   ceil_test
   SUITE
@@ -213,6 +229,22 @@ add_fp_unittest(
   UNIT_TEST_ONLY
 )
 
+add_fp_unittest(
+  ceilf128_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    ceilf128_test.cpp
+  HDRS
+    CeilTest.h
+  DEPENDS
+    libc.include.math
+    libc.src.math.ceilf128
+    libc.src.__support.FPUtil.fp_bits
+  # FIXME: Currently fails on the GPU build.
+  UNIT_TEST_ONLY
+)
+
 add_fp_unittest(
   floor_test
   SUITE
@@ -261,6 +293,22 @@ add_fp_unittest(
   UNIT_TEST_ONLY
 )
 
+add_fp_unittest(
+  floorf128_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    floorf128_test.cpp
+  HDRS
+    FloorTest.h
+  DEPENDS
+    libc.include.math
+    libc.src.math.floorf128
+    libc.src.__support.FPUtil.fp_bits
+  # FIXME: Currently fails on the GPU build.
+  UNIT_TEST_ONLY
+)
+
 add_fp_unittest(
   round_test
   SUITE
@@ -309,6 +357,22 @@ add_fp_unittest(
   UNIT_TEST_ONLY
 )
 
+add_fp_unittest(
+  roundf128_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    roundf128_test.cpp
+  HDRS
+    RoundTest.h
+  DEPENDS
+    libc.include.math
+    libc.src.math.roundf128
+    libc.src.__support.FPUtil.fp_bits
+  # FIXME: Currently fails on the GPU build.
+  UNIT_TEST_ONLY
+)
+
 add_fp_unittest(
   lround_test
   SUITE

diff  --git a/libc/test/src/math/smoke/ceilf128_test.cpp b/libc/test/src/math/smoke/ceilf128_test.cpp
new file mode 100644
index 00000000000000..f0da8258f79bc0
--- /dev/null
+++ b/libc/test/src/math/smoke/ceilf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for ceilf128 --------------------------------------------===//
+//
+// 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 "CeilTest.h"
+
+#include "src/math/ceilf128.h"
+
+LIST_CEIL_TESTS(float128, LIBC_NAMESPACE::ceilf128)

diff  --git a/libc/test/src/math/smoke/floorf128_test.cpp b/libc/test/src/math/smoke/floorf128_test.cpp
new file mode 100644
index 00000000000000..1858a4aad0ad50
--- /dev/null
+++ b/libc/test/src/math/smoke/floorf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for floorf128 -------------------------------------------===//
+//
+// 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 "FloorTest.h"
+
+#include "src/math/floorf128.h"
+
+LIST_FLOOR_TESTS(float128, LIBC_NAMESPACE::floorf128)

diff  --git a/libc/test/src/math/smoke/roundf128_test.cpp b/libc/test/src/math/smoke/roundf128_test.cpp
new file mode 100644
index 00000000000000..01c70c87667b65
--- /dev/null
+++ b/libc/test/src/math/smoke/roundf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for roundf128 -------------------------------------------===//
+//
+// 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 "RoundTest.h"
+
+#include "src/math/roundf128.h"
+
+LIST_ROUND_TESTS(float128, LIBC_NAMESPACE::roundf128)

diff  --git a/libc/test/src/math/smoke/truncf128_test.cpp b/libc/test/src/math/smoke/truncf128_test.cpp
new file mode 100644
index 00000000000000..7d6487b7d85673
--- /dev/null
+++ b/libc/test/src/math/smoke/truncf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for truncf128 -------------------------------------------===//
+//
+// 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 "TruncTest.h"
+
+#include "src/math/truncf128.h"
+
+LIST_TRUNC_TESTS(float128, LIBC_NAMESPACE::truncf128)


        


More information about the libc-commits mailing list