r188806 - Remove duplicated error checking.
Rafael Espindola
rafael.espindola at gmail.com
Tue Aug 20 08:30:32 PDT 2013
Author: rafael
Date: Tue Aug 20 10:30:32 2013
New Revision: 188806
URL: http://llvm.org/viewvc/llvm-project?rev=188806&view=rev
Log:
Remove duplicated error checking.
The driver validates its options, so we don't need to redo the work in
"clang -cc1".
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=188806&r1=188805&r2=188806&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Tue Aug 20 10:30:32 2013
@@ -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;
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=188806&r1=188805&r2=188806&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Aug 20 10:30:32 2013
@@ -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
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=188806&r1=188805&r2=188806&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Aug 20 10:30:32 2013
@@ -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(l
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::St
}
}
-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(ll
Name = "sse41";
if (Name == "rdrnd")
Name = "rdrand";
- if (!Features.count(Name))
- return false;
Features[Name] = Enabled;
@@ -2279,8 +2232,6 @@ bool X86TargetInfo::setFeatureEnabled(ll
} 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 TargetInf
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
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
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.
More information about the cfe-commits
mailing list