]> granicus.if.org Git - clang/commitdiff
Add preprocessor support for powerpc vsx.
authorEric Christopher <echristo@gmail.com>
Wed, 16 Oct 2013 21:19:26 +0000 (21:19 +0000)
committerEric Christopher <echristo@gmail.com>
Wed, 16 Oct 2013 21:19:26 +0000 (21:19 +0000)
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

lib/Basic/Targets.cpp
test/Preprocessor/predefined-arch-macros.c

index d1b459701b38ae3adfaa876a69acddcbf4e415cc..8037ebad863a18754d86c8ea1b668d6bb0a11368 100644 (file)
@@ -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::BuiltinInfo[] = {
 #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(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__
index af90c2d0d27eb05b0114b31d56e42cd254d4bf20..4430a79106895a36ca920bdf729f01b374a091d1 100644 (file)
 // 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__