[llvm-commits] [llvm] r89236 - in /llvm/trunk: include/llvm/Target/SubtargetFeature.h lib/Target/SubtargetFeature.cpp tools/lto/LTOCodeGenerator.cpp tools/lto/LTOModule.cpp tools/lto/LTOModule.h
Viktor Kutuzov
vkutuzov at accesssoftek.com
Wed Nov 18 12:20:06 PST 2009
Author: vkutuzov
Date: Wed Nov 18 14:20:05 2009
New Revision: 89236
URL: http://llvm.org/viewvc/llvm-project?rev=89236&view=rev
Log:
Added getDefaultSubtargetFeatures method to SubtargetFeatures class which returns a correct feature string for given triple.
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
llvm/trunk/tools/lto/LTOModule.h
Modified: llvm/trunk/include/llvm/Target/SubtargetFeature.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/SubtargetFeature.h?rev=89236&r1=89235&r2=89236&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/SubtargetFeature.h (original)
+++ llvm/trunk/include/llvm/Target/SubtargetFeature.h Wed Nov 18 14:20:05 2009
@@ -21,6 +21,7 @@
#include <string>
#include <vector>
#include <cstring>
+#include "llvm/ADT/Triple.h"
#include "llvm/System/DataTypes.h"
namespace llvm {
@@ -106,6 +107,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);
};
} // End namespace llvm
Modified: llvm/trunk/lib/Target/SubtargetFeature.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SubtargetFeature.cpp?rev=89236&r1=89235&r2=89236&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SubtargetFeature.cpp (original)
+++ llvm/trunk/lib/Target/SubtargetFeature.cpp Wed Nov 18 14:20:05 2009
@@ -357,3 +357,30 @@
void SubtargetFeatures::dump() const {
print(errs());
}
+
+/// 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) {
+ switch (Triple.getVendor()) {
+ case Triple::Apple:
+ switch (Triple.getArch()) {
+ case Triple::ppc: // powerpc-apple-*
+ return std::string("altivec");
+ case Triple::ppc64: // powerpc64-apple-*
+ return std::string("64bit,altivec");
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return std::string("");
+}
Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=89236&r1=89235&r2=89236&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Wed Nov 18 14:20:05 2009
@@ -305,7 +305,8 @@
}
// construct LTModule, hand over ownership of module and target
- std::string FeatureStr = getFeatureString(Triple.c_str());
+ const std::string FeatureStr =
+ SubtargetFeatures::getDefaultSubtargetFeatures(llvm::Triple(Triple));
_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=89236&r1=89235&r2=89236&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.cpp (original)
+++ llvm/trunk/tools/lto/LTOModule.cpp Wed Nov 18 14:20:05 2009
@@ -19,6 +19,7 @@
#include "llvm/Module.h"
#include "llvm/ModuleProvider.h"
#include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Support/SystemUtils.h"
#include "llvm/Support/Mangler.h"
@@ -120,27 +121,6 @@
return makeLTOModule(buffer.get(), errMsg);
}
-/// getFeatureString - 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 getFeatureString(const char *TargetTriple) {
- InitializeAllTargets();
-
- SubtargetFeatures Features;
-
- if (strncmp(TargetTriple, "powerpc-apple-", 14) == 0) {
- Features.AddFeature("altivec", true);
- } else if (strncmp(TargetTriple, "powerpc64-apple-", 16) == 0) {
- Features.AddFeature("64bit", true);
- Features.AddFeature("altivec", true);
- }
-
- return Features.getString();
-}
-
LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer,
std::string& errMsg)
{
@@ -161,7 +141,8 @@
return NULL;
// construct LTModule, hand over ownership of module and target
- std::string FeatureStr = getFeatureString(Triple.c_str());
+ const std::string FeatureStr =
+ SubtargetFeatures::getDefaultSubtargetFeatures(llvm::Triple(Triple));
TargetMachine* target = march->createTargetMachine(Triple, FeatureStr);
return new LTOModule(m.take(), target);
}
Modified: llvm/trunk/tools/lto/LTOModule.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.h?rev=89236&r1=89235&r2=89236&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.h (original)
+++ llvm/trunk/tools/lto/LTOModule.h Wed Nov 18 14:20:05 2009
@@ -107,7 +107,5 @@
llvm::StringMap<NameAndAttributes> _undefines;
};
-extern std::string getFeatureString(const char *TargetTriple);
-
#endif // LTO_MODULE_H
More information about the llvm-commits
mailing list