diff options
Diffstat (limited to 'contrib/llvm/lib/Support/Triple.cpp')
| -rw-r--r-- | contrib/llvm/lib/Support/Triple.cpp | 63 | 
1 files changed, 61 insertions, 2 deletions
diff --git a/contrib/llvm/lib/Support/Triple.cpp b/contrib/llvm/lib/Support/Triple.cpp index 6783b40a125d..2687a67556d3 100644 --- a/contrib/llvm/lib/Support/Triple.cpp +++ b/contrib/llvm/lib/Support/Triple.cpp @@ -12,8 +12,8 @@  #include "llvm/ADT/SmallString.h"  #include "llvm/ADT/StringSwitch.h"  #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/TargetParser.h"  #include "llvm/Support/Host.h" +#include "llvm/Support/TargetParser.h"  #include <cstring>  using namespace llvm; @@ -34,6 +34,7 @@ StringRef Triple::getArchTypeName(ArchType Kind) {    case mips64:         return "mips64";    case mips64el:       return "mips64el";    case msp430:         return "msp430"; +  case nios2:          return "nios2";    case ppc64:          return "powerpc64";    case ppc64le:        return "powerpc64le";    case ppc:            return "powerpc"; @@ -98,6 +99,8 @@ StringRef Triple::getArchTypePrefix(ArchType Kind) {    case mips64:    case mips64el:    return "mips"; +  case nios2:       return "nios2"; +    case hexagon:     return "hexagon";    case amdgcn:      return "amdgcn"; @@ -161,6 +164,7 @@ StringRef Triple::getVendorTypeName(VendorType Kind) {    case Myriad: return "myriad";    case AMD: return "amd";    case Mesa: return "mesa"; +  case SUSE: return "suse";    }    llvm_unreachable("Invalid VendorType!"); @@ -170,6 +174,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {    switch (Kind) {    case UnknownOS: return "unknown"; +  case Ananas: return "ananas";    case CloudABI: return "cloudabi";    case Darwin: return "darwin";    case DragonFly: return "dragonfly"; @@ -261,6 +266,7 @@ Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {      .Case("mips64", mips64)      .Case("mips64el", mips64el)      .Case("msp430", msp430) +    .Case("nios2", nios2)      .Case("ppc64", ppc64)      .Case("ppc32", ppc)      .Case("ppc", ppc) @@ -383,6 +389,7 @@ static Triple::ArchType parseArch(StringRef ArchName) {      .Cases("mipsel", "mipsallegrexel", Triple::mipsel)      .Cases("mips64", "mips64eb", Triple::mips64)      .Case("mips64el", Triple::mips64el) +    .Case("nios2", Triple::nios2)      .Case("r600", Triple::r600)      .Case("amdgcn", Triple::amdgcn)      .Case("riscv32", Triple::riscv32) @@ -443,11 +450,13 @@ static Triple::VendorType parseVendor(StringRef VendorName) {      .Case("myriad", Triple::Myriad)      .Case("amd", Triple::AMD)      .Case("mesa", Triple::Mesa) +    .Case("suse", Triple::SUSE)      .Default(Triple::UnknownVendor);  }  static Triple::OSType parseOS(StringRef OSName) {    return StringSwitch<Triple::OSType>(OSName) +    .StartsWith("ananas", Triple::Ananas)      .StartsWith("cloudabi", Triple::CloudABI)      .StartsWith("darwin", Triple::Darwin)      .StartsWith("dragonfly", Triple::DragonFly) @@ -457,7 +466,7 @@ static Triple::OSType parseOS(StringRef OSName) {      .StartsWith("kfreebsd", Triple::KFreeBSD)      .StartsWith("linux", Triple::Linux)      .StartsWith("lv2", Triple::Lv2) -    .StartsWith("macosx", Triple::MacOSX) +    .StartsWith("macos", Triple::MacOSX)      .StartsWith("netbsd", Triple::NetBSD)      .StartsWith("openbsd", Triple::OpenBSD)      .StartsWith("solaris", Triple::Solaris) @@ -510,6 +519,7 @@ static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {      .EndsWith("coff", Triple::COFF)      .EndsWith("elf", Triple::ELF)      .EndsWith("macho", Triple::MachO) +    .EndsWith("wasm", Triple::Wasm)      .Default(Triple::UnknownObjectFormat);  } @@ -550,6 +560,8 @@ static Triple::SubArchType parseSubArch(StringRef SubArchName) {    case ARM::AK_ARMV7A:    case ARM::AK_ARMV7R:      return Triple::ARMSubArch_v7; +  case ARM::AK_ARMV7VE: +    return Triple::ARMSubArch_v7ve;    case ARM::AK_ARMV7K:      return Triple::ARMSubArch_v7k;    case ARM::AK_ARMV7M: @@ -581,6 +593,7 @@ static StringRef getObjectFormatTypeName(Triple::ObjectFormatType Kind) {    case Triple::COFF: return "coff";    case Triple::ELF: return "elf";    case Triple::MachO: return "macho"; +  case Triple::Wasm: return "wasm";    }    llvm_unreachable("unknown object format type");  } @@ -619,6 +632,7 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {    case Triple::mips64el:    case Triple::mipsel:    case Triple::msp430: +  case Triple::nios2:    case Triple::nvptx:    case Triple::nvptx64:    case Triple::ppc64le: @@ -865,6 +879,10 @@ std::string Triple::normalize(StringRef Str) {      }    } +  // SUSE uses "gnueabi" to mean "gnueabihf" +  if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI) +    Components[3] = "gnueabihf"; +    if (OS == Triple::Win32) {      Components.resize(4);      Components[2] = "windows"; @@ -978,6 +996,8 @@ void Triple::getOSVersion(unsigned &Major, unsigned &Minor,    StringRef OSTypeName = getOSTypeName(getOS());    if (OSName.startswith(OSTypeName))      OSName = OSName.substr(OSTypeName.size()); +  else if (getOS() == MacOSX) +    OSName.consume_front("macos");    parseVersionFromName(OSName, Major, Minor, Micro);  } @@ -1152,6 +1172,7 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {    case llvm::Triple::le32:    case llvm::Triple::mips:    case llvm::Triple::mipsel: +  case llvm::Triple::nios2:    case llvm::Triple::nvptx:    case llvm::Triple::ppc:    case llvm::Triple::r600: @@ -1235,6 +1256,7 @@ Triple Triple::get32BitArchVariant() const {    case Triple::le32:    case Triple::mips:    case Triple::mipsel: +  case Triple::nios2:    case Triple::nvptx:    case Triple::ppc:    case Triple::r600: @@ -1282,6 +1304,7 @@ Triple Triple::get64BitArchVariant() const {    case Triple::kalimba:    case Triple::lanai:    case Triple::msp430: +  case Triple::nios2:    case Triple::r600:    case Triple::tce:    case Triple::tcele: @@ -1353,6 +1376,7 @@ Triple Triple::getBigEndianArchVariant() const {    case Triple::le32:    case Triple::le64:    case Triple::msp430: +  case Triple::nios2:    case Triple::nvptx64:    case Triple::nvptx:    case Triple::r600: @@ -1439,6 +1463,7 @@ bool Triple::isLittleEndian() const {    case Triple::mips64el:    case Triple::mipsel:    case Triple::msp430: +  case Triple::nios2:    case Triple::nvptx64:    case Triple::nvptx:    case Triple::ppc64le: @@ -1464,6 +1489,39 @@ bool Triple::isLittleEndian() const {    }  } +bool Triple::isCompatibleWith(const Triple &Other) const { +  // ARM and Thumb triples are compatible, if subarch, vendor and OS match. +  if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) || +      (getArch() == Triple::arm && Other.getArch() == Triple::thumb) || +      (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) || +      (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) { +    if (getVendor() == Triple::Apple) +      return getSubArch() == Other.getSubArch() && +             getVendor() == Other.getVendor() && getOS() == Other.getOS(); +    else +      return getSubArch() == Other.getSubArch() && +             getVendor() == Other.getVendor() && getOS() == Other.getOS() && +             getEnvironment() == Other.getEnvironment() && +             getObjectFormat() == Other.getObjectFormat(); +  } + +  // If vendor is apple, ignore the version number. +  if (getVendor() == Triple::Apple) +    return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() && +           getVendor() == Other.getVendor() && getOS() == Other.getOS(); + +  return *this == Other; +} + +std::string Triple::merge(const Triple &Other) const { +  // If vendor is apple, pick the triple with the larger version number. +  if (getVendor() == Triple::Apple) +    if (Other.isOSVersionLT(*this)) +      return str(); + +  return Other.str(); +} +  StringRef Triple::getARMCPUForArch(StringRef MArch) const {    if (MArch.empty())      MArch = getArchName(); @@ -1511,6 +1569,7 @@ StringRef Triple::getARMCPUForArch(StringRef MArch) const {        return "strongarm";      }    case llvm::Triple::NaCl: +  case llvm::Triple::OpenBSD:      return "cortex-a8";    default:      switch (getEnvironment()) {  | 
