r192849 - Add preprocessor support for powerpc vsx.
Eric Christopher
echristo at gmail.com
Wed Oct 16 14:19:26 PDT 2013
Author: echristo
Date: Wed Oct 16 16:19:26 2013
New Revision: 192849
URL: http://llvm.org/viewvc/llvm-project?rev=192849&view=rev
Log:
Add preprocessor support for powerpc vsx.
The test should be expanded upon for more powerpc checking.
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=192849&r1=192848&r2=192849&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Oct 16 16:19:26 2013
@@ -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<bool> &Features) const;
+ virtual bool HandleTargetFeatures(std::vector<std::string> &Features,
+ DiagnosticsEngine &Diags);
virtual bool hasFeature(StringRef Feature) const;
virtual void getGCCRegNames(const char * const *&Names,
@@ -876,6 +883,29 @@ const Builtin::Info PPCTargetInfo::Built
#include "clang/Basic/BuiltinsPPC.def"
};
+ /// HandleTargetFeatures - Perform initialization based on the user
+/// configured set of features.
+bool PPCTargetInfo::HandleTargetFeatures(std::vector<std::string> &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(con
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__
Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=192849&r1=192848&r2=192849&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Wed Oct 16 16:19:26 2013
@@ -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__
More information about the cfe-commits
mailing list