Skip to content

Commit f9e94eb

Browse files
committed
[Clang] Enable _Complex __float128
When I added __float128 a while ago, I neglected to add support for the complex variant of the type. This patch just adds that. Differential revision: https://reviews.llvm.org/D80533
1 parent 45251ef commit f9e94eb

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

clang/lib/Sema/DeclSpec.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,8 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
12691269
// Note that this intentionally doesn't include _Complex _Bool.
12701270
if (!S.getLangOpts().CPlusPlus)
12711271
S.Diag(TSTLoc, diag::ext_integer_complex);
1272-
} else if (TypeSpecType != TST_float && TypeSpecType != TST_double) {
1272+
} else if (TypeSpecType != TST_float && TypeSpecType != TST_double &&
1273+
TypeSpecType != TST_float128) {
12731274
S.Diag(TSCLoc, diag::err_invalid_complex_spec)
12741275
<< getSpecifierName((TST)TypeSpecType, Policy);
12751276
TypeSpecComplex = TSC_unspecified;

clang/test/CodeGen/ppc64-complex-parms.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1+
// REQUIRES: powerpc-registered-target
12
// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
3+
// RUN: %clang_cc1 -target-feature +float128 -DTEST_F128 -triple \
4+
// RUN: powerpc64le-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s \
5+
// RUN: --check-prefix CHECK-F128
26

37
float crealf(_Complex float);
48
double creal(_Complex double);
59
long double creall(_Complex long double);
10+
#ifdef TEST_F128
11+
__float128 crealf128(_Complex __float128);
12+
__float128 foo_f128(_Complex __float128 x) {
13+
return crealf128(x);
14+
}
15+
// CHECK-F128: define fp128 @foo_f128(fp128 {{[%A-Za-z0-9.]+}}, fp128 {{[%A-Za-z0-9.]+}})
16+
#endif
617

718
float foo_float(_Complex float x) {
819
return crealf(x);

clang/test/CodeGen/ppc64-complex-return.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
// REQUIRES: powerpc-registered-target
22
// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
3+
// RUN: %clang_cc1 -target-feature +float128 -DTEST_F128 -triple \
4+
// RUN: powerpc64le-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s \
5+
// RUN: --check-prefix CHECK-F128
36

47
float crealf(_Complex float);
58
double creal(_Complex double);
69
long double creall(_Complex long double);
10+
#ifdef TEST_F128
11+
__float128 crealf128(_Complex __float128);
12+
_Complex __float128 foo_f128(_Complex __float128 x) {
13+
return x;
14+
}
15+
16+
// CHECK-F128: define { fp128, fp128 } @foo_f128(fp128 {{[%A-Za-z0-9.]+}}, fp128 {{[%A-Za-z0-9.]+}}) [[NUW:#[0-9]+]] {
17+
#endif
718

819
_Complex float foo_float(_Complex float x) {
920
return x;
@@ -80,6 +91,17 @@ long double bar_long_double(void) {
8091
// CHECK: extractvalue { ppc_fp128, ppc_fp128 } [[VAR3]], 0
8192
// CHECK: extractvalue { ppc_fp128, ppc_fp128 } [[VAR3]], 1
8293

94+
#ifdef TEST_F128
95+
__float128 bar_f128(void) {
96+
return crealf128(foo_f128(2.0Q - 2.5Qi));
97+
}
98+
99+
// CHECK-F128: define fp128 @bar_f128() [[NUW]] {
100+
// CHECK-F128: [[VAR3:[%A-Za-z0-9.]+]] = call { fp128, fp128 } @foo_f128
101+
// CHECK-F128: extractvalue { fp128, fp128 } [[VAR3]], 0
102+
// CHECK-F128: extractvalue { fp128, fp128 } [[VAR3]], 1
103+
#endif
104+
83105
int bar_int(void) {
84106
return __real__(foo_int(2 - 3i));
85107
}

0 commit comments

Comments
 (0)