TargetInfo: create less temporary strings.

llvm-svn: 152029
This commit is contained in:
Benjamin Kramer 2012-03-05 15:10:44 +00:00
parent 9952cf94b5
commit 27402c61c8
2 changed files with 18 additions and 17 deletions

View File

@ -587,7 +587,7 @@ public:
///
/// \return - False on error (invalid feature name).
virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
const std::string &Name,
StringRef Name,
bool Enabled) const {
return false;
}

View File

@ -1007,7 +1007,7 @@ namespace {
}
virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
const std::string &Name,
StringRef Name,
bool Enabled) const;
};
@ -1029,7 +1029,7 @@ namespace {
}
bool PTXTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
const std::string &Name,
StringRef Name,
bool Enabled) const {
if(std::binary_search(AvailableFeatures.begin(), AvailableFeatures.end(),
Name)) {
@ -1422,7 +1422,7 @@ public:
virtual void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const;
virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
const std::string &Name,
StringRef Name,
bool Enabled) const;
virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const;
virtual bool hasFeature(StringRef Feature) const;
@ -1701,7 +1701,7 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const {
}
bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
const std::string &Name,
StringRef Name,
bool Enabled) const {
// FIXME: This *really* should not be here. We need some way of translating
// options into llvm subtarget features.
@ -1815,38 +1815,40 @@ void X86TargetInfo::HandleTargetFeatures(std::vector<std::string> &Features) {
if (Features[i][0] == '-')
continue;
if (Features[i].substr(1) == "aes") {
StringRef Feature = StringRef(Features[i]).substr(1);
if (Feature == "aes") {
HasAES = true;
continue;
}
if (Features[i].substr(1) == "lzcnt") {
if (Feature == "lzcnt") {
HasLZCNT = true;
continue;
}
if (Features[i].substr(1) == "bmi") {
if (Feature == "bmi") {
HasBMI = true;
continue;
}
if (Features[i].substr(1) == "bmi2") {
if (Feature == "bmi2") {
HasBMI2 = true;
continue;
}
if (Features[i].substr(1) == "popcnt") {
if (Feature == "popcnt") {
HasPOPCNT = true;
continue;
}
if (Features[i].substr(1) == "fma4") {
if (Feature == "fma4") {
HasFMA4 = true;
continue;
}
assert(Features[i][0] == '+' && "Invalid target feature!");
X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Features[i].substr(1))
X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature)
.Case("avx2", AVX2)
.Case("avx", AVX)
.Case("sse42", SSE42)
@ -1859,7 +1861,7 @@ void X86TargetInfo::HandleTargetFeatures(std::vector<std::string> &Features) {
SSELevel = std::max(SSELevel, Level);
MMX3DNowEnum ThreeDNowLevel =
llvm::StringSwitch<MMX3DNowEnum>(Features[i].substr(1))
llvm::StringSwitch<MMX3DNowEnum>(Feature)
.Case("3dnowa", AMD3DNowAthlon)
.Case("3dnow", AMD3DNow)
.Case("mmx", MMX)
@ -2713,7 +2715,7 @@ public:
}
virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
const std::string &Name,
StringRef Name,
bool Enabled) const {
if (Name == "soft-float" || Name == "soft-float-abi" ||
Name == "vfp2" || Name == "vfp3" || Name == "neon" || Name == "d16") {
@ -3148,7 +3150,7 @@ public:
"i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32";
}
virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
const std::string &Name,
StringRef Name,
bool Enabled) const {
if (Name == "soft-float")
Features[Name] = Enabled;
@ -4117,8 +4119,7 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
Opts.Features.clear();
for (llvm::StringMap<bool>::const_iterator it = Features.begin(),
ie = Features.end(); it != ie; ++it)
Opts.Features.push_back(std::string(it->second ? "+" : "-") +
it->first().str());
Opts.Features.push_back((it->second ? "+" : "-") + it->first().str());
Target->HandleTargetFeatures(Opts.Features);
return Target.take();