summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Target/SubtargetFeature.h7
-rw-r--r--llvm/lib/Target/SubtargetFeature.cpp28
-rw-r--r--llvm/tools/lto/LTOCodeGenerator.cpp5
-rw-r--r--llvm/tools/lto/LTOModule.cpp5
4 files changed, 30 insertions, 15 deletions
diff --git a/llvm/include/llvm/Target/SubtargetFeature.h b/llvm/include/llvm/Target/SubtargetFeature.h
index 38a3cc2fefa..45468714a3b 100644
--- a/llvm/include/llvm/Target/SubtargetFeature.h
+++ b/llvm/include/llvm/Target/SubtargetFeature.h
@@ -108,9 +108,10 @@ public:
// Dump feature info.
void dump() const;
- /// Retrieve a formatted string of the default features for
- /// the specified target triple.
- static std::string getDefaultSubtargetFeatures(const Triple &Triple);
+ /// Retrieve a formatted string of the default features for the specified
+ /// target triple.
+ void getDefaultSubtargetFeatures(const std::string &CPU,
+ const Triple& Triple);
};
} // End namespace llvm
diff --git a/llvm/lib/Target/SubtargetFeature.cpp b/llvm/lib/Target/SubtargetFeature.cpp
index 2094cc945a4..035e64a017b 100644
--- a/llvm/lib/Target/SubtargetFeature.cpp
+++ b/llvm/lib/Target/SubtargetFeature.cpp
@@ -359,29 +359,41 @@ void SubtargetFeatures::dump() const {
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) {
+void SubtargetFeatures::getDefaultSubtargetFeatures(const std::string &CPU,
+ const Triple& Triple) {
+ setCPU(CPU);
+
+ const char *Attrs = 0;
+
switch (Triple.getVendor()) {
case Triple::Apple:
switch (Triple.getArch()) {
case Triple::ppc: // powerpc-apple-*
- return std::string("altivec");
+ Attrs = "altivec";
+ break;
case Triple::ppc64: // powerpc64-apple-*
- return std::string("64bit,altivec");
+ Attrs = "64bit,altivec";
+ break;
default:
break;
}
break;
default:
break;
- }
+ }
+
+ StringRef SR(Attrs);
- return std::string("");
+ while (!SR.empty()) {
+ std::pair<StringRef, StringRef> Res = SR.split(',');
+ AddFeature(Res.first);
+ SR = Res.second;
+ }
}
diff --git a/llvm/tools/lto/LTOCodeGenerator.cpp b/llvm/tools/lto/LTOCodeGenerator.cpp
index 10105921c4e..59e8405e7ec 100644
--- a/llvm/tools/lto/LTOCodeGenerator.cpp
+++ b/llvm/tools/lto/LTOCodeGenerator.cpp
@@ -300,8 +300,9 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg)
}
// construct LTModule, hand over ownership of module and target
- const std::string FeatureStr =
- SubtargetFeatures::getDefaultSubtargetFeatures(llvm::Triple(Triple));
+ SubtargetFeatures Features;
+ Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple));
+ std::string FeatureStr = Features.getString();
_target = march->createTargetMachine(Triple, FeatureStr);
}
return false;
diff --git a/llvm/tools/lto/LTOModule.cpp b/llvm/tools/lto/LTOModule.cpp
index b269e782375..0870205a778 100644
--- a/llvm/tools/lto/LTOModule.cpp
+++ b/llvm/tools/lto/LTOModule.cpp
@@ -140,8 +140,9 @@ LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer,
return NULL;
// construct LTModule, hand over ownership of module and target
- const std::string FeatureStr =
- SubtargetFeatures::getDefaultSubtargetFeatures(llvm::Triple(Triple));
+ SubtargetFeatures Features;
+ Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple));
+ std::string FeatureStr = Features.getString();
TargetMachine* target = march->createTargetMachine(Triple, FeatureStr);
return new LTOModule(m.take(), target);
}
OpenPOWER on IntegriCloud