When we turn on vsx it should also turn on altivec explicitly, same

with disabling it as well as disabling all vsx specific features when
turning off altivec.

Fixes PR32663.

llvm-svn: 300395
This commit is contained in:
Eric Christopher 2017-04-15 06:15:00 +00:00
parent 908ed7f20c
commit d26d8839d8
2 changed files with 29 additions and 19 deletions

View File

@ -1548,28 +1548,30 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
void PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
StringRef Name, bool Enabled) const {
// If we're enabling direct-move or power8-vector go ahead and enable vsx
// as well. Do the inverse if we're disabling vsx. We'll diagnose any user
// incompatible options.
if (Enabled) {
if (Name == "direct-move" ||
Name == "power8-vector" ||
Name == "float128" ||
Name == "power9-vector") {
// power9-vector is really a superset of power8-vector so encode that.
Features[Name] = Features["vsx"] = true;
if (Name == "power9-vector")
Features["power8-vector"] = true;
} else {
Features[Name] = true;
}
// If we're enabling any of the vsx based features then enable vsx and
// altivec. We'll diagnose any problems later.
bool FeatureHasVSX = llvm::StringSwitch<bool>(Name)
.Case("vsx", true)
.Case("direct-move", true)
.Case("power8-vector", true)
.Case("power9-vector", true)
.Case("float128", true)
.Default(false);
if (FeatureHasVSX)
Features["vsx"] = Features["altivec"] = true;
if (Name == "power9-vector")
Features["power8-vector"] = true;
Features[Name] = true;
} else {
if (Name == "vsx") {
Features[Name] = Features["direct-move"] = Features["power8-vector"] =
// If we're disabling altivec or vsx go ahead and disable all of the vsx
// features.
if ((Name == "altivec") || (Name == "vsx"))
Features["vsx"] = Features["direct-move"] = Features["power8-vector"] =
Features["float128"] = Features["power9-vector"] = false;
} else {
Features[Name] = false;
}
if (Name == "power8-vector")
Features["power9-vector"] = false;
Features[Name] = false;
}
}

View File

@ -1957,6 +1957,14 @@
// End X86/GCC/Linux tests ------------------
// Begin PPC/GCC/Linux tests ----------------
// Check that VSX also turns on altivec.
// RUN: %clang -mvsx -E -dM %s -o - 2>&1 \
// RUN: -target powerpc-unknown-linux \
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_PPC_VSX_M32
//
// CHECK_PPC_VSX_M32: #define __ALTIVEC__ 1
// CHECK_PPC_VSX_M32: #define __VSX__ 1
//
// RUN: %clang -mvsx -E -dM %s -o - 2>&1 \
// RUN: -target powerpc64-unknown-linux \
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_PPC_VSX_M64