diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -297,11 +297,11 @@ if (ExplicitType == FloatModeKind::Float128) return hasFloat128Type() ? FloatModeKind::Float128 : FloatModeKind::NoFloat; - if (&getLongDoubleFormat() == &llvm::APFloat::PPCDoubleDouble() || - &getLongDoubleFormat() == &llvm::APFloat::IEEEquad()) - return FloatModeKind::LongDouble; - if (hasFloat128Type()) - return FloatModeKind::Float128; + if (ExplicitType == FloatModeKind::Ibm128) + return hasIbm128Type() ? FloatModeKind::Ibm128 + : FloatModeKind::NoFloat; + if (ExplicitType == FloatModeKind::LongDouble) + return ExplicitType; break; } diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -4233,6 +4233,10 @@ ExplicitType = FloatModeKind::LongDouble; DestWidth = 128; break; + case 'I': + ExplicitType = FloatModeKind::Ibm128; + DestWidth = Str[1] == 'I' ? 0 : 128; + break; } if (Str[1] == 'F') { IntegerMode = false; diff --git a/clang/test/CodeGenCXX/ibm128-declarations.cpp b/clang/test/CodeGenCXX/ibm128-declarations.cpp --- a/clang/test/CodeGenCXX/ibm128-declarations.cpp +++ b/clang/test/CodeGenCXX/ibm128-declarations.cpp @@ -59,6 +59,12 @@ constexpr static __ibm128 mem = Q; }; +typedef float w128ibm __attribute__((mode(IF))); +typedef _Complex float w128ibm_c __attribute__((mode(IC))); + +w128ibm icmode_self(w128ibm x) { return x; } +w128ibm_c icmode_self_complex(w128ibm_c x) { return x; } + int main(void) { __ibm128 lf; CTest ct(lf); @@ -115,6 +121,9 @@ // CHECK: ret ppc_fp128 %2 // CHECK: } +// CHECK: define dso_local ppc_fp128 @_Z11icmode_selfg(ppc_fp128 %x) +// CHECK: define dso_local { ppc_fp128, ppc_fp128 } @_Z19icmode_self_complexCg(ppc_fp128 %x.coerce0, ppc_fp128 %x.coerce1) + // CHECK: define dso_local signext i32 @main() // CHECK: entry: // CHECK: %0 = load ppc_fp128, ppc_fp128* %lf, align 16 diff --git a/clang/test/Sema/attr-mode.c b/clang/test/Sema/attr-mode.c --- a/clang/test/Sema/attr-mode.c +++ b/clang/test/Sema/attr-mode.c @@ -92,6 +92,12 @@ void f_ft128_complex_arg(_Complex long double *x); void test_TFtype(f128ibm *a) { f_ft128_arg (a); } void test_TCtype(c128ibm *a) { f_ft128_complex_arg (a); } +typedef float w128ibm __attribute__((mode(IF))); +typedef _Complex float cw128ibm __attribute__((mode(IC))); +void f_ibm128_arg(__ibm128 *x); +void f_ibm128_complex_arg(_Complex __ibm128 *x); +void test_IFtype(w128ibm *a) { f_ibm128_arg(a); } +void test_ICtype(cw128ibm *a) { f_ibm128_complex_arg(a); } #elif TEST_F128_PPC64 typedef int invalid_7 __attribute((mode(KF))); // expected-error{{type of machine mode does not match type of base type}} typedef int invalid_8 __attribute((mode(KI))); // expected-error{{unknown machine mode}}