summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/SubtargetFeature.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2010-05-11 00:30:02 +0000
committerBill Wendling <isanbard@gmail.com>2010-05-11 00:30:02 +0000
commita12c1ff25a2d85c01979ff1ccdb87874812e3624 (patch)
treebc2319984cf50b75fdcfcf5768df0b340e98cba7 /llvm/lib/Target/SubtargetFeature.cpp
parent1ef066083617570b4284018b9b0257ab2b5a6590 (diff)
downloadbcm5719-llvm-a12c1ff25a2d85c01979ff1ccdb87874812e3624.tar.gz
bcm5719-llvm-a12c1ff25a2d85c01979ff1ccdb87874812e3624.zip
The getDefaultSubtargetFeatures method of SubtargetFeature did actually return a
string of features for that target. However LTO was using that string to pass into the "create target machine" stuff. That stuff needed the feature string to be in a particular form. In particular, it needed the CPU specified first and then the attributes. If there isn't a CPU specified, it required it to be blank -- e.g., ",+altivec". Yuck. Modify the getDefaultSubtargetFeatures method to be a non-static member function. For all attributes for a specific subtarget, it will add them in like normal. It will also take a CPU string so that it can satisfy this horrible syntax. llvm-svn: 103451
Diffstat (limited to 'llvm/lib/Target/SubtargetFeature.cpp')
-rw-r--r--llvm/lib/Target/SubtargetFeature.cpp28
1 files changed, 20 insertions, 8 deletions
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;
+ }
}
OpenPOWER on IntegriCloud