From: Eric Christopher Date: Wed, 16 Oct 2013 21:19:26 +0000 (+0000) Subject: Add preprocessor support for powerpc vsx. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=165432092b7a329d51c32365067237bfdb71267f;p=clang Add preprocessor support for powerpc vsx. The test should be expanded upon for more powerpc checking. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192849 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index d1b459701b..8037ebad86 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -658,8 +658,13 @@ class PPCTargetInfo : public TargetInfo { static const char * const GCCRegNames[]; static const TargetInfo::GCCRegAlias GCCRegAliases[]; std::string CPU; + + // Target cpu features. + bool HasVSX; + public: - PPCTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { + PPCTargetInfo(const llvm::Triple &Triple) + : TargetInfo(Triple), HasVSX(false) { BigEndian = (Triple.getArch() != llvm::Triple::ppc64le); LongDoubleWidth = LongDoubleAlign = 128; LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble; @@ -755,6 +760,8 @@ public: virtual void getDefaultFeatures(llvm::StringMap &Features) const; + virtual bool HandleTargetFeatures(std::vector &Features, + DiagnosticsEngine &Diags); virtual bool hasFeature(StringRef Feature) const; virtual void getGCCRegNames(const char * const *&Names, @@ -876,6 +883,29 @@ const Builtin::Info PPCTargetInfo::BuiltinInfo[] = { #include "clang/Basic/BuiltinsPPC.def" }; + /// HandleTargetFeatures - Perform initialization based on the user +/// configured set of features. +bool PPCTargetInfo::HandleTargetFeatures(std::vector &Features, + DiagnosticsEngine &Diags) { + // Remember the maximum enabled sselevel. + for (unsigned i = 0, e = Features.size(); i !=e; ++i) { + // Ignore disabled features. + if (Features[i][0] == '-') + continue; + + StringRef Feature = StringRef(Features[i]).substr(1); + + if (Feature == "vsx") { + HasVSX = true; + continue; + } + + // TODO: Finish this list and add an assert that we've handled them + // all. + } + + return true; +} /// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific /// #defines that are not tied to a specific subtarget. @@ -1006,13 +1036,15 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__TOS_BGQ__"); } + if (HasVSX) + Builder.defineMacro("__VSX__"); + // FIXME: The following are not yet generated here by Clang, but are // generated by GCC: // // _SOFT_FLOAT_ // __RECIP_PRECISION__ // __APPLE_ALTIVEC__ - // __VSX__ // __RECIP__ // __RECIPF__ // __RSQRTE__ diff --git a/test/Preprocessor/predefined-arch-macros.c b/test/Preprocessor/predefined-arch-macros.c index af90c2d0d2..4430a79106 100644 --- a/test/Preprocessor/predefined-arch-macros.c +++ b/test/Preprocessor/predefined-arch-macros.c @@ -1373,3 +1373,10 @@ // CHECK_BDVER2_M64: #define __x86_64__ 1 // // End X86/GCC/Linux tests ------------------ + +// Begin PPC/GCC/Linux tests ---------------- +// RUN: %clang -mvsx -E -dM %s -o - 2>&1 \ +// RUN: -target powerpc64-unknown-linux \ +// RUN: | FileCheck %s -check-prefix=CHECK_PPC_VSX_M64 +// +// CHECK_PPC_VSX_M64: #define __VSX__