[Clang] Enable IC/IF mode for __ibm128
As for 128-bit floating points on PowerPC, compiler should have three machine modes: - IFmode, always IBM extended double - KFmode, always IEEE 754R 128-bit floating point - TFmode, matches the semantics for long double This commit adds support for IF mode with its complex variant, IC mode. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D109950
This commit is contained in:
@@ -297,11 +297,11 @@ FloatModeKind TargetInfo::getRealTypeByWidth(unsigned BitWidth,
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -4233,6 +4233,10 @@ static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth,
|
||||
ExplicitType = FloatModeKind::LongDouble;
|
||||
DestWidth = 128;
|
||||
break;
|
||||
case 'I':
|
||||
ExplicitType = FloatModeKind::Ibm128;
|
||||
DestWidth = Str[1] == 'I' ? 0 : 128;
|
||||
break;
|
||||
}
|
||||
if (Str[1] == 'F') {
|
||||
IntegerMode = false;
|
||||
|
||||
@@ -59,6 +59,12 @@ template <__ibm128 Q> struct T2 {
|
||||
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 @@ int main(void) {
|
||||
// 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
|
||||
|
||||
@@ -92,6 +92,12 @@ void f_ft128_arg(long double *x);
|
||||
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}}
|
||||
|
||||
Reference in New Issue
Block a user