summaryrefslogtreecommitdiffstats
path: root/lib/Support/Triple.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/Triple.cpp')
-rw-r--r--lib/Support/Triple.cpp46
1 files changed, 43 insertions, 3 deletions
diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
index e74b23c..d4b150a 100644
--- a/lib/Support/Triple.cpp
+++ b/lib/Support/Triple.cpp
@@ -141,6 +141,7 @@ const char *Triple::getOSTypeName(OSType Kind) {
switch (Kind) {
case UnknownOS: return "unknown";
+ case CloudABI: return "cloudabi";
case Darwin: return "darwin";
case DragonFly: return "dragonfly";
case FreeBSD: return "freebsd";
@@ -280,6 +281,7 @@ static Triple::ArchType parseARMArch(StringRef ArchName) {
.Cases("v7", "v7a", "v7em", "v7l", arch)
.Cases("v7m", "v7r", "v7s", arch)
.Cases("v8", "v8a", arch)
+ .Cases("v8.1", "v8.1a", arch)
.Default(Triple::UnknownArch);
}
@@ -345,6 +347,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
static Triple::OSType parseOS(StringRef OSName) {
return StringSwitch<Triple::OSType>(OSName)
+ .StartsWith("cloudabi", Triple::CloudABI)
.StartsWith("darwin", Triple::Darwin)
.StartsWith("dragonfly", Triple::DragonFly)
.StartsWith("freebsd", Triple::FreeBSD)
@@ -401,6 +404,7 @@ static Triple::SubArchType parseSubArch(StringRef SubArchName) {
SubArchName = SubArchName.substr(0, SubArchName.size() - 2);
return StringSwitch<Triple::SubArchType>(SubArchName)
+ .EndsWith("v8.1a", Triple::ARMSubArch_v8_1a)
.EndsWith("v8", Triple::ARMSubArch_v8)
.EndsWith("v8a", Triple::ARMSubArch_v8)
.EndsWith("v7", Triple::ARMSubArch_v7)
@@ -413,6 +417,7 @@ static Triple::SubArchType parseSubArch(StringRef SubArchName) {
.EndsWith("v6", Triple::ARMSubArch_v6)
.EndsWith("v6m", Triple::ARMSubArch_v6m)
.EndsWith("v6sm", Triple::ARMSubArch_v6m)
+ .EndsWith("v6k", Triple::ARMSubArch_v6k)
.EndsWith("v6t2", Triple::ARMSubArch_v6t2)
.EndsWith("v5", Triple::ARMSubArch_v5)
.EndsWith("v5e", Triple::ARMSubArch_v5)
@@ -436,6 +441,30 @@ static const char *getObjectFormatTypeName(Triple::ObjectFormatType Kind) {
}
static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
+ switch (T.getArch()) {
+ default:
+ break;
+ case Triple::hexagon:
+ case Triple::mips:
+ case Triple::mipsel:
+ case Triple::mips64:
+ case Triple::mips64el:
+ case Triple::r600:
+ case Triple::amdgcn:
+ case Triple::sparc:
+ case Triple::sparcv9:
+ case Triple::systemz:
+ case Triple::xcore:
+ case Triple::ppc64le:
+ return Triple::ELF;
+
+ case Triple::ppc:
+ case Triple::ppc64:
+ if (T.isOSDarwin())
+ return Triple::MachO;
+ return Triple::ELF;
+ }
+
if (T.isOSDarwin())
return Triple::MachO;
else if (T.isOSWindows())
@@ -714,6 +743,14 @@ void Triple::getOSVersion(unsigned &Major, unsigned &Minor,
unsigned &Micro) const {
StringRef OSName = getOSName();
+ // For Android, we care about the Android version rather than the Linux
+ // version.
+ if (getEnvironment() == Android) {
+ OSName = getEnvironmentName().substr(strlen("android"));
+ if (OSName.startswith("eabi"))
+ OSName = OSName.substr(strlen("eabi"));
+ }
+
// Assume that the OS portion of the triple starts with the canonical name.
StringRef OSTypeName = getOSTypeName(getOS());
if (OSName.startswith(OSTypeName))
@@ -839,7 +876,7 @@ void Triple::setArchName(StringRef Str) {
Triple += getVendorName();
Triple += "-";
Triple += getOSAndEnvironmentName();
- setTriple(Triple.str());
+ setTriple(Triple);
}
void Triple::setVendorName(StringRef Str) {
@@ -1063,9 +1100,9 @@ const char *Triple::getARMCPUForArch(StringRef MArch) const {
.Cases("v5", "v5t", "arm10tdmi")
.Cases("v5e", "v5te", "arm1022e")
.Case("v5tej", "arm926ej-s")
- .Cases("v6", "v6k", "arm1136jf-s")
+ .Case("v6", "arm1136jf-s")
.Case("v6j", "arm1136j-s")
- .Cases("v6z", "v6zk", "arm1176jzf-s")
+ .Cases("v6k", "v6z", "v6zk", "arm1176jzf-s")
.Case("v6t2", "arm1156t2-s")
.Cases("v6m", "v6-m", "v6sm", "v6s-m", "cortex-m0")
.Cases("v7", "v7a", "v7-a", "v7l", "v7-l", "cortex-a8")
@@ -1074,6 +1111,7 @@ const char *Triple::getARMCPUForArch(StringRef MArch) const {
.Cases("v7m", "v7-m", "cortex-m3")
.Cases("v7em", "v7e-m", "cortex-m4")
.Cases("v8", "v8a", "v8-a", "cortex-a53")
+ .Cases("v8.1a", "v8.1-a", "generic-armv8.1-a")
.Default(nullptr);
else
result = llvm::StringSwitch<const char *>(MArch)
@@ -1099,6 +1137,8 @@ const char *Triple::getARMCPUForArch(StringRef MArch) const {
default:
return "strongarm";
}
+ case llvm::Triple::NaCl:
+ return "cortex-a8";
default:
switch (getEnvironment()) {
case llvm::Triple::EABIHF: