[libc][math] Refactor dadd family to header-only (#182142)
Closes https://github.com/llvm/llvm-project/issues/182141
This commit is contained in:
parent
2e6740541b
commit
4db2ce4d54
@ -75,6 +75,8 @@
|
||||
#include "math/coshf16.h"
|
||||
#include "math/cospif.h"
|
||||
#include "math/cospif16.h"
|
||||
#include "math/daddf128.h"
|
||||
#include "math/daddl.h"
|
||||
#include "math/dfmaf128.h"
|
||||
#include "math/dfmal.h"
|
||||
#include "math/dsqrtl.h"
|
||||
|
||||
29
libc/shared/math/daddf128.h
Normal file
29
libc/shared/math/daddf128.h
Normal file
@ -0,0 +1,29 @@
|
||||
//===-- Shared daddf128 function --------------------------------*- 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_SHARED_MATH_DADDF128_H
|
||||
#define LLVM_LIBC_SHARED_MATH_DADDF128_H
|
||||
|
||||
#include "include/llvm-libc-types/float128.h"
|
||||
|
||||
#ifdef LIBC_TYPES_HAS_FLOAT128
|
||||
|
||||
#include "shared/libc_common.h"
|
||||
#include "src/__support/math/daddf128.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
namespace shared {
|
||||
|
||||
using math::daddf128;
|
||||
|
||||
} // namespace shared
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
|
||||
#endif // LIBC_TYPES_HAS_FLOAT128
|
||||
|
||||
#endif // LLVM_LIBC_SHARED_MATH_DADDF128_H
|
||||
23
libc/shared/math/daddl.h
Normal file
23
libc/shared/math/daddl.h
Normal file
@ -0,0 +1,23 @@
|
||||
//===-- Shared daddl function -----------------------------------*- 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_SHARED_MATH_DADDL_H
|
||||
#define LLVM_LIBC_SHARED_MATH_DADDL_H
|
||||
|
||||
#include "shared/libc_common.h"
|
||||
#include "src/__support/math/daddl.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
namespace shared {
|
||||
|
||||
using math::daddl;
|
||||
|
||||
} // namespace shared
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
|
||||
#endif // LLVM_LIBC_SHARED_MATH_DADDL_H
|
||||
@ -881,6 +881,25 @@ add_header_library(
|
||||
libc.src.__support.macros.optimization
|
||||
)
|
||||
|
||||
add_header_library(
|
||||
daddf128
|
||||
HDRS
|
||||
daddf128.h
|
||||
DEPENDS
|
||||
libc.include.llvm-libc-types.float128
|
||||
libc.src.__support.FPUtil.generic.add_sub
|
||||
libc.src.__support.macros.config
|
||||
)
|
||||
|
||||
add_header_library(
|
||||
daddl
|
||||
HDRS
|
||||
daddl.h
|
||||
DEPENDS
|
||||
libc.src.__support.FPUtil.generic.add_sub
|
||||
libc.src.__support.macros.config
|
||||
)
|
||||
|
||||
add_header_library(
|
||||
dsqrtl
|
||||
HDRS
|
||||
|
||||
31
libc/src/__support/math/daddf128.h
Normal file
31
libc/src/__support/math/daddf128.h
Normal file
@ -0,0 +1,31 @@
|
||||
//===-- Implementation header for daddf128 ----------------------*- 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___SUPPORT_MATH_DADDF128_H
|
||||
#define LLVM_LIBC_SRC___SUPPORT_MATH_DADDF128_H
|
||||
|
||||
#include "include/llvm-libc-types/float128.h"
|
||||
|
||||
#ifdef LIBC_TYPES_HAS_FLOAT128
|
||||
|
||||
#include "src/__support/FPUtil/generic/add_sub.h"
|
||||
#include "src/__support/macros/config.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
namespace math {
|
||||
|
||||
LIBC_INLINE double daddf128(float128 x, float128 y) {
|
||||
return fputil::generic::add<double>(x, y);
|
||||
}
|
||||
|
||||
} // namespace math
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
|
||||
#endif // LIBC_TYPES_HAS_FLOAT128
|
||||
|
||||
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_DADDF128_H
|
||||
25
libc/src/__support/math/daddl.h
Normal file
25
libc/src/__support/math/daddl.h
Normal file
@ -0,0 +1,25 @@
|
||||
//===-- Implementation header for daddl -------------------------*- 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___SUPPORT_MATH_DADDL_H
|
||||
#define LLVM_LIBC_SRC___SUPPORT_MATH_DADDL_H
|
||||
|
||||
#include "src/__support/FPUtil/generic/add_sub.h"
|
||||
#include "src/__support/macros/config.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
namespace math {
|
||||
|
||||
LIBC_INLINE double daddl(long double x, long double y) {
|
||||
return fputil::generic::add<double>(x, y);
|
||||
}
|
||||
|
||||
} // namespace math
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
|
||||
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_DADDL_H
|
||||
@ -185,7 +185,7 @@ add_entrypoint_object(
|
||||
HDRS
|
||||
../daddl.h
|
||||
DEPENDS
|
||||
libc.src.__support.FPUtil.generic.add_sub
|
||||
libc.src.__support.math.daddl
|
||||
)
|
||||
|
||||
add_entrypoint_object(
|
||||
@ -195,8 +195,7 @@ add_entrypoint_object(
|
||||
HDRS
|
||||
../daddf128.h
|
||||
DEPENDS
|
||||
libc.src.__support.macros.properties.types
|
||||
libc.src.__support.FPUtil.generic.add_sub
|
||||
libc.src.__support.math.daddf128
|
||||
)
|
||||
|
||||
add_entrypoint_object(
|
||||
|
||||
@ -7,14 +7,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "src/math/daddf128.h"
|
||||
#include "src/__support/FPUtil/generic/add_sub.h"
|
||||
#include "src/__support/common.h"
|
||||
#include "src/__support/macros/config.h"
|
||||
#include "src/__support/math/daddf128.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
LLVM_LIBC_FUNCTION(double, daddf128, (float128 x, float128 y)) {
|
||||
return fputil::generic::add<double>(x, y);
|
||||
return math::daddf128(x, y);
|
||||
}
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
|
||||
@ -7,14 +7,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "src/math/daddl.h"
|
||||
#include "src/__support/FPUtil/generic/add_sub.h"
|
||||
#include "src/__support/common.h"
|
||||
#include "src/__support/macros/config.h"
|
||||
#include "src/__support/math/daddl.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
LLVM_LIBC_FUNCTION(double, daddl, (long double x, long double y)) {
|
||||
return fputil::generic::add<double>(x, y);
|
||||
return math::daddl(x, y);
|
||||
}
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
|
||||
@ -72,6 +72,8 @@ add_fp_unittest(
|
||||
libc.src.__support.math.coshf16
|
||||
libc.src.__support.math.cospif
|
||||
libc.src.__support.math.cospif16
|
||||
libc.src.__support.math.daddf128
|
||||
libc.src.__support.math.daddl
|
||||
libc.src.__support.math.dfmaf128
|
||||
libc.src.__support.math.dfmal
|
||||
libc.src.__support.math.dsqrtl
|
||||
|
||||
@ -316,6 +316,7 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
|
||||
|
||||
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::bf16mull(0.0L, 0.0L));
|
||||
EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::ceill(0.0L));
|
||||
EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::daddl(0.0L, 0.0L));
|
||||
EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::faddl(0.0L, 0.0L));
|
||||
EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::fdiml(0.0L, 0.0L));
|
||||
EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::floorl(0.0L));
|
||||
@ -375,6 +376,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
|
||||
EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizef128(&canonicalizef128_cx,
|
||||
&canonicalizef128_x));
|
||||
EXPECT_FP_EQ(float128(0.0), canonicalizef128_cx);
|
||||
|
||||
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::bf16subf128(
|
||||
float128(0.0), float128(0.0)));
|
||||
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::bf16fmaf128(
|
||||
@ -384,6 +386,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
|
||||
EXPECT_FP_EQ(bfloat16(2.0), LIBC_NAMESPACE::shared::bf16divf128(
|
||||
float128(4.0), float128(2.0)));
|
||||
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::ceilf128(float128(0.0)));
|
||||
EXPECT_FP_EQ(float128(0.0),
|
||||
LIBC_NAMESPACE::shared::daddf128(float128(0.0), float128(0.0)));
|
||||
EXPECT_FP_EQ(float128(0.0),
|
||||
LIBC_NAMESPACE::shared::faddf128(float128(0.0), float128(0.0)));
|
||||
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::floorf128(float128(0.0)));
|
||||
|
||||
@ -3716,6 +3716,25 @@ libc_support_library(
|
||||
],
|
||||
)
|
||||
|
||||
libc_support_library(
|
||||
name = "__support_math_daddf128",
|
||||
hdrs = ["src/__support/math/daddf128.h"],
|
||||
deps = [
|
||||
":__support_fputil_basic_operations",
|
||||
":__support_macros_config",
|
||||
":llvm_libc_types_float128",
|
||||
],
|
||||
)
|
||||
|
||||
libc_support_library(
|
||||
name = "__support_math_daddl",
|
||||
hdrs = ["src/__support/math/daddl.h"],
|
||||
deps = [
|
||||
":__support_fputil_basic_operations",
|
||||
":__support_macros_config",
|
||||
],
|
||||
)
|
||||
|
||||
libc_support_library(
|
||||
name = "__support_math_dsqrtl",
|
||||
hdrs = ["src/__support/math/dsqrtl.h"],
|
||||
@ -6646,10 +6665,18 @@ libc_math_function(
|
||||
],
|
||||
)
|
||||
|
||||
libc_math_function(name = "daddl")
|
||||
libc_math_function(
|
||||
name = "daddl",
|
||||
additional_deps = [
|
||||
":__support_math_daddl",
|
||||
],
|
||||
)
|
||||
|
||||
libc_math_function(
|
||||
name = "daddf128",
|
||||
additional_deps = [
|
||||
":__support_math_daddf128",
|
||||
],
|
||||
)
|
||||
|
||||
libc_math_function(name = "ddivl")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user