diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Basic/Targets.cpp | 40 | ||||
| -rw-r--r-- | clang/test/Preprocessor/predefined-arch-macros.c | 8 |
2 files changed, 29 insertions, 19 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 18f503d091c..a457f6deee7 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -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; } } diff --git a/clang/test/Preprocessor/predefined-arch-macros.c b/clang/test/Preprocessor/predefined-arch-macros.c index 5252d2ce0d2..a0eb8cbcca9 100644 --- a/clang/test/Preprocessor/predefined-arch-macros.c +++ b/clang/test/Preprocessor/predefined-arch-macros.c @@ -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 |

