[clang] 85e5658 - [Clang] Enable _Complex __ibm128 type
Qiu Chaofan via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 8 19:54:44 PDT 2021
Author: Qiu Chaofan
Date: 2021-10-09T10:48:44+08:00
New Revision: 85e565898ff36e5e50ff6e7ed6bf82b1cfbf89d6
URL: https://github.com/llvm/llvm-project/commit/85e565898ff36e5e50ff6e7ed6bf82b1cfbf89d6
DIFF: https://github.com/llvm/llvm-project/commit/85e565898ff36e5e50ff6e7ed6bf82b1cfbf89d6.diff
LOG: [Clang] Enable _Complex __ibm128 type
fae0dfa implemented the new __ibm128 type, this patch enables its
complex form.
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D109948
Added:
Modified:
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/DeclSpec.cpp
clang/test/CodeGen/ppc64-complex-parms.c
clang/test/CodeGen/ppc64-complex-return.c
Removed:
################################################################################
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 0ce93905a44e2..f4239869e93db 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -6334,7 +6334,7 @@ QualType ASTContext::getFloatingTypeOfSizeWithinDomain(QualType Size,
case BFloat16Rank: llvm_unreachable("Complex bfloat16 is not supported");
case Float16Rank:
case HalfRank: llvm_unreachable("Complex half is not supported");
- case Ibm128Rank: llvm_unreachable("Complex __ibm128 is not supported");
+ case Ibm128Rank: return getComplexType(Ibm128Ty);
case FloatRank: return getComplexType(FloatTy);
case DoubleRank: return getComplexType(DoubleTy);
case LongDoubleRank: return getComplexType(LongDoubleTy);
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 662e93743ebd3..4405f29f3d996 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -1307,7 +1307,8 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
if (!S.getLangOpts().CPlusPlus)
S.Diag(TSTLoc, diag::ext_integer_complex);
} else if (TypeSpecType != TST_float && TypeSpecType != TST_double &&
- TypeSpecType != TST_float128 && TypeSpecType != TST_float16) {
+ TypeSpecType != TST_float128 && TypeSpecType != TST_float16 &&
+ TypeSpecType != TST_ibm128) {
// FIXME: __fp16?
S.Diag(TSCLoc, diag::err_invalid_complex_spec)
<< getSpecifierName((TST)TypeSpecType, Policy);
diff --git a/clang/test/CodeGen/ppc64-complex-parms.c b/clang/test/CodeGen/ppc64-complex-parms.c
index 4f91a6f9814cf..1d5ffc840b79a 100644
--- a/clang/test/CodeGen/ppc64-complex-parms.c
+++ b/clang/test/CodeGen/ppc64-complex-parms.c
@@ -33,6 +33,13 @@ long double foo_long_double(_Complex long double x) {
// CHECK: define{{.*}} ppc_fp128 @foo_long_double(ppc_fp128 {{[%A-Za-z0-9.]+}}, ppc_fp128 {{[%A-Za-z0-9.]+}}) [[NUW]] {
+__ibm128 foo_ibm128(_Complex __ibm128 x) {
+ // We don't have a suffix for explicit __ibm128 type yet. Use *l instead.
+ return creall(x);
+}
+
+// CHECK: define{{.*}} ppc_fp128 @foo_ibm128(ppc_fp128 {{[%A-Za-z0-9.]+}}, ppc_fp128 {{[%A-Za-z0-9.]+}}) [[NUW]] {
+
int foo_int(_Complex int x) {
return __real__ x;
}
@@ -111,6 +118,22 @@ void bar_long_double(void) {
// CHECK: %[[VAR27:[A-Za-z0-9.]+]] = load ppc_fp128, ppc_fp128* %[[VAR26]], align 16
// CHECK: %{{[A-Za-z0-9.]+}} = call ppc_fp128 @foo_long_double(ppc_fp128 %[[VAR25]], ppc_fp128 %[[VAR27]])
+void bar_ibm128(void) {
+ foo_ibm128(2.0L - 2.5Li);
+}
+
+// CHECK: define{{.*}} void @bar_ibm128() [[NUW]] {
+// CHECK: %[[VAR21:[A-Za-z0-9.]+]] = alloca { ppc_fp128, ppc_fp128 }, align 16
+// CHECK: %[[VAR22:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 0
+// CHECK: %[[VAR23:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 1
+// CHECK: store ppc_fp128 0xM40000000000000000000000000000000, ppc_fp128* %[[VAR22]]
+// CHECK: store ppc_fp128 0xMC0040000000000008000000000000000, ppc_fp128* %[[VAR23]]
+// CHECK: %[[VAR24:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 0
+// CHECK: %[[VAR25:[A-Za-z0-9.]+]] = load ppc_fp128, ppc_fp128* %[[VAR24]], align 16
+// CHECK: %[[VAR26:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 1
+// CHECK: %[[VAR27:[A-Za-z0-9.]+]] = load ppc_fp128, ppc_fp128* %[[VAR26]], align 16
+// CHECK: %{{[A-Za-z0-9.]+}} = call ppc_fp128 @foo_ibm128(ppc_fp128 %[[VAR25]], ppc_fp128 %[[VAR27]])
+
void bar_int(void) {
foo_int(2 - 3i);
}
diff --git a/clang/test/CodeGen/ppc64-complex-return.c b/clang/test/CodeGen/ppc64-complex-return.c
index eafe822bbee8e..474a75385c244 100644
--- a/clang/test/CodeGen/ppc64-complex-return.c
+++ b/clang/test/CodeGen/ppc64-complex-return.c
@@ -34,6 +34,12 @@ _Complex long double foo_long_double(_Complex long double x) {
// CHECK: define{{.*}} { ppc_fp128, ppc_fp128 } @foo_long_double(ppc_fp128 {{[%A-Za-z0-9.]+}}, ppc_fp128 {{[%A-Za-z0-9.]+}}) [[NUW]] {
+_Complex __ibm128 foo_ibm128(_Complex __ibm128 x) {
+ return x;
+}
+
+// CHECK: define{{.*}} { ppc_fp128, ppc_fp128 } @foo_ibm128(ppc_fp128 {{[%A-Za-z0-9.]+}}, ppc_fp128 {{[%A-Za-z0-9.]+}}) [[NUW]] {
+
_Complex int foo_int(_Complex int x) {
return x;
}
@@ -91,6 +97,15 @@ long double bar_long_double(void) {
// CHECK: extractvalue { ppc_fp128, ppc_fp128 } [[VAR3]], 0
// CHECK: extractvalue { ppc_fp128, ppc_fp128 } [[VAR3]], 1
+__ibm128 bar_ibm128(void) {
+ return creall(foo_ibm128(2.0L - 2.5Li));
+}
+
+// CHECK: define{{.*}} ppc_fp128 @bar_ibm128() [[NUW]] {
+// CHECK: [[VAR3:[%A-Za-z0-9.]+]] = call { ppc_fp128, ppc_fp128 } @foo_ibm128
+// CHECK: extractvalue { ppc_fp128, ppc_fp128 } [[VAR3]], 0
+// CHECK: extractvalue { ppc_fp128, ppc_fp128 } [[VAR3]], 1
+
#ifdef TEST_F128
__float128 bar_f128(void) {
return crealf128(foo_f128(2.0Q - 2.5Qi));
More information about the cfe-commits
mailing list