2009-04-01 23:53:23 +02:00
|
|
|
//===----------- Triple.cpp - Triple unit tests ---------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "llvm/ADT/Triple.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
TEST(TripleTest, BasicParsing) {
|
|
|
|
Triple T;
|
|
|
|
|
|
|
|
T = Triple("");
|
2009-07-26 05:31:47 +02:00
|
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T = Triple("-");
|
2009-07-26 05:31:47 +02:00
|
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T = Triple("--");
|
2009-07-26 05:31:47 +02:00
|
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T = Triple("---");
|
2009-07-26 05:31:47 +02:00
|
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T = Triple("----");
|
2009-07-26 05:31:47 +02:00
|
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("-", T.getEnvironmentName().str());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T = Triple("a");
|
2009-07-26 05:31:47 +02:00
|
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T = Triple("a-b");
|
2009-07-26 05:31:47 +02:00
|
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
|
|
EXPECT_EQ("b", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T = Triple("a-b-c");
|
2009-07-26 05:31:47 +02:00
|
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
|
|
EXPECT_EQ("b", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("c", T.getOSName().str());
|
|
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T = Triple("a-b-c-d");
|
2009-07-26 05:31:47 +02:00
|
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
|
|
EXPECT_EQ("b", T.getVendorName().str());
|
|
|
|
EXPECT_EQ("c", T.getOSName().str());
|
|
|
|
EXPECT_EQ("d", T.getEnvironmentName().str());
|
2009-04-01 23:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TripleTest, ParsedIDs) {
|
|
|
|
Triple T;
|
|
|
|
|
|
|
|
T = Triple("i386-apple-darwin");
|
2009-06-09 23:48:57 +02:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::Apple, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Darwin, T.getOS());
|
2010-09-16 10:25:48 +02:00
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T = Triple("x86_64-pc-linux-gnu");
|
2009-06-09 23:48:57 +02:00
|
|
|
EXPECT_EQ(Triple::x86_64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
2011-01-21 19:25:47 +01:00
|
|
|
EXPECT_EQ(Triple::GNU, T.getEnvironment());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
2012-04-02 20:31:33 +02:00
|
|
|
T = Triple("powerpc-bgp-linux");
|
|
|
|
EXPECT_EQ(Triple::ppc, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::BGP, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("powerpc-bgp-cnk");
|
|
|
|
EXPECT_EQ(Triple::ppc, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::BGP, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::CNK, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("powerpc64-bgq-linux");
|
|
|
|
EXPECT_EQ(Triple::ppc64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::BGQ, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2012-10-12 13:08:57 +02:00
|
|
|
T = Triple("powerpc-ibm-aix");
|
|
|
|
EXPECT_EQ(Triple::ppc, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::IBM, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::AIX, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
|
|
|
T = Triple("powerpc64-ibm-aix");
|
|
|
|
EXPECT_EQ(Triple::ppc64, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::IBM, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::AIX, T.getOS());
|
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
|
|
|
|
2009-04-01 23:53:23 +02:00
|
|
|
T = Triple("powerpc-dunno-notsure");
|
2009-06-09 23:48:57 +02:00
|
|
|
EXPECT_EQ(Triple::ppc, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
2010-09-16 10:25:48 +02:00
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
2011-02-02 11:08:38 +01:00
|
|
|
T = Triple("arm-none-none-eabi");
|
2011-01-21 19:25:47 +01:00
|
|
|
EXPECT_EQ(Triple::arm, T.getArch());
|
2011-02-02 11:08:38 +01:00
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
2011-01-21 19:25:47 +01:00
|
|
|
EXPECT_EQ(Triple::EABI, T.getEnvironment());
|
|
|
|
|
2009-04-01 23:53:23 +02:00
|
|
|
T = Triple("huh");
|
2009-06-09 23:48:57 +02:00
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getArch());
|
2010-08-12 13:31:39 +02:00
|
|
|
}
|
2009-08-18 21:26:55 +02:00
|
|
|
|
2010-08-12 13:31:39 +02:00
|
|
|
static std::string Join(StringRef A, StringRef B, StringRef C) {
|
|
|
|
std::string Str = A; Str += '-'; Str += B; Str += '-'; Str += C;
|
|
|
|
return Str;
|
|
|
|
}
|
2009-08-18 21:26:55 +02:00
|
|
|
|
2010-08-12 13:31:39 +02:00
|
|
|
static std::string Join(StringRef A, StringRef B, StringRef C, StringRef D) {
|
|
|
|
std::string Str = A; Str += '-'; Str += B; Str += '-'; Str += C; Str += '-';
|
|
|
|
Str += D; return Str;
|
|
|
|
}
|
2009-08-18 21:26:55 +02:00
|
|
|
|
2010-08-12 13:31:39 +02:00
|
|
|
TEST(TripleTest, Normalization) {
|
2011-01-21 19:25:47 +01:00
|
|
|
|
2010-08-12 13:31:39 +02:00
|
|
|
EXPECT_EQ("", Triple::normalize(""));
|
|
|
|
EXPECT_EQ("-", Triple::normalize("-"));
|
|
|
|
EXPECT_EQ("--", Triple::normalize("--"));
|
|
|
|
EXPECT_EQ("---", Triple::normalize("---"));
|
|
|
|
EXPECT_EQ("----", Triple::normalize("----"));
|
|
|
|
|
|
|
|
EXPECT_EQ("a", Triple::normalize("a"));
|
|
|
|
EXPECT_EQ("a-b", Triple::normalize("a-b"));
|
|
|
|
EXPECT_EQ("a-b-c", Triple::normalize("a-b-c"));
|
|
|
|
EXPECT_EQ("a-b-c-d", Triple::normalize("a-b-c-d"));
|
|
|
|
|
|
|
|
EXPECT_EQ("i386-b-c", Triple::normalize("i386-b-c"));
|
|
|
|
EXPECT_EQ("i386-a-c", Triple::normalize("a-i386-c"));
|
|
|
|
EXPECT_EQ("i386-a-b", Triple::normalize("a-b-i386"));
|
2010-09-16 10:25:48 +02:00
|
|
|
EXPECT_EQ("i386-a-b-c", Triple::normalize("a-b-c-i386"));
|
2010-08-12 13:31:39 +02:00
|
|
|
|
|
|
|
EXPECT_EQ("a-pc-c", Triple::normalize("a-pc-c"));
|
|
|
|
EXPECT_EQ("-pc-b-c", Triple::normalize("pc-b-c"));
|
|
|
|
EXPECT_EQ("a-pc-b", Triple::normalize("a-b-pc"));
|
2010-09-16 10:25:48 +02:00
|
|
|
EXPECT_EQ("a-pc-b-c", Triple::normalize("a-b-c-pc"));
|
2010-08-12 13:31:39 +02:00
|
|
|
|
|
|
|
EXPECT_EQ("a-b-linux", Triple::normalize("a-b-linux"));
|
|
|
|
EXPECT_EQ("--linux-b-c", Triple::normalize("linux-b-c"));
|
|
|
|
EXPECT_EQ("a--linux-c", Triple::normalize("a-linux-c"));
|
|
|
|
|
|
|
|
EXPECT_EQ("i386-pc-a", Triple::normalize("a-pc-i386"));
|
|
|
|
EXPECT_EQ("i386-pc-", Triple::normalize("-pc-i386"));
|
|
|
|
EXPECT_EQ("-pc-linux-c", Triple::normalize("linux-pc-c"));
|
|
|
|
EXPECT_EQ("-pc-linux", Triple::normalize("linux-pc-"));
|
|
|
|
|
|
|
|
EXPECT_EQ("i386", Triple::normalize("i386"));
|
|
|
|
EXPECT_EQ("-pc", Triple::normalize("pc"));
|
|
|
|
EXPECT_EQ("--linux", Triple::normalize("linux"));
|
|
|
|
|
2011-01-21 19:25:47 +01:00
|
|
|
EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-gnu-linux"));
|
|
|
|
|
2010-08-12 13:31:39 +02:00
|
|
|
// Check that normalizing a permutated set of valid components returns a
|
|
|
|
// triple with the unpermuted components.
|
|
|
|
StringRef C[4];
|
2012-02-21 04:39:36 +01:00
|
|
|
for (int Arch = 1+Triple::UnknownArch; Arch <= Triple::amdil; ++Arch) {
|
2010-08-12 13:31:39 +02:00
|
|
|
C[0] = Triple::getArchTypeName(Triple::ArchType(Arch));
|
|
|
|
for (int Vendor = 1+Triple::UnknownVendor; Vendor <= Triple::PC;
|
|
|
|
++Vendor) {
|
|
|
|
C[1] = Triple::getVendorTypeName(Triple::VendorType(Vendor));
|
|
|
|
for (int OS = 1+Triple::UnknownOS; OS <= Triple::Minix; ++OS) {
|
|
|
|
C[2] = Triple::getOSTypeName(Triple::OSType(OS));
|
2011-02-03 09:14:04 +01:00
|
|
|
|
|
|
|
std::string E = Join(C[0], C[1], C[2]);
|
|
|
|
EXPECT_EQ(E, Triple::normalize(Join(C[0], C[1], C[2])));
|
|
|
|
|
|
|
|
EXPECT_EQ(E, Triple::normalize(Join(C[0], C[2], C[1])));
|
|
|
|
EXPECT_EQ(E, Triple::normalize(Join(C[1], C[2], C[0])));
|
|
|
|
EXPECT_EQ(E, Triple::normalize(Join(C[1], C[0], C[2])));
|
|
|
|
EXPECT_EQ(E, Triple::normalize(Join(C[2], C[0], C[1])));
|
|
|
|
EXPECT_EQ(E, Triple::normalize(Join(C[2], C[1], C[0])));
|
|
|
|
|
2011-02-02 11:08:38 +01:00
|
|
|
for (int Env = 1+Triple::UnknownEnvironment; Env <= Triple::MachO;
|
|
|
|
++Env) {
|
|
|
|
C[3] = Triple::getEnvironmentTypeName(Triple::EnvironmentType(Env));
|
|
|
|
|
|
|
|
std::string F = Join(C[0], C[1], C[2], C[3]);
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[0], C[1], C[2], C[3])));
|
|
|
|
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[0], C[1], C[3], C[2])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[0], C[2], C[3], C[1])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[0], C[2], C[1], C[3])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[0], C[3], C[1], C[2])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[0], C[3], C[2], C[1])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[1], C[2], C[3], C[0])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[1], C[2], C[0], C[3])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[1], C[3], C[0], C[2])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[1], C[3], C[2], C[0])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[1], C[0], C[2], C[3])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[1], C[0], C[3], C[2])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[2], C[3], C[0], C[1])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[2], C[3], C[1], C[0])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[2], C[0], C[1], C[3])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[2], C[0], C[3], C[1])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[2], C[1], C[3], C[0])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[2], C[1], C[0], C[3])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[3], C[0], C[1], C[2])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[3], C[0], C[2], C[1])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[3], C[1], C[2], C[0])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[3], C[1], C[0], C[2])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[3], C[2], C[0], C[1])));
|
|
|
|
EXPECT_EQ(F, Triple::normalize(Join(C[3], C[2], C[1], C[0])));
|
|
|
|
}
|
2010-08-12 13:31:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Various real-world funky triples. The value returned by GCC's config.sub
|
|
|
|
// is given in the comment.
|
|
|
|
EXPECT_EQ("i386--mingw32", Triple::normalize("i386-mingw32")); // i386-pc-mingw32
|
|
|
|
EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-linux-gnu")); // x86_64-pc-linux-gnu
|
|
|
|
EXPECT_EQ("i486--linux-gnu", Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu
|
|
|
|
EXPECT_EQ("i386-redhat-linux", Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu
|
|
|
|
EXPECT_EQ("i686--linux", Triple::normalize("i686-linux")); // i686-pc-linux-gnu
|
2011-02-02 11:08:38 +01:00
|
|
|
EXPECT_EQ("arm-none--eabi", Triple::normalize("arm-none-eabi")); // arm-none-eabi
|
2009-04-01 23:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TripleTest, MutateName) {
|
|
|
|
Triple T;
|
2009-06-09 23:48:57 +02:00
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
2010-09-16 10:25:48 +02:00
|
|
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T.setArchName("i386");
|
2009-06-09 23:48:57 +02:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ("i386--", T.getTriple());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T.setVendorName("pc");
|
2009-06-09 23:48:57 +02:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ("i386-pc-", T.getTriple());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T.setOSName("linux");
|
2009-06-09 23:48:57 +02:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ("i386-pc-linux", T.getTriple());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T.setEnvironmentName("gnu");
|
2009-06-09 23:48:57 +02:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
EXPECT_EQ("i386-pc-linux-gnu", T.getTriple());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T.setOSName("freebsd");
|
2009-06-09 23:48:57 +02:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::FreeBSD, T.getOS());
|
|
|
|
EXPECT_EQ("i386-pc-freebsd-gnu", T.getTriple());
|
2009-04-01 23:53:23 +02:00
|
|
|
|
|
|
|
T.setOSAndEnvironmentName("darwin");
|
2009-06-09 23:48:57 +02:00
|
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
|
|
EXPECT_EQ(Triple::Darwin, T.getOS());
|
|
|
|
EXPECT_EQ("i386-pc-darwin", T.getTriple());
|
2011-01-21 19:25:47 +01:00
|
|
|
|
2009-04-01 23:53:23 +02:00
|
|
|
}
|
|
|
|
|
2012-01-31 05:52:32 +01:00
|
|
|
TEST(TripleTest, BitWidthPredicates) {
|
|
|
|
Triple T;
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::arm);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::hexagon);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips64);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::msp430);
|
|
|
|
EXPECT_TRUE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::ppc);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::ppc64);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::x86);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
|
|
|
|
|
|
|
T.setArch(Triple::x86_64);
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
|
|
|
}
|
|
|
|
|
2012-02-06 21:46:33 +01:00
|
|
|
TEST(TripleTest, BitWidthArchVariants) {
|
|
|
|
Triple T;
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::UnknownArch);
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::arm);
|
|
|
|
EXPECT_EQ(Triple::arm, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips);
|
|
|
|
EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mipsel);
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::ppc);
|
|
|
|
EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
|
|
|
|
|
2012-05-24 23:38:21 +02:00
|
|
|
T.setArch(Triple::nvptx);
|
|
|
|
EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
|
2012-02-06 21:46:33 +01:00
|
|
|
|
|
|
|
T.setArch(Triple::sparc);
|
|
|
|
EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::x86);
|
|
|
|
EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips64);
|
|
|
|
EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::mips64el);
|
|
|
|
EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::ppc64);
|
|
|
|
EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
|
|
|
|
|
2012-05-24 23:38:21 +02:00
|
|
|
T.setArch(Triple::nvptx64);
|
|
|
|
EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
|
2012-02-06 21:46:33 +01:00
|
|
|
|
|
|
|
T.setArch(Triple::sparcv9);
|
|
|
|
EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
|
|
|
|
|
|
|
|
T.setArch(Triple::x86_64);
|
|
|
|
EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
|
|
|
|
EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
|
|
|
|
}
|
|
|
|
|
2012-05-09 21:31:41 +02:00
|
|
|
TEST(TripleTest, getOSVersion) {
|
|
|
|
Triple T;
|
|
|
|
unsigned Major, Minor, Micro;
|
|
|
|
|
|
|
|
T = Triple("i386-apple-darwin9");
|
2013-01-31 00:48:13 +01:00
|
|
|
EXPECT_TRUE(T.isMacOSX());
|
|
|
|
EXPECT_FALSE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
2012-05-09 21:31:41 +02:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)5, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)3, Major);
|
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
|
|
|
|
T = Triple("x86_64-apple-darwin9");
|
2013-01-31 00:48:13 +01:00
|
|
|
EXPECT_TRUE(T.isMacOSX());
|
|
|
|
EXPECT_FALSE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
2012-05-09 21:31:41 +02:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)5, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)3, Major);
|
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
|
|
|
|
T = Triple("x86_64-apple-macosx");
|
2013-01-31 00:48:13 +01:00
|
|
|
EXPECT_TRUE(T.isMacOSX());
|
|
|
|
EXPECT_FALSE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
2012-05-09 21:31:41 +02:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)4, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)3, Major);
|
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
|
|
|
|
T = Triple("x86_64-apple-macosx10.7");
|
2013-01-31 00:48:13 +01:00
|
|
|
EXPECT_TRUE(T.isMacOSX());
|
|
|
|
EXPECT_FALSE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_FALSE(T.isArch32Bit());
|
|
|
|
EXPECT_TRUE(T.isArch64Bit());
|
2012-05-09 21:31:41 +02:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)7, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)3, Major);
|
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
|
|
|
|
T = Triple("armv7-apple-ios");
|
2013-01-31 00:48:13 +01:00
|
|
|
EXPECT_FALSE(T.isMacOSX());
|
|
|
|
EXPECT_TRUE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
2012-05-09 21:31:41 +02:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)4, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)3, Major);
|
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
|
|
|
|
T = Triple("armv7-apple-ios5.0");
|
2013-01-31 00:48:13 +01:00
|
|
|
EXPECT_FALSE(T.isMacOSX());
|
|
|
|
EXPECT_TRUE(T.isiOS());
|
|
|
|
EXPECT_FALSE(T.isArch16Bit());
|
|
|
|
EXPECT_TRUE(T.isArch32Bit());
|
|
|
|
EXPECT_FALSE(T.isArch64Bit());
|
2012-05-09 21:31:41 +02:00
|
|
|
T.getMacOSXVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)10, Major);
|
|
|
|
EXPECT_EQ((unsigned)4, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
T.getiOSVersion(Major, Minor, Micro);
|
|
|
|
EXPECT_EQ((unsigned)5, Major);
|
|
|
|
EXPECT_EQ((unsigned)0, Minor);
|
|
|
|
EXPECT_EQ((unsigned)0, Micro);
|
|
|
|
}
|
|
|
|
|
2009-04-01 23:53:23 +02:00
|
|
|
}
|