[llvm-commits] [llvm] r81274 - in /llvm/trunk: include/llvm/ADT/Triple.h lib/Support/Triple.cpp
Daniel Dunbar
daniel at zuster.org
Tue Sep 8 16:32:51 PDT 2009
Author: ddunbar
Date: Tue Sep 8 18:32:51 2009
New Revision: 81274
URL: http://llvm.org/viewvc/llvm-project?rev=81274&view=rev
Log:
Add Triple::getArchTypeForDarwinArchName, which converts a "Darwin" architecture
name (e.g. "ppc") to the appropriate constant.
Also, StringRefize additional Triple constructor.
Modified:
llvm/trunk/include/llvm/ADT/Triple.h
llvm/trunk/lib/Support/Triple.cpp
Modified: llvm/trunk/include/llvm/ADT/Triple.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=81274&r1=81273&r2=81274&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h (original)
+++ llvm/trunk/include/llvm/ADT/Triple.h Tue Sep 8 18:32:51 2009
@@ -118,8 +118,8 @@
/// @{
Triple() : Data(), Arch(InvalidArch) {}
- explicit Triple(const StringRef &Str) : Data(Str), Arch(InvalidArch) {}
- explicit Triple(const char *ArchStr, const char *VendorStr, const char *OSStr)
+ explicit Triple(StringRef Str) : Data(Str), Arch(InvalidArch) {}
+ explicit Triple(StringRef ArchStr, StringRef VendorStr, StringRef OSStr)
: Data(ArchStr), Arch(InvalidArch) {
Data += '-';
Data += VendorStr;
@@ -258,10 +258,19 @@
/// getOSTypeName - Get the canonical name for the \arg Kind vendor.
static const char *getOSTypeName(OSType Kind);
+ /// @}
+ /// @name Static helpers for converting alternate architecture names.
+ /// @{
+
/// getArchTypeForLLVMName - The canonical type for the given LLVM
/// architecture name (e.g., "x86").
static ArchType getArchTypeForLLVMName(const StringRef &Str);
+ /// getArchTypeForDarwinArchName - Get the architecture type for a "Darwin"
+ /// architecture name, for example as accepted by "gcc -arch" (see also
+ /// arch(3)).
+ static ArchType getArchTypeForDarwinArchName(const StringRef &Str);
+
/// @}
};
Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=81274&r1=81273&r2=81274&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Tue Sep 8 18:32:51 2009
@@ -139,6 +139,40 @@
return UnknownArch;
}
+Triple::ArchType Triple::getArchTypeForDarwinArchName(const StringRef &Str) {
+ // See arch(3) and llvm-gcc's driver-driver.c. We don't implement support for
+ // archs which Darwin doesn't use.
+
+ // The matching this routine does is fairly pointless, since it is neither the
+ // complete architecture list, nor a reasonable subset. The problem is that
+ // historically the driver driver accepts this and also ties its -march=
+ // handling to the architecture name, so we need to be careful before removing
+ // support for it.
+
+ if (Str == "ppc" || Str == "ppc601" || Str == "ppc603" || Str == "ppc604" ||
+ Str == "ppc604e" || Str == "ppc750" || Str == "ppc7400" ||
+ Str == "ppc7450" || Str == "ppc970")
+ return Triple::ppc;
+
+ if (Str == "ppc64")
+ return Triple::ppc64;
+
+ if (Str == "i386" || Str == "i486" || Str == "i486SX" || Str == "pentium" ||
+ Str == "i586" || Str == "pentpro" || Str == "i686" || Str == "pentIIm3" ||
+ Str == "pentIIm5" || Str == "pentium4")
+ return Triple::x86;
+
+ if (Str == "x86_64")
+ return Triple::x86_64;
+
+ // This is derived from the driver driver.
+ if (Str == "arm" || Str == "armv4t" || Str == "armv5" || Str == "xscale" ||
+ Str == "armv6" || Str == "armv7")
+ return Triple::arm;
+
+ return Triple::UnknownArch;
+}
+
//
void Triple::Parse() const {
More information about the llvm-commits
mailing list