Skip to content

Commit abd9102

Browse files
authored
[libc][complex] add cfloat16 and cfloat128 compiler flags (#121140)
Proper fix for the temporary fix in #114696
1 parent 03093b6 commit abd9102

30 files changed

+62
-132
lines changed

libc/cmake/modules/CheckCompilerFeatures.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ set(
1313
"float16_conversion"
1414
"float128"
1515
"fixed_point"
16+
"cfloat16"
17+
"cfloat128"
1618
)
1719

1820
# Making sure ALL_COMPILER_FEATURES is sorted.
@@ -110,6 +112,10 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES)
110112
set(LIBC_TYPES_HAS_FLOAT128 TRUE)
111113
elseif(${feature} STREQUAL "fixed_point")
112114
set(LIBC_COMPILER_HAS_FIXED_POINT TRUE)
115+
elseif(${feature} STREQUAL "cfloat16")
116+
set(LIBC_TYPES_HAS_CFLOAT16 TRUE)
117+
elseif(${feature} STREQUAL "cfloat128")
118+
set(LIBC_TYPES_HAS_CFLOAT128 TRUE)
113119
elseif(${feature} STREQUAL "builtin_ceil_floor_rint_trunc")
114120
set(LIBC_COMPILER_HAS_BUILTIN_CEIL_FLOOR_RINT_TRUNC TRUE)
115121
elseif(${feature} STREQUAL "builtin_fmax_fmin")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "src/__support/macros/properties/complex_types.h"
2+
3+
#ifndef LIBC_TYPES_HAS_CFLOAT128
4+
#error unsupported
5+
#endif
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "src/__support/macros/properties/complex_types.h"
2+
3+
#ifndef LIBC_TYPES_HAS_CFLOAT16
4+
#error unsupported
5+
#endif

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,17 @@ set(TARGET_LIBM_ENTRYPOINTS
619619
libc.src.math.ufromfpxl
620620
)
621621

622-
if(LIBC_TYPES_HAS_FLOAT16)
622+
if(LIBC_TYPES_HAS_CFLOAT16)
623623
list(APPEND TARGET_LIBM_ENTRYPOINTS
624624
# complex.h C23 _Complex _Float16 entrypoints
625-
# libc.src.complex.crealf16
626-
# libc.src.complex.cimagf16
627-
# libc.src.complex.conjf16
628-
# libc.src.complex.cprojf16
629-
625+
libc.src.complex.crealf16
626+
libc.src.complex.cimagf16
627+
libc.src.complex.conjf16
628+
libc.src.complex.cprojf16
629+
)
630+
endif()
631+
632+
if(LIBC_TYPES_HAS_FLOAT16)
630633
# math.h C23 _Float16 entrypoints
631634
libc.src.math.canonicalizef16
632635
libc.src.math.ceilf16
@@ -726,14 +729,18 @@ if(LIBC_TYPES_HAS_FLOAT16)
726729
# endif()
727730
endif()
728731

729-
if(LIBC_TYPES_HAS_FLOAT128)
732+
if(LIBC_TYPES_HAS_CFLOAT128)
730733
list(APPEND TARGET_LIBM_ENTRYPOINTS
731734
# complex.h C23 _Complex _Float128 entrypoints
732735
libc.src.complex.crealf128
733736
libc.src.complex.cimagf128
734737
libc.src.complex.conjf128
735738
libc.src.complex.cprojf128
739+
)
740+
endif()
736741

742+
if(LIBC_TYPES_HAS_FLOAT128)
743+
list(APPEND TARGET_LIBM_ENTRYPOINTS
737744
# math.h C23 _Float128 entrypoints
738745
libc.src.math.canonicalizef128
739746
libc.src.math.ceilf128

libc/config/linux/riscv/entrypoints.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,14 +620,17 @@ set(TARGET_LIBM_ENTRYPOINTS
620620
libc.src.math.ufromfpxl
621621
)
622622

623-
if(LIBC_TYPES_HAS_FLOAT128)
623+
if(LIBC_TYPES_HAS_CFLOAT128)
624624
list(APPEND TARGET_LIBM_ENTRYPOINTS
625625
# complex.h C23 _Complex _Float128 entrypoints
626626
libc.src.complex.crealf128
627627
libc.src.complex.cimagf128
628628
libc.src.complex.conjf128
629629
libc.src.complex.cprojf128
630-
630+
)
631+
endif()
632+
633+
if(LIBC_TYPES_HAS_FLOAT128)
631634
# math.h C23 _Float128 entrypoints
632635
libc.src.math.canonicalizef128
633636
libc.src.math.ceilf128

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -624,14 +624,18 @@ set(TARGET_LIBM_ENTRYPOINTS
624624
libc.src.math.ufromfpxl
625625
)
626626

627-
if(LIBC_TYPES_HAS_FLOAT16)
627+
if(LIBC_TYPES_HAS_CFLOAT16)
628628
list(APPEND TARGET_LIBM_ENTRYPOINTS
629629
# complex.h C23 _Complex _Float16 entrypoints
630630
libc.src.complex.crealf16
631631
libc.src.complex.cimagf16
632632
libc.src.complex.conjf16
633633
libc.src.complex.cprojf16
634+
)
635+
endif()
634636

637+
if(LIBC_TYPES_HAS_FLOAT16)
638+
list(APPEND TARGET_LIBM_ENTRYPOINTS
635639
# math.h C23 _Float16 entrypoints
636640
libc.src.math.canonicalizef16
637641
libc.src.math.ceilf16
@@ -736,14 +740,18 @@ if(LIBC_TYPES_HAS_FLOAT16)
736740
endif()
737741
endif()
738742

739-
if(LIBC_TYPES_HAS_FLOAT128)
743+
if(LIBC_TYPES_HAS_CFLOAT128)
740744
list(APPEND TARGET_LIBM_ENTRYPOINTS
741745
# complex.h C23 _Complex _Float128 entrypoints
742-
# libc.src.complex.crealf128
743-
# libc.src.complex.cimagf128
744-
# libc.src.complex.conjf128
745-
# libc.src.complex.cprojf128
746-
746+
libc.src.complex.crealf128
747+
libc.src.complex.cimagf128
748+
libc.src.complex.conjf128
749+
libc.src.complex.cprojf128
750+
)
751+
endif()
752+
753+
if(LIBC_TYPES_HAS_FLOAT128)
754+
list(APPEND TARGET_LIBM_ENTRYPOINTS
747755
# math.h C23 _Float128 entrypoints
748756
libc.src.math.canonicalizef128
749757
libc.src.math.ceilf128

libc/src/complex/cimagf128.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/macros/properties/complex_types.h"
10-
#include "src/__support/macros/properties/types.h"
11-
12-
#if defined(LIBC_TYPES_HAS_CFLOAT128)
13-
149
#ifndef LLVM_LIBC_SRC_COMPLEX_CIMAGF128_H
1510
#define LLVM_LIBC_SRC_COMPLEX_CIMAGF128_H
1611

1712
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/complex_types.h"
14+
#include "src/__support/macros/properties/types.h"
1815

1916
namespace LIBC_NAMESPACE_DECL {
2017

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

2522
#endif // LLVM_LIBC_SRC_COMPLEX_CIMAGF128_H
26-
27-
#endif // LIBC_TYPES_HAS_CFLOAT128

libc/src/complex/cimagf16.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/macros/properties/complex_types.h"
10-
#include "src/__support/macros/properties/types.h"
11-
12-
#if defined(LIBC_TYPES_HAS_CFLOAT16)
13-
149
#ifndef LLVM_LIBC_SRC_COMPLEX_CIMAGF16_H
1510
#define LLVM_LIBC_SRC_COMPLEX_CIMAGF16_H
1611

1712
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/complex_types.h"
14+
#include "src/__support/macros/properties/types.h"
1815

1916
namespace LIBC_NAMESPACE_DECL {
2017

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

2522
#endif // LLVM_LIBC_SRC_COMPLEX_CIMAGF16_H
26-
27-
#endif // LIBC_TYPES_HAS_CFLOAT16

libc/src/complex/conjf128.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/macros/properties/complex_types.h"
10-
11-
#if defined(LIBC_TYPES_HAS_CFLOAT128)
12-
139
#ifndef LLVM_LIBC_SRC_COMPLEX_CONJF128_H
1410
#define LLVM_LIBC_SRC_COMPLEX_CONJF128_H
1511

1612
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/complex_types.h"
1714

1815
namespace LIBC_NAMESPACE_DECL {
1916

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

2421
#endif // LLVM_LIBC_SRC_COMPLEX_CONJF128_H
25-
26-
#endif // LIBC_TYPES_HAS_CFLOAT128

libc/src/complex/conjf16.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/macros/properties/complex_types.h"
10-
11-
#if defined(LIBC_TYPES_HAS_CFLOAT16)
12-
139
#ifndef LLVM_LIBC_SRC_COMPLEX_CONJF16_H
1410
#define LLVM_LIBC_SRC_COMPLEX_CONJF16_H
1511

1612
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/complex_types.h"
1714

1815
namespace LIBC_NAMESPACE_DECL {
1916

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

2421
#endif // LLVM_LIBC_SRC_COMPLEX_CONJF16_H
25-
26-
#endif // LIBC_TYPES_HAS_CFLOAT16

libc/src/complex/cprojf128.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/macros/properties/complex_types.h"
10-
11-
#if defined(LIBC_TYPES_HAS_CFLOAT128)
12-
139
#ifndef LLVM_LIBC_SRC_COMPLEX_CPROJF128_H
1410
#define LLVM_LIBC_SRC_COMPLEX_CPROJF128_H
1511

1612
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/complex_types.h"
1714

1815
namespace LIBC_NAMESPACE_DECL {
1916

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

2421
#endif // LLVM_LIBC_SRC_COMPLEX_CPROJF128_H
25-
26-
#endif // LIBC_TYPES_HAS_CFLOAT128

libc/src/complex/cprojf16.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/macros/properties/complex_types.h"
10-
11-
#if defined(LIBC_TYPES_HAS_CFLOAT16)
12-
139
#ifndef LLVM_LIBC_SRC_COMPLEX_CPROJF16_H
1410
#define LLVM_LIBC_SRC_COMPLEX_CPROJF16_H
1511

1612
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/complex_types.h"
1714

1815
namespace LIBC_NAMESPACE_DECL {
1916

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

2421
#endif // LLVM_LIBC_SRC_COMPLEX_CPROJF16_H
25-
26-
#endif // LIBC_TYPES_HAS_CFLOAT16

libc/src/complex/crealf128.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/macros/properties/complex_types.h"
10-
#include "src/__support/macros/properties/types.h"
11-
12-
#if defined(LIBC_TYPES_HAS_CFLOAT128)
13-
149
#ifndef LLVM_LIBC_SRC_COMPLEX_CREALF128_H
1510
#define LLVM_LIBC_SRC_COMPLEX_CREALF128_H
1611

1712
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/complex_types.h"
14+
#include "src/__support/macros/properties/types.h"
1815

1916
namespace LIBC_NAMESPACE_DECL {
2017

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

2522
#endif // LLVM_LIBC_SRC_COMPLEX_CREALF128_H
26-
27-
#endif // LIBC_TYPES_HAS_CFLOAT128

libc/src/complex/crealf16.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/macros/properties/complex_types.h"
10-
#include "src/__support/macros/properties/types.h"
11-
12-
#if defined(LIBC_TYPES_HAS_CFLOAT16)
13-
149
#ifndef LLVM_LIBC_SRC_COMPLEX_CREALF16_H
1510
#define LLVM_LIBC_SRC_COMPLEX_CREALF16_H
1611

1712
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/complex_types.h"
14+
#include "src/__support/macros/properties/types.h"
1815

1916
namespace LIBC_NAMESPACE_DECL {
2017

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

2522
#endif // LLVM_LIBC_SRC_COMPLEX_CREALF16_H
26-
27-
#endif // LIBC_TYPES_HAS_CFLOAT16

libc/src/complex/generic/cimagf128.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/complex/cimagf128.h"
10-
#if defined(LIBC_TYPES_HAS_CFLOAT128)
11-
1210
#include "src/__support/CPP/bit.h"
1311
#include "src/__support/common.h"
1412
#include "src/__support/complex_type.h"
@@ -21,5 +19,3 @@ LLVM_LIBC_FUNCTION(float128, cimagf128, (cfloat128 x)) {
2119
}
2220

2321
} // namespace LIBC_NAMESPACE_DECL
24-
25-
#endif // LIBC_TYPES_HAS_CFLOAT128

libc/src/complex/generic/cimagf16.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/complex/cimagf16.h"
10-
#if defined(LIBC_TYPES_HAS_CFLOAT16)
11-
1210
#include "src/__support/CPP/bit.h"
1311
#include "src/__support/common.h"
1412
#include "src/__support/complex_type.h"
@@ -21,5 +19,3 @@ LLVM_LIBC_FUNCTION(float16, cimagf16, (cfloat16 x)) {
2119
}
2220

2321
} // namespace LIBC_NAMESPACE_DECL
24-
25-
#endif // LIBC_TYPES_HAS_CFLOAT16

libc/src/complex/generic/conjf128.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/complex/conjf128.h"
10-
#if defined(LIBC_TYPES_HAS_CFLOAT128)
11-
1210
#include "src/__support/common.h"
1311
#include "src/__support/complex_type.h"
1412

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

2119
} // namespace LIBC_NAMESPACE_DECL
22-
23-
#endif // LIBC_TYPES_HAS_CFLOAT128

libc/src/complex/generic/conjf16.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/complex/conjf16.h"
10-
#if defined(LIBC_TYPES_HAS_CFLOAT16)
11-
1210
#include "src/__support/common.h"
1311
#include "src/__support/complex_type.h"
1412

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

2119
} // namespace LIBC_NAMESPACE_DECL
22-
23-
#endif // LIBC_TYPES_HAS_CFLOAT16

libc/src/complex/generic/cprojf128.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/complex/cprojf128.h"
10-
#if defined(LIBC_TYPES_HAS_CFLOAT128)
11-
1210
#include "src/__support/common.h"
1311
#include "src/__support/complex_type.h"
1412

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

2119
} // namespace LIBC_NAMESPACE_DECL
22-
23-
#endif // LIBC_TYPES_HAS_CFLOAT128

0 commit comments

Comments
 (0)