Skip to content

[libc][complex] add cfloat16 and cfloat128 compiler flags #121140

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

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions libc/cmake/modules/CheckCompilerFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ set(
"float16_conversion"
"float128"
"fixed_point"
"cfloat16"
"cfloat128"
)

# Making sure ALL_COMPILER_FEATURES is sorted.
Expand Down Expand Up @@ -110,6 +112,10 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES)
set(LIBC_TYPES_HAS_FLOAT128 TRUE)
elseif(${feature} STREQUAL "fixed_point")
set(LIBC_COMPILER_HAS_FIXED_POINT TRUE)
elseif(${feature} STREQUAL "cfloat16")
set(LIBC_TYPES_HAS_CFLOAT16 TRUE)
elseif(${feature} STREQUAL "cfloat128")
set(LIBC_TYPES_HAS_CFLOAT128 TRUE)
elseif(${feature} STREQUAL "builtin_ceil_floor_rint_trunc")
set(LIBC_COMPILER_HAS_BUILTIN_CEIL_FLOOR_RINT_TRUNC TRUE)
elseif(${feature} STREQUAL "builtin_fmax_fmin")
Expand Down
5 changes: 5 additions & 0 deletions libc/cmake/modules/compiler_features/check_cfloat128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "src/__support/macros/properties/complex_types.h"

#ifndef LIBC_TYPES_HAS_CFLOAT128
#error unsupported
#endif
5 changes: 5 additions & 0 deletions libc/cmake/modules/compiler_features/check_cfloat16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "src/__support/macros/properties/complex_types.h"

#ifndef LIBC_TYPES_HAS_CFLOAT16
#error unsupported
#endif
21 changes: 14 additions & 7 deletions libc/config/linux/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -619,14 +619,17 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpxl
)

if(LIBC_TYPES_HAS_FLOAT16)
if(LIBC_TYPES_HAS_CFLOAT16)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# complex.h C23 _Complex _Float16 entrypoints
# libc.src.complex.crealf16
# libc.src.complex.cimagf16
# libc.src.complex.conjf16
# libc.src.complex.cprojf16

libc.src.complex.crealf16
libc.src.complex.cimagf16
libc.src.complex.conjf16
libc.src.complex.cprojf16
)
endif()

if(LIBC_TYPES_HAS_FLOAT16)
# math.h C23 _Float16 entrypoints
libc.src.math.canonicalizef16
libc.src.math.ceilf16
Expand Down Expand Up @@ -726,14 +729,18 @@ if(LIBC_TYPES_HAS_FLOAT16)
# endif()
endif()

if(LIBC_TYPES_HAS_FLOAT128)
if(LIBC_TYPES_HAS_CFLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# complex.h C23 _Complex _Float128 entrypoints
libc.src.complex.crealf128
libc.src.complex.cimagf128
libc.src.complex.conjf128
libc.src.complex.cprojf128
)
endif()

if(LIBC_TYPES_HAS_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
libc.src.math.ceilf128
Expand Down
7 changes: 5 additions & 2 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,17 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpxl
)

if(LIBC_TYPES_HAS_FLOAT128)
if(LIBC_TYPES_HAS_CFLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# complex.h C23 _Complex _Float128 entrypoints
libc.src.complex.crealf128
libc.src.complex.cimagf128
libc.src.complex.conjf128
libc.src.complex.cprojf128

)
endif()

if(LIBC_TYPES_HAS_FLOAT128)
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
libc.src.math.ceilf128
Expand Down
22 changes: 15 additions & 7 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,18 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpxl
)

if(LIBC_TYPES_HAS_FLOAT16)
if(LIBC_TYPES_HAS_CFLOAT16)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# complex.h C23 _Complex _Float16 entrypoints
libc.src.complex.crealf16
libc.src.complex.cimagf16
libc.src.complex.conjf16
libc.src.complex.cprojf16
)
endif()

if(LIBC_TYPES_HAS_FLOAT16)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float16 entrypoints
libc.src.math.canonicalizef16
libc.src.math.ceilf16
Expand Down Expand Up @@ -736,14 +740,18 @@ if(LIBC_TYPES_HAS_FLOAT16)
endif()
endif()

if(LIBC_TYPES_HAS_FLOAT128)
if(LIBC_TYPES_HAS_CFLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# complex.h C23 _Complex _Float128 entrypoints
# libc.src.complex.crealf128
# libc.src.complex.cimagf128
# libc.src.complex.conjf128
# libc.src.complex.cprojf128

libc.src.complex.crealf128
libc.src.complex.cimagf128
libc.src.complex.conjf128
libc.src.complex.cprojf128
)
endif()

if(LIBC_TYPES_HAS_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
libc.src.math.ceilf128
Expand Down
9 changes: 2 additions & 7 deletions libc/src/complex/cimagf128.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
//
//===----------------------------------------------------------------------===//

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

#if defined(LIBC_TYPES_HAS_CFLOAT128)

#ifndef LLVM_LIBC_SRC_COMPLEX_CIMAGF128_H
#define LLVM_LIBC_SRC_COMPLEX_CIMAGF128_H

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

namespace LIBC_NAMESPACE_DECL {

Expand All @@ -23,5 +20,3 @@ float128 cimagf128(cfloat128 x);
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CIMAGF128_H

#endif // LIBC_TYPES_HAS_CFLOAT128
9 changes: 2 additions & 7 deletions libc/src/complex/cimagf16.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
//
//===----------------------------------------------------------------------===//

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

#if defined(LIBC_TYPES_HAS_CFLOAT16)

#ifndef LLVM_LIBC_SRC_COMPLEX_CIMAGF16_H
#define LLVM_LIBC_SRC_COMPLEX_CIMAGF16_H

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

namespace LIBC_NAMESPACE_DECL {

Expand All @@ -23,5 +20,3 @@ float16 cimagf16(cfloat16 x);
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CIMAGF16_H

#endif // LIBC_TYPES_HAS_CFLOAT16
7 changes: 1 addition & 6 deletions libc/src/complex/conjf128.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/macros/properties/complex_types.h"

#if defined(LIBC_TYPES_HAS_CFLOAT128)

#ifndef LLVM_LIBC_SRC_COMPLEX_CONJF128_H
#define LLVM_LIBC_SRC_COMPLEX_CONJF128_H

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

namespace LIBC_NAMESPACE_DECL {

Expand All @@ -22,5 +19,3 @@ cfloat128 conjf128(cfloat128 x);
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CONJF128_H

#endif // LIBC_TYPES_HAS_CFLOAT128
7 changes: 1 addition & 6 deletions libc/src/complex/conjf16.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/macros/properties/complex_types.h"

#if defined(LIBC_TYPES_HAS_CFLOAT16)

#ifndef LLVM_LIBC_SRC_COMPLEX_CONJF16_H
#define LLVM_LIBC_SRC_COMPLEX_CONJF16_H

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

namespace LIBC_NAMESPACE_DECL {

Expand All @@ -22,5 +19,3 @@ cfloat16 conjf16(cfloat16 x);
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CONJF16_H

#endif // LIBC_TYPES_HAS_CFLOAT16
7 changes: 1 addition & 6 deletions libc/src/complex/cprojf128.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/macros/properties/complex_types.h"

#if defined(LIBC_TYPES_HAS_CFLOAT128)

#ifndef LLVM_LIBC_SRC_COMPLEX_CPROJF128_H
#define LLVM_LIBC_SRC_COMPLEX_CPROJF128_H

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

namespace LIBC_NAMESPACE_DECL {

Expand All @@ -22,5 +19,3 @@ cfloat128 cprojf128(cfloat128 x);
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CPROJF128_H

#endif // LIBC_TYPES_HAS_CFLOAT128
7 changes: 1 addition & 6 deletions libc/src/complex/cprojf16.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/macros/properties/complex_types.h"

#if defined(LIBC_TYPES_HAS_CFLOAT16)

#ifndef LLVM_LIBC_SRC_COMPLEX_CPROJF16_H
#define LLVM_LIBC_SRC_COMPLEX_CPROJF16_H

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

namespace LIBC_NAMESPACE_DECL {

Expand All @@ -22,5 +19,3 @@ cfloat16 cprojf16(cfloat16 x);
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CPROJF16_H

#endif // LIBC_TYPES_HAS_CFLOAT16
9 changes: 2 additions & 7 deletions libc/src/complex/crealf128.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
//
//===----------------------------------------------------------------------===//

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

#if defined(LIBC_TYPES_HAS_CFLOAT128)

#ifndef LLVM_LIBC_SRC_COMPLEX_CREALF128_H
#define LLVM_LIBC_SRC_COMPLEX_CREALF128_H

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

namespace LIBC_NAMESPACE_DECL {

Expand All @@ -23,5 +20,3 @@ float128 crealf128(cfloat128 x);
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CREALF128_H

#endif // LIBC_TYPES_HAS_CFLOAT128
9 changes: 2 additions & 7 deletions libc/src/complex/crealf16.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
//
//===----------------------------------------------------------------------===//

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

#if defined(LIBC_TYPES_HAS_CFLOAT16)

#ifndef LLVM_LIBC_SRC_COMPLEX_CREALF16_H
#define LLVM_LIBC_SRC_COMPLEX_CREALF16_H

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

namespace LIBC_NAMESPACE_DECL {

Expand All @@ -23,5 +20,3 @@ float16 crealf16(cfloat16 x);
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CREALF16_H

#endif // LIBC_TYPES_HAS_CFLOAT16
4 changes: 0 additions & 4 deletions libc/src/complex/generic/cimagf128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//

#include "src/complex/cimagf128.h"
#if defined(LIBC_TYPES_HAS_CFLOAT128)

#include "src/__support/CPP/bit.h"
#include "src/__support/common.h"
#include "src/__support/complex_type.h"
Expand All @@ -21,5 +19,3 @@ LLVM_LIBC_FUNCTION(float128, cimagf128, (cfloat128 x)) {
}

} // namespace LIBC_NAMESPACE_DECL

#endif // LIBC_TYPES_HAS_CFLOAT128
4 changes: 0 additions & 4 deletions libc/src/complex/generic/cimagf16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//

#include "src/complex/cimagf16.h"
#if defined(LIBC_TYPES_HAS_CFLOAT16)

#include "src/__support/CPP/bit.h"
#include "src/__support/common.h"
#include "src/__support/complex_type.h"
Expand All @@ -21,5 +19,3 @@ LLVM_LIBC_FUNCTION(float16, cimagf16, (cfloat16 x)) {
}

} // namespace LIBC_NAMESPACE_DECL

#endif // LIBC_TYPES_HAS_CFLOAT16
4 changes: 0 additions & 4 deletions libc/src/complex/generic/conjf128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//

#include "src/complex/conjf128.h"
#if defined(LIBC_TYPES_HAS_CFLOAT128)

#include "src/__support/common.h"
#include "src/__support/complex_type.h"

Expand All @@ -19,5 +17,3 @@ LLVM_LIBC_FUNCTION(cfloat128, conjf128, (cfloat128 x)) {
}

} // namespace LIBC_NAMESPACE_DECL

#endif // LIBC_TYPES_HAS_CFLOAT128
4 changes: 0 additions & 4 deletions libc/src/complex/generic/conjf16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//

#include "src/complex/conjf16.h"
#if defined(LIBC_TYPES_HAS_CFLOAT16)

#include "src/__support/common.h"
#include "src/__support/complex_type.h"

Expand All @@ -19,5 +17,3 @@ LLVM_LIBC_FUNCTION(cfloat16, conjf16, (cfloat16 x)) {
}

} // namespace LIBC_NAMESPACE_DECL

#endif // LIBC_TYPES_HAS_CFLOAT16
4 changes: 0 additions & 4 deletions libc/src/complex/generic/cprojf128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//

#include "src/complex/cprojf128.h"
#if defined(LIBC_TYPES_HAS_CFLOAT128)

#include "src/__support/common.h"
#include "src/__support/complex_type.h"

Expand All @@ -19,5 +17,3 @@ LLVM_LIBC_FUNCTION(cfloat128, cprojf128, (cfloat128 x)) {
}

} // namespace LIBC_NAMESPACE_DECL

#endif // LIBC_TYPES_HAS_CFLOAT128
Loading
Loading