diff options
author | Eric Christopher <echristo@gmail.com> | 2014-05-05 23:26:59 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2014-05-05 23:26:59 +0000 |
commit | 4b33ec96d3420e237485441b7423663ee4e9ac76 (patch) | |
tree | 546c286d9741e510e51310cf2376d543d0a27f1a /llvm/lib/MC/SubtargetFeature.cpp | |
parent | ef8a9518826b5b6b726eec66fd2fce6a3532ac66 (diff) | |
download | bcm5719-llvm-4b33ec96d3420e237485441b7423663ee4e9ac76.tar.gz bcm5719-llvm-4b33ec96d3420e237485441b7423663ee4e9ac76.zip |
Walk back commits for unused function parameters - they're still being
used via dragonegg for now.
llvm-svn: 208016
Diffstat (limited to 'llvm/lib/MC/SubtargetFeature.cpp')
-rw-r--r-- | llvm/lib/MC/SubtargetFeature.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/llvm/lib/MC/SubtargetFeature.cpp b/llvm/lib/MC/SubtargetFeature.cpp index dd69b0fe8c0..6af92c74a42 100644 --- a/llvm/lib/MC/SubtargetFeature.cpp +++ b/llvm/lib/MC/SubtargetFeature.cpp @@ -51,6 +51,18 @@ static inline bool isEnabled(const StringRef Feature) { return Ch == '+'; } +/// PrependFlag - Return a string with a prepended flag; '+' or '-'. +/// +static inline std::string PrependFlag(const StringRef Feature, + bool IsEnabled) { + assert(!Feature.empty() && "Empty string"); + if (hasFlag(Feature)) + return Feature; + std::string Prefix = IsEnabled ? "+" : "-"; + Prefix += Feature; + return Prefix; +} + /// Split - Splits a string of comma separated items in to a vector of strings. /// static void Split(std::vector<std::string> &V, const StringRef S) { @@ -97,11 +109,13 @@ static std::string Join(const std::vector<std::string> &V) { } /// Adding features. -void SubtargetFeatures::AddFeature(const StringRef String) { - // Don't add empty features or features we already have. - if (!String.empty()) - // Convert to lowercase, prepend flag if we don't already have a flag. - Features.push_back(hasFlag(String) ? String.str() : "+" + String.lower()); +void SubtargetFeatures::AddFeature(const StringRef String, + bool IsEnabled) { + // Don't add empty features + if (!String.empty()) { + // Convert to lowercase, prepend flag and add to vector + Features.push_back(PrependFlag(String.lower(), IsEnabled)); + } } /// Find KV in array using binary search. |