-// Returns architecture name that is understood by the target assembler.
-const char *Triple::getArchNameForAssembler() {
- if (!isOSDarwin() && getVendor() != Triple::Apple)
- return NULL;
-
- return StringSwitch<const char*>(getArchName())
- .Case("i386", "i386")
- .Case("x86_64", "x86_64")
- .Case("powerpc", "ppc")
- .Case("powerpc64", "ppc64")
- .Cases("mblaze", "microblaze", "mblaze")
- .Case("arm", "arm")
- .Cases("armv4t", "thumbv4t", "armv4t")
- .Cases("armv5", "armv5e", "thumbv5", "thumbv5e", "armv5")
- .Cases("armv6", "thumbv6", "armv6")
- .Cases("armv7", "thumbv7", "armv7")
- .Case("ptx32", "ptx32")
- .Case("ptx64", "ptx64")
- .Case("le32", "le32")
- .Case("amdil", "amdil")
- .Default(NULL);
-}
-
-Triple::ArchType Triple::ParseArch(StringRef ArchName) {
- return StringSwitch<ArchType>(ArchName)
- .Cases("i386", "i486", "i586", "i686", x86)
- .Cases("i786", "i886", "i986", x86) // FIXME: Do we need to support these?
- .Cases("amd64", "x86_64", x86_64)
- .Case("powerpc", ppc)
- .Cases("powerpc64", "ppu", ppc64)
- .Case("mblaze", mblaze)
- .Cases("arm", "xscale", arm)
- // FIXME: It would be good to replace these with explicit names for all the
- // various suffixes supported.
- .StartsWith("armv", arm)
- .Case("thumb", thumb)
- .StartsWith("thumbv", thumb)
- .Cases("spu", "cellspu", cellspu)
- .Case("msp430", msp430)
- .Cases("mips", "mipseb", "mipsallegrex", mips)
- .Cases("mipsel", "mipsallegrexel", "psp", mipsel)
- .Cases("mips64", "mips64eb", mips64)
- .Case("mips64el", mips64el)
- .Case("hexagon", hexagon)
- .Case("sparc", sparc)
- .Case("sparcv9", sparcv9)
- .Case("tce", tce)
- .Case("xcore", xcore)
- .Case("ptx32", ptx32)
- .Case("ptx64", ptx64)
- .Case("le32", le32)
- .Case("amdil", amdil)
- .Default(UnknownArch);
+static Triple::VendorType parseVendor(StringRef VendorName) {
+ return StringSwitch<Triple::VendorType>(VendorName)
+ .Case("apple", Triple::Apple)
+ .Case("pc", Triple::PC)
+ .Case("scei", Triple::SCEI)
+ .Case("bgp", Triple::BGP)
+ .Case("bgq", Triple::BGQ)
+ .Case("fsl", Triple::Freescale)
+ .Case("ibm", Triple::IBM)
+ .Case("img", Triple::ImaginationTechnologies)
+ .Case("mti", Triple::MipsTechnologies)
+ .Case("nvidia", Triple::NVIDIA)
+ .Case("csr", Triple::CSR)
+ .Default(Triple::UnknownVendor);
+}
+
+static Triple::OSType parseOS(StringRef OSName) {
+ return StringSwitch<Triple::OSType>(OSName)
+ .StartsWith("darwin", Triple::Darwin)
+ .StartsWith("dragonfly", Triple::DragonFly)
+ .StartsWith("freebsd", Triple::FreeBSD)
+ .StartsWith("ios", Triple::IOS)
+ .StartsWith("kfreebsd", Triple::KFreeBSD)
+ .StartsWith("linux", Triple::Linux)
+ .StartsWith("lv2", Triple::Lv2)
+ .StartsWith("macosx", Triple::MacOSX)
+ .StartsWith("netbsd", Triple::NetBSD)
+ .StartsWith("openbsd", Triple::OpenBSD)
+ .StartsWith("solaris", Triple::Solaris)
+ .StartsWith("win32", Triple::Win32)
+ .StartsWith("windows", Triple::Win32)
+ .StartsWith("haiku", Triple::Haiku)
+ .StartsWith("minix", Triple::Minix)
+ .StartsWith("rtems", Triple::RTEMS)
+ .StartsWith("nacl", Triple::NaCl)
+ .StartsWith("cnk", Triple::CNK)
+ .StartsWith("bitrig", Triple::Bitrig)
+ .StartsWith("aix", Triple::AIX)
+ .StartsWith("cuda", Triple::CUDA)
+ .StartsWith("nvcl", Triple::NVCL)
+ .Default(Triple::UnknownOS);
+}
+
+static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
+ return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
+ .StartsWith("eabihf", Triple::EABIHF)
+ .StartsWith("eabi", Triple::EABI)
+ .StartsWith("gnueabihf", Triple::GNUEABIHF)
+ .StartsWith("gnueabi", Triple::GNUEABI)
+ .StartsWith("gnux32", Triple::GNUX32)
+ .StartsWith("code16", Triple::CODE16)
+ .StartsWith("gnu", Triple::GNU)
+ .StartsWith("android", Triple::Android)
+ .StartsWith("msvc", Triple::MSVC)
+ .StartsWith("itanium", Triple::Itanium)
+ .StartsWith("cygnus", Triple::Cygnus)
+ .Default(Triple::UnknownEnvironment);
+}
+
+static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
+ return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
+ .EndsWith("coff", Triple::COFF)
+ .EndsWith("elf", Triple::ELF)
+ .EndsWith("macho", Triple::MachO)
+ .Default(Triple::UnknownObjectFormat);
+}
+
+static Triple::SubArchType parseSubArch(StringRef SubArchName) {
+ return StringSwitch<Triple::SubArchType>(SubArchName)
+ .EndsWith("v8", Triple::ARMSubArch_v8)
+ .EndsWith("v8a", Triple::ARMSubArch_v8)
+ .EndsWith("v7", Triple::ARMSubArch_v7)
+ .EndsWith("v7a", Triple::ARMSubArch_v7)
+ .EndsWith("v7em", Triple::ARMSubArch_v7em)
+ .EndsWith("v7l", Triple::ARMSubArch_v7)
+ .EndsWith("v7m", Triple::ARMSubArch_v7m)
+ .EndsWith("v7r", Triple::ARMSubArch_v7)
+ .EndsWith("v7s", Triple::ARMSubArch_v7s)
+ .EndsWith("v6", Triple::ARMSubArch_v6)
+ .EndsWith("v6m", Triple::ARMSubArch_v6m)
+ .EndsWith("v6t2", Triple::ARMSubArch_v6t2)
+ .EndsWith("v5", Triple::ARMSubArch_v5)
+ .EndsWith("v5e", Triple::ARMSubArch_v5)
+ .EndsWith("v5t", Triple::ARMSubArch_v5)
+ .EndsWith("v5te", Triple::ARMSubArch_v5te)
+ .EndsWith("v4t", Triple::ARMSubArch_v4t)
+ .Default(Triple::NoSubArch);
+}
+
+static const char *getObjectFormatTypeName(Triple::ObjectFormatType Kind) {
+ switch (Kind) {
+ case Triple::UnknownObjectFormat: return "";
+ case Triple::COFF: return "coff";
+ case Triple::ELF: return "elf";
+ case Triple::MachO: return "macho";
+ }
+ llvm_unreachable("unknown object format type");