]> granicus.if.org Git - clang/commitdiff
Remove duplicated error checking.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 20 Aug 2013 15:30:32 +0000 (15:30 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 20 Aug 2013 15:30:32 +0000 (15:30 +0000)
The driver validates its options, so we don't need to redo the work in
"clang -cc1".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188806 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticCommonKinds.td
include/clang/Basic/TargetInfo.h
lib/Basic/Targets.cpp

index cec938b180de24f745be80997f1968fc8fc56802..c67b437ddff88071330240f3f08ff6a8ef7693d9 100644 (file)
@@ -115,7 +115,6 @@ def err_target_unknown_triple : Error<
 def err_target_unknown_cpu : Error<"unknown target CPU '%0'">;
 def err_target_unknown_abi : Error<"unknown target ABI '%0'">;
 def err_target_unknown_cxxabi : Error<"unknown C++ ABI '%0'">;
-def err_target_invalid_feature : Error<"invalid target feature '%0'">;
 
 // Source manager
 def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;
index 60028365e900233d5d2ab867e9dcdd1dff7d94ae..821a469d617c56a1fe591472068047910b6c694f 100644 (file)
@@ -672,12 +672,10 @@ public:
 
   /// \brief Enable or disable a specific target feature;
   /// the feature name must be valid.
-  ///
-  /// \return False on error (invalid feature name).
-  virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
+  virtual void setFeatureEnabled(llvm::StringMap<bool> &Features,
                                  StringRef Name,
                                  bool Enabled) const {
-    return false;
+    Features[Name] = Enabled;
   }
 
   /// \brief Perform initialization based on the user configured
index 49531baa66557c56f1efca030f7b2196aeb10222..788579de7a1c82e3319ae9db632d0575763d8a7b 100644 (file)
@@ -727,10 +727,6 @@ public:
 
   virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const;
 
-  virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
-                                 StringRef Name,
-                                 bool Enabled) const;
-
   virtual bool hasFeature(StringRef Feature) const;
   
   virtual void getGCCRegNames(const char * const *&Names,
@@ -1021,18 +1017,6 @@ void PPCTargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const {
   Features["qpx"] = (CPU == "a2q");
 }
 
-bool PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
-                                         StringRef Name,
-                                         bool Enabled) const {
-  if (Name == "altivec" || Name == "fprnd" || Name == "mfocrf" ||
-      Name == "popcntd" || Name == "qpx") {
-    Features[Name] = Enabled;
-    return true;
-  }
-
-  return false;
-}
-
 bool PPCTargetInfo::hasFeature(StringRef Feature) const {
   return Feature == "powerpc";
 }
@@ -1772,7 +1756,7 @@ public:
                    bool Enabled) const;
   void setXOPLevel(llvm::StringMap<bool> &Features, XOPEnum Level,
                    bool Enabled) const;
-  virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
+  virtual void setFeatureEnabled(llvm::StringMap<bool> &Features,
                                  StringRef Name,
                                  bool Enabled) const;
   virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const;
@@ -1925,35 +1909,6 @@ public:
 };
 
 void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const {
-  // FIXME: This should not be here.
-  Features["3dnow"] = false;
-  Features["3dnowa"] = false;
-  Features["mmx"] = false;
-  Features["sse"] = false;
-  Features["sse2"] = false;
-  Features["sse3"] = false;
-  Features["ssse3"] = false;
-  Features["sse41"] = false;
-  Features["sse42"] = false;
-  Features["sse4a"] = false;
-  Features["aes"] = false;
-  Features["pclmul"] = false;
-  Features["avx"] = false;
-  Features["avx2"] = false;
-  Features["avx-512"] = false;
-  Features["lzcnt"] = false;
-  Features["rdrand"] = false;
-  Features["bmi"] = false;
-  Features["bmi2"] = false;
-  Features["popcnt"] = false;
-  Features["rtm"] = false;
-  Features["prfchw"] = false;
-  Features["rdseed"] = false;
-  Features["fma4"] = false;
-  Features["fma"] = false;
-  Features["xop"] = false;
-  Features["f16c"] = false;
-
   // FIXME: This *really* should not be here.
 
   // X86_64 always has SSE2.
@@ -2223,7 +2178,7 @@ void X86TargetInfo::setXOPLevel(llvm::StringMap<bool> &Features, XOPEnum Level,
   }
 }
 
-bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
+void X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
                                       StringRef Name,
                                       bool Enabled) const {
   // FIXME: This *really* should not be here.  We need some way of translating
@@ -2234,8 +2189,6 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
     Name = "sse41";
   if (Name == "rdrnd")
     Name = "rdrand";
-  if (!Features.count(Name))
-    return false;
 
   Features[Name] = Enabled;
 
@@ -2279,8 +2232,6 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
   } else if (Name == "sse4a") {
     setXOPLevel(Features, SSE4A, Enabled);
   }
-
-  return true;
 }
 
 /// HandleTargetOptions - Perform initialization based on the user
@@ -3294,16 +3245,6 @@ public:
     return Feature == "aarch64" || (Feature == "neon" && FPU == NeonMode);
   }
 
-  virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
-                                 StringRef Name, bool Enabled) const {
-    if (Name == "neon") {
-      Features[Name] = Enabled;
-      return true;
-    }
-
-    return false;
-  }
-
   virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
     FPU = FPUMode;
     for (unsigned i = 0, e = Features.size(); i != e; ++i) {
@@ -3595,19 +3536,6 @@ public:
     }
   }
 
-  virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
-                                 StringRef Name,
-                                 bool Enabled) const {
-    if (Name == "soft-float" || Name == "soft-float-abi" ||
-        Name == "vfp2" || Name == "vfp3" || Name == "vfp4" || Name == "neon" ||
-        Name == "d16" || Name == "neonfp" || Name == "v8fp") {
-      Features[Name] = Enabled;
-    } else
-      return false;
-
-    return true;
-  }
-
   virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
     FPU = 0;
     SoftFloat = SoftFloatABI = false;
@@ -4107,16 +4035,6 @@ class SparcTargetInfo : public TargetInfo {
 public:
   SparcTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {}
 
-  virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
-                                 StringRef Name,
-                                 bool Enabled) const {
-    if (Name == "soft-float")
-      Features[Name] = Enabled;
-    else
-      return false;
-
-    return true;
-  }
   virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
     SoftFloat = false;
     for (unsigned i = 0, e = Features.size(); i != e; ++i)
@@ -4689,26 +4607,14 @@ public:
     return "";
   }
 
-  virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
+  virtual void setFeatureEnabled(llvm::StringMap<bool> &Features,
                                  StringRef Name,
                                  bool Enabled) const {
-    if (Name == "soft-float" || Name == "single-float" ||
-        Name == "o32" || Name == "n32" || Name == "n64" || Name == "eabi" ||
-        Name == "mips32" || Name == "mips32r2" ||
-        Name == "mips64" || Name == "mips64r2" ||
-        Name == "mips16" || Name == "micromips" ||
-        Name == "dsp" || Name == "dspr2" ||
-        Name == "msa") {
-      Features[Name] = Enabled;
-      return true;
-    } else if (Name == "32") {
-      Features["o32"] = Enabled;
-      return true;
-    } else if (Name == "64") {
-      Features["n64"] = Enabled;
-      return true;
-    }
-    return false;
+    if (Name == "32")
+      Name = "o32";
+    else if (Name == "64")
+      Name = "n64";
+    Features[Name] = Enabled;
   }
 
   virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
@@ -5574,10 +5480,7 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
       continue;
 
     // Apply the feature via the target.
-    if (!Target->setFeatureEnabled(Features, Name + 1, true)) {
-      Diags.Report(diag::err_target_invalid_feature) << Name;
-      return 0;
-    }
+    Target->setFeatureEnabled(Features, Name + 1, true);
   }
 
   // Then the disables.
@@ -5591,11 +5494,8 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
       continue;
 
     // Apply the feature via the target.
-    if (Name[0] != '-' ||
-        !Target->setFeatureEnabled(Features, Name + 1, false)) {
-      Diags.Report(diag::err_target_invalid_feature) << Name;
-      return 0;
-    }
+    assert(Name[0] == '-');
+    Target->setFeatureEnabled(Features, Name + 1, false);
   }
 
   // Add the features to the compile options.