switch (Kind) {
case UnknownArch: return "unknown";
- case aarch64: return "aarch64";
- case arm: return "arm";
- case hexagon: return "hexagon";
- case mips: return "mips";
- case mipsel: return "mipsel";
- case mips64: return "mips64";
- case mips64el:return "mips64el";
- case msp430: return "msp430";
- case ppc64: return "powerpc64";
- case ppc64le: return "powerpc64le";
- case ppc: return "powerpc";
- case r600: return "r600";
- case sparc: return "sparc";
- case sparcv9: return "sparcv9";
- case systemz: return "s390x";
- case tce: return "tce";
- case thumb: return "thumb";
- case x86: return "i386";
- case x86_64: return "x86_64";
- case xcore: return "xcore";
- case nvptx: return "nvptx";
- case nvptx64: return "nvptx64";
- case le32: return "le32";
- case amdil: return "amdil";
- case spir: return "spir";
- case spir64: return "spir64";
+ case aarch64: return "aarch64";
+ case aarch64_be: return "aarch64_be";
+ case arm: return "arm";
+ case armeb: return "armeb";
+ case arm64: return "arm64";
+ case arm64_be: return "arm64_be";
+ case hexagon: return "hexagon";
+ case mips: return "mips";
+ case mipsel: return "mipsel";
+ case mips64: return "mips64";
+ case mips64el: return "mips64el";
+ case msp430: return "msp430";
+ case ppc64: return "powerpc64";
+ case ppc64le: return "powerpc64le";
+ case ppc: return "powerpc";
+ case r600: return "r600";
+ case sparc: return "sparc";
+ case sparcv9: return "sparcv9";
+ case systemz: return "s390x";
+ case tce: return "tce";
+ case thumb: return "thumb";
+ case thumbeb: return "thumbeb";
+ case x86: return "i386";
+ case x86_64: return "x86_64";
+ case xcore: return "xcore";
+ case nvptx: return "nvptx";
+ case nvptx64: return "nvptx64";
+ case le32: return "le32";
+ case amdil: return "amdil";
+ case spir: return "spir";
+ case spir64: return "spir64";
}
llvm_unreachable("Invalid ArchType!");
const char *Triple::getArchTypePrefix(ArchType Kind) {
switch (Kind) {
default:
- return 0;
+ return nullptr;
- case aarch64: return "aarch64";
+ case aarch64:
+ case aarch64_be: return "aarch64";
case arm:
- case thumb: return "arm";
+ case armeb:
+ case thumb:
+ case thumbeb: return "arm";
+
+ case arm64:
+ case arm64_be: return "arm64";
case ppc64:
case ppc64le:
- case ppc: return "ppc";
+ case ppc: return "ppc";
case mips:
case mipsel:
case mips64:
- case mips64el:return "mips";
+ case mips64el: return "mips";
- case hexagon: return "hexagon";
+ case hexagon: return "hexagon";
- case r600: return "r600";
+ case r600: return "r600";
case sparcv9:
- case sparc: return "sparc";
+ case sparc: return "sparc";
- case systemz: return "systemz";
+ case systemz: return "systemz";
case x86:
- case x86_64: return "x86";
+ case x86_64: return "x86";
+
+ case xcore: return "xcore";
- case xcore: return "xcore";
+ case nvptx: return "nvptx";
+ case nvptx64: return "nvptx";
- case nvptx: return "nvptx";
- case nvptx64: return "nvptx";
- case le32: return "le32";
- case amdil: return "amdil";
- case spir: return "spir";
- case spir64: return "spir";
+ case le32: return "le32";
+ case amdil: return "amdil";
+ case spir: return "spir";
+ case spir64: return "spir";
}
}
case NetBSD: return "netbsd";
case OpenBSD: return "openbsd";
case Solaris: return "solaris";
- case Win32: return "win32";
+ case Win32: return "windows";
case Haiku: return "haiku";
case Minix: return "minix";
case RTEMS: return "rtems";
case GNUEABIHF: return "gnueabihf";
case GNUEABI: return "gnueabi";
case GNUX32: return "gnux32";
+ case CODE16: return "code16";
case EABI: return "eabi";
- case MachO: return "macho";
+ case EABIHF: return "eabihf";
case Android: return "android";
- case ELF: return "elf";
+ case MSVC: return "msvc";
+ case Itanium: return "itanium";
+ case Cygnus: return "cygnus";
}
llvm_unreachable("Invalid EnvironmentType!");
Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
return StringSwitch<Triple::ArchType>(Name)
.Case("aarch64", aarch64)
+ .Case("aarch64_be", aarch64_be)
.Case("arm", arm)
+ .Case("armeb", armeb)
+ .Case("arm64", arm64)
+ .Case("arm64_be", arm64_be)
.Case("mips", mips)
.Case("mipsel", mipsel)
.Case("mips64", mips64)
.Case("systemz", systemz)
.Case("tce", tce)
.Case("thumb", thumb)
+ .Case("thumbeb", thumbeb)
.Case("x86", x86)
.Case("x86-64", x86_64)
.Case("xcore", xcore)
// Returns architecture name that is understood by the target assembler.
const char *Triple::getArchNameForAssembler() {
if (!isOSDarwin() && getVendor() != Triple::Apple)
- return NULL;
+ return nullptr;
return StringSwitch<const char*>(getArchName())
.Case("i386", "i386")
.Cases("armv5", "armv5e", "thumbv5", "thumbv5e", "armv5")
.Cases("armv6", "thumbv6", "armv6")
.Cases("armv7", "thumbv7", "armv7")
+ .Case("armeb", "armeb")
+ .Case("arm64", "arm64")
+ .Case("arm64_be", "arm64")
.Case("r600", "r600")
.Case("nvptx", "nvptx")
.Case("nvptx64", "nvptx64")
.Case("amdil", "amdil")
.Case("spir", "spir")
.Case("spir64", "spir64")
- .Default(NULL);
+ .Default(nullptr);
}
static Triple::ArchType parseArch(StringRef ArchName) {
.Cases("powerpc64", "ppu", Triple::ppc64)
.Case("powerpc64le", Triple::ppc64le)
.Case("aarch64", Triple::aarch64)
+ .Case("aarch64_be", Triple::aarch64_be)
.Cases("arm", "xscale", Triple::arm)
// FIXME: It would be good to replace these with explicit names for all the
// various suffixes supported.
.StartsWith("armv", Triple::arm)
+ .Case("armeb", Triple::armeb)
+ .StartsWith("armebv", Triple::armeb)
.Case("thumb", Triple::thumb)
.StartsWith("thumbv", Triple::thumb)
+ .Case("thumbeb", Triple::thumbeb)
+ .StartsWith("thumbebv", Triple::thumbeb)
+ .Case("arm64", Triple::arm64)
+ .Case("arm64_be", Triple::arm64_be)
.Case("msp430", Triple::msp430)
.Cases("mips", "mipseb", "mipsallegrex", Triple::mips)
.Cases("mipsel", "mipsallegrexel", Triple::mipsel)
.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)
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("macho", Triple::MachO)
.StartsWith("android", Triple::Android)
- .StartsWith("elf", Triple::ELF)
+ .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 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");
+}
+
+static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
+ if (T.isOSDarwin())
+ return Triple::MachO;
+ else if (T.isOSWindows())
+ return Triple::COFF;
+ return Triple::ELF;
+}
+
/// \brief Construct a triple from the string representation provided.
///
/// This stores the string representation and parses the various pieces into
Arch(parseArch(getArchName())),
Vendor(parseVendor(getVendorName())),
OS(parseOS(getOSName())),
- Environment(parseEnvironment(getEnvironmentName())) {
+ Environment(parseEnvironment(getEnvironmentName())),
+ ObjectFormat(parseFormat(getEnvironmentName())) {
+ if (ObjectFormat == Triple::UnknownObjectFormat)
+ ObjectFormat = getDefaultFormat(*this);
}
/// \brief Construct a triple from string representations of the architecture,
Arch(parseArch(ArchStr.str())),
Vendor(parseVendor(VendorStr.str())),
OS(parseOS(OSStr.str())),
- Environment() {
+ Environment(), ObjectFormat(Triple::UnknownObjectFormat) {
+ ObjectFormat = getDefaultFormat(*this);
}
/// \brief Construct a triple from string representations of the architecture,
Arch(parseArch(ArchStr.str())),
Vendor(parseVendor(VendorStr.str())),
OS(parseOS(OSStr.str())),
- Environment(parseEnvironment(EnvironmentStr.str())) {
+ Environment(parseEnvironment(EnvironmentStr.str())),
+ ObjectFormat(parseFormat(EnvironmentStr.str())) {
+ if (ObjectFormat == Triple::UnknownObjectFormat)
+ ObjectFormat = getDefaultFormat(*this);
}
std::string Triple::normalize(StringRef Str) {
EnvironmentType Environment = UnknownEnvironment;
if (Components.size() > 3)
Environment = parseEnvironment(Components[3]);
+ ObjectFormatType ObjectFormat = UnknownObjectFormat;
+ if (Components.size() > 4)
+ ObjectFormat = parseFormat(Components[4]);
// Note which components are already in their final position. These will not
// be moved.
case 3:
Environment = parseEnvironment(Comp);
Valid = Environment != UnknownEnvironment;
+ if (!Valid) {
+ ObjectFormat = parseFormat(Comp);
+ Valid = ObjectFormat != UnknownObjectFormat;
+ }
break;
}
if (!Valid)
// Special case logic goes here. At this point Arch, Vendor and OS have the
// correct values for the computed components.
+ if (OS == Triple::Win32) {
+ Components.resize(4);
+ Components[2] = "windows";
+ if (Environment == UnknownEnvironment) {
+ if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
+ Components[3] = "msvc";
+ else
+ Components[3] = getObjectFormatTypeName(ObjectFormat);
+ }
+ } else if (OS == Triple::MinGW32) {
+ Components.resize(4);
+ Components[2] = "windows";
+ Components[3] = "gnu";
+ } else if (OS == Triple::Cygwin) {
+ Components.resize(4);
+ Components[2] = "windows";
+ Components[3] = "cygnus";
+ }
+ if (OS == Triple::MinGW32 || OS == Triple::Cygwin ||
+ (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
+ if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
+ Components.resize(5);
+ Components[4] = getObjectFormatTypeName(ObjectFormat);
+ }
+ }
+
// Stick the corrected components back together to form the normalized string.
std::string Normalized;
for (unsigned i = 0, e = Components.size(); i != e; ++i) {
// the clang driver combines OS X and IOS support into a common Darwin
// toolchain that wants to know the iOS version number even when targeting
// OS X.
- Major = 3;
+ Major = 5;
Minor = 0;
Micro = 0;
break;
case IOS:
getOSVersion(Major, Minor, Micro);
- // Default to 3.0.
+ // Default to 5.0 (or 7.0 for arm64).
if (Major == 0)
- Major = 3;
+ Major = (getArch() == arm64) ? 7 : 5;
break;
}
}
setEnvironmentName(getEnvironmentTypeName(Kind));
}
+void Triple::setObjectFormat(ObjectFormatType Kind) {
+ if (Environment == UnknownEnvironment)
+ return setEnvironmentName(getObjectFormatTypeName(Kind));
+
+ Twine Env = getEnvironmentTypeName(Environment) + Twine("-") +
+ getObjectFormatTypeName(Kind);
+ setEnvironmentName(Env.str());
+}
+
void Triple::setArchName(StringRef Str) {
// Work around a miscompilation bug for Twines in gcc 4.0.3.
SmallString<64> Triple;
case llvm::Triple::amdil:
case llvm::Triple::arm:
+ case llvm::Triple::armeb:
case llvm::Triple::hexagon:
case llvm::Triple::le32:
case llvm::Triple::mips:
case llvm::Triple::sparc:
case llvm::Triple::tce:
case llvm::Triple::thumb:
+ case llvm::Triple::thumbeb:
case llvm::Triple::x86:
case llvm::Triple::xcore:
case llvm::Triple::spir:
return 32;
+ case llvm::Triple::arm64:
+ case llvm::Triple::arm64_be:
case llvm::Triple::aarch64:
+ case llvm::Triple::aarch64_be:
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
case llvm::Triple::nvptx64:
switch (getArch()) {
case Triple::UnknownArch:
case Triple::aarch64:
+ case Triple::aarch64_be:
+ case Triple::arm64:
+ case Triple::arm64_be:
case Triple::msp430:
case Triple::systemz:
case Triple::ppc64le:
case Triple::amdil:
case Triple::spir:
case Triple::arm:
+ case Triple::armeb:
case Triple::hexagon:
case Triple::le32:
case Triple::mips:
case Triple::sparc:
case Triple::tce:
case Triple::thumb:
+ case Triple::thumbeb:
case Triple::x86:
case Triple::xcore:
// Already 32-bit.
case Triple::mips64: T.setArch(Triple::mips); break;
case Triple::mips64el: T.setArch(Triple::mipsel); break;
case Triple::nvptx64: T.setArch(Triple::nvptx); break;
- case Triple::ppc64: T.setArch(Triple::ppc); break;
+ case Triple::ppc64: T.setArch(Triple::ppc); break;
case Triple::sparcv9: T.setArch(Triple::sparc); break;
case Triple::x86_64: T.setArch(Triple::x86); break;
case Triple::spir64: T.setArch(Triple::spir); break;
case Triple::UnknownArch:
case Triple::amdil:
case Triple::arm:
+ case Triple::armeb:
case Triple::hexagon:
case Triple::le32:
case Triple::msp430:
case Triple::r600:
case Triple::tce:
case Triple::thumb:
+ case Triple::thumbeb:
case Triple::xcore:
T.setArch(UnknownArch);
break;
case Triple::aarch64:
+ case Triple::aarch64_be:
case Triple::spir64:
case Triple::mips64:
case Triple::mips64el:
case Triple::sparcv9:
case Triple::systemz:
case Triple::x86_64:
+ case Triple::arm64:
+ case Triple::arm64_be:
// Already 64-bit.
break;