If a global variable has a specified alignment that is less than the preferred
[oota-llvm.git] / lib / Target / SubtargetFeature.cpp
index 1085668a76250686c3b80b5bcad53c362d2809e9..3cf95b57c5dcba2f14d8699f6db4304e0bd53c23 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Target/SubtargetFeature.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/ADT/StringExtras.h"
 #include <algorithm>
 #include <cassert>
 #include <cctype>
+#include <cstdlib>
 using namespace llvm;
 
 //===----------------------------------------------------------------------===//
@@ -66,7 +68,7 @@ static void Split(std::vector<std::string> &V, const std::string &S) {
   while (true) {
     // Find the next comma
     size_t Comma = S.find(',', Pos);
-    // If no comma found then the the rest of the string is used
+    // If no comma found then the rest of the string is used
     if (Comma == std::string::npos) {
       // Add string to vector
       V.push_back(S.substr(Pos));
@@ -110,33 +112,6 @@ void SubtargetFeatures::AddFeature(const std::string &String,
   }
 }
 
-/// Add a set of features from the comma-separated string.
-void SubtargetFeatures::AddFeatures(const std::string &String)
-{
-  std::vector<std::string> _Features;
-
-  Split(_Features, String);
-  // Nothing is specified.
-  if (_Features.size() == 0)
-    return;
-
-  for (std::vector<std::string>::iterator it = _Features.begin(),
-          end = _Features.end(); it != end; ++it) {
-    // AddFeature will take care of feature string normalization.
-    AddFeature(*it);
-  }
-}
-
-/// Add a set of features from the parsed command line parameters.
-void SubtargetFeatures::AddFeatures(const cl::list<std::string> &List)
-{
-  for (cl::list<std::string>::const_iterator it = List.begin(),
-          end = List.end(); it != end; ++it) {
-    // AddFeature will take care of feature string normalization.
-    AddFeature(*it);
-  }
-}
-
 /// Find KV in array using binary search.
 template<typename T> const T *Find(const std::string &S, const T *A, size_t L) {
   // Make the lower bound element we're looking for
@@ -188,7 +163,7 @@ static void Help(const SubtargetFeatureKV *CPUTable, size_t CPUTableSize,
   
   errs() << "Use +feature to enable a feature, or -feature to disable it.\n"
        << "For example, llc -mcpu=mycpu -mattr=+feature1,-feature2\n";
-  exit(1);
+  std::exit(1);
 }
 
 //===----------------------------------------------------------------------===//
@@ -382,32 +357,28 @@ void SubtargetFeatures::print(raw_ostream &OS) const {
 /// dump - Dump feature info.
 ///
 void SubtargetFeatures::dump() const {
-  print(errs());
+  print(dbgs());
 }
 
-/// getDefaultSubtargetFeatures - Return a string listing
-/// the features associated with the target triple.
+/// getDefaultSubtargetFeatures - Return a string listing the features
+/// associated with the target triple.
 ///
 /// FIXME: This is an inelegant way of specifying the features of a
 /// subtarget. It would be better if we could encode this information
 /// into the IR. See <rdar://5972456>.
 ///
-std::string SubtargetFeatures::getDefaultSubtargetFeatures(
-                                               const Triple& Triple) {
-  switch (Triple.getVendor()) {
-  case Triple::Apple:
-    switch (Triple.getArch()) {
-    case Triple::ppc:   // powerpc-apple-*
-      return std::string("altivec");
-    case Triple::ppc64: // powerpc64-apple-*
-      return std::string("64bit,altivec");
-    default:
-      break;
+void SubtargetFeatures::getDefaultSubtargetFeatures(const std::string &CPU,
+                                                    const Triple& Triple) {
+  setCPU(CPU);
+
+  if (Triple.getVendor() == Triple::Apple) {
+    if (Triple.getArch() == Triple::ppc) {
+      // powerpc-apple-*
+      AddFeature("altivec");
+    } else if (Triple.getArch() == Triple::ppc64) {
+      // powerpc64-apple-*
+      AddFeature("64bit");
+      AddFeature("altivec");
     }
-    break;
-  default:
-    break;
-  } 
-
-  return std::string("");
+  }
 }