[libc-commits] [libc] [libc][math][c23] Add fsub{, l, f128} and remainderf128 C23 math functions (PR #101576)
via libc-commits
libc-commits at lists.llvm.org
Sun Aug 4 20:16:46 PDT 2024
https://github.com/aaryanshukla updated https://github.com/llvm/llvm-project/pull/101576
>From 00592adf7ff01bf264cd59f6155ce351249986d7 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Thu, 1 Aug 2024 18:01:21 +0000
Subject: [PATCH 1/8] script
---
libc/llvm_libc_add_math_function.py | 161 ++++++++++++++++++++++++++++
1 file changed, 161 insertions(+)
create mode 100755 libc/llvm_libc_add_math_function.py
diff --git a/libc/llvm_libc_add_math_function.py b/libc/llvm_libc_add_math_function.py
new file mode 100755
index 0000000000000..810543570ffc1
--- /dev/null
+++ b/libc/llvm_libc_add_math_function.py
@@ -0,0 +1,161 @@
+#!/usr/bin/python
+# Example usage:
+# cd path/to/llvm-project
+# ./path/to/llvm_libc_add_math_function.py '' 'TYPE' 'ceil' 'TYPE x' 'CeilTest' 'LIST_CEIL_TESTS'
+# ./path/to/llvm_libc_add_math_function.py 'f16' 'TYPE' 'ceil' 'TYPE x' 'CeilTest' 'LIST_CEIL_TESTS'
+import sys
+import subprocess
+
+MAX_FILE_TITLE_LEN = 66
+
+EMACS_CXX_MODE = "-*- C++ -*-"
+
+FILE_HEADER_TEMPLATE = """//===-- {file_title}===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+"""
+
+HEADER_TEMPLATE = """{file_header}
+#ifndef LLVM_LIBC_SRC_MATH_{fn_identifier_uppercase}_H
+#define LLVM_LIBC_SRC_MATH_{fn_identifier_uppercase}_H
+
+#include "src/__support/macros/config.h"
+{includes}
+namespace LIBC_NAMESPACE_DECL {{
+
+{fn_return_type} {fn_identifier}({fn_param_list});
+
+}} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_{fn_identifier_uppercase}_H
+"""
+
+IMPL_TEMPLATE = """{file_header}
+#include "src/math/{fn_identifier}.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {{
+
+LLVM_LIBC_FUNCTION({fn_return_type}, {fn_identifier}, ({fn_param_list})) {{
+ // TODO: Implement function.
+}}
+
+}} // namespace LIBC_NAMESPACE_DECL
+"""
+
+TEST_TEMPLATE = """{file_header}
+#include "{test_class}.h"
+
+#include "src/math/{fn_identifier}.h"
+
+{test_macro}({fn_return_type}, LIBC_NAMESPACE::{fn_identifier})
+"""
+
+
+def get_type_from_suffix(suffix):
+ match suffix:
+ case "":
+ return "double"
+ case "f":
+ return "float"
+ case "l":
+ return "long double"
+ case "f16":
+ return "float16"
+ case "f128":
+ return "float128"
+ case _:
+ raise ValueError("Unknown suffix")
+
+
+def get_file_title(base_title, emacs_mode=""):
+ dashes = "-" * (MAX_FILE_TITLE_LEN - len(base_title) - len(emacs_mode))
+ return f"{base_title} {dashes}{emacs_mode}"
+
+
+def get_include_for_type(type_identifier):
+ match type_identifier:
+ case "float16" | "float128":
+ return '#include "src/__support/macros/properties/types.h"'
+
+
+if __name__ == "__main__":
+ (
+ _,
+ generic_type_suffix,
+ fn_return_type_tmpl,
+ fn_identifier_prefix,
+ fn_param_list_tmpl,
+ test_class,
+ test_macro,
+ *_,
+ ) = sys.argv
+
+ generic_type = get_type_from_suffix(generic_type_suffix)
+ fn_return_type = fn_return_type_tmpl.replace("TYPE", generic_type)
+ fn_identifier = fn_identifier_prefix + generic_type_suffix
+ fn_identifier_uppercase = fn_identifier.upper()
+ fn_param_list = fn_param_list_tmpl.replace("TYPE", generic_type)
+
+ with open(f"libc/src/math/{fn_identifier}.h", "w") as header:
+ header_title = get_file_title(
+ f"Implementation header for {fn_identifier}", EMACS_CXX_MODE
+ )
+ header_file_header = FILE_HEADER_TEMPLATE.format(file_title=header_title)
+
+ header_includes = ""
+
+ if (generic_type_include := get_include_for_type(generic_type)) is not None:
+ header_includes = f"{generic_type_include}\n"
+
+ header.write(
+ HEADER_TEMPLATE.format(
+ file_header=header_file_header,
+ fn_identifier_uppercase=fn_identifier_uppercase,
+ includes=header_includes,
+ fn_return_type=fn_return_type,
+ fn_identifier=fn_identifier,
+ fn_param_list=fn_param_list,
+ )
+ )
+
+ with open(f"libc/src/math/generic/{fn_identifier}.cpp", "w") as impl:
+ impl_title = get_file_title(f"Implementation of {fn_identifier} function")
+ impl_file_header = FILE_HEADER_TEMPLATE.format(file_title=impl_title)
+
+ impl.write(
+ IMPL_TEMPLATE.format(
+ file_header=impl_file_header,
+ fn_return_type=fn_return_type,
+ fn_identifier=fn_identifier,
+ fn_param_list=fn_param_list,
+ )
+ )
+
+ with open(f"libc/test/src/math/smoke/{fn_identifier}_test.cpp", "w") as test:
+ test_title = get_file_title(f"Unittests for {fn_identifier}")
+ test_file_header = FILE_HEADER_TEMPLATE.format(file_title=test_title)
+
+ test.write(
+ TEST_TEMPLATE.format(
+ file_header=test_file_header,
+ test_class=test_class,
+ test_macro=test_macro,
+ fn_return_type=fn_return_type,
+ fn_identifier=fn_identifier,
+ )
+ )
+
+ if generic_type == "float16":
+ subprocess.run(
+ r"sed -i 's/^\(| "
+ + fn_identifier_prefix
+ + r" \+\(| \(|check|\|N\/A\)\? \+\)\{3\}| \) \{7\}/\1|check|/' libc/docs/math/index.rst && git diff libc/docs/math/index.rst",
+ shell=True,
+ check=True,
+ )
\ No newline at end of file
>From 56f04976187833586978c5bb2a8b49dbe53d5677 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Thu, 1 Aug 2024 19:52:21 +0000
Subject: [PATCH 2/8] finished generic and headers
---
libc/config/darwin/arm/entrypoints.txt | 2 +
libc/config/darwin/x86_64/entrypoints.txt | 2 +
libc/config/linux/aarch64/entrypoints.txt | 3 +
libc/config/linux/arm/entrypoints.txt | 2 +
libc/config/linux/riscv/entrypoints.txt | 3 +
libc/config/linux/x86_64/entrypoints.txt | 3 +
libc/config/windows/entrypoints.txt | 2 +
libc/llvm_libc_add_math_function.py | 161 ---------------------
libc/src/math/fsub.h | 20 +++
libc/src/math/fsubf128.h | 21 +++
libc/src/math/fsubl.h | 20 +++
libc/src/math/generic/fsub.cpp | 19 +++
libc/src/math/generic/fsubf128.cpp | 19 +++
libc/src/math/generic/fsubl.cpp | 19 +++
libc/test/src/math/smoke/fsub_test.cpp | 13 ++
libc/test/src/math/smoke/fsubf128_test.cpp | 13 ++
libc/test/src/math/smoke/fsubl_test.cpp | 13 ++
17 files changed, 174 insertions(+), 161 deletions(-)
delete mode 100755 libc/llvm_libc_add_math_function.py
create mode 100644 libc/src/math/fsub.h
create mode 100644 libc/src/math/fsubf128.h
create mode 100644 libc/src/math/fsubl.h
create mode 100644 libc/src/math/generic/fsub.cpp
create mode 100644 libc/src/math/generic/fsubf128.cpp
create mode 100644 libc/src/math/generic/fsubl.cpp
create mode 100644 libc/test/src/math/smoke/fsub_test.cpp
create mode 100644 libc/test/src/math/smoke/fsubf128_test.cpp
create mode 100644 libc/test/src/math/smoke/fsubl_test.cpp
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..d09d524e9bbcf 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
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..0ebda238d42dd 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
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/llvm_libc_add_math_function.py b/libc/llvm_libc_add_math_function.py
deleted file mode 100755
index 810543570ffc1..0000000000000
--- a/libc/llvm_libc_add_math_function.py
+++ /dev/null
@@ -1,161 +0,0 @@
-#!/usr/bin/python
-# Example usage:
-# cd path/to/llvm-project
-# ./path/to/llvm_libc_add_math_function.py '' 'TYPE' 'ceil' 'TYPE x' 'CeilTest' 'LIST_CEIL_TESTS'
-# ./path/to/llvm_libc_add_math_function.py 'f16' 'TYPE' 'ceil' 'TYPE x' 'CeilTest' 'LIST_CEIL_TESTS'
-import sys
-import subprocess
-
-MAX_FILE_TITLE_LEN = 66
-
-EMACS_CXX_MODE = "-*- C++ -*-"
-
-FILE_HEADER_TEMPLATE = """//===-- {file_title}===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-"""
-
-HEADER_TEMPLATE = """{file_header}
-#ifndef LLVM_LIBC_SRC_MATH_{fn_identifier_uppercase}_H
-#define LLVM_LIBC_SRC_MATH_{fn_identifier_uppercase}_H
-
-#include "src/__support/macros/config.h"
-{includes}
-namespace LIBC_NAMESPACE_DECL {{
-
-{fn_return_type} {fn_identifier}({fn_param_list});
-
-}} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_{fn_identifier_uppercase}_H
-"""
-
-IMPL_TEMPLATE = """{file_header}
-#include "src/math/{fn_identifier}.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {{
-
-LLVM_LIBC_FUNCTION({fn_return_type}, {fn_identifier}, ({fn_param_list})) {{
- // TODO: Implement function.
-}}
-
-}} // namespace LIBC_NAMESPACE_DECL
-"""
-
-TEST_TEMPLATE = """{file_header}
-#include "{test_class}.h"
-
-#include "src/math/{fn_identifier}.h"
-
-{test_macro}({fn_return_type}, LIBC_NAMESPACE::{fn_identifier})
-"""
-
-
-def get_type_from_suffix(suffix):
- match suffix:
- case "":
- return "double"
- case "f":
- return "float"
- case "l":
- return "long double"
- case "f16":
- return "float16"
- case "f128":
- return "float128"
- case _:
- raise ValueError("Unknown suffix")
-
-
-def get_file_title(base_title, emacs_mode=""):
- dashes = "-" * (MAX_FILE_TITLE_LEN - len(base_title) - len(emacs_mode))
- return f"{base_title} {dashes}{emacs_mode}"
-
-
-def get_include_for_type(type_identifier):
- match type_identifier:
- case "float16" | "float128":
- return '#include "src/__support/macros/properties/types.h"'
-
-
-if __name__ == "__main__":
- (
- _,
- generic_type_suffix,
- fn_return_type_tmpl,
- fn_identifier_prefix,
- fn_param_list_tmpl,
- test_class,
- test_macro,
- *_,
- ) = sys.argv
-
- generic_type = get_type_from_suffix(generic_type_suffix)
- fn_return_type = fn_return_type_tmpl.replace("TYPE", generic_type)
- fn_identifier = fn_identifier_prefix + generic_type_suffix
- fn_identifier_uppercase = fn_identifier.upper()
- fn_param_list = fn_param_list_tmpl.replace("TYPE", generic_type)
-
- with open(f"libc/src/math/{fn_identifier}.h", "w") as header:
- header_title = get_file_title(
- f"Implementation header for {fn_identifier}", EMACS_CXX_MODE
- )
- header_file_header = FILE_HEADER_TEMPLATE.format(file_title=header_title)
-
- header_includes = ""
-
- if (generic_type_include := get_include_for_type(generic_type)) is not None:
- header_includes = f"{generic_type_include}\n"
-
- header.write(
- HEADER_TEMPLATE.format(
- file_header=header_file_header,
- fn_identifier_uppercase=fn_identifier_uppercase,
- includes=header_includes,
- fn_return_type=fn_return_type,
- fn_identifier=fn_identifier,
- fn_param_list=fn_param_list,
- )
- )
-
- with open(f"libc/src/math/generic/{fn_identifier}.cpp", "w") as impl:
- impl_title = get_file_title(f"Implementation of {fn_identifier} function")
- impl_file_header = FILE_HEADER_TEMPLATE.format(file_title=impl_title)
-
- impl.write(
- IMPL_TEMPLATE.format(
- file_header=impl_file_header,
- fn_return_type=fn_return_type,
- fn_identifier=fn_identifier,
- fn_param_list=fn_param_list,
- )
- )
-
- with open(f"libc/test/src/math/smoke/{fn_identifier}_test.cpp", "w") as test:
- test_title = get_file_title(f"Unittests for {fn_identifier}")
- test_file_header = FILE_HEADER_TEMPLATE.format(file_title=test_title)
-
- test.write(
- TEST_TEMPLATE.format(
- file_header=test_file_header,
- test_class=test_class,
- test_macro=test_macro,
- fn_return_type=fn_return_type,
- fn_identifier=fn_identifier,
- )
- )
-
- if generic_type == "float16":
- subprocess.run(
- r"sed -i 's/^\(| "
- + fn_identifier_prefix
- + r" \+\(| \(|check|\|N\/A\)\? \+\)\{3\}| \) \{7\}/\1|check|/' libc/docs/math/index.rst && git diff libc/docs/math/index.rst",
- shell=True,
- check=True,
- )
\ No newline at end of file
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/fsub.cpp b/libc/src/math/generic/fsub.cpp
new file mode 100644
index 0000000000000..d4e85a36d5285
--- /dev/null
+++ b/libc/src/math/generic/fsub.cpp
@@ -0,0 +1,19 @@
+//===-- 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/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fsub, (double x, double y)) {
+ // TODO: Implement function.
+}
+
+} // 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..255fc88c059af
--- /dev/null
+++ b/libc/src/math/generic/fsubf128.cpp
@@ -0,0 +1,19 @@
+//===-- 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/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fsubf128, (float128 x, float128 y)) {
+ // TODO: Implement function.
+}
+
+} // 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..dda6d5db51e75
--- /dev/null
+++ b/libc/src/math/generic/fsubl.cpp
@@ -0,0 +1,19 @@
+//===-- 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/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fsubl, (long double x, long double y)) {
+ // TODO: Implement function.
+}
+
+} // namespace LIBC_NAMESPACE_DECL
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..b6cb573334132
--- /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, 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..0256aebdf2a75
--- /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, LIBC_NAMESPACE::fsubf128)
diff --git a/libc/test/src/math/smoke/fsubl_test.cpp b/libc/test/src/math/smoke/fsubl_test.cpp
new file mode 100644
index 0000000000000..361a2bc461fb4
--- /dev/null
+++ b/libc/test/src/math/smoke/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, LIBC_NAMESPACE::fsubl)
>From c999ff3c6575faef5d5e02aac5010126fb9551d5 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Thu, 1 Aug 2024 22:04:33 +0000
Subject: [PATCH 3/8] going to add to header spec
---
libc/src/math/CMakeLists.txt | 4 +++
libc/src/math/generic/CMakeLists.txt | 37 ++++++++++++++++++++
libc/src/math/generic/fsub.cpp | 3 +-
libc/src/math/generic/fsubf128.cpp | 3 +-
libc/src/math/generic/fsubl.cpp | 3 +-
libc/test/src/math/CMakeLists.txt | 39 ++++++++++++++++++++++
libc/test/src/math/fsub_test.cpp | 13 ++++++++
libc/test/src/math/fsubf128_test.cpp | 13 ++++++++
libc/test/src/math/fsubl_test.cpp | 13 ++++++++
libc/test/src/math/smoke/CMakeLists.txt | 36 ++++++++++++++++++++
libc/test/src/math/smoke/fsub_test.cpp | 2 +-
libc/test/src/math/smoke/fsubf128_test.cpp | 2 +-
libc/test/src/math/smoke/fsubl_test.cpp | 2 +-
13 files changed, 164 insertions(+), 6 deletions(-)
create mode 100644 libc/test/src/math/fsub_test.cpp
create mode 100644 libc/test/src/math/fsubf128_test.cpp
create mode 100644 libc/test/src/math/fsubl_test.cpp
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index bd022ad88d884..108d6b4d3fde4 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)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 927d97578316e..f3b6f09e88165 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
diff --git a/libc/src/math/generic/fsub.cpp b/libc/src/math/generic/fsub.cpp
index d4e85a36d5285..97e28015c0487 100644
--- a/libc/src/math/generic/fsub.cpp
+++ b/libc/src/math/generic/fsub.cpp
@@ -7,13 +7,14 @@
//===----------------------------------------------------------------------===//
#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)) {
- // TODO: Implement function.
+ 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
index 255fc88c059af..3efb34992b748 100644
--- a/libc/src/math/generic/fsubf128.cpp
+++ b/libc/src/math/generic/fsubf128.cpp
@@ -7,13 +7,14 @@
//===----------------------------------------------------------------------===//
#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)) {
- // TODO: Implement function.
+ 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
index dda6d5db51e75..be74f85016671 100644
--- a/libc/src/math/generic/fsubl.cpp
+++ b/libc/src/math/generic/fsubl.cpp
@@ -7,13 +7,14 @@
//===----------------------------------------------------------------------===//
#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)) {
- // TODO: Implement function.
+ return fputil::generic::sub<float16>(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
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..17976305d090e 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
+ fsubl_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
index b6cb573334132..3c825f7f28af4 100644
--- a/libc/test/src/math/smoke/fsub_test.cpp
+++ b/libc/test/src/math/smoke/fsub_test.cpp
@@ -10,4 +10,4 @@
#include "src/math/fsub.h"
-LIST_SUB_TESTS(float, LIBC_NAMESPACE::fsub)
+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
index 0256aebdf2a75..8f46d91116bde 100644
--- a/libc/test/src/math/smoke/fsubf128_test.cpp
+++ b/libc/test/src/math/smoke/fsubf128_test.cpp
@@ -10,4 +10,4 @@
#include "src/math/fsubf128.h"
-LIST_SUB_TESTS(float, LIBC_NAMESPACE::fsubf128)
+LIST_SUB_TESTS(float, float128, LIBC_NAMESPACE::fsubf128)
diff --git a/libc/test/src/math/smoke/fsubl_test.cpp b/libc/test/src/math/smoke/fsubl_test.cpp
index 361a2bc461fb4..8723432603b00 100644
--- a/libc/test/src/math/smoke/fsubl_test.cpp
+++ b/libc/test/src/math/smoke/fsubl_test.cpp
@@ -10,4 +10,4 @@
#include "src/math/fsubl.h"
-LIST_SUB_TESTS(float, LIBC_NAMESPACE::fsubl)
+LIST_SUB_TESTS(float, long double, LIBC_NAMESPACE::fsubl)
>From 10f87726f9108b17b044690d7d0f780f4b86166f Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Thu, 1 Aug 2024 22:54:58 +0000
Subject: [PATCH 4/8] [libc][math][c23]:
---
libc/config/linux/aarch64/entrypoints.txt | 1 +
libc/config/linux/x86_64/entrypoints.txt | 1 +
libc/newhdrgen/yaml/math.yaml | 30 +++++++++++++++++++++++
libc/src/math/CMakeLists.txt | 1 +
libc/src/math/generic/CMakeLists.txt | 13 ++++++++++
libc/src/math/generic/fsubl.cpp | 2 +-
libc/src/math/generic/remainderf128.cpp | 21 ++++++++++++++++
libc/src/math/remainderf128.h | 21 ++++++++++++++++
libc/test/src/math/smoke/CMakeLists.txt | 2 +-
9 files changed, 90 insertions(+), 2 deletions(-)
create mode 100644 libc/src/math/generic/remainderf128.cpp
create mode 100644 libc/src/math/remainderf128.h
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index d09d524e9bbcf..57e92ecdbb014 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -656,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/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 0ebda238d42dd..eee6a0c756d89 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -701,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/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 108d6b4d3fde4..92eb20e5e61fe 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -386,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/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index f3b6f09e88165..4c312b7360af7 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3020,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/fsubl.cpp b/libc/src/math/generic/fsubl.cpp
index be74f85016671..cad5a2d5d452a 100644
--- a/libc/src/math/generic/fsubl.cpp
+++ b/libc/src/math/generic/fsubl.cpp
@@ -14,7 +14,7 @@
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float, fsubl, (long double x, long double y)) {
- return fputil::generic::sub<float16>(x, 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/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 17976305d090e..622dc1ee50d86 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4256,7 +4256,7 @@ add_fp_unittest(
SUITE
libc-math-smoke-tests
SRCS
- fsubl_test.cpp
+ fsubf128_test.cpp
HDRS
SubTest.h
DEPENDS
>From ac942e0936fc661c873fbe75037d51b77f15ebee Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Fri, 2 Aug 2024 08:33:59 +0000
Subject: [PATCH 5/8] removed fsubf128 from unittests
- added <long double> to <float>
---
libc/test/src/math/CMakeLists.txt | 13 -------------
libc/test/src/math/fsubf128_test.cpp | 13 -------------
libc/utils/MPFRWrapper/MPFRUtils.cpp | 11 +++++++++++
3 files changed, 11 insertions(+), 26 deletions(-)
delete mode 100644 libc/test/src/math/fsubf128_test.cpp
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 644b74a0ac0a9..bec78f93b4062 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2320,19 +2320,6 @@ add_fp_unittest(
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/fsubf128_test.cpp b/libc/test/src/math/fsubf128_test.cpp
deleted file mode 100644
index 8f46d91116bde..0000000000000
--- a/libc/test/src/math/fsubf128_test.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-//===-- 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/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 4263c9dccb6a5..1695354565f56 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -1086,9 +1086,14 @@ template void
explain_ternary_operation_one_output_error(Operation,
const TernaryInput<long double> &,
long double, double, RoundingMode);
+template void explain_ternary_operation_one_output_error(
+ Operation, const TernaryInput<double> &, float, double, RoundingMode);
+template void explain_ternary_operation_one_output_error(
+ Operation, const TernaryInput<long double> &, float, double, RoundingMode);
template void explain_ternary_operation_one_output_error(
Operation, const TernaryInput<long double> &, double, double, RoundingMode);
+
#ifdef LIBC_TYPES_HAS_FLOAT16
template void explain_ternary_operation_one_output_error(
Operation, const TernaryInput<float> &, float16, double, RoundingMode);
@@ -1277,6 +1282,8 @@ compare_ternary_operation_one_output(Operation,
template bool compare_ternary_operation_one_output(
Operation, const TernaryInput<long double> &, double, double, RoundingMode);
+template bool compare_ternary_operation_one_output(
+ Operation, const TernaryInput<long double> &, float, double, RoundingMode);
#ifdef LIBC_TYPES_HAS_FLOAT16
template bool compare_ternary_operation_one_output(Operation,
const TernaryInput<float> &,
@@ -1286,6 +1293,10 @@ template bool compare_ternary_operation_one_output(Operation,
const TernaryInput<double> &,
float16, double,
RoundingMode);
+template bool compare_ternary_operation_one_output(Operation,
+ const TernaryInput<double> &,
+ float, double, RoundingMode);
+
template bool
compare_ternary_operation_one_output(Operation,
const TernaryInput<long double> &, float16,
>From 0537314c4ea068b759d143f84423ac15b2308cee Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Fri, 2 Aug 2024 22:33:46 +0000
Subject: [PATCH 6/8] updated index.rst
---
libc/docs/math/index.rst | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index bbe5b19a9da95..3fa60141ed5a6 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -118,7 +118,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| ddiv | N/A | N/A | | N/A | | 7.12.14.4 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| dfma | N/A | N/A | |check| | N/A | |check|\* | 7.12.14.5 | F.10.11 |
+| dfma | N/A | N/A | |check| | N/A | |check|\* | 7.12.14.5 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| dmul | N/A | N/A | |check| | N/A | |check|\* | 7.12.14.3 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
@@ -176,7 +176,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| fromfpx | |check| | |check| | |check| | |check| | |check| | 7.12.9.11 | F.10.6.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| fsub | N/A | | | N/A | | 7.12.14.2 | F.10.11 |
+| fsub | N/A | |check| | |check| | N/A | |check| | 7.12.14.2 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| getpayload | |check| | |check| | | |check| | |check| | F.10.13.1 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
@@ -210,7 +210,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| nextup | |check| | |check| | |check| | |check| | |check| | 7.12.11.5 | F.10.8.5 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| remainder | |check| | |check| | |check| | |check| | | 7.12.10.2 | F.10.7.2 |
+| remainder | |check| | |check| | |check| | |check| | |check| | 7.12.10.2 | F.10.7.2 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| remquo | |check| | |check| | |check| | |check| | |check| | 7.12.10.3 | F.10.7.3 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
>From 7ea12c98c24954778e0dd15d2a1100a17dc4c9c1 Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Sun, 4 Aug 2024 20:16:27 -0700
Subject: [PATCH 7/8] Update libc/test/src/math/smoke/CMakeLists.txt
Co-authored-by: OverMighty <its.overmighty at gmail.com>
---
libc/test/src/math/smoke/CMakeLists.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 622dc1ee50d86..a7c7f431294bd 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4260,6 +4260,8 @@ add_fp_unittest(
HDRS
SubTest.h
DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
libc.src.math.fsubf128
)
>From 99ac8a190b32c9dd4f7d6e6ff3cb9e091a866c85 Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Sun, 4 Aug 2024 20:16:36 -0700
Subject: [PATCH 8/8] Update libc/docs/math/index.rst
Co-authored-by: OverMighty <its.overmighty at gmail.com>
---
libc/docs/math/index.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 3fa60141ed5a6..1f114c2f676ca 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -176,7 +176,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| fromfpx | |check| | |check| | |check| | |check| | |check| | 7.12.9.11 | F.10.6.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| fsub | N/A | |check| | |check| | N/A | |check| | 7.12.14.2 | F.10.11 |
+| fsub | N/A | |check| | |check| | N/A | |check|\* | 7.12.14.2 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| getpayload | |check| | |check| | | |check| | |check| | F.10.13.1 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
More information about the libc-commits
mailing list