From 165c17051012da5f37e7341e136ee2996cbe1bc5 Mon Sep 17 00:00:00 2001 From: Job Hernandez Date: Tue, 23 Jul 2024 09:41:53 -0700 Subject: [PATCH 1/6] add entrypoints and tests for totalordermag --- libc/config/darwin/arm/entrypoints.txt | 3 ++ libc/config/darwin/x86_64/entrypoints.txt | 3 ++ libc/config/linux/aarch64/entrypoints.txt | 6 ++- libc/config/linux/arm/entrypoints.txt | 3 ++ libc/config/linux/riscv/entrypoints.txt | 4 ++ libc/config/linux/x86_64/entrypoints.txt | 4 ++ libc/spec/llvm_libc_ext.td | 1 + libc/spec/stdc.td | 4 ++ libc/src/math/CMakeLists.txt | 5 ++ libc/src/math/generic/CMakeLists.txt | 48 +++++++++++++++++++ libc/src/math/generic/totalordermag.cpp | 21 ++++++++ libc/src/math/generic/totalordermagf.cpp | 21 ++++++++ libc/src/math/generic/totalordermagf128.cpp | 21 ++++++++ libc/src/math/generic/totalordermagl.cpp | 21 ++++++++ libc/src/math/totalordermag.h | 20 ++++++++ libc/src/math/totalordermagf.h | 20 ++++++++ libc/src/math/totalordermagf128.h | 21 ++++++++ libc/src/math/totalordermagl.h | 20 ++++++++ libc/test/src/math/smoke/CMakeLists.txt | 48 +++++++++++++++++++ .../src/math/smoke/totalordermag_test.cpp | 13 +++++ .../src/math/smoke/totalordermagf128_test.cpp | 13 +++++ .../src/math/smoke/totalordermagf_test.cpp | 13 +++++ .../src/math/smoke/totalordermagl_test.cpp | 13 +++++ 23 files changed, 345 insertions(+), 1 deletion(-) create mode 100644 libc/src/math/generic/totalordermag.cpp create mode 100644 libc/src/math/generic/totalordermagf.cpp create mode 100644 libc/src/math/generic/totalordermagf128.cpp create mode 100644 libc/src/math/generic/totalordermagl.cpp create mode 100644 libc/src/math/totalordermag.h create mode 100644 libc/src/math/totalordermagf.h create mode 100644 libc/src/math/totalordermagf128.h create mode 100644 libc/src/math/totalordermagl.h create mode 100644 libc/test/src/math/smoke/totalordermag_test.cpp create mode 100644 libc/test/src/math/smoke/totalordermagf128_test.cpp create mode 100644 libc/test/src/math/smoke/totalordermagf_test.cpp create mode 100644 libc/test/src/math/smoke/totalordermagl_test.cpp diff --git a/libc/config/darwin/arm/entrypoints.txt b/libc/config/darwin/arm/entrypoints.txt index ea5c7b537bbec..3b50666b968e8 100644 --- a/libc/config/darwin/arm/entrypoints.txt +++ b/libc/config/darwin/arm/entrypoints.txt @@ -241,6 +241,9 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.tan libc.src.math.tanf libc.src.math.tanhf + libc.src.math.totalordermag + libc.src.math.totalordermagf + libc.src.math.totalordermagl libc.src.math.trunc libc.src.math.truncf libc.src.math.truncl diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt index 1a7353172d464..df9f9bfd54e81 100644 --- a/libc/config/darwin/x86_64/entrypoints.txt +++ b/libc/config/darwin/x86_64/entrypoints.txt @@ -207,6 +207,9 @@ set(TARGET_LIBM_ENTRYPOINTS #libc.src.math.sqrtl #libc.src.math.tanf #libc.src.math.tanhf + #libc.src.math.totalordermag + #libc.src.math.totalordermagf + #libc.src.math.totalordermagl #libc.src.math.trunc #libc.src.math.truncf #libc.src.math.truncl diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index 0be6f884f0368..cb98bf5d50c64 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -190,7 +190,7 @@ set(TARGET_LIBC_ENTRYPOINTS libc.src.stdlib.strtol libc.src.stdlib.strtold libc.src.stdlib.strtoll - libc.src.stdlib.strtoul + libc.src.stdlib.strtoul//===-- Implementation of totalordermagl function -------------------------===// libc.src.stdlib.strtoull # stdlib.h external entrypoints @@ -514,6 +514,9 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.tan libc.src.math.tanf libc.src.math.tanhf + libc.src.math.totalordermag + libc.src.math.totalordermagf + libc.src.math.totalordermagl libc.src.math.trunc libc.src.math.truncf libc.src.math.truncl @@ -637,6 +640,7 @@ if(LIBC_TYPES_HAS_FLOAT128) libc.src.math.roundevenf128 libc.src.math.scalbnf128 libc.src.math.sqrtf128 + libc.src.math.totalordermagf128 libc.src.math.truncf128 libc.src.math.ufromfpf128 libc.src.math.ufromfpxf128 diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt index 55f118395c22e..61ee68ac66082 100644 --- a/libc/config/linux/arm/entrypoints.txt +++ b/libc/config/linux/arm/entrypoints.txt @@ -373,6 +373,9 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.tan libc.src.math.tanf libc.src.math.tanhf + libc.src.math.totalordermag + libc.src.math.totalordermagf + libc.src.math.totalordermagl libc.src.math.trunc libc.src.math.truncf libc.src.math.truncl diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index 597aeb361afe4..07466805b34cd 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -542,6 +542,9 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.tan libc.src.math.tanf libc.src.math.tanhf + libc.src.math.totalordermag + libc.src.math.totalordermagf + libc.src.math.totalordermagl libc.src.math.trunc libc.src.math.truncf libc.src.math.truncl @@ -600,6 +603,7 @@ if(LIBC_TYPES_HAS_FLOAT128) libc.src.math.roundf128 libc.src.math.scalbnf128 libc.src.math.sqrtf128 + libc.src.math.totalordermagf128 libc.src.math.truncf128 libc.src.math.ufromfpf128 libc.src.math.ufromfpxf128 diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index f7813fc16ff7c..035ceb8ca57bf 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -542,6 +542,9 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.tan libc.src.math.tanf libc.src.math.tanhf + libc.src.math.totalordermag + libc.src.math.totalordermagf + libc.src.math.totalordermagl libc.src.math.trunc libc.src.math.truncf libc.src.math.truncl @@ -686,6 +689,7 @@ if(LIBC_TYPES_HAS_FLOAT128) libc.src.math.roundf128 libc.src.math.scalbnf128 libc.src.math.sqrtf128 + libc.src.math.totalordermagf128 libc.src.math.truncf128 libc.src.math.ufromfpf128 libc.src.math.ufromfpxf128 diff --git a/libc/spec/llvm_libc_ext.td b/libc/spec/llvm_libc_ext.td index f3a8862574ac5..bb0deca4a7937 100644 --- a/libc/spec/llvm_libc_ext.td +++ b/libc/spec/llvm_libc_ext.td @@ -88,6 +88,7 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> { GuardedFunctionSpec<"f16sqrtl", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"fsqrtf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, + GuardedFunctionSpec<"totalordermagf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"powi", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"powif", RetValSpec, [ArgSpec, ArgSpec]>, diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td index 0aae65308d33a..89541d44c5c0e 100644 --- a/libc/spec/stdc.td +++ b/libc/spec/stdc.td @@ -569,6 +569,10 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"tan", RetValSpec, [ArgSpec]>, FunctionSpec<"tanf", RetValSpec, [ArgSpec]>, + FunctionSpec<"totalordermag", RetValSpec, [ArgSpec, ArgSpec]>, + FunctionSpec<"totalordermagf", RetValSpec, [ArgSpec, ArgSpec]>, + FunctionSpec<"totalordermagl", RetValSpec, [ArgSpec, ArgSpec]>, + FunctionSpec<"erff", RetValSpec, [ArgSpec]>, FunctionSpec<"exp", RetValSpec, [ArgSpec]>, diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt index 25aef3f72e3cd..c477a2dd1bcac 100644 --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -430,6 +430,11 @@ add_math_entrypoint_object(tanf) add_math_entrypoint_object(tanh) add_math_entrypoint_object(tanhf) +add_math_entrypoint_object(totalordermag) +add_math_entrypoint_object(totalordermagf) +add_math_entrypoint_object(totalordermagl) +add_math_entrypoint_object(totalordermagf128) + add_math_entrypoint_object(tgamma) add_math_entrypoint_object(tgammaf) diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index ef96d6c4c2f37..79a10a7a4f039 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -3977,6 +3977,54 @@ add_entrypoint_object( -O3 ) +add_entrypoint_object( + totalordermag + SRCS + totalordermag.cpp + HDRS + ../totalordermag.h + DEPENDS + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( + totalordermagf + SRCS + totalordermagf.cpp + HDRS + ../totalordermagf.h + DEPENDS + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( + totalordermagl + SRCS + totalordermagl.cpp + HDRS + ../totalordermagl.h + DEPENDS + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( + totalordermagf128 + SRCS + totalordermagf128.cpp + HDRS + ../totalordermagf128.h + DEPENDS + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + add_entrypoint_object( getpayloadf16 SRCS diff --git a/libc/src/math/generic/totalordermag.cpp b/libc/src/math/generic/totalordermag.cpp new file mode 100644 index 0000000000000..d18f3591ee84a --- /dev/null +++ b/libc/src/math/generic/totalordermag.cpp @@ -0,0 +1,21 @@ +//===-- Implementation of totalordermagf16 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/totalordermag.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, totalordermag, + (const double *x, const double *y)) { + return static_cast(fputil::totalordermag(*x, *y)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/totalordermagf.cpp b/libc/src/math/generic/totalordermagf.cpp new file mode 100644 index 0000000000000..eec7c01d8fb46 --- /dev/null +++ b/libc/src/math/generic/totalordermagf.cpp @@ -0,0 +1,21 @@ +//===-- Implementation of totalordermagf 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/totalordermagf.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, totalordermagf, + (const float *x, const float *y)) { + return static_cast(fputil::totalordermag(*x, *y)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/totalordermagf128.cpp b/libc/src/math/generic/totalordermagf128.cpp new file mode 100644 index 0000000000000..ad8f3064cd32c --- /dev/null +++ b/libc/src/math/generic/totalordermagf128.cpp @@ -0,0 +1,21 @@ +//===-- Implementation of totalordermagf128 function ---------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "src/math/totalordermagf128.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, totalordermagf128, + (const float128 *x, const float128 *y)) { + return static_cast(fputil::totalordermag(*x, *y)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/totalordermagl.cpp b/libc/src/math/generic/totalordermagl.cpp new file mode 100644 index 0000000000000..49eed62bf99eb --- /dev/null +++ b/libc/src/math/generic/totalordermagl.cpp @@ -0,0 +1,21 @@ +//===-- Implementation of totalordermagl 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/totalordermagl.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, totalordermagl, + (const long double *x, const long double *y)) { + return static_cast(fputil::totalordermag(*x, *y)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/totalordermag.h b/libc/src/math/totalordermag.h new file mode 100644 index 0000000000000..cfdd868add674 --- /dev/null +++ b/libc/src/math/totalordermag.h @@ -0,0 +1,20 @@ +//===-- Implementation header for totalordermag -----------------*- 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_TOTALORDERMAG_H +#define LLVM_LIBC_SRC_MATH_TOTALORDERMAG_H + +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +int totalordermag(const double *x, const double *y); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_TOTALORDERMAG_H diff --git a/libc/src/math/totalordermagf.h b/libc/src/math/totalordermagf.h new file mode 100644 index 0000000000000..47ddd831808f5 --- /dev/null +++ b/libc/src/math/totalordermagf.h @@ -0,0 +1,20 @@ +//===-- Implementation header for totalordermagf ----------------*- 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_TOTALORDERMAGF_H +#define LLVM_LIBC_SRC_MATH_TOTALORDERMAGF_H + +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +int totalordermagf(const float *x, const float *y); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_TOTALORDERMAGF_H diff --git a/libc/src/math/totalordermagf128.h b/libc/src/math/totalordermagf128.h new file mode 100644 index 0000000000000..1011661f34ad7 --- /dev/null +++ b/libc/src/math/totalordermagf128.h @@ -0,0 +1,21 @@ +//===-- Implementation header for totalordermagf128 ------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_MATH_TOTALORDERMAGF128_H +#define LLVM_LIBC_SRC_MATH_TOTALORDERMAGF128_H + +#include "src/__support/macros/config.h" +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE_DECL { + +int totalordermagf128(const float128 *x, const float128 *y); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_TOTALORDERMAGF128_H diff --git a/libc/src/math/totalordermagl.h b/libc/src/math/totalordermagl.h new file mode 100644 index 0000000000000..64d27f1566877 --- /dev/null +++ b/libc/src/math/totalordermagl.h @@ -0,0 +1,20 @@ +//===-- Implementation header for totalordermag -----------------*- 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_TOTALORDERMAGL_H +#define LLVM_LIBC_SRC_MATH_TOTALORDERMAGL_H + +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +int totalordermagl(const long double *x, const long double *y); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_TOTALORDERMAGl_H diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index 1b3c51739c0fe..150bfd2487cf7 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -3655,6 +3655,54 @@ add_fp_unittest( libc.src.math.totalordermagf16 ) +add_fp_unittest( + totalordermag_test + SUITE + libc-math-smoke-tests + SRCS + totalordermag_test.cpp + HDRS + TotalOrderMagTest.h + DEPENDS + libc.src.math.totalordermag +) + +add_fp_unittest( + totalordermagf_test + SUITE + libc-math-smoke-tests + SRCS + totalordermagf_test.cpp + HDRS + TotalOrderMagTest.h + DEPENDS + libc.src.math.totalordermagf +) + +add_fp_unittest( + totalordermagl_test + SUITE + libc-math-smoke-tests + SRCS + totalordermagl_test.cpp + HDRS + TotalOrderMagTest.h + DEPENDS + libc.src.math.totalordermagl +) + +add_fp_unittest( + totalordermagf128_test + SUITE + libc-math-smoke-tests + SRCS + totalordermagf128_test.cpp + HDRS + TotalOrderMagTest.h + DEPENDS + libc.src.math.totalordermagf128 +) + add_fp_unittest( getpayloadf16_test SUITE diff --git a/libc/test/src/math/smoke/totalordermag_test.cpp b/libc/test/src/math/smoke/totalordermag_test.cpp new file mode 100644 index 0000000000000..6c3b6ddbd7422 --- /dev/null +++ b/libc/test/src/math/smoke/totalordermag_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for totalordermag ---------------------------------------===// +// +// 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 "TotalOrderMagTest.h" + +#include "src/math/totalordermag.h" + +LIST_TOTALORDERMAG_TESTS(double, LIBC_NAMESPACE::totalordermag) diff --git a/libc/test/src/math/smoke/totalordermagf128_test.cpp b/libc/test/src/math/smoke/totalordermagf128_test.cpp new file mode 100644 index 0000000000000..6cbe24ff8778f --- /dev/null +++ b/libc/test/src/math/smoke/totalordermagf128_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for totalordermagf128 -----------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "TotalOrderMagTest.h" + +#include "src/math/totalordermagf128.h" + +LIST_TOTALORDERMAG_TESTS(float128, LIBC_NAMESPACE::totalordermagf128) diff --git a/libc/test/src/math/smoke/totalordermagf_test.cpp b/libc/test/src/math/smoke/totalordermagf_test.cpp new file mode 100644 index 0000000000000..c54cea21a52c7 --- /dev/null +++ b/libc/test/src/math/smoke/totalordermagf_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for totalordermagf --------------------------------------===// +// +// 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 "TotalOrderMagTest.h" + +#include "src/math/totalordermagf.h" + +LIST_TOTALORDERMAG_TESTS(float, LIBC_NAMESPACE::totalordermagf) diff --git a/libc/test/src/math/smoke/totalordermagl_test.cpp b/libc/test/src/math/smoke/totalordermagl_test.cpp new file mode 100644 index 0000000000000..bdb9f616aded7 --- /dev/null +++ b/libc/test/src/math/smoke/totalordermagl_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for totalordermagl --------------------------------------===// +// +// 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 "TotalOrderMagTest.h" + +#include "src/math/totalordermagl.h" + +LIST_TOTALORDERMAG_TESTS(long double, LIBC_NAMESPACE::totalordermagl) From 3c5f59c734793633588ff07563e6addcd232cdc0 Mon Sep 17 00:00:00 2001 From: Job Hernandez Date: Tue, 23 Jul 2024 10:46:50 -0700 Subject: [PATCH 2/6] address review --- libc/config/linux/aarch64/entrypoints.txt | 2 +- libc/spec/llvm_libc_ext.td | 1 - libc/spec/stdc.td | 11 +++++------ libc/src/math/CMakeLists.txt | 9 ++++----- libc/src/math/generic/CMakeLists.txt | 1 + 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index cb98bf5d50c64..2334fed773702 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -190,7 +190,7 @@ set(TARGET_LIBC_ENTRYPOINTS libc.src.stdlib.strtol libc.src.stdlib.strtold libc.src.stdlib.strtoll - libc.src.stdlib.strtoul//===-- Implementation of totalordermagl function -------------------------===// + libc.src.stdlib.strtoul libc.src.stdlib.strtoull # stdlib.h external entrypoints diff --git a/libc/spec/llvm_libc_ext.td b/libc/spec/llvm_libc_ext.td index bb0deca4a7937..f3a8862574ac5 100644 --- a/libc/spec/llvm_libc_ext.td +++ b/libc/spec/llvm_libc_ext.td @@ -88,7 +88,6 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> { GuardedFunctionSpec<"f16sqrtl", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"fsqrtf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - GuardedFunctionSpec<"totalordermagf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"powi", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"powif", RetValSpec, [ArgSpec, ArgSpec]>, diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td index 89541d44c5c0e..ca7df13e65c0e 100644 --- a/libc/spec/stdc.td +++ b/libc/spec/stdc.td @@ -569,10 +569,6 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"tan", RetValSpec, [ArgSpec]>, FunctionSpec<"tanf", RetValSpec, [ArgSpec]>, - FunctionSpec<"totalordermag", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"totalordermagf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"totalordermagl", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"erff", RetValSpec, [ArgSpec]>, FunctionSpec<"exp", RetValSpec, [ArgSpec]>, @@ -724,9 +720,12 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"dsqrtl", RetValSpec, [ArgSpec]>, + GuardedFunctionSpec<"totalorderf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"totalorderf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - + FunctionSpec<"totalordermag", RetValSpec, [ArgSpec, ArgSpec]>, + FunctionSpec<"totalordermagf", RetValSpec, [ArgSpec, ArgSpec]>, + FunctionSpec<"totalordermagl", RetValSpec, [ArgSpec, ArgSpec]>, + GuardedFunctionSpec<"totalordermagf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, GuardedFunctionSpec<"totalordermagf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"getpayloadf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt index c477a2dd1bcac..ad4c0e02aeb8a 100644 --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -430,16 +430,15 @@ add_math_entrypoint_object(tanf) add_math_entrypoint_object(tanh) add_math_entrypoint_object(tanhf) -add_math_entrypoint_object(totalordermag) -add_math_entrypoint_object(totalordermagf) -add_math_entrypoint_object(totalordermagl) -add_math_entrypoint_object(totalordermagf128) - add_math_entrypoint_object(tgamma) add_math_entrypoint_object(tgammaf) add_math_entrypoint_object(totalorderf16) +add_math_entrypoint_object(totalordermag) +add_math_entrypoint_object(totalordermagf) +add_math_entrypoint_object(totalordermagl) +add_math_entrypoint_object(totalordermagf128) add_math_entrypoint_object(totalordermagf16) add_math_entrypoint_object(trunc) diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index 79a10a7a4f039..124ceaded91c3 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -4021,6 +4021,7 @@ add_entrypoint_object( ../totalordermagf128.h DEPENDS libc.src.__support.FPUtil.basic_operations + libc.src.__support.macros.properties.types COMPILE_OPTIONS -O3 ) From 42ba27b7a97b8cb0df46a77ef698ef29170c3e29 Mon Sep 17 00:00:00 2001 From: Job Hernandez Date: Tue, 23 Jul 2024 10:47:23 -0700 Subject: [PATCH 3/6] clang format --- libc/src/math/generic/totalordermag.cpp | 3 +-- libc/src/math/generic/totalordermagf.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libc/src/math/generic/totalordermag.cpp b/libc/src/math/generic/totalordermag.cpp index d18f3591ee84a..34b0d2793bb0e 100644 --- a/libc/src/math/generic/totalordermag.cpp +++ b/libc/src/math/generic/totalordermag.cpp @@ -13,8 +13,7 @@ namespace LIBC_NAMESPACE_DECL { -LLVM_LIBC_FUNCTION(int, totalordermag, - (const double *x, const double *y)) { +LLVM_LIBC_FUNCTION(int, totalordermag, (const double *x, const double *y)) { return static_cast(fputil::totalordermag(*x, *y)); } diff --git a/libc/src/math/generic/totalordermagf.cpp b/libc/src/math/generic/totalordermagf.cpp index eec7c01d8fb46..6b93bac51d0fb 100644 --- a/libc/src/math/generic/totalordermagf.cpp +++ b/libc/src/math/generic/totalordermagf.cpp @@ -13,8 +13,7 @@ namespace LIBC_NAMESPACE_DECL { -LLVM_LIBC_FUNCTION(int, totalordermagf, - (const float *x, const float *y)) { +LLVM_LIBC_FUNCTION(int, totalordermagf, (const float *x, const float *y)) { return static_cast(fputil::totalordermag(*x, *y)); } From bba3d957909854af67f5dbb8cf3e97e723457a73 Mon Sep 17 00:00:00 2001 From: Job Hernandez Date: Wed, 24 Jul 2024 10:02:45 -0700 Subject: [PATCH 4/6] address review --- libc/spec/stdc.td | 2 +- libc/src/math/CMakeLists.txt | 2 +- libc/src/math/generic/CMakeLists.txt | 24 ++++++++++----------- libc/src/math/generic/totalordermagf128.cpp | 2 +- libc/src/math/totalordermagf128.h | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td index ca7df13e65c0e..d5a5cb6fedb4b 100644 --- a/libc/spec/stdc.td +++ b/libc/spec/stdc.td @@ -725,8 +725,8 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"totalordermag", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"totalordermagf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"totalordermagl", RetValSpec, [ArgSpec, ArgSpec]>, + GuardedFunctionSpec<"totalordermagf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"totalordermagf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - GuardedFunctionSpec<"totalordermagf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"getpayloadf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt index ad4c0e02aeb8a..d70af33522d2b 100644 --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -438,8 +438,8 @@ add_math_entrypoint_object(totalorderf16) add_math_entrypoint_object(totalordermag) add_math_entrypoint_object(totalordermagf) add_math_entrypoint_object(totalordermagl) -add_math_entrypoint_object(totalordermagf128) add_math_entrypoint_object(totalordermagf16) +add_math_entrypoint_object(totalordermagf128) add_math_entrypoint_object(trunc) add_math_entrypoint_object(truncf) diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index 124ceaded91c3..80e862542e29c 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -3965,18 +3965,6 @@ add_entrypoint_object( -O3 ) -add_entrypoint_object( - totalordermagf16 - SRCS - totalordermagf16.cpp - HDRS - ../totalordermagf16.h - DEPENDS - libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - -O3 -) - add_entrypoint_object( totalordermag SRCS @@ -4013,6 +4001,18 @@ add_entrypoint_object( -O3 ) +add_entrypoint_object( + totalordermagf16 + SRCS + totalordermagf16.cpp + HDRS + ../totalordermagf16.h + DEPENDS + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + add_entrypoint_object( totalordermagf128 SRCS diff --git a/libc/src/math/generic/totalordermagf128.cpp b/libc/src/math/generic/totalordermagf128.cpp index ad8f3064cd32c..b32abfa8d09b1 100644 --- a/libc/src/math/generic/totalordermagf128.cpp +++ b/libc/src/math/generic/totalordermagf128.cpp @@ -1,4 +1,4 @@ -//===-- Implementation of totalordermagf128 function ---------------------===// +//===-- Implementation of totalordermagf128 function ----------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/src/math/totalordermagf128.h b/libc/src/math/totalordermagf128.h index 1011661f34ad7..389d0596b9d4b 100644 --- a/libc/src/math/totalordermagf128.h +++ b/libc/src/math/totalordermagf128.h @@ -1,4 +1,4 @@ -//===-- Implementation header for totalordermagf128 ------------*- C++ -*-===// +//===-- Implementation header for totalordermagf128 -------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. From a9a6a9e784faf7cae0227711ec9aa870933489a3 Mon Sep 17 00:00:00 2001 From: Job Hernandez Date: Wed, 24 Jul 2024 10:13:09 -0700 Subject: [PATCH 5/6] update docs --- 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 f287c16fd01e2..64de548a1ea1c 100644 --- a/libc/docs/math/index.rst +++ b/libc/docs/math/index.rst @@ -230,7 +230,7 @@ Basic Operations +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | totalorder | | | | |check| | | F.10.12.1 | N/A | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| totalordermag | | | | |check| | | F.10.12.2 | N/A | +| totalordermag | |check| | |check| | |check| | |check| | |check| | F.10.12.2 | N/A | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | trunc | |check| | |check| | |check| | |check| | |check| | 7.12.9.9 | F.10.6.9 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ From dc7e4de7b7a5ab8e3080abba1f9f3d2dbaf7cd36 Mon Sep 17 00:00:00 2001 From: Job Hernandez Date: Wed, 24 Jul 2024 16:47:27 -0700 Subject: [PATCH 6/6] address review --- libc/src/math/generic/totalordermag.cpp | 2 +- libc/test/src/math/smoke/CMakeLists.txt | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libc/src/math/generic/totalordermag.cpp b/libc/src/math/generic/totalordermag.cpp index 34b0d2793bb0e..fb8215cad68fe 100644 --- a/libc/src/math/generic/totalordermag.cpp +++ b/libc/src/math/generic/totalordermag.cpp @@ -1,4 +1,4 @@ -//===-- Implementation of totalordermagf16 function -----------------------===// +//===-- Implementation of totalordermag 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/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index 150bfd2487cf7..5ddc88a38eb64 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -3643,18 +3643,6 @@ add_fp_unittest( libc.src.math.totalorderf16 ) -add_fp_unittest( - totalordermagf16_test - SUITE - libc-math-smoke-tests - SRCS - totalordermagf16_test.cpp - HDRS - TotalOrderMagTest.h - DEPENDS - libc.src.math.totalordermagf16 -) - add_fp_unittest( totalordermag_test SUITE @@ -3691,6 +3679,18 @@ add_fp_unittest( libc.src.math.totalordermagl ) +add_fp_unittest( + totalordermagf16_test + SUITE + libc-math-smoke-tests + SRCS + totalordermagf16_test.cpp + HDRS + TotalOrderMagTest.h + DEPENDS + libc.src.math.totalordermagf16 +) + add_fp_unittest( totalordermagf128_test SUITE