[libc-commits] [libc] [libc][math][c23] Add fadd{l, f128} C23 math functions (PR #102531)

via libc-commits libc-commits at lists.llvm.org
Thu Aug 8 16:26:38 PDT 2024


https://github.com/aaryanshukla updated https://github.com/llvm/llvm-project/pull/102531

>From ef9d7304babe38de0aee3720fe1941eff2f9fd46 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Thu, 8 Aug 2024 20:38:29 +0000
Subject: [PATCH 1/9] [libc][math][c23] functions

---
 libc/config/linux/aarch64/entrypoints.txt  |  2 ++
 libc/config/linux/arm/entrypoints.txt      |  1 +
 libc/config/linux/riscv/entrypoints.txt    |  2 ++
 libc/config/linux/x86_64/entrypoints.txt   |  2 ++
 libc/config/windows/entrypoints.txt        |  1 +
 libc/spec/stdc.td                          |  1 +
 libc/src/math/CMakeLists.txt               |  3 +++
 libc/src/math/fadd.h                       |  2 +-
 libc/src/math/faddf128.h                   | 22 +++++++++++++++++
 libc/src/math/faddl.h                      | 20 ++++++++++++++++
 libc/src/math/generic/CMakeLists.txt       | 25 +++++++++++++++++++
 libc/src/math/generic/fadd.cpp             |  2 +-
 libc/src/math/generic/faddf128.cpp         | 20 ++++++++++++++++
 libc/src/math/generic/faddl.cpp            | 20 ++++++++++++++++
 libc/test/src/math/CMakeLists.txt          | 14 +++++++++++
 libc/test/src/math/faddl_test.cpp          | 13 ++++++++++
 libc/test/src/math/smoke/CMakeLists.txt    | 28 ++++++++++++++++++++++
 libc/test/src/math/smoke/faddf128_test.cpp | 13 ++++++++++
 libc/test/src/math/smoke/faddl_test.cpp    | 13 ++++++++++
 19 files changed, 202 insertions(+), 2 deletions(-)
 create mode 100644 libc/src/math/faddf128.h
 create mode 100644 libc/src/math/faddl.h
 create mode 100644 libc/src/math/generic/faddf128.cpp
 create mode 100644 libc/src/math/generic/faddl.cpp
 create mode 100644 libc/test/src/math/faddl_test.cpp
 create mode 100644 libc/test/src/math/smoke/faddf128_test.cpp
 create mode 100644 libc/test/src/math/smoke/faddl_test.cpp

diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index b92b96c89315e2..34bf671a270925 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -407,6 +407,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fabsf
     libc.src.math.fabsl
     libc.src.math.fadd 
+    libc.src.math.faddl
     libc.src.math.fdim
     libc.src.math.fdimf
     libc.src.math.fdiml
@@ -683,6 +684,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.dsqrtf128
     libc.src.math.dsubf128
     libc.src.math.fabsf128
+    libc.src.math.faddf128
     libc.src.math.fdimf128
     libc.src.math.fdivf128
     libc.src.math.ffmaf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index c6b7b6cc9acfa2..1f0fd4eb2481b6 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -243,6 +243,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fabsf
     libc.src.math.fabsl
     libc.src.math.fadd 
+    libc.src.math.faddl
     libc.src.math.fdim
     libc.src.math.fdimf
     libc.src.math.fdiml
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index a90fdbef31bf2e..1036774f8c7025 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -406,6 +406,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fabsf
     libc.src.math.fabsl
     libc.src.math.fadd 
+    libc.src.math.faddl
     libc.src.math.fdim
     libc.src.math.fdimf
     libc.src.math.fdiml
@@ -590,6 +591,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.dsqrtf128
     libc.src.math.dsubf128
     libc.src.math.fabsf128
+    libc.src.math.faddf128
     libc.src.math.fdimf128
     libc.src.math.fdivf128
     libc.src.math.ffmaf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 9ec86f13850dbe..9294a57f99d9a3 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -406,6 +406,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fabsf
     libc.src.math.fabsl
     libc.src.math.fadd 
+    libc.src.math.faddl
     libc.src.math.fdim
     libc.src.math.fdimf
     libc.src.math.fdiml
@@ -679,6 +680,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.dsqrtf128
     libc.src.math.dsubf128
     libc.src.math.fabsf128
+    libc.src.math.faddf128
     libc.src.math.fdimf128
     libc.src.math.fdivf128
     libc.src.math.ffmaf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index d28183549647f1..99d0307bfadd84 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -152,6 +152,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fabsf
     libc.src.math.fabsl
     libc.src.math.fadd
+    libc.src.math.faddl
     libc.src.math.fdim
     libc.src.math.fdimf
     libc.src.math.fdiml
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 5dde6ac67f5a86..d4f90f29cd1fed 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -408,6 +408,7 @@ def StdC : StandardSpec<"stdc"> {
           GuardedFunctionSpec<"fabsf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
           GuardedFunctionSpec<"fabsf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
           FunctionSpec<"fadd", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
+          FunctionSpec<"faddl", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
 
           FunctionSpec<"fdim", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
           FunctionSpec<"fdimf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index a0bd5269169fa3..c9e6a37952fee2 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -160,7 +160,10 @@ add_math_entrypoint_object(fabsf)
 add_math_entrypoint_object(fabsl)
 add_math_entrypoint_object(fabsf16)
 add_math_entrypoint_object(fabsf128)
+
 add_math_entrypoint_object(fadd)
+add_math_entrypoint_object(faddl)
+add_math_entrypoint_object(faddf128)
 
 add_math_entrypoint_object(fdim)
 add_math_entrypoint_object(fdimf)
diff --git a/libc/src/math/fadd.h b/libc/src/math/fadd.h
index ec3ce18bb676a6..1dead013e3e5ca 100644
--- a/libc/src/math/fadd.h
+++ b/libc/src/math/fadd.h
@@ -1,4 +1,4 @@
-//===-- Implementation of fadd function ----------------------------------===//
+//===-- Implementation of fadd function -----------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/math/faddf128.h b/libc/src/math/faddf128.h
new file mode 100644
index 00000000000000..37886450e4fd12
--- /dev/null
+++ b/libc/src/math/faddf128.h
@@ -0,0 +1,22 @@
+//===-- Implementation of faddf128 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/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+
+#ifndef LLVM_LIBC_SRC_MATH_FADDF128_H
+#define LLVM_LIBC_SRC_MATH_FADDF128_H
+
+namespace LIBC_NAMESPACE_DECL {
+
+float faddf128(float128 x, float128 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FADDF128_H
diff --git a/libc/src/math/faddl.h b/libc/src/math/faddl.h
new file mode 100644
index 00000000000000..9550f9c112cb02
--- /dev/null
+++ b/libc/src/math/faddl.h
@@ -0,0 +1,20 @@
+//===-- Implementation of faddl 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/__support/macros/config.h"
+
+#ifndef LLVM_LIBC_SRC_MATH_FADDL_H
+#define LLVM_LIBC_SRC_MATH_FADDL_H
+
+namespace LIBC_NAMESPACE_DECL {
+
+float faddl(long double x, long double y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FADDL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index be5cc2e02635af..91e21194e1fb86 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -586,6 +586,31 @@ add_entrypoint_object(
     -O3
 )
 
+add_entrypoint_object(
+  faddl
+  SRCS
+    faddl.cpp
+  HDRS
+    ../faddl.h
+  DEPENDS
+    libc.src.__support.FPUtil.basic_operations
+  COMPILE_OPTIONS
+    -O3
+)
+
+add_entrypoint_object(
+  faddf128
+  SRCS
+    faddf128.cpp
+  HDRS
+    ../faddf128.h
+  DEPENDS
+    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.macros.properties.types
+  COMPILE_OPTIONS
+    -O3
+)
+
 add_entrypoint_object(
   trunc
   SRCS
diff --git a/libc/src/math/generic/fadd.cpp b/libc/src/math/generic/fadd.cpp
index 66e5188cbcfd4c..60460f87086570 100644
--- a/libc/src/math/generic/fadd.cpp
+++ b/libc/src/math/generic/fadd.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation of fadd function ----------------------------------===//
+//===-- Implementation of fadd function -----------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/math/generic/faddf128.cpp b/libc/src/math/generic/faddf128.cpp
new file mode 100644
index 00000000000000..953b1a1ce092ee
--- /dev/null
+++ b/libc/src/math/generic/faddf128.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of faddf128 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/faddf128.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, faddf128, (float128 x, float128 y)) {
+  return fputil::generic::add<float>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/faddl.cpp b/libc/src/math/generic/faddl.cpp
new file mode 100644
index 00000000000000..b5c6ab4031c383
--- /dev/null
+++ b/libc/src/math/generic/faddl.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of faddl 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/faddl.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, faddl, (long double x, long double y)) {
+  return fputil::generic::add<float>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index f3703eb59999b1..e9be9f7dc815cf 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -202,6 +202,20 @@ add_fp_unittest(
     libc.src.__support.FPUtil.basic_operations
 )
 
+add_fp_unittest(
+  faddl_test
+  NEED_MPFR
+  SUITE
+    libc-math-unittests
+  SRCS
+    faddl_test.cpp
+  HDRS
+    AddTest.h
+  DEPENDS
+    libc.src.math.faddl
+    libc.src.__support.FPUtil.basic_operations
+)
+
 add_fp_unittest(
   trunc_test
   NEED_MPFR
diff --git a/libc/test/src/math/faddl_test.cpp b/libc/test/src/math/faddl_test.cpp
new file mode 100644
index 00000000000000..9c99b32ee7c422
--- /dev/null
+++ b/libc/test/src/math/faddl_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for faddl -----------------------------------------------===//
+//
+// 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 "AddTest.h"
+
+#include "src/math/faddl.h"
+
+LIST_ADD_TESTS(float, long double, LIBC_NAMESPACE::faddl)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 21818e4734a682..d3b920b88b8b4f 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -155,6 +155,34 @@ add_fp_unittest(
 
 )
 
+add_fp_unittest(
+  faddl_test
+  NEED_MPFR
+  SUITE
+    libc-math-unittests
+  SRCS
+    faddl_test.cpp
+  HDRS
+    AddTest.h
+  DEPENDS
+    libc.src.math.faddl
+    libc.src.__support.FPUtil.basic_operations
+)
+
+add_fp_unittest(
+  faddf128_test
+  NEED_MPFR
+  SUITE
+    libc-math-unittests
+  SRCS
+    faddf128_test.cpp
+  HDRS
+    AddTest.h
+  DEPENDS
+    libc.src.math.faddf128
+    libc.src.__support.FPUtil.basic_operations
+)
+
 add_fp_unittest(
   trunc_test
   SUITE
diff --git a/libc/test/src/math/smoke/faddf128_test.cpp b/libc/test/src/math/smoke/faddf128_test.cpp
new file mode 100644
index 00000000000000..5a11b5f419cad2
--- /dev/null
+++ b/libc/test/src/math/smoke/faddf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for faddf128 --------------------------------------------===//
+//
+// 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 "AddTest.h"
+
+#include "src/math/faddf128.h"
+
+LIST_ADD_TESTS(float, float128, LIBC_NAMESPACE::faddf128)
diff --git a/libc/test/src/math/smoke/faddl_test.cpp b/libc/test/src/math/smoke/faddl_test.cpp
new file mode 100644
index 00000000000000..9c99b32ee7c422
--- /dev/null
+++ b/libc/test/src/math/smoke/faddl_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for faddl -----------------------------------------------===//
+//
+// 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 "AddTest.h"
+
+#include "src/math/faddl.h"
+
+LIST_ADD_TESTS(float, long double, LIBC_NAMESPACE::faddl)

>From a31e0054f9e1d662d23ae9edb3d976e498896d0e Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Thu, 8 Aug 2024 20:48:49 +0000
Subject: [PATCH 2/9] added headers

---
 libc/newhdrgen/yaml/math.yaml | 22 ++++++++++++++++++++++
 libc/spec/llvm_libc_ext.td    |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/libc/newhdrgen/yaml/math.yaml b/libc/newhdrgen/yaml/math.yaml
index d22546e50b3feb..8207b33521d342 100644
--- a/libc/newhdrgen/yaml/math.yaml
+++ b/libc/newhdrgen/yaml/math.yaml
@@ -76,6 +76,28 @@ functions:
     return_type: long double
     arguments:
       - type: long double
+  - name: fadd
+    standards:
+      - stdc
+    return_type: float
+    arguments:
+      - type: double 
+      - type: double
+  - name: faddl
+    standards:
+      - faddl
+    return_type: float
+    arguments:
+      - type: long double
+      - type: long double
+  - name: faddf128
+    standards:
+      - llvm_libc_ext
+    return_type: float
+    arguments:
+      - type: float128
+      - type: float128
+    guard: LIBC_TYPES_HAS_FLOAT128
   - name: fdim
     standards:
       - stdc
diff --git a/libc/spec/llvm_libc_ext.td b/libc/spec/llvm_libc_ext.td
index c4cbca80072bfe..38e9b64dccd944 100644
--- a/libc/spec/llvm_libc_ext.td
+++ b/libc/spec/llvm_libc_ext.td
@@ -72,6 +72,8 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> {
           GuardedFunctionSpec<"f16subf", RetValSpec<Float16Type>, [ArgSpec<FloatType>, ArgSpec<FloatType>], "LIBC_TYPES_HAS_FLOAT16">,
           GuardedFunctionSpec<"f16subl", RetValSpec<Float16Type>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>], "LIBC_TYPES_HAS_FLOAT16">,
           
+          GuardedFunctionSpec<"faddf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
+
           GuardedFunctionSpec<"fdivf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
 
           GuardedFunctionSpec<"ffmaf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,

>From 0a4157e3374a59d3d9377efc3db35a07406be9e1 Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Thu, 8 Aug 2024 14:39:45 -0700
Subject: [PATCH 3/9] Update llvm_libc_ext.td

---
 libc/spec/llvm_libc_ext.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/spec/llvm_libc_ext.td b/libc/spec/llvm_libc_ext.td
index 42f1a51df81021..7ce48c3804b096 100644
--- a/libc/spec/llvm_libc_ext.td
+++ b/libc/spec/llvm_libc_ext.td
@@ -70,7 +70,7 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> {
 
           GuardedFunctionSpec<"f16sub", RetValSpec<Float16Type>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>], "LIBC_TYPES_HAS_FLOAT16">,
           GuardedFunctionSpec<"f16subf", RetValSpec<Float16Type>, [ArgSpec<FloatType>, ArgSpec<FloatType>], "LIBC_TYPES_HAS_FLOAT16">,
-          GuardedFunctionSpec<"f16subl", RetValSpec<Float16Type>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>], "LIBC_TYPES_HAS_FLOAT16">,          
+          GuardedFunctionSpec<"f16subl", RetValSpec<Float16Type>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>], "LIBC_TYPES_HAS_FLOAT16">,     
           
           GuardedFunctionSpec<"faddf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
 

>From 2d6098c095ac3a8b5730c244a527278d97a08e18 Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Thu, 8 Aug 2024 14:40:41 -0700
Subject: [PATCH 4/9] Update faddf128.h

---
 libc/src/math/faddf128.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libc/src/math/faddf128.h b/libc/src/math/faddf128.h
index 37886450e4fd12..4260de08c1dd42 100644
--- a/libc/src/math/faddf128.h
+++ b/libc/src/math/faddf128.h
@@ -9,7 +9,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/properties/types.h"
 
-
 #ifndef LLVM_LIBC_SRC_MATH_FADDF128_H
 #define LLVM_LIBC_SRC_MATH_FADDF128_H
 

>From a9713550fba978af0b6c5f4f987ca946e3860158 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Thu, 8 Aug 2024 22:59:45 +0000
Subject: [PATCH 5/9] updated .h

---
 libc/src/math/fadd.h                 | 3 +--
 libc/src/math/faddf128.h             | 5 ++---
 libc/src/math/faddl.h                | 3 +--
 libc/src/math/generic/CMakeLists.txt | 4 ++--
 4 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/libc/src/math/fadd.h b/libc/src/math/fadd.h
index 1dead013e3e5ca..40c3f0fa7b4eb6 100644
--- a/libc/src/math/fadd.h
+++ b/libc/src/math/fadd.h
@@ -6,11 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/macros/config.h"
-
 #ifndef LLVM_LIBC_SRC_MATH_FADD_H
 #define LLVM_LIBC_SRC_MATH_FADD_H
 
+#include "src/__support/macros/config.h"
 namespace LIBC_NAMESPACE_DECL {
 
 float fadd(double x, double y);
diff --git a/libc/src/math/faddf128.h b/libc/src/math/faddf128.h
index 4260de08c1dd42..24e6842b22a863 100644
--- a/libc/src/math/faddf128.h
+++ b/libc/src/math/faddf128.h
@@ -6,12 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
 #ifndef LLVM_LIBC_SRC_MATH_FADDF128_H
 #define LLVM_LIBC_SRC_MATH_FADDF128_H
 
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
 namespace LIBC_NAMESPACE_DECL {
 
 float faddf128(float128 x, float128 y);
diff --git a/libc/src/math/faddl.h b/libc/src/math/faddl.h
index 9550f9c112cb02..d50632b0e2ed36 100644
--- a/libc/src/math/faddl.h
+++ b/libc/src/math/faddl.h
@@ -6,11 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/macros/config.h"
-
 #ifndef LLVM_LIBC_SRC_MATH_FADDL_H
 #define LLVM_LIBC_SRC_MATH_FADDL_H
 
+#include "src/__support/macros/config.h"
 namespace LIBC_NAMESPACE_DECL {
 
 float faddl(long double x, long double y);
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 4d1356562f29c6..0828cd6dee1201 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -593,7 +593,7 @@ add_entrypoint_object(
   HDRS
     ../fadd.h
   DEPENDS
-    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.FPUtil.generic.add_sub
   COMPILE_OPTIONS
     -O3
 )
@@ -605,7 +605,7 @@ add_entrypoint_object(
   HDRS
     ../faddl.h
   DEPENDS
-    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.FPUtil.generic.add_sub
   COMPILE_OPTIONS
     -O3
 )

>From 06b7a7a00a38df2bd6f403e90ca6893f7ae464cf Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Thu, 8 Aug 2024 16:00:57 -0700
Subject: [PATCH 6/9] Update fadd.h

---
 libc/src/math/fadd.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libc/src/math/fadd.h b/libc/src/math/fadd.h
index 40c3f0fa7b4eb6..fe795687f9ac55 100644
--- a/libc/src/math/fadd.h
+++ b/libc/src/math/fadd.h
@@ -10,6 +10,7 @@
 #define LLVM_LIBC_SRC_MATH_FADD_H
 
 #include "src/__support/macros/config.h"
+
 namespace LIBC_NAMESPACE_DECL {
 
 float fadd(double x, double y);

>From 1465b787eae7f24598f6afe74e001b44a5f258e7 Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Thu, 8 Aug 2024 16:01:46 -0700
Subject: [PATCH 7/9] Update faddf128.h

---
 libc/src/math/faddf128.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libc/src/math/faddf128.h b/libc/src/math/faddf128.h
index 24e6842b22a863..73e5ff11f7a81a 100644
--- a/libc/src/math/faddf128.h
+++ b/libc/src/math/faddf128.h
@@ -11,6 +11,7 @@
 
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/properties/types.h"
+
 namespace LIBC_NAMESPACE_DECL {
 
 float faddf128(float128 x, float128 y);

>From aab06fad8bb8f63fdc73111a4db9e40b24e5946d Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Thu, 8 Aug 2024 16:10:36 -0700
Subject: [PATCH 8/9] Update faddl.h

---
 libc/src/math/faddl.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libc/src/math/faddl.h b/libc/src/math/faddl.h
index d50632b0e2ed36..b1dc2069e3956a 100644
--- a/libc/src/math/faddl.h
+++ b/libc/src/math/faddl.h
@@ -10,6 +10,7 @@
 #define LLVM_LIBC_SRC_MATH_FADDL_H
 
 #include "src/__support/macros/config.h"
+
 namespace LIBC_NAMESPACE_DECL {
 
 float faddl(long double x, long double y);

>From cd024ea5c5b74d5c67485092beef64ea6edf952e Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Thu, 8 Aug 2024 16:26:27 -0700
Subject: [PATCH 9/9] Update libc/spec/stdc.td

Co-authored-by: OverMighty <its.overmighty at gmail.com>
---
 libc/spec/stdc.td | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 7643679c97f8b0..449625b8cab3ec 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -407,6 +407,7 @@ def StdC : StandardSpec<"stdc"> {
           FunctionSpec<"fabsl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
           GuardedFunctionSpec<"fabsf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
           GuardedFunctionSpec<"fabsf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
+
           FunctionSpec<"fadd", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
           FunctionSpec<"faddl", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
 



More information about the libc-commits mailing list