[llvm-commits] [llvm] r103451 - in /llvm/trunk: include/llvm/Target/SubtargetFeature.h lib/Target/SubtargetFeature.cpp tools/lto/LTOCodeGenerator.cpp tools/lto/LTOModule.cpp
Bill Wendling
isanbard at gmail.com
Mon May 10 17:30:02 PDT 2010
Author: void
Date: Mon May 10 19:30:02 2010
New Revision: 103451
URL: http://llvm.org/viewvc/llvm-project?rev=103451&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/Target/SubtargetFeature.h
llvm/trunk/lib/Target/SubtargetFeature.cpp
llvm/trunk/tools/lto/LTOCodeGenerator.cpp
llvm/trunk/tools/lto/LTOModule.cpp
Modified: llvm/trunk/include/llvm/Target/SubtargetFeature.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/SubtargetFeature.h?rev=103451&r1=103450&r2=103451&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/SubtargetFeature.h (original)
+++ llvm/trunk/include/llvm/Target/SubtargetFeature.h Mon May 10 19:30:02 2010
@@ -108,9 +108,10 @@
// 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
Modified: llvm/trunk/lib/Target/SubtargetFeature.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SubtargetFeature.cpp?rev=103451&r1=103450&r2=103451&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SubtargetFeature.cpp (original)
+++ llvm/trunk/lib/Target/SubtargetFeature.cpp Mon May 10 19:30:02 2010
@@ -359,29 +359,41 @@
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;
+ }
}
Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=103451&r1=103450&r2=103451&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Mon May 10 19:30:02 2010
@@ -300,8 +300,9 @@
}
// 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;
Modified: llvm/trunk/tools/lto/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=103451&r1=103450&r2=103451&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.cpp (original)
+++ llvm/trunk/tools/lto/LTOModule.cpp Mon May 10 19:30:02 2010
@@ -140,8 +140,9 @@
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);
}
More information about the llvm-commits
mailing list