diff options
author | Lei Huang <lei@ca.ibm.com> | 2021-09-02 13:31:10 -0500 |
---|---|---|
committer | Lei Huang <lei@ca.ibm.com> | 2021-10-04 14:16:47 -0500 |
commit | 8b3d944a97cc944a24ed1296c801da5654896092 (patch) | |
tree | 8a4c47d86839a29d81beab5a6cbe1f680f5487b5 /clang/lib/Sema/DeclSpec.cpp | |
parent | dc4d94e620a9fea54b23293cc95c7f143f1e5bee (diff) | |
download | llvm-8b3d944a97cc944a24ed1296c801da5654896092.zip llvm-8b3d944a97cc944a24ed1296c801da5654896092.tar.gz llvm-8b3d944a97cc944a24ed1296c801da5654896092.tar.bz2 |
[PowerPC] Disable vector types when not supported by subtarget features
Update clang to treat vector unsigned long long and friends as invalid
for AltiVec without VSX.
Reported in: https://bugs.llvm.org/show_bug.cgi?id=47782
Reviewed By: nemanjai, amyk
Differential Revision: https://reviews.llvm.org/D109178
Diffstat (limited to 'clang/lib/Sema/DeclSpec.cpp')
-rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index d7b4ceac2..662e937 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -1156,6 +1156,17 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) { // Validate and finalize AltiVec vector declspec. if (TypeAltiVecVector) { + // No vector long long without VSX (or ZVector). + if ((getTypeSpecWidth() == TypeSpecifierWidth::LongLong) && + !S.Context.getTargetInfo().hasFeature("vsx") && + !S.getLangOpts().ZVector) + S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_long_long_decl_spec); + + // No vector __int128 prior to Power8. + if ((TypeSpecType == TST_int128) && + !S.Context.getTargetInfo().hasFeature("power8-vector")) + S.Diag(TSTLoc, diag::err_invalid_vector_int128_decl_spec); + if (TypeAltiVecBool) { // Sign specifiers are not allowed with vector bool. (PIM 2.1) if (getTypeSpecSign() != TypeSpecifierSign::Unspecified) { @@ -1184,13 +1195,6 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) { S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_bool_decl_spec) << getSpecifierName(getTypeSpecWidth()); - // vector bool long long requires VSX support or ZVector. - if ((getTypeSpecWidth() == TypeSpecifierWidth::LongLong) && - (!S.Context.getTargetInfo().hasFeature("vsx")) && - (!S.Context.getTargetInfo().hasFeature("power8-vector")) && - !S.getLangOpts().ZVector) - S.Diag(TSTLoc, diag::err_invalid_vector_long_long_decl_spec); - // Elements of vector bool are interpreted as unsigned. (PIM 2.1) if ((TypeSpecType == TST_char) || (TypeSpecType == TST_int) || (TypeSpecType == TST_int128) || @@ -1213,13 +1217,15 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) { !S.Context.getTargetInfo().hasFeature("arch12")) S.Diag(TSTLoc, diag::err_invalid_vector_float_decl_spec); } else if (getTypeSpecWidth() == TypeSpecifierWidth::Long) { - // vector long is unsupported for ZVector and deprecated for AltiVec. + // Vector long is unsupported for ZVector, or without VSX, and deprecated + // for AltiVec. // It has also been historically deprecated on AIX (as an alias for // "vector int" in both 32-bit and 64-bit modes). It was then made // unsupported in the Clang-based XL compiler since the deprecated type // has a number of conflicting semantics and continuing to support it // is a disservice to users. if (S.getLangOpts().ZVector || + !S.Context.getTargetInfo().hasFeature("vsx") || S.Context.getTargetInfo().getTriple().isOSAIX()) S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_long_decl_spec); else |