Home | History | Annotate | Download | only in ADT
      1 //===----------- Triple.cpp - Triple unit tests ---------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #include "gtest/gtest.h"
     11 #include "llvm/ADT/Triple.h"
     12 
     13 using namespace llvm;
     14 
     15 namespace {
     16 
     17 TEST(TripleTest, BasicParsing) {
     18   Triple T;
     19 
     20   T = Triple("");
     21   EXPECT_EQ("", T.getArchName().str());
     22   EXPECT_EQ("", T.getVendorName().str());
     23   EXPECT_EQ("", T.getOSName().str());
     24   EXPECT_EQ("", T.getEnvironmentName().str());
     25 
     26   T = Triple("-");
     27   EXPECT_EQ("", T.getArchName().str());
     28   EXPECT_EQ("", T.getVendorName().str());
     29   EXPECT_EQ("", T.getOSName().str());
     30   EXPECT_EQ("", T.getEnvironmentName().str());
     31 
     32   T = Triple("--");
     33   EXPECT_EQ("", T.getArchName().str());
     34   EXPECT_EQ("", T.getVendorName().str());
     35   EXPECT_EQ("", T.getOSName().str());
     36   EXPECT_EQ("", T.getEnvironmentName().str());
     37 
     38   T = Triple("---");
     39   EXPECT_EQ("", T.getArchName().str());
     40   EXPECT_EQ("", T.getVendorName().str());
     41   EXPECT_EQ("", T.getOSName().str());
     42   EXPECT_EQ("", T.getEnvironmentName().str());
     43 
     44   T = Triple("----");
     45   EXPECT_EQ("", T.getArchName().str());
     46   EXPECT_EQ("", T.getVendorName().str());
     47   EXPECT_EQ("", T.getOSName().str());
     48   EXPECT_EQ("-", T.getEnvironmentName().str());
     49 
     50   T = Triple("a");
     51   EXPECT_EQ("a", T.getArchName().str());
     52   EXPECT_EQ("", T.getVendorName().str());
     53   EXPECT_EQ("", T.getOSName().str());
     54   EXPECT_EQ("", T.getEnvironmentName().str());
     55 
     56   T = Triple("a-b");
     57   EXPECT_EQ("a", T.getArchName().str());
     58   EXPECT_EQ("b", T.getVendorName().str());
     59   EXPECT_EQ("", T.getOSName().str());
     60   EXPECT_EQ("", T.getEnvironmentName().str());
     61 
     62   T = Triple("a-b-c");
     63   EXPECT_EQ("a", T.getArchName().str());
     64   EXPECT_EQ("b", T.getVendorName().str());
     65   EXPECT_EQ("c", T.getOSName().str());
     66   EXPECT_EQ("", T.getEnvironmentName().str());
     67 
     68   T = Triple("a-b-c-d");
     69   EXPECT_EQ("a", T.getArchName().str());
     70   EXPECT_EQ("b", T.getVendorName().str());
     71   EXPECT_EQ("c", T.getOSName().str());
     72   EXPECT_EQ("d", T.getEnvironmentName().str());
     73 }
     74 
     75 TEST(TripleTest, ParsedIDs) {
     76   Triple T;
     77 
     78   T = Triple("i386-apple-darwin");
     79   EXPECT_EQ(Triple::x86, T.getArch());
     80   EXPECT_EQ(Triple::Apple, T.getVendor());
     81   EXPECT_EQ(Triple::Darwin, T.getOS());
     82   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
     83 
     84   T = Triple("i386-pc-elfiamcu");
     85   EXPECT_EQ(Triple::x86, T.getArch());
     86   EXPECT_EQ(Triple::PC, T.getVendor());
     87   EXPECT_EQ(Triple::ELFIAMCU, T.getOS());
     88   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
     89 
     90   T = Triple("x86_64-pc-linux-gnu");
     91   EXPECT_EQ(Triple::x86_64, T.getArch());
     92   EXPECT_EQ(Triple::PC, T.getVendor());
     93   EXPECT_EQ(Triple::Linux, T.getOS());
     94   EXPECT_EQ(Triple::GNU, T.getEnvironment());
     95 
     96   T = Triple("powerpc-bgp-linux");
     97   EXPECT_EQ(Triple::ppc, T.getArch());
     98   EXPECT_EQ(Triple::BGP, T.getVendor());
     99   EXPECT_EQ(Triple::Linux, T.getOS());
    100   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    101 
    102   T = Triple("powerpc-bgp-cnk");
    103   EXPECT_EQ(Triple::ppc, T.getArch());
    104   EXPECT_EQ(Triple::BGP, T.getVendor());
    105   EXPECT_EQ(Triple::CNK, T.getOS());
    106   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    107 
    108   T = Triple("powerpc64-bgq-linux");
    109   EXPECT_EQ(Triple::ppc64, T.getArch());
    110   EXPECT_EQ(Triple::BGQ, T.getVendor());
    111   EXPECT_EQ(Triple::Linux, T.getOS());
    112   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    113 
    114   T = Triple("powerpc-ibm-aix");
    115   EXPECT_EQ(Triple::ppc, T.getArch());
    116   EXPECT_EQ(Triple::IBM, T.getVendor());
    117   EXPECT_EQ(Triple::AIX, T.getOS());
    118   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    119 
    120   T = Triple("powerpc64-ibm-aix");
    121   EXPECT_EQ(Triple::ppc64, T.getArch());
    122   EXPECT_EQ(Triple::IBM, T.getVendor());
    123   EXPECT_EQ(Triple::AIX, T.getOS());
    124   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    125 
    126   T = Triple("powerpc-dunno-notsure");
    127   EXPECT_EQ(Triple::ppc, T.getArch());
    128   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    129   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    130   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    131 
    132   T = Triple("arm-none-none-eabi");
    133   EXPECT_EQ(Triple::arm, T.getArch());
    134   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    135   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    136   EXPECT_EQ(Triple::EABI, T.getEnvironment());
    137 
    138   T = Triple("armv6hl-none-linux-gnueabi");
    139   EXPECT_EQ(Triple::arm, T.getArch());
    140   EXPECT_EQ(Triple::Linux, T.getOS());
    141   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    142   EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
    143 
    144   T = Triple("armv7hl-none-linux-gnueabi");
    145   EXPECT_EQ(Triple::arm, T.getArch());
    146   EXPECT_EQ(Triple::Linux, T.getOS());
    147   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    148   EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
    149 
    150   T = Triple("amdil-unknown-unknown");
    151   EXPECT_EQ(Triple::amdil, T.getArch());
    152   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    153   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    154 
    155   T = Triple("amdil64-unknown-unknown");
    156   EXPECT_EQ(Triple::amdil64, T.getArch());
    157   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    158   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    159 
    160   T = Triple("hsail-unknown-unknown");
    161   EXPECT_EQ(Triple::hsail, T.getArch());
    162   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    163   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    164 
    165   T = Triple("hsail64-unknown-unknown");
    166   EXPECT_EQ(Triple::hsail64, T.getArch());
    167   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    168   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    169 
    170   T = Triple("sparcel-unknown-unknown");
    171   EXPECT_EQ(Triple::sparcel, T.getArch());
    172   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    173   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    174 
    175   T = Triple("spir-unknown-unknown");
    176   EXPECT_EQ(Triple::spir, T.getArch());
    177   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    178   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    179 
    180   T = Triple("spir64-unknown-unknown");
    181   EXPECT_EQ(Triple::spir64, T.getArch());
    182   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    183   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    184 
    185   T = Triple("x86_64-unknown-cloudabi");
    186   EXPECT_EQ(Triple::x86_64, T.getArch());
    187   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    188   EXPECT_EQ(Triple::CloudABI, T.getOS());
    189   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    190 
    191   T = Triple("wasm32-unknown-unknown");
    192   EXPECT_EQ(Triple::wasm32, T.getArch());
    193   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    194   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    195   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    196 
    197   T = Triple("wasm64-unknown-unknown");
    198   EXPECT_EQ(Triple::wasm64, T.getArch());
    199   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    200   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    201   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    202 
    203   T = Triple("avr-unknown-unknown");
    204   EXPECT_EQ(Triple::avr, T.getArch());
    205   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    206   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    207   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    208 
    209   T = Triple("avr");
    210   EXPECT_EQ(Triple::avr, T.getArch());
    211   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    212   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    213   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    214 
    215   T = Triple("huh");
    216   EXPECT_EQ(Triple::UnknownArch, T.getArch());
    217 }
    218 
    219 static std::string Join(StringRef A, StringRef B, StringRef C) {
    220   std::string Str = A; Str += '-'; Str += B; Str += '-'; Str += C;
    221   return Str;
    222 }
    223 
    224 static std::string Join(StringRef A, StringRef B, StringRef C, StringRef D) {
    225   std::string Str = A; Str += '-'; Str += B; Str += '-'; Str += C; Str += '-';
    226   Str += D; return Str;
    227 }
    228 
    229 TEST(TripleTest, Normalization) {
    230 
    231   EXPECT_EQ("", Triple::normalize(""));
    232   EXPECT_EQ("-", Triple::normalize("-"));
    233   EXPECT_EQ("--", Triple::normalize("--"));
    234   EXPECT_EQ("---", Triple::normalize("---"));
    235   EXPECT_EQ("----", Triple::normalize("----"));
    236 
    237   EXPECT_EQ("a", Triple::normalize("a"));
    238   EXPECT_EQ("a-b", Triple::normalize("a-b"));
    239   EXPECT_EQ("a-b-c", Triple::normalize("a-b-c"));
    240   EXPECT_EQ("a-b-c-d", Triple::normalize("a-b-c-d"));
    241 
    242   EXPECT_EQ("i386-b-c", Triple::normalize("i386-b-c"));
    243   EXPECT_EQ("i386-a-c", Triple::normalize("a-i386-c"));
    244   EXPECT_EQ("i386-a-b", Triple::normalize("a-b-i386"));
    245   EXPECT_EQ("i386-a-b-c", Triple::normalize("a-b-c-i386"));
    246 
    247   EXPECT_EQ("a-pc-c", Triple::normalize("a-pc-c"));
    248   EXPECT_EQ("-pc-b-c", Triple::normalize("pc-b-c"));
    249   EXPECT_EQ("a-pc-b", Triple::normalize("a-b-pc"));
    250   EXPECT_EQ("a-pc-b-c", Triple::normalize("a-b-c-pc"));
    251 
    252   EXPECT_EQ("a-b-linux", Triple::normalize("a-b-linux"));
    253   EXPECT_EQ("--linux-b-c", Triple::normalize("linux-b-c"));
    254   EXPECT_EQ("a--linux-c", Triple::normalize("a-linux-c"));
    255 
    256   EXPECT_EQ("i386-pc-a", Triple::normalize("a-pc-i386"));
    257   EXPECT_EQ("i386-pc-", Triple::normalize("-pc-i386"));
    258   EXPECT_EQ("-pc-linux-c", Triple::normalize("linux-pc-c"));
    259   EXPECT_EQ("-pc-linux", Triple::normalize("linux-pc-"));
    260 
    261   EXPECT_EQ("i386", Triple::normalize("i386"));
    262   EXPECT_EQ("-pc", Triple::normalize("pc"));
    263   EXPECT_EQ("--linux", Triple::normalize("linux"));
    264 
    265   EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-gnu-linux"));
    266 
    267   // Check that normalizing a permutated set of valid components returns a
    268   // triple with the unpermuted components.
    269   StringRef C[4];
    270   for (int Arch = 1+Triple::UnknownArch; Arch <= Triple::LastArchType; ++Arch) {
    271     C[0] = Triple::getArchTypeName(Triple::ArchType(Arch));
    272     for (int Vendor = 1+Triple::UnknownVendor; Vendor <= Triple::LastVendorType;
    273          ++Vendor) {
    274       C[1] = Triple::getVendorTypeName(Triple::VendorType(Vendor));
    275       for (int OS = 1+Triple::UnknownOS; OS <= Triple::LastOSType; ++OS) {
    276         if (OS == Triple::Win32)
    277           continue;
    278 
    279         C[2] = Triple::getOSTypeName(Triple::OSType(OS));
    280 
    281         std::string E = Join(C[0], C[1], C[2]);
    282         EXPECT_EQ(E, Triple::normalize(Join(C[0], C[1], C[2])));
    283 
    284         EXPECT_EQ(E, Triple::normalize(Join(C[0], C[2], C[1])));
    285         EXPECT_EQ(E, Triple::normalize(Join(C[1], C[2], C[0])));
    286         EXPECT_EQ(E, Triple::normalize(Join(C[1], C[0], C[2])));
    287         EXPECT_EQ(E, Triple::normalize(Join(C[2], C[0], C[1])));
    288         EXPECT_EQ(E, Triple::normalize(Join(C[2], C[1], C[0])));
    289 
    290         for (int Env = 1 + Triple::UnknownEnvironment; Env <= Triple::LastEnvironmentType;
    291              ++Env) {
    292           C[3] = Triple::getEnvironmentTypeName(Triple::EnvironmentType(Env));
    293 
    294           std::string F = Join(C[0], C[1], C[2], C[3]);
    295           EXPECT_EQ(F, Triple::normalize(Join(C[0], C[1], C[2], C[3])));
    296 
    297           EXPECT_EQ(F, Triple::normalize(Join(C[0], C[1], C[3], C[2])));
    298           EXPECT_EQ(F, Triple::normalize(Join(C[0], C[2], C[3], C[1])));
    299           EXPECT_EQ(F, Triple::normalize(Join(C[0], C[2], C[1], C[3])));
    300           EXPECT_EQ(F, Triple::normalize(Join(C[0], C[3], C[1], C[2])));
    301           EXPECT_EQ(F, Triple::normalize(Join(C[0], C[3], C[2], C[1])));
    302           EXPECT_EQ(F, Triple::normalize(Join(C[1], C[2], C[3], C[0])));
    303           EXPECT_EQ(F, Triple::normalize(Join(C[1], C[2], C[0], C[3])));
    304           EXPECT_EQ(F, Triple::normalize(Join(C[1], C[3], C[0], C[2])));
    305           EXPECT_EQ(F, Triple::normalize(Join(C[1], C[3], C[2], C[0])));
    306           EXPECT_EQ(F, Triple::normalize(Join(C[1], C[0], C[2], C[3])));
    307           EXPECT_EQ(F, Triple::normalize(Join(C[1], C[0], C[3], C[2])));
    308           EXPECT_EQ(F, Triple::normalize(Join(C[2], C[3], C[0], C[1])));
    309           EXPECT_EQ(F, Triple::normalize(Join(C[2], C[3], C[1], C[0])));
    310           EXPECT_EQ(F, Triple::normalize(Join(C[2], C[0], C[1], C[3])));
    311           EXPECT_EQ(F, Triple::normalize(Join(C[2], C[0], C[3], C[1])));
    312           EXPECT_EQ(F, Triple::normalize(Join(C[2], C[1], C[3], C[0])));
    313           EXPECT_EQ(F, Triple::normalize(Join(C[2], C[1], C[0], C[3])));
    314           EXPECT_EQ(F, Triple::normalize(Join(C[3], C[0], C[1], C[2])));
    315           EXPECT_EQ(F, Triple::normalize(Join(C[3], C[0], C[2], C[1])));
    316           EXPECT_EQ(F, Triple::normalize(Join(C[3], C[1], C[2], C[0])));
    317           EXPECT_EQ(F, Triple::normalize(Join(C[3], C[1], C[0], C[2])));
    318           EXPECT_EQ(F, Triple::normalize(Join(C[3], C[2], C[0], C[1])));
    319           EXPECT_EQ(F, Triple::normalize(Join(C[3], C[2], C[1], C[0])));
    320         }
    321       }
    322     }
    323   }
    324 
    325   // Various real-world funky triples.  The value returned by GCC's config.sub
    326   // is given in the comment.
    327   EXPECT_EQ("i386--windows-gnu", Triple::normalize("i386-mingw32")); // i386-pc-mingw32
    328   EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-linux-gnu")); // x86_64-pc-linux-gnu
    329   EXPECT_EQ("i486--linux-gnu", Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu
    330   EXPECT_EQ("i386-redhat-linux", Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu
    331   EXPECT_EQ("i686--linux", Triple::normalize("i686-linux")); // i686-pc-linux-gnu
    332   EXPECT_EQ("arm-none--eabi", Triple::normalize("arm-none-eabi")); // arm-none-eabi
    333 }
    334 
    335 TEST(TripleTest, MutateName) {
    336   Triple T;
    337   EXPECT_EQ(Triple::UnknownArch, T.getArch());
    338   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
    339   EXPECT_EQ(Triple::UnknownOS, T.getOS());
    340   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
    341 
    342   T.setArchName("i386");
    343   EXPECT_EQ(Triple::x86, T.getArch());
    344   EXPECT_EQ("i386--", T.getTriple());
    345 
    346   T.setVendorName("pc");
    347   EXPECT_EQ(Triple::x86, T.getArch());
    348   EXPECT_EQ(Triple::PC, T.getVendor());
    349   EXPECT_EQ("i386-pc-", T.getTriple());
    350 
    351   T.setOSName("linux");
    352   EXPECT_EQ(Triple::x86, T.getArch());
    353   EXPECT_EQ(Triple::PC, T.getVendor());
    354   EXPECT_EQ(Triple::Linux, T.getOS());
    355   EXPECT_EQ("i386-pc-linux", T.getTriple());
    356 
    357   T.setEnvironmentName("gnu");
    358   EXPECT_EQ(Triple::x86, T.getArch());
    359   EXPECT_EQ(Triple::PC, T.getVendor());
    360   EXPECT_EQ(Triple::Linux, T.getOS());
    361   EXPECT_EQ("i386-pc-linux-gnu", T.getTriple());
    362 
    363   T.setOSName("freebsd");
    364   EXPECT_EQ(Triple::x86, T.getArch());
    365   EXPECT_EQ(Triple::PC, T.getVendor());
    366   EXPECT_EQ(Triple::FreeBSD, T.getOS());
    367   EXPECT_EQ("i386-pc-freebsd-gnu", T.getTriple());
    368 
    369   T.setOSAndEnvironmentName("darwin");
    370   EXPECT_EQ(Triple::x86, T.getArch());
    371   EXPECT_EQ(Triple::PC, T.getVendor());
    372   EXPECT_EQ(Triple::Darwin, T.getOS());
    373   EXPECT_EQ("i386-pc-darwin", T.getTriple());
    374 
    375   T.setEnvironmentName("amdopencl");
    376   EXPECT_EQ(Triple::AMDOpenCL, T.getEnvironment());
    377 }
    378 
    379 TEST(TripleTest, BitWidthPredicates) {
    380   Triple T;
    381   EXPECT_FALSE(T.isArch16Bit());
    382   EXPECT_FALSE(T.isArch32Bit());
    383   EXPECT_FALSE(T.isArch64Bit());
    384 
    385   T.setArch(Triple::arm);
    386   EXPECT_FALSE(T.isArch16Bit());
    387   EXPECT_TRUE(T.isArch32Bit());
    388   EXPECT_FALSE(T.isArch64Bit());
    389 
    390   T.setArch(Triple::hexagon);
    391   EXPECT_FALSE(T.isArch16Bit());
    392   EXPECT_TRUE(T.isArch32Bit());
    393   EXPECT_FALSE(T.isArch64Bit());
    394 
    395   T.setArch(Triple::mips);
    396   EXPECT_FALSE(T.isArch16Bit());
    397   EXPECT_TRUE(T.isArch32Bit());
    398   EXPECT_FALSE(T.isArch64Bit());
    399 
    400   T.setArch(Triple::mips64);
    401   EXPECT_FALSE(T.isArch16Bit());
    402   EXPECT_FALSE(T.isArch32Bit());
    403   EXPECT_TRUE(T.isArch64Bit());
    404 
    405   T.setArch(Triple::msp430);
    406   EXPECT_TRUE(T.isArch16Bit());
    407   EXPECT_FALSE(T.isArch32Bit());
    408   EXPECT_FALSE(T.isArch64Bit());
    409 
    410   T.setArch(Triple::ppc);
    411   EXPECT_FALSE(T.isArch16Bit());
    412   EXPECT_TRUE(T.isArch32Bit());
    413   EXPECT_FALSE(T.isArch64Bit());
    414 
    415   T.setArch(Triple::ppc64);
    416   EXPECT_FALSE(T.isArch16Bit());
    417   EXPECT_FALSE(T.isArch32Bit());
    418   EXPECT_TRUE(T.isArch64Bit());
    419 
    420   T.setArch(Triple::x86);
    421   EXPECT_FALSE(T.isArch16Bit());
    422   EXPECT_TRUE(T.isArch32Bit());
    423   EXPECT_FALSE(T.isArch64Bit());
    424 
    425   T.setArch(Triple::x86_64);
    426   EXPECT_FALSE(T.isArch16Bit());
    427   EXPECT_FALSE(T.isArch32Bit());
    428   EXPECT_TRUE(T.isArch64Bit());
    429 
    430   T.setArch(Triple::amdil);
    431   EXPECT_FALSE(T.isArch16Bit());
    432   EXPECT_TRUE(T.isArch32Bit());
    433   EXPECT_FALSE(T.isArch64Bit());
    434 
    435   T.setArch(Triple::amdil64);
    436   EXPECT_FALSE(T.isArch16Bit());
    437   EXPECT_FALSE(T.isArch32Bit());
    438   EXPECT_TRUE(T.isArch64Bit());
    439 
    440   T.setArch(Triple::hsail);
    441   EXPECT_FALSE(T.isArch16Bit());
    442   EXPECT_TRUE(T.isArch32Bit());
    443   EXPECT_FALSE(T.isArch64Bit());
    444 
    445   T.setArch(Triple::hsail64);
    446   EXPECT_FALSE(T.isArch16Bit());
    447   EXPECT_FALSE(T.isArch32Bit());
    448   EXPECT_TRUE(T.isArch64Bit());
    449 
    450   T.setArch(Triple::spir);
    451   EXPECT_FALSE(T.isArch16Bit());
    452   EXPECT_TRUE(T.isArch32Bit());
    453   EXPECT_FALSE(T.isArch64Bit());
    454 
    455   T.setArch(Triple::spir64);
    456   EXPECT_FALSE(T.isArch16Bit());
    457   EXPECT_FALSE(T.isArch32Bit());
    458   EXPECT_TRUE(T.isArch64Bit());
    459 
    460   T.setArch(Triple::sparc);
    461   EXPECT_FALSE(T.isArch16Bit());
    462   EXPECT_TRUE(T.isArch32Bit());
    463   EXPECT_FALSE(T.isArch64Bit());
    464 
    465   T.setArch(Triple::sparcel);
    466   EXPECT_FALSE(T.isArch16Bit());
    467   EXPECT_TRUE(T.isArch32Bit());
    468   EXPECT_FALSE(T.isArch64Bit());
    469 
    470   T.setArch(Triple::sparcv9);
    471   EXPECT_FALSE(T.isArch16Bit());
    472   EXPECT_FALSE(T.isArch32Bit());
    473   EXPECT_TRUE(T.isArch64Bit());
    474 
    475   T.setArch(Triple::wasm32);
    476   EXPECT_FALSE(T.isArch16Bit());
    477   EXPECT_TRUE(T.isArch32Bit());
    478   EXPECT_FALSE(T.isArch64Bit());
    479 
    480   T.setArch(Triple::wasm64);
    481   EXPECT_FALSE(T.isArch16Bit());
    482   EXPECT_FALSE(T.isArch32Bit());
    483   EXPECT_TRUE(T.isArch64Bit());
    484 
    485   T.setArch(Triple::avr);
    486   EXPECT_TRUE(T.isArch16Bit());
    487   EXPECT_FALSE(T.isArch32Bit());
    488   EXPECT_FALSE(T.isArch64Bit());
    489 }
    490 
    491 TEST(TripleTest, BitWidthArchVariants) {
    492   Triple T;
    493   EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
    494   EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
    495 
    496   T.setArch(Triple::UnknownArch);
    497   EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
    498   EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
    499 
    500   T.setArch(Triple::mips);
    501   EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
    502   EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
    503 
    504   T.setArch(Triple::mipsel);
    505   EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
    506   EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
    507 
    508   T.setArch(Triple::ppc);
    509   EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
    510   EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
    511 
    512   T.setArch(Triple::nvptx);
    513   EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
    514   EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
    515 
    516   T.setArch(Triple::sparc);
    517   EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
    518   EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
    519 
    520   T.setArch(Triple::x86);
    521   EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
    522   EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
    523 
    524   T.setArch(Triple::mips64);
    525   EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
    526   EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
    527 
    528   T.setArch(Triple::mips64el);
    529   EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
    530   EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
    531 
    532   T.setArch(Triple::ppc64);
    533   EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
    534   EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
    535 
    536   T.setArch(Triple::nvptx64);
    537   EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
    538   EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
    539 
    540   T.setArch(Triple::sparcv9);
    541   EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
    542   EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
    543 
    544   T.setArch(Triple::x86_64);
    545   EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
    546   EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
    547 
    548   T.setArch(Triple::amdil);
    549   EXPECT_EQ(Triple::amdil, T.get32BitArchVariant().getArch());
    550   EXPECT_EQ(Triple::amdil64, T.get64BitArchVariant().getArch());
    551 
    552   T.setArch(Triple::amdil64);
    553   EXPECT_EQ(Triple::amdil, T.get32BitArchVariant().getArch());
    554   EXPECT_EQ(Triple::amdil64, T.get64BitArchVariant().getArch());
    555 
    556   T.setArch(Triple::hsail);
    557   EXPECT_EQ(Triple::hsail, T.get32BitArchVariant().getArch());
    558   EXPECT_EQ(Triple::hsail64, T.get64BitArchVariant().getArch());
    559 
    560   T.setArch(Triple::hsail64);
    561   EXPECT_EQ(Triple::hsail, T.get32BitArchVariant().getArch());
    562   EXPECT_EQ(Triple::hsail64, T.get64BitArchVariant().getArch());
    563 
    564   T.setArch(Triple::spir);
    565   EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
    566   EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
    567 
    568   T.setArch(Triple::spir64);
    569   EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
    570   EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
    571 
    572   T.setArch(Triple::wasm32);
    573   EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
    574   EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
    575 
    576   T.setArch(Triple::wasm64);
    577   EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
    578   EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
    579 }
    580 
    581 TEST(TripleTest, EndianArchVariants) {
    582   Triple T;
    583   EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
    584   EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
    585 
    586   T.setArch(Triple::UnknownArch);
    587   EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
    588   EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
    589 
    590   T.setArch(Triple::aarch64_be);
    591   EXPECT_EQ(Triple::aarch64_be, T.getBigEndianArchVariant().getArch());
    592   EXPECT_EQ(Triple::aarch64, T.getLittleEndianArchVariant().getArch());
    593 
    594   T.setArch(Triple::aarch64);
    595   EXPECT_EQ(Triple::aarch64_be, T.getBigEndianArchVariant().getArch());
    596   EXPECT_EQ(Triple::aarch64, T.getLittleEndianArchVariant().getArch());
    597 
    598   T.setArch(Triple::armeb);
    599   EXPECT_EQ(Triple::armeb, T.getBigEndianArchVariant().getArch());
    600   EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
    601 
    602   T.setArch(Triple::arm);
    603   EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
    604   EXPECT_EQ(Triple::arm, T.getLittleEndianArchVariant().getArch());
    605 
    606   T.setArch(Triple::bpfeb);
    607   EXPECT_EQ(Triple::bpfeb, T.getBigEndianArchVariant().getArch());
    608   EXPECT_EQ(Triple::bpfel, T.getLittleEndianArchVariant().getArch());
    609 
    610   T.setArch(Triple::bpfel);
    611   EXPECT_EQ(Triple::bpfeb, T.getBigEndianArchVariant().getArch());
    612   EXPECT_EQ(Triple::bpfel, T.getLittleEndianArchVariant().getArch());
    613 
    614   T.setArch(Triple::mips64);
    615   EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
    616   EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
    617 
    618   T.setArch(Triple::mips64el);
    619   EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
    620   EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
    621 
    622   T.setArch(Triple::mips);
    623   EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
    624   EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
    625 
    626   T.setArch(Triple::mipsel);
    627   EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
    628   EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
    629 
    630   T.setArch(Triple::ppc);
    631   EXPECT_EQ(Triple::ppc, T.getBigEndianArchVariant().getArch());
    632   EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
    633 
    634   T.setArch(Triple::ppc64);
    635   EXPECT_EQ(Triple::ppc64, T.getBigEndianArchVariant().getArch());
    636   EXPECT_EQ(Triple::ppc64le, T.getLittleEndianArchVariant().getArch());
    637 
    638   T.setArch(Triple::ppc64le);
    639   EXPECT_EQ(Triple::ppc64, T.getBigEndianArchVariant().getArch());
    640   EXPECT_EQ(Triple::ppc64le, T.getLittleEndianArchVariant().getArch());
    641 
    642   T.setArch(Triple::sparc);
    643   EXPECT_EQ(Triple::sparc, T.getBigEndianArchVariant().getArch());
    644   EXPECT_EQ(Triple::sparcel, T.getLittleEndianArchVariant().getArch());
    645 
    646   T.setArch(Triple::sparcel);
    647   EXPECT_EQ(Triple::sparc, T.getBigEndianArchVariant().getArch());
    648   EXPECT_EQ(Triple::sparcel, T.getLittleEndianArchVariant().getArch());
    649 
    650   T.setArch(Triple::thumb);
    651   EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
    652   EXPECT_EQ(Triple::thumb, T.getLittleEndianArchVariant().getArch());
    653 
    654   T.setArch(Triple::thumbeb);
    655   EXPECT_EQ(Triple::thumbeb, T.getBigEndianArchVariant().getArch());
    656   EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
    657 }
    658 
    659 TEST(TripleTest, getOSVersion) {
    660   Triple T;
    661   unsigned Major, Minor, Micro;
    662 
    663   T = Triple("i386-apple-darwin9");
    664   EXPECT_TRUE(T.isMacOSX());
    665   EXPECT_FALSE(T.isiOS());
    666   EXPECT_FALSE(T.isArch16Bit());
    667   EXPECT_TRUE(T.isArch32Bit());
    668   EXPECT_FALSE(T.isArch64Bit());
    669   T.getMacOSXVersion(Major, Minor, Micro);
    670   EXPECT_EQ((unsigned)10, Major);
    671   EXPECT_EQ((unsigned)5, Minor);
    672   EXPECT_EQ((unsigned)0, Micro);
    673   T.getiOSVersion(Major, Minor, Micro);
    674   EXPECT_EQ((unsigned)5, Major);
    675   EXPECT_EQ((unsigned)0, Minor);
    676   EXPECT_EQ((unsigned)0, Micro);
    677 
    678   T = Triple("x86_64-apple-darwin9");
    679   EXPECT_TRUE(T.isMacOSX());
    680   EXPECT_FALSE(T.isiOS());
    681   EXPECT_FALSE(T.isArch16Bit());
    682   EXPECT_FALSE(T.isArch32Bit());
    683   EXPECT_TRUE(T.isArch64Bit());
    684   T.getMacOSXVersion(Major, Minor, Micro);
    685   EXPECT_EQ((unsigned)10, Major);
    686   EXPECT_EQ((unsigned)5, Minor);
    687   EXPECT_EQ((unsigned)0, Micro);
    688   T.getiOSVersion(Major, Minor, Micro);
    689   EXPECT_EQ((unsigned)5, Major);
    690   EXPECT_EQ((unsigned)0, Minor);
    691   EXPECT_EQ((unsigned)0, Micro);
    692 
    693   T = Triple("x86_64-apple-macosx");
    694   EXPECT_TRUE(T.isMacOSX());
    695   EXPECT_FALSE(T.isiOS());
    696   EXPECT_FALSE(T.isArch16Bit());
    697   EXPECT_FALSE(T.isArch32Bit());
    698   EXPECT_TRUE(T.isArch64Bit());
    699   T.getMacOSXVersion(Major, Minor, Micro);
    700   EXPECT_EQ((unsigned)10, Major);
    701   EXPECT_EQ((unsigned)4, Minor);
    702   EXPECT_EQ((unsigned)0, Micro);
    703   T.getiOSVersion(Major, Minor, Micro);
    704   EXPECT_EQ((unsigned)5, Major);
    705   EXPECT_EQ((unsigned)0, Minor);
    706   EXPECT_EQ((unsigned)0, Micro);
    707 
    708   T = Triple("x86_64-apple-macosx10.7");
    709   EXPECT_TRUE(T.isMacOSX());
    710   EXPECT_FALSE(T.isiOS());
    711   EXPECT_FALSE(T.isArch16Bit());
    712   EXPECT_FALSE(T.isArch32Bit());
    713   EXPECT_TRUE(T.isArch64Bit());
    714   T.getMacOSXVersion(Major, Minor, Micro);
    715   EXPECT_EQ((unsigned)10, Major);
    716   EXPECT_EQ((unsigned)7, Minor);
    717   EXPECT_EQ((unsigned)0, Micro);
    718   T.getiOSVersion(Major, Minor, Micro);
    719   EXPECT_EQ((unsigned)5, Major);
    720   EXPECT_EQ((unsigned)0, Minor);
    721   EXPECT_EQ((unsigned)0, Micro);
    722 
    723   T = Triple("armv7-apple-ios");
    724   EXPECT_FALSE(T.isMacOSX());
    725   EXPECT_TRUE(T.isiOS());
    726   EXPECT_FALSE(T.isArch16Bit());
    727   EXPECT_TRUE(T.isArch32Bit());
    728   EXPECT_FALSE(T.isArch64Bit());
    729   T.getMacOSXVersion(Major, Minor, Micro);
    730   EXPECT_EQ((unsigned)10, Major);
    731   EXPECT_EQ((unsigned)4, Minor);
    732   EXPECT_EQ((unsigned)0, Micro);
    733   T.getiOSVersion(Major, Minor, Micro);
    734   EXPECT_EQ((unsigned)5, Major);
    735   EXPECT_EQ((unsigned)0, Minor);
    736   EXPECT_EQ((unsigned)0, Micro);
    737 
    738   T = Triple("armv7-apple-ios7.0");
    739   EXPECT_FALSE(T.isMacOSX());
    740   EXPECT_TRUE(T.isiOS());
    741   EXPECT_FALSE(T.isArch16Bit());
    742   EXPECT_TRUE(T.isArch32Bit());
    743   EXPECT_FALSE(T.isArch64Bit());
    744   T.getMacOSXVersion(Major, Minor, Micro);
    745   EXPECT_EQ((unsigned)10, Major);
    746   EXPECT_EQ((unsigned)4, Minor);
    747   EXPECT_EQ((unsigned)0, Micro);
    748   T.getiOSVersion(Major, Minor, Micro);
    749   EXPECT_EQ((unsigned)7, Major);
    750   EXPECT_EQ((unsigned)0, Minor);
    751   EXPECT_EQ((unsigned)0, Micro);
    752 }
    753 
    754 TEST(TripleTest, FileFormat) {
    755   EXPECT_EQ(Triple::ELF, Triple("i686-unknown-linux-gnu").getObjectFormat());
    756   EXPECT_EQ(Triple::ELF, Triple("i686-unknown-freebsd").getObjectFormat());
    757   EXPECT_EQ(Triple::ELF, Triple("i686-unknown-netbsd").getObjectFormat());
    758   EXPECT_EQ(Triple::ELF, Triple("i686--win32-elf").getObjectFormat());
    759   EXPECT_EQ(Triple::ELF, Triple("i686---elf").getObjectFormat());
    760 
    761   EXPECT_EQ(Triple::MachO, Triple("i686-apple-macosx").getObjectFormat());
    762   EXPECT_EQ(Triple::MachO, Triple("i686-apple-ios").getObjectFormat());
    763   EXPECT_EQ(Triple::MachO, Triple("i686---macho").getObjectFormat());
    764 
    765   EXPECT_EQ(Triple::COFF, Triple("i686--win32").getObjectFormat());
    766 
    767   EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
    768   EXPECT_EQ(Triple::ELF, Triple("i686-pc-cygwin-elf").getObjectFormat());
    769 
    770   Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
    771   EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
    772 
    773   Triple GNUWindowsNormalized(Triple::normalize("i686-pc-windows-gnu-elf"));
    774   EXPECT_EQ(Triple::ELF, GNUWindowsNormalized.getObjectFormat());
    775 
    776   Triple CygnusNormalised(Triple::normalize("i686-pc-windows-cygnus-elf"));
    777   EXPECT_EQ(Triple::ELF, CygnusNormalised.getObjectFormat());
    778 
    779   Triple CygwinNormalized(Triple::normalize("i686-pc-cygwin-elf"));
    780   EXPECT_EQ(Triple::ELF, CygwinNormalized.getObjectFormat());
    781 
    782   Triple T = Triple("");
    783   T.setObjectFormat(Triple::ELF);
    784   EXPECT_EQ(Triple::ELF, T.getObjectFormat());
    785 }
    786 
    787 TEST(TripleTest, NormalizeWindows) {
    788   EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-win32"));
    789   EXPECT_EQ("i686--windows-msvc", Triple::normalize("i686-win32"));
    790   EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32"));
    791   EXPECT_EQ("i686--windows-gnu", Triple::normalize("i686-mingw32"));
    792   EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32-w64"));
    793   EXPECT_EQ("i686--windows-gnu", Triple::normalize("i686-mingw32-w64"));
    794   EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-cygwin"));
    795   EXPECT_EQ("i686--windows-cygnus", Triple::normalize("i686-cygwin"));
    796 
    797   EXPECT_EQ("x86_64-pc-windows-msvc", Triple::normalize("x86_64-pc-win32"));
    798   EXPECT_EQ("x86_64--windows-msvc", Triple::normalize("x86_64-win32"));
    799   EXPECT_EQ("x86_64-pc-windows-gnu", Triple::normalize("x86_64-pc-mingw32"));
    800   EXPECT_EQ("x86_64--windows-gnu", Triple::normalize("x86_64-mingw32"));
    801   EXPECT_EQ("x86_64-pc-windows-gnu", Triple::normalize("x86_64-pc-mingw32-w64"));
    802   EXPECT_EQ("x86_64--windows-gnu", Triple::normalize("x86_64-mingw32-w64"));
    803 
    804   EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-win32-elf"));
    805   EXPECT_EQ("i686--windows-elf", Triple::normalize("i686-win32-elf"));
    806   EXPECT_EQ("i686-pc-windows-macho", Triple::normalize("i686-pc-win32-macho"));
    807   EXPECT_EQ("i686--windows-macho", Triple::normalize("i686-win32-macho"));
    808 
    809   EXPECT_EQ("x86_64-pc-windows-elf", Triple::normalize("x86_64-pc-win32-elf"));
    810   EXPECT_EQ("x86_64--windows-elf", Triple::normalize("x86_64-win32-elf"));
    811   EXPECT_EQ("x86_64-pc-windows-macho", Triple::normalize("x86_64-pc-win32-macho"));
    812   EXPECT_EQ("x86_64--windows-macho", Triple::normalize("x86_64-win32-macho"));
    813 
    814   EXPECT_EQ("i686-pc-windows-cygnus",
    815             Triple::normalize("i686-pc-windows-cygnus"));
    816   EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-windows-gnu"));
    817   EXPECT_EQ("i686-pc-windows-itanium", Triple::normalize("i686-pc-windows-itanium"));
    818   EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-windows-msvc"));
    819 
    820   EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-windows-elf-elf"));
    821 }
    822 
    823 TEST(TripleTest, getARMCPUForArch) {
    824   // Standard ARM Architectures.
    825   {
    826     llvm::Triple Triple("armv4-unknown-eabi");
    827     EXPECT_EQ("strongarm", Triple.getARMCPUForArch());
    828   }
    829   {
    830     llvm::Triple Triple("armv4t-unknown-eabi");
    831     EXPECT_EQ("arm7tdmi", Triple.getARMCPUForArch());
    832   }
    833   {
    834     llvm::Triple Triple("armv5-unknown-eabi");
    835     EXPECT_EQ("arm10tdmi", Triple.getARMCPUForArch());
    836   }
    837   {
    838     llvm::Triple Triple("armv5t-unknown-eabi");
    839     EXPECT_EQ("arm10tdmi", Triple.getARMCPUForArch());
    840   }
    841   {
    842     llvm::Triple Triple("armv5e-unknown-eabi");
    843     EXPECT_EQ("arm1022e", Triple.getARMCPUForArch());
    844   }
    845   {
    846     llvm::Triple Triple("armv5tej-unknown-eabi");
    847     EXPECT_EQ("arm926ej-s", Triple.getARMCPUForArch());
    848   }
    849   {
    850     llvm::Triple Triple("armv6-unknown-eabi");
    851     EXPECT_EQ("arm1136jf-s", Triple.getARMCPUForArch());
    852   }
    853   {
    854     llvm::Triple Triple("armv6j-unknown-eabi");
    855     EXPECT_EQ("arm1136jf-s", Triple.getARMCPUForArch());
    856   }
    857   {
    858     llvm::Triple Triple("armv6k-unknown-eabi");
    859     EXPECT_EQ("arm1176j-s", Triple.getARMCPUForArch());
    860   }
    861   {
    862     llvm::Triple Triple("armv6kz-unknown-eabi");
    863     EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
    864   }
    865   {
    866     llvm::Triple Triple("armv6zk-unknown-eabi");
    867     EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
    868   }
    869   {
    870     llvm::Triple Triple("armv6t2-unknown-eabi");
    871     EXPECT_EQ("arm1156t2-s", Triple.getARMCPUForArch());
    872   }
    873   {
    874     llvm::Triple Triple("armv6m-unknown-eabi");
    875     EXPECT_EQ("cortex-m0", Triple.getARMCPUForArch());
    876   }
    877   {
    878     llvm::Triple Triple("armv7-unknown-eabi");
    879     EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
    880   }
    881   {
    882     llvm::Triple Triple("armv7a-unknown-eabi");
    883     EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
    884   }
    885   {
    886     llvm::Triple Triple("armv7m-unknown-eabi");
    887     EXPECT_EQ("cortex-m3", Triple.getARMCPUForArch());
    888   }
    889   {
    890     llvm::Triple Triple("armv7r-unknown-eabi");
    891     EXPECT_EQ("cortex-r4", Triple.getARMCPUForArch());
    892   }
    893   {
    894     llvm::Triple Triple("armv7r-unknown-eabi");
    895     EXPECT_EQ("cortex-r4", Triple.getARMCPUForArch());
    896   }
    897   {
    898     llvm::Triple Triple("armv7r-unknown-eabi");
    899     EXPECT_EQ("cortex-r4", Triple.getARMCPUForArch());
    900   }
    901   {
    902     llvm::Triple Triple("armv7r-unknown-eabi");
    903     EXPECT_EQ("cortex-r4", Triple.getARMCPUForArch());
    904   }
    905   {
    906     llvm::Triple Triple("armv8a-unknown-eabi");
    907     EXPECT_EQ("cortex-a53", Triple.getARMCPUForArch());
    908   }
    909   {
    910     llvm::Triple Triple("armv8.1a-unknown-eabi");
    911     EXPECT_EQ("generic", Triple.getARMCPUForArch());
    912   }
    913   // Non-synonym names, using -march style, not default arch.
    914   {
    915     llvm::Triple Triple("arm");
    916     EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch("armv7-a"));
    917   }
    918   {
    919     llvm::Triple Triple("arm");
    920     EXPECT_EQ("cortex-m3", Triple.getARMCPUForArch("armv7-m"));
    921   }
    922   {
    923     llvm::Triple Triple("arm");
    924     EXPECT_EQ("cortex-a53", Triple.getARMCPUForArch("armv8"));
    925   }
    926   {
    927     llvm::Triple Triple("arm");
    928     EXPECT_EQ("cortex-a53", Triple.getARMCPUForArch("armv8-a"));
    929   }
    930   // Platform specific defaults.
    931   {
    932     llvm::Triple Triple("arm--nacl");
    933     EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
    934   }
    935   {
    936     llvm::Triple Triple("armv6-unknown-freebsd");
    937     EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
    938   }
    939   {
    940     llvm::Triple Triple("thumbv6-unknown-freebsd");
    941     EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
    942   }
    943   {
    944     llvm::Triple Triple("armebv6-unknown-freebsd");
    945     EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
    946   }
    947   {
    948     llvm::Triple Triple("arm--win32");
    949     EXPECT_EQ("cortex-a9", Triple.getARMCPUForArch());
    950   }
    951   // Some alternative architectures
    952   {
    953     llvm::Triple Triple("xscale-unknown-eabi");
    954     EXPECT_EQ("xscale", Triple.getARMCPUForArch());
    955   }
    956   {
    957     llvm::Triple Triple("iwmmxt-unknown-eabi");
    958     EXPECT_EQ("iwmmxt", Triple.getARMCPUForArch());
    959   }
    960   {
    961     llvm::Triple Triple("armv7s-apple-ios7");
    962     EXPECT_EQ("swift", Triple.getARMCPUForArch());
    963   }
    964   {
    965     llvm::Triple Triple("armv7em-apple-ios7");
    966     EXPECT_EQ("cortex-m4", Triple.getARMCPUForArch());
    967   }
    968   {
    969     llvm::Triple Triple("armv7l-linux-gnueabihf");
    970     EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
    971   }
    972   {
    973     llvm::Triple Triple("armv6sm-apple-ios7");
    974     EXPECT_EQ("cortex-m0", Triple.getARMCPUForArch());
    975   }
    976   // armeb is permitted, but armebeb is not
    977   {
    978     llvm::Triple Triple("armeb-none-eabi");
    979     EXPECT_EQ("arm7tdmi", Triple.getARMCPUForArch());
    980   }
    981   {
    982     llvm::Triple Triple("armebeb-none-eabi");
    983     EXPECT_EQ("", Triple.getARMCPUForArch());
    984   }
    985   {
    986     llvm::Triple Triple("armebv6eb-none-eabi");
    987     EXPECT_EQ("", Triple.getARMCPUForArch());
    988   }
    989   // armebv6 and armv6eb are permitted, but armebv6eb is not
    990   {
    991     llvm::Triple Triple("armebv6-non-eabi");
    992     EXPECT_EQ("arm1136jf-s", Triple.getARMCPUForArch());
    993   }
    994   {
    995     llvm::Triple Triple("armv6eb-none-eabi");
    996     EXPECT_EQ("arm1136jf-s", Triple.getARMCPUForArch());
    997   }
    998   // xscaleeb is permitted, but armebxscale is not
    999   {
   1000     llvm::Triple Triple("xscaleeb-none-eabi");
   1001     EXPECT_EQ("xscale", Triple.getARMCPUForArch());
   1002   }
   1003   {
   1004     llvm::Triple Triple("armebxscale-none-eabi");
   1005     EXPECT_EQ("", Triple.getARMCPUForArch());
   1006   }
   1007 }
   1008 
   1009 TEST(TripleTest, NormalizeARM) {
   1010   EXPECT_EQ("armv6--netbsd-eabi", Triple::normalize("armv6-netbsd-eabi"));
   1011   EXPECT_EQ("armv7--netbsd-eabi", Triple::normalize("armv7-netbsd-eabi"));
   1012   EXPECT_EQ("armv6eb--netbsd-eabi", Triple::normalize("armv6eb-netbsd-eabi"));
   1013   EXPECT_EQ("armv7eb--netbsd-eabi", Triple::normalize("armv7eb-netbsd-eabi"));
   1014   EXPECT_EQ("armv6--netbsd-eabihf", Triple::normalize("armv6-netbsd-eabihf"));
   1015   EXPECT_EQ("armv7--netbsd-eabihf", Triple::normalize("armv7-netbsd-eabihf"));
   1016   EXPECT_EQ("armv6eb--netbsd-eabihf", Triple::normalize("armv6eb-netbsd-eabihf"));
   1017   EXPECT_EQ("armv7eb--netbsd-eabihf", Triple::normalize("armv7eb-netbsd-eabihf"));
   1018 
   1019   Triple T;
   1020   T = Triple("armv6--netbsd-eabi");
   1021   EXPECT_EQ(Triple::arm, T.getArch());
   1022   T = Triple("armv6eb--netbsd-eabi");
   1023   EXPECT_EQ(Triple::armeb, T.getArch());
   1024 }
   1025 
   1026 TEST(TripleTest, ParseARMArch) {
   1027   // ARM
   1028   {
   1029     Triple T = Triple("arm");
   1030     EXPECT_EQ(Triple::arm, T.getArch());
   1031   }
   1032   {
   1033     Triple T = Triple("armv6t2");
   1034     EXPECT_EQ(Triple::arm, T.getArch());
   1035   }
   1036   {
   1037     Triple T = Triple("armv8");
   1038     EXPECT_EQ(Triple::arm, T.getArch());
   1039   }
   1040   {
   1041     Triple T = Triple("armeb");
   1042     EXPECT_EQ(Triple::armeb, T.getArch());
   1043   }
   1044   {
   1045     Triple T = Triple("armv5eb");
   1046     EXPECT_EQ(Triple::armeb, T.getArch());
   1047   }
   1048   {
   1049     Triple T = Triple("armebv7m");
   1050     EXPECT_EQ(Triple::armeb, T.getArch());
   1051   }
   1052   {
   1053     Triple T = Triple("armv7eb");
   1054     EXPECT_EQ(Triple::armeb, T.getArch());
   1055   }
   1056   // THUMB
   1057   {
   1058     Triple T = Triple("thumb");
   1059     EXPECT_EQ(Triple::thumb, T.getArch());
   1060   }
   1061   {
   1062     Triple T = Triple("thumbv7a");
   1063     EXPECT_EQ(Triple::thumb, T.getArch());
   1064   }
   1065   {
   1066     Triple T = Triple("thumbeb");
   1067     EXPECT_EQ(Triple::thumbeb, T.getArch());
   1068   }
   1069   {
   1070     Triple T = Triple("thumbv4teb");
   1071     EXPECT_EQ(Triple::thumbeb, T.getArch());
   1072   }
   1073   {
   1074     Triple T = Triple("thumbebv7");
   1075     EXPECT_EQ(Triple::thumbeb, T.getArch());
   1076   }
   1077   {
   1078     Triple T = Triple("armv6m");
   1079     EXPECT_EQ(Triple::thumb, T.getArch());
   1080   }
   1081   {
   1082     Triple T = Triple("thumbv2");
   1083     EXPECT_EQ(Triple::UnknownArch, T.getArch());
   1084   }
   1085   {
   1086     Triple T = Triple("thumbebv6eb");
   1087     EXPECT_EQ(Triple::UnknownArch, T.getArch());
   1088   }
   1089   // AARCH64
   1090   {
   1091     Triple T = Triple("arm64");
   1092     EXPECT_EQ(Triple::aarch64, T.getArch());
   1093   }
   1094   {
   1095     Triple T = Triple("aarch64");
   1096     EXPECT_EQ(Triple::aarch64, T.getArch());
   1097   }
   1098   {
   1099     Triple T = Triple("aarch64_be");
   1100     EXPECT_EQ(Triple::aarch64_be, T.getArch());
   1101   }
   1102   {
   1103     Triple T = Triple("aarch64be");
   1104     EXPECT_EQ(Triple::UnknownArch, T.getArch());
   1105   }
   1106   {
   1107     Triple T = Triple("arm64be");
   1108     EXPECT_EQ(Triple::UnknownArch, T.getArch());
   1109   }
   1110 }
   1111 } // end anonymous namespace
   1112