Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc][math] Implement iscanonical[f|l] as a libc math function #110565

Merged
merged 11 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libc/config/linux/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ilogb
libc.src.math.ilogbf
libc.src.math.ilogbl
libc.src.math.iscanonical
libc.src.math.iscanonicalf
libc.src.math.iscanonicall
libc.src.math.isnan
libc.src.math.isnanf
libc.src.math.isnanl
Expand Down Expand Up @@ -637,6 +640,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.fromfpxf16
libc.src.math.getpayloadf16
libc.src.math.ilogbf16
libc.src.math.iscanonicalf16
libc.src.math.ldexpf16
libc.src.math.llogbf16
libc.src.math.llrintf16
Expand Down Expand Up @@ -720,6 +724,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.fsubf128
libc.src.math.getpayloadf128
libc.src.math.ilogbf128
libc.src.math.iscanonicalf128
libc.src.math.ldexpf128
libc.src.math.llogbf128
libc.src.math.llrintf128
Expand Down
4 changes: 4 additions & 0 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ilogb
libc.src.math.ilogbf
libc.src.math.ilogbl
libc.src.math.iscanonical
libc.src.math.iscanonicalf
libc.src.math.iscanonicall
libc.src.math.isnan
libc.src.math.isnanf
libc.src.math.isnanl
Expand Down Expand Up @@ -627,6 +630,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.fsubf128
libc.src.math.getpayloadf128
libc.src.math.ilogbf128
libc.src.math.iscanonicalf128
libc.src.math.ldexpf128
libc.src.math.llogbf128
libc.src.math.llrintf128
Expand Down
5 changes: 5 additions & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ilogb
libc.src.math.ilogbf
libc.src.math.ilogbl
libc.src.math.iscanonical
libc.src.math.iscanonicalf
libc.src.math.iscanonicall
libc.src.math.isnan
libc.src.math.isnanf
libc.src.math.isnanl
Expand Down Expand Up @@ -637,6 +640,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.fromfpxf16
libc.src.math.getpayloadf16
libc.src.math.ilogbf16
libc.src.math.iscanonicalf16
libc.src.math.ldexpf16
libc.src.math.llogbf16
libc.src.math.llrintf16
Expand Down Expand Up @@ -717,6 +721,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.fsubf128
libc.src.math.getpayloadf128
libc.src.math.ilogbf128
libc.src.math.iscanonicalf128
libc.src.math.ldexpf128
libc.src.math.llogbf128
libc.src.math.llrintf128
Expand Down
6 changes: 6 additions & 0 deletions libc/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ add_math_entrypoint_object(canonicalizel)
add_math_entrypoint_object(canonicalizef16)
add_math_entrypoint_object(canonicalizef128)

add_math_entrypoint_object(iscanonical)
add_math_entrypoint_object(iscanonicalf)
add_math_entrypoint_object(iscanonicall)
add_math_entrypoint_object(iscanonicalf16)
add_math_entrypoint_object(iscanonicalf128)

add_math_entrypoint_object(cbrt)
add_math_entrypoint_object(cbrtf)

Expand Down
54 changes: 54 additions & 0 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,60 @@ add_entrypoint_object(
libc.src.__support.FPUtil.basic_operations
)

add_entrypoint_object(
iscanonical
SRCS
iscanonical.cpp
HDRS
../iscanonical.h
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
iscanonicalf
SRCS
iscanonicalf.cpp
HDRS
../iscanonicalf.h
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
iscanonicall
SRCS
iscanonicall.cpp
HDRS
../iscanonicall.h
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
iscanonicalf16
SRCS
iscanonicalf16.cpp
HDRS
../iscanonicalf16.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.macros.properties.types
)

add_entrypoint_object(
iscanonicalf128
SRCS
iscanonicalf128.cpp
HDRS
../iscanonicalf128.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.macros.properties.types
)

add_entrypoint_object(
ceil
SRCS
Expand Down
21 changes: 21 additions & 0 deletions libc/src/math/generic/iscanonical.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation of iscanonical 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/iscanonical.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, iscanonical, (double x)) {
double temp;
return static_cast<int>(fputil::canonicalize(temp, x) == 0);
}

} // namespace LIBC_NAMESPACE_DECL
21 changes: 21 additions & 0 deletions libc/src/math/generic/iscanonicalf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation of iscanonicalf 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/iscanonicalf.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, iscanonicalf, (float x)) {
float temp;
return static_cast<int>(fputil::canonicalize(temp, x) == 0);
}

} // namespace LIBC_NAMESPACE_DECL
21 changes: 21 additions & 0 deletions libc/src/math/generic/iscanonicalf128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation of iscanonicalf128 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/iscanonicalf128.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, iscanonicalf128, (float128 x)) {
float128 temp;
return static_cast<int>(fputil::canonicalize(temp, x) == 0);
}

} // namespace LIBC_NAMESPACE_DECL
21 changes: 21 additions & 0 deletions libc/src/math/generic/iscanonicalf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation of iscanonicalf16 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/iscanonicalf16.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, iscanonicalf16, (float16 x)) {
float16 temp;
return static_cast<int>(fputil::canonicalize(temp, x) == 0);
}

} // namespace LIBC_NAMESPACE_DECL
21 changes: 21 additions & 0 deletions libc/src/math/generic/iscanonicall.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation of iscanonicall 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/iscanonicall.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, iscanonicall, (long double x)) {
long double temp;
return static_cast<int>(fputil::canonicalize(temp, x) == 0);
}

} // namespace LIBC_NAMESPACE_DECL
20 changes: 20 additions & 0 deletions libc/src/math/iscanonical.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for iscanonical -------------------*- 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_ISCANONICAL_H
#define LLVM_LIBC_SRC_MATH_ISCANONICAL_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

int iscanonical(double x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_ISCANONICAL_H
20 changes: 20 additions & 0 deletions libc/src/math/iscanonicalf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for iscanonicalf ------------------*- 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_ISCANONICALF_H
#define LLVM_LIBC_SRC_MATH_ISCANONICALF_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

int iscanonicalf(float x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_ISCANONICALF_H
21 changes: 21 additions & 0 deletions libc/src/math/iscanonicalf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for iscanonicalf128 ---------------*- 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_ISCANONICALF128_H
#define LLVM_LIBC_SRC_MATH_ISCANONICALF128_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE_DECL {

int iscanonicalf128(float128 x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_ISCANONICALF128_H
21 changes: 21 additions & 0 deletions libc/src/math/iscanonicalf16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for iscanonicalf16 ----------------*- 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_ISCANONICALF16_H
#define LLVM_LIBC_SRC_MATH_ISCANONICALF16_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE_DECL {

int iscanonicalf16(float16 x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_ISCANONICALF16_H
20 changes: 20 additions & 0 deletions libc/src/math/iscanonicall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for iscanonicall ------------------*- 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_ISCANONICALL_H
#define LLVM_LIBC_SRC_MATH_ISCANONICALL_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

int iscanonicall(long double x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_ISCANONICALL_H
Loading
Loading