diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Headers/altivec.h | 32 | ||||
-rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 13 |
3 files changed, 43 insertions, 6 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 4604b1cfa0f..587b13fe412 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -1136,7 +1136,9 @@ void PPCTargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const { } bool PPCTargetInfo::hasFeature(StringRef Feature) const { - return Feature == "powerpc"; + return (Feature == "powerpc" || + (Feature == "vsx" && HasVSX) || + (Feature == "power8-vector" && HasP8Vector)); } diff --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h index 373eded482f..1ffefa85851 100644 --- a/clang/lib/Headers/altivec.h +++ b/clang/lib/Headers/altivec.h @@ -2667,8 +2667,20 @@ vec_max(vector unsigned int __a, vector bool int __b) static vector float __ATTRS_o_ai vec_max(vector float __a, vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvmaxsp(__a, __b); +#else return __builtin_altivec_vmaxfp(__a, __b); +#endif +} + +#ifdef __VSX__ +static vector double __ATTRS_o_ai +vec_max(vector double __a, vector double __b) +{ + return __builtin_vsx_xvmaxdp(__a, __b); } +#endif /* vec_vmaxsb */ @@ -2795,7 +2807,11 @@ vec_vmaxuw(vector unsigned int __a, vector bool int __b) static vector float __attribute__((__always_inline__)) vec_vmaxfp(vector float __a, vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvmaxsp(__a, __b); +#else return __builtin_altivec_vmaxfp(__a, __b); +#endif } /* vec_mergeh */ @@ -3299,8 +3315,20 @@ vec_min(vector unsigned int __a, vector bool int __b) static vector float __ATTRS_o_ai vec_min(vector float __a, vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvminsp(__a, __b); +#else return __builtin_altivec_vminfp(__a, __b); +#endif +} + +#ifdef __VSX__ +static vector double __ATTRS_o_ai +vec_min(vector double __a, vector double __b) +{ + return __builtin_vsx_xvmindp(__a, __b); } +#endif /* vec_vminsb */ @@ -3427,7 +3455,11 @@ vec_vminuw(vector unsigned int __a, vector bool int __b) static vector float __attribute__((__always_inline__)) vec_vminfp(vector float __a, vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvminsp(__a, __b); +#else return __builtin_altivec_vminfp(__a, __b); +#endif } /* vec_mladd */ diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index bed94127b28..6e77d2769fa 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -18,6 +18,7 @@ #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/TypeLoc.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/TargetInfo.h" #include "clang/Lex/Preprocessor.h" #include "clang/Parse/ParseDiagnostic.h" // FIXME: remove this back-dependency! #include "clang/Sema/LocInfoType.h" @@ -689,11 +690,6 @@ bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc, } TypeSpecType = T; TypeSpecOwned = false; - if (TypeAltiVecVector && !TypeAltiVecBool && (TypeSpecType == TST_double)) { - PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy); - DiagID = diag::err_invalid_vector_decl_spec; - return true; - } return false; } @@ -987,6 +983,13 @@ void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP, const PrintingPoli if ((TypeSpecType == TST_char) || (TypeSpecType == TST_int) || (TypeSpecWidth != TSW_unspecified)) TypeSpecSign = TSS_unsigned; + } else if (TypeSpecType == TST_double) { + // vector long double and vector long long double are never allowed. + // vector double is OK for Power7 and later. + if (TypeSpecWidth == TSW_long || TypeSpecWidth == TSW_longlong) + Diag(D, TSWLoc, diag::err_invalid_vector_long_double_decl_spec); + else if (!PP.getTargetInfo().hasFeature("vsx")) + Diag(D, TSTLoc, diag::err_invalid_vector_double_decl_spec); } else if (TypeSpecWidth == TSW_long) { Diag(D, TSWLoc, diag::warn_vector_long_decl_spec_combination) << getSpecifierName((TST)TypeSpecType, Policy); |