123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//===----------- Triple.cpp - Triple unit tests ---------------------------===//
223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//
323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//                     The LLVM Compiler Infrastructure
423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//
523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar// This file is distributed under the University of Illinois Open Source
623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar// License. See LICENSE.TXT for details.
723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//
823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar//===----------------------------------------------------------------------===//
923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
1023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar#include "gtest/gtest.h"
1123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar#include "llvm/ADT/Triple.h"
1223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
1323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbarusing namespace llvm;
1423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
1523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbarnamespace {
1623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
1723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel DunbarTEST(TripleTest, BasicParsing) {
1823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  Triple T;
1923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
2023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("");
21a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getArchName().str());
22a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getVendorName().str());
23a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getOSName().str());
24a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getEnvironmentName().str());
2523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
2623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("-");
27a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getArchName().str());
28a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getVendorName().str());
29a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getOSName().str());
30a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getEnvironmentName().str());
3123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
3223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("--");
33a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getArchName().str());
34a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getVendorName().str());
35a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getOSName().str());
36a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getEnvironmentName().str());
3723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
3823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("---");
39a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getArchName().str());
40a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getVendorName().str());
41a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getOSName().str());
42a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getEnvironmentName().str());
4323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
4423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("----");
45a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getArchName().str());
46a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getVendorName().str());
47a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getOSName().str());
48a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("-", T.getEnvironmentName().str());
4923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
5023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("a");
51a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("a", T.getArchName().str());
52a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getVendorName().str());
53a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getOSName().str());
54a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getEnvironmentName().str());
5523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
5623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("a-b");
57a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("a", T.getArchName().str());
58a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("b", T.getVendorName().str());
59a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getOSName().str());
60a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getEnvironmentName().str());
6123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
6223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("a-b-c");
63a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("a", T.getArchName().str());
64a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("b", T.getVendorName().str());
65a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("c", T.getOSName().str());
66a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("", T.getEnvironmentName().str());
6723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
6823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("a-b-c-d");
69a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("a", T.getArchName().str());
70a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("b", T.getVendorName().str());
71a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("c", T.getOSName().str());
72a14d225ef4d3d8bd8ec9ec913246d1fb47d2edc1Daniel Dunbar  EXPECT_EQ("d", T.getEnvironmentName().str());
7323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar}
7423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
7523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel DunbarTEST(TripleTest, ParsedIDs) {
7623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  Triple T;
7723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
7823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("i386-apple-darwin");
79efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::x86, T.getArch());
80efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::Apple, T.getVendor());
81efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::Darwin, T.getOS());
825754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
8323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
84cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T = Triple("i386-pc-elfiamcu");
85cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::x86, T.getArch());
86cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::PC, T.getVendor());
87cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::ELFIAMCU, T.getOS());
88cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
89cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
9023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("x86_64-pc-linux-gnu");
91efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::x86_64, T.getArch());
92efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::PC, T.getVendor());
93efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::Linux, T.getOS());
94859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin  EXPECT_EQ(Triple::GNU, T.getEnvironment());
9523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
96a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  T = Triple("powerpc-bgp-linux");
97a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::ppc, T.getArch());
98a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::BGP, T.getVendor());
99a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::Linux, T.getOS());
100a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
101a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel
102a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  T = Triple("powerpc-bgp-cnk");
103a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::ppc, T.getArch());
104a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::BGP, T.getVendor());
105a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::CNK, T.getOS());
106a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
107a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel
108a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  T = Triple("powerpc64-bgq-linux");
109a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::ppc64, T.getArch());
110a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::BGQ, T.getVendor());
111a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::Linux, T.getOS());
112a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
113a47406c442a81aaf368b6e1a9b31d1730975a717Hal Finkel
1142e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands  T = Triple("powerpc-ibm-aix");
1152e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands  EXPECT_EQ(Triple::ppc, T.getArch());
1162e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands  EXPECT_EQ(Triple::IBM, T.getVendor());
1172e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands  EXPECT_EQ(Triple::AIX, T.getOS());
1182e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
1192e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands
1202e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands  T = Triple("powerpc64-ibm-aix");
1212e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands  EXPECT_EQ(Triple::ppc64, T.getArch());
1222e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands  EXPECT_EQ(Triple::IBM, T.getVendor());
1232e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands  EXPECT_EQ(Triple::AIX, T.getOS());
1242e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
1252e522d05278a69cf75b41dcd4b358e46b5350425Duncan Sands
12623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("powerpc-dunno-notsure");
127efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::ppc, T.getArch());
128efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
129efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::UnknownOS, T.getOS());
1305754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
13123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
132ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands  T = Triple("arm-none-none-eabi");
133859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin  EXPECT_EQ(Triple::arm, T.getArch());
134ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
135ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands  EXPECT_EQ(Triple::UnknownOS, T.getOS());
136859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin  EXPECT_EQ(Triple::EABI, T.getEnvironment());
137859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin
1386948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  T = Triple("armv6hl-none-linux-gnueabi");
1396948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_EQ(Triple::arm, T.getArch());
1406948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_EQ(Triple::Linux, T.getOS());
1416948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1426948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
1436948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar
1446948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  T = Triple("armv7hl-none-linux-gnueabi");
1456948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_EQ(Triple::arm, T.getArch());
1466948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_EQ(Triple::Linux, T.getOS());
1476948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1486948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
1496948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar
15037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T = Triple("amdil-unknown-unknown");
15137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::amdil, T.getArch());
15237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
15337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownOS, T.getOS());
15437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
15537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T = Triple("amdil64-unknown-unknown");
15637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::amdil64, T.getArch());
15737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
15837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownOS, T.getOS());
15937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
16037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T = Triple("hsail-unknown-unknown");
16137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::hsail, T.getArch());
16237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
16337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownOS, T.getOS());
16437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
16537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T = Triple("hsail64-unknown-unknown");
16637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::hsail64, T.getArch());
16737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
16837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownOS, T.getOS());
16937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
1706948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  T = Triple("sparcel-unknown-unknown");
1716948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_EQ(Triple::sparcel, T.getArch());
1726948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1736948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownOS, T.getOS());
1746948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar
17537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T = Triple("spir-unknown-unknown");
17637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::spir, T.getArch());
17737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
17837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownOS, T.getOS());
17937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
18037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T = Triple("spir64-unknown-unknown");
18137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::spir64, T.getArch());
18237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
18337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::UnknownOS, T.getOS());
18437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
1854c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar  T = Triple("x86_64-unknown-cloudabi");
1864c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar  EXPECT_EQ(Triple::x86_64, T.getArch());
1874c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1884c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar  EXPECT_EQ(Triple::CloudABI, T.getOS());
1894c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
1904c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar
191cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T = Triple("wasm32-unknown-unknown");
192cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::wasm32, T.getArch());
193cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
194cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownOS, T.getOS());
195cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
196cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
197cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T = Triple("wasm64-unknown-unknown");
198cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::wasm64, T.getArch());
199cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
200cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownOS, T.getOS());
201cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
202cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
203cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T = Triple("avr-unknown-unknown");
204cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::avr, T.getArch());
205cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
206cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownOS, T.getOS());
207cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
208cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
209cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T = Triple("avr");
210cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::avr, T.getArch());
211cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
212cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownOS, T.getOS());
213cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
214cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
21523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T = Triple("huh");
216efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::UnknownArch, T.getArch());
217335db223926931db204bf54d4accac6677b8e6b1Duncan Sands}
218651aa689cc37d5932fac0e096aa8b536f282aa21Daniel Dunbar
219335db223926931db204bf54d4accac6677b8e6b1Duncan Sandsstatic std::string Join(StringRef A, StringRef B, StringRef C) {
220335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  std::string Str = A; Str += '-'; Str += B; Str += '-'; Str += C;
221335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  return Str;
222335db223926931db204bf54d4accac6677b8e6b1Duncan Sands}
223651aa689cc37d5932fac0e096aa8b536f282aa21Daniel Dunbar
224335db223926931db204bf54d4accac6677b8e6b1Duncan Sandsstatic std::string Join(StringRef A, StringRef B, StringRef C, StringRef D) {
225335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  std::string Str = A; Str += '-'; Str += B; Str += '-'; Str += C; Str += '-';
226335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  Str += D; return Str;
227335db223926931db204bf54d4accac6677b8e6b1Duncan Sands}
228651aa689cc37d5932fac0e096aa8b536f282aa21Daniel Dunbar
229335db223926931db204bf54d4accac6677b8e6b1Duncan SandsTEST(TripleTest, Normalization) {
230859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin
231335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("", Triple::normalize(""));
232335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("-", Triple::normalize("-"));
233335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("--", Triple::normalize("--"));
234335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("---", Triple::normalize("---"));
235335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("----", Triple::normalize("----"));
236335db223926931db204bf54d4accac6677b8e6b1Duncan Sands
237335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("a", Triple::normalize("a"));
238335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("a-b", Triple::normalize("a-b"));
239335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("a-b-c", Triple::normalize("a-b-c"));
240335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("a-b-c-d", Triple::normalize("a-b-c-d"));
241335db223926931db204bf54d4accac6677b8e6b1Duncan Sands
242335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("i386-b-c", Triple::normalize("i386-b-c"));
243335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("i386-a-c", Triple::normalize("a-i386-c"));
244335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("i386-a-b", Triple::normalize("a-b-i386"));
2455754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  EXPECT_EQ("i386-a-b-c", Triple::normalize("a-b-c-i386"));
246335db223926931db204bf54d4accac6677b8e6b1Duncan Sands
247335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("a-pc-c", Triple::normalize("a-pc-c"));
248335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("-pc-b-c", Triple::normalize("pc-b-c"));
249335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("a-pc-b", Triple::normalize("a-b-pc"));
2505754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  EXPECT_EQ("a-pc-b-c", Triple::normalize("a-b-c-pc"));
251335db223926931db204bf54d4accac6677b8e6b1Duncan Sands
252335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("a-b-linux", Triple::normalize("a-b-linux"));
253335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("--linux-b-c", Triple::normalize("linux-b-c"));
254335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("a--linux-c", Triple::normalize("a-linux-c"));
255335db223926931db204bf54d4accac6677b8e6b1Duncan Sands
256335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("i386-pc-a", Triple::normalize("a-pc-i386"));
257335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("i386-pc-", Triple::normalize("-pc-i386"));
258335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("-pc-linux-c", Triple::normalize("linux-pc-c"));
259335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("-pc-linux", Triple::normalize("linux-pc-"));
260335db223926931db204bf54d4accac6677b8e6b1Duncan Sands
261335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("i386", Triple::normalize("i386"));
262335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("-pc", Triple::normalize("pc"));
263335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("--linux", Triple::normalize("linux"));
264335db223926931db204bf54d4accac6677b8e6b1Duncan Sands
265859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin  EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-gnu-linux"));
266859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin
267335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  // Check that normalizing a permutated set of valid components returns a
268335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  // triple with the unpermuted components.
269335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  StringRef C[4];
2706948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  for (int Arch = 1+Triple::UnknownArch; Arch <= Triple::LastArchType; ++Arch) {
271335db223926931db204bf54d4accac6677b8e6b1Duncan Sands    C[0] = Triple::getArchTypeName(Triple::ArchType(Arch));
2726948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    for (int Vendor = 1+Triple::UnknownVendor; Vendor <= Triple::LastVendorType;
273335db223926931db204bf54d4accac6677b8e6b1Duncan Sands         ++Vendor) {
274335db223926931db204bf54d4accac6677b8e6b1Duncan Sands      C[1] = Triple::getVendorTypeName(Triple::VendorType(Vendor));
2756948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar      for (int OS = 1+Triple::UnknownOS; OS <= Triple::LastOSType; ++OS) {
27637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines        if (OS == Triple::Win32)
27736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines          continue;
27836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
279335db223926931db204bf54d4accac6677b8e6b1Duncan Sands        C[2] = Triple::getOSTypeName(Triple::OSType(OS));
280ee64684710486bf8a0cd156d0516e0a7caecfb0bDuncan Sands
281ee64684710486bf8a0cd156d0516e0a7caecfb0bDuncan Sands        std::string E = Join(C[0], C[1], C[2]);
282ee64684710486bf8a0cd156d0516e0a7caecfb0bDuncan Sands        EXPECT_EQ(E, Triple::normalize(Join(C[0], C[1], C[2])));
283ee64684710486bf8a0cd156d0516e0a7caecfb0bDuncan Sands
284ee64684710486bf8a0cd156d0516e0a7caecfb0bDuncan Sands        EXPECT_EQ(E, Triple::normalize(Join(C[0], C[2], C[1])));
285ee64684710486bf8a0cd156d0516e0a7caecfb0bDuncan Sands        EXPECT_EQ(E, Triple::normalize(Join(C[1], C[2], C[0])));
286ee64684710486bf8a0cd156d0516e0a7caecfb0bDuncan Sands        EXPECT_EQ(E, Triple::normalize(Join(C[1], C[0], C[2])));
287ee64684710486bf8a0cd156d0516e0a7caecfb0bDuncan Sands        EXPECT_EQ(E, Triple::normalize(Join(C[2], C[0], C[1])));
288ee64684710486bf8a0cd156d0516e0a7caecfb0bDuncan Sands        EXPECT_EQ(E, Triple::normalize(Join(C[2], C[1], C[0])));
289ee64684710486bf8a0cd156d0516e0a7caecfb0bDuncan Sands
2906948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar        for (int Env = 1 + Triple::UnknownEnvironment; Env <= Triple::LastEnvironmentType;
291ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands             ++Env) {
292ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          C[3] = Triple::getEnvironmentTypeName(Triple::EnvironmentType(Env));
293ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands
294ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          std::string F = Join(C[0], C[1], C[2], C[3]);
295ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[1], C[2], C[3])));
296ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands
297ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[1], C[3], C[2])));
298ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[2], C[3], C[1])));
299ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[2], C[1], C[3])));
300ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[3], C[1], C[2])));
301ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[3], C[2], C[1])));
302ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[2], C[3], C[0])));
303ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[2], C[0], C[3])));
304ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[3], C[0], C[2])));
305ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[3], C[2], C[0])));
306ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[0], C[2], C[3])));
307ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[0], C[3], C[2])));
308ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[3], C[0], C[1])));
309ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[3], C[1], C[0])));
310ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[0], C[1], C[3])));
311ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[0], C[3], C[1])));
312ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[1], C[3], C[0])));
313ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[1], C[0], C[3])));
314ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[0], C[1], C[2])));
315ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[0], C[2], C[1])));
316ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[1], C[2], C[0])));
317ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[1], C[0], C[2])));
318ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[2], C[0], C[1])));
319ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[2], C[1], C[0])));
320ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands        }
321335db223926931db204bf54d4accac6677b8e6b1Duncan Sands      }
322335db223926931db204bf54d4accac6677b8e6b1Duncan Sands    }
323335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  }
324335db223926931db204bf54d4accac6677b8e6b1Duncan Sands
325335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  // Various real-world funky triples.  The value returned by GCC's config.sub
326335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  // is given in the comment.
32736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i386--windows-gnu", Triple::normalize("i386-mingw32")); // i386-pc-mingw32
328335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-linux-gnu")); // x86_64-pc-linux-gnu
329335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("i486--linux-gnu", Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu
330335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("i386-redhat-linux", Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu
331335db223926931db204bf54d4accac6677b8e6b1Duncan Sands  EXPECT_EQ("i686--linux", Triple::normalize("i686-linux")); // i686-pc-linux-gnu
332ae200c60c31666da81a8550172de03a9f417ba1bDuncan Sands  EXPECT_EQ("arm-none--eabi", Triple::normalize("arm-none-eabi")); // arm-none-eabi
33323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar}
33423e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
33523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel DunbarTEST(TripleTest, MutateName) {
33623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  Triple T;
337efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::UnknownArch, T.getArch());
338efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
339efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::UnknownOS, T.getOS());
3405754a4525625a67a6c9b4f63512ea9db6997bf05Duncan Sands  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
34123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
34223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T.setArchName("i386");
343efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::x86, T.getArch());
344efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ("i386--", T.getTriple());
34523e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
34623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T.setVendorName("pc");
347efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::x86, T.getArch());
348efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::PC, T.getVendor());
349efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ("i386-pc-", T.getTriple());
35023e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
35123e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T.setOSName("linux");
352efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::x86, T.getArch());
353efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::PC, T.getVendor());
354efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::Linux, T.getOS());
355efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ("i386-pc-linux", T.getTriple());
35623e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
35723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T.setEnvironmentName("gnu");
358efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::x86, T.getArch());
359efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::PC, T.getVendor());
360efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::Linux, T.getOS());
361efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ("i386-pc-linux-gnu", T.getTriple());
36223e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
36323e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T.setOSName("freebsd");
364efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::x86, T.getArch());
365efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::PC, T.getVendor());
366efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::FreeBSD, T.getOS());
367efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ("i386-pc-freebsd-gnu", T.getTriple());
36823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
36923e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar  T.setOSAndEnvironmentName("darwin");
370efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::x86, T.getArch());
371efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::PC, T.getVendor());
372efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ(Triple::Darwin, T.getOS());
373efee4ee46e5cc8f108391a33f2119891531989c6Misha Brukman  EXPECT_EQ("i386-pc-darwin", T.getTriple());
374859f8183639346378ed29d1e04a4b070ebc7e97fRenato Golin
375cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setEnvironmentName("amdopencl");
376cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::AMDOpenCL, T.getEnvironment());
37723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar}
37823e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar
3796f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler CarruthTEST(TripleTest, BitWidthPredicates) {
3806f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  Triple T;
3816f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch16Bit());
3826f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch32Bit());
3836f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch64Bit());
3846f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
3856f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  T.setArch(Triple::arm);
3866f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch16Bit());
3876f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_TRUE(T.isArch32Bit());
3886f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch64Bit());
3896f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
3906f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  T.setArch(Triple::hexagon);
3916f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch16Bit());
3926f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_TRUE(T.isArch32Bit());
3936f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch64Bit());
3946f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
3956f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  T.setArch(Triple::mips);
3966f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch16Bit());
3976f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_TRUE(T.isArch32Bit());
3986f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch64Bit());
3996f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
4006f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  T.setArch(Triple::mips64);
4016f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch16Bit());
4026f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch32Bit());
4036f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_TRUE(T.isArch64Bit());
4046f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
4056f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  T.setArch(Triple::msp430);
4066f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_TRUE(T.isArch16Bit());
4076f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch32Bit());
4086f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch64Bit());
4096f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
4106f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  T.setArch(Triple::ppc);
4116f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch16Bit());
4126f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_TRUE(T.isArch32Bit());
4136f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch64Bit());
4146f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
4156f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  T.setArch(Triple::ppc64);
4166f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch16Bit());
4176f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch32Bit());
4186f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_TRUE(T.isArch64Bit());
4196f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
4206f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  T.setArch(Triple::x86);
4216f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch16Bit());
4226f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_TRUE(T.isArch32Bit());
4236f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch64Bit());
4246f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
4256f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  T.setArch(Triple::x86_64);
4266f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch16Bit());
4276f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_FALSE(T.isArch32Bit());
4286f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth  EXPECT_TRUE(T.isArch64Bit());
42937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
43037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::amdil);
43137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch16Bit());
43237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_TRUE(T.isArch32Bit());
43337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch64Bit());
43437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
43537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::amdil64);
43637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch16Bit());
43737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch32Bit());
43837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_TRUE(T.isArch64Bit());
43937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
44037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::hsail);
44137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch16Bit());
44237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_TRUE(T.isArch32Bit());
44337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch64Bit());
44437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
44537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::hsail64);
44637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch16Bit());
44737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch32Bit());
44837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_TRUE(T.isArch64Bit());
44937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
45037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::spir);
45137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch16Bit());
45237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_TRUE(T.isArch32Bit());
45337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch64Bit());
45437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
45537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::spir64);
45637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch16Bit());
45737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_FALSE(T.isArch32Bit());
45837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_TRUE(T.isArch64Bit());
4596948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar
4606948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  T.setArch(Triple::sparc);
4616948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch16Bit());
4626948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_TRUE(T.isArch32Bit());
4636948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch64Bit());
4646948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar
4656948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  T.setArch(Triple::sparcel);
4666948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch16Bit());
4676948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_TRUE(T.isArch32Bit());
4686948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch64Bit());
4696948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar
4706948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  T.setArch(Triple::sparcv9);
4716948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch16Bit());
4726948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch32Bit());
4736948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  EXPECT_TRUE(T.isArch64Bit());
474cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
475cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::wasm32);
476cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch16Bit());
477cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_TRUE(T.isArch32Bit());
478cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch64Bit());
479cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
480cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::wasm64);
481cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch16Bit());
482cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch32Bit());
483cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_TRUE(T.isArch64Bit());
484cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
485cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::avr);
486cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_TRUE(T.isArch16Bit());
487cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch32Bit());
488cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_FALSE(T.isArch64Bit());
4896f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth}
4906f72ac4799a1a20c07cd96cc994dd6394ebff9a2Chandler Carruth
4917d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler CarruthTEST(TripleTest, BitWidthArchVariants) {
4927d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  Triple T;
4937d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
4947d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
4957d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
4967d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  T.setArch(Triple::UnknownArch);
4977d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
4987d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
4997d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
5007d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  T.setArch(Triple::mips);
5017d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
5027d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
5037d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
5047d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  T.setArch(Triple::mipsel);
5057d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
5067d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
5077d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
5087d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  T.setArch(Triple::ppc);
5097d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
5107d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
5117d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
51242a0b48dd3773574f648c19b4d9abafb6b4a4f16Justin Holewinski  T.setArch(Triple::nvptx);
51342a0b48dd3773574f648c19b4d9abafb6b4a4f16Justin Holewinski  EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
51442a0b48dd3773574f648c19b4d9abafb6b4a4f16Justin Holewinski  EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
5157d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
5167d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  T.setArch(Triple::sparc);
5177d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
5187d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
5197d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
5207d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  T.setArch(Triple::x86);
5217d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
5227d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
5237d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
5247d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  T.setArch(Triple::mips64);
5257d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
5267d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
5277d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
5287d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  T.setArch(Triple::mips64el);
5297d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
5307d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
5317d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
5327d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  T.setArch(Triple::ppc64);
5337d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
5347d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
5357d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
53642a0b48dd3773574f648c19b4d9abafb6b4a4f16Justin Holewinski  T.setArch(Triple::nvptx64);
53742a0b48dd3773574f648c19b4d9abafb6b4a4f16Justin Holewinski  EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
53842a0b48dd3773574f648c19b4d9abafb6b4a4f16Justin Holewinski  EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
5397d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
5407d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  T.setArch(Triple::sparcv9);
5417d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
5427d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
5437d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
5447d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  T.setArch(Triple::x86_64);
5457d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
5467d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth  EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
54737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
54837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::amdil);
54937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::amdil, T.get32BitArchVariant().getArch());
55037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::amdil64, T.get64BitArchVariant().getArch());
55137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
55237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::amdil64);
55337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::amdil, T.get32BitArchVariant().getArch());
55437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::amdil64, T.get64BitArchVariant().getArch());
55537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
55637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::hsail);
55737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::hsail, T.get32BitArchVariant().getArch());
55837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::hsail64, T.get64BitArchVariant().getArch());
55937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
56037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::hsail64);
56137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::hsail, T.get32BitArchVariant().getArch());
56237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::hsail64, T.get64BitArchVariant().getArch());
56337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
56437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::spir);
56537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
56637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
56737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
56837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  T.setArch(Triple::spir64);
56937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
57037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
571cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
572cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::wasm32);
573cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
574cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
575cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
576cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::wasm64);
577cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
578cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
579cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar}
580cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
581cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga NainarTEST(TripleTest, EndianArchVariants) {
582cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  Triple T;
583cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
584cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
585cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
586cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::UnknownArch);
587cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
588cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
589cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
590cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::aarch64_be);
591cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::aarch64_be, T.getBigEndianArchVariant().getArch());
592cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::aarch64, T.getLittleEndianArchVariant().getArch());
593cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
594cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::aarch64);
595cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::aarch64_be, T.getBigEndianArchVariant().getArch());
596cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::aarch64, T.getLittleEndianArchVariant().getArch());
597cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
598cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::armeb);
599cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::armeb, T.getBigEndianArchVariant().getArch());
600cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
601cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
602cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::arm);
603cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
604cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::arm, T.getLittleEndianArchVariant().getArch());
605cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
606cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::bpfeb);
607cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::bpfeb, T.getBigEndianArchVariant().getArch());
608cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::bpfel, T.getLittleEndianArchVariant().getArch());
609cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
610cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::bpfel);
611cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::bpfeb, T.getBigEndianArchVariant().getArch());
612cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::bpfel, T.getLittleEndianArchVariant().getArch());
613cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
614cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::mips64);
615cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
616cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
617cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
618cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::mips64el);
619cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
620cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
621cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
622cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::mips);
623cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
624cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
625cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
626cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::mipsel);
627cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
628cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
629cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
630cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::ppc);
631cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::ppc, T.getBigEndianArchVariant().getArch());
632cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
633cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
634cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::ppc64);
635cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::ppc64, T.getBigEndianArchVariant().getArch());
636cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::ppc64le, T.getLittleEndianArchVariant().getArch());
637cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
638cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::ppc64le);
639cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::ppc64, T.getBigEndianArchVariant().getArch());
640cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::ppc64le, T.getLittleEndianArchVariant().getArch());
641cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
642cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::sparc);
643cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::sparc, T.getBigEndianArchVariant().getArch());
644cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::sparcel, T.getLittleEndianArchVariant().getArch());
645cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
646cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::sparcel);
647cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::sparc, T.getBigEndianArchVariant().getArch());
648cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::sparcel, T.getLittleEndianArchVariant().getArch());
649cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
650cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::thumb);
651cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
652cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::thumb, T.getLittleEndianArchVariant().getArch());
653cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar
654cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  T.setArch(Triple::thumbeb);
655cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::thumbeb, T.getBigEndianArchVariant().getArch());
656cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
6577d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth}
6587d5a289f2d7d75c29df4c17856ab54dd28dec508Chandler Carruth
6599166d23327c8dfb5b600795715e75e8b446b5690Chad RosierTEST(TripleTest, getOSVersion) {
6609166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  Triple T;
6619166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  unsigned Major, Minor, Micro;
6629166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier
6639166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T = Triple("i386-apple-darwin9");
66469f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isMacOSX());
66569f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isiOS());
66669f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch16Bit());
66769f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isArch32Bit());
66869f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch64Bit());
6699166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getMacOSXVersion(Major, Minor, Micro);
6709166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)10, Major);
6719166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)5, Minor);
6729166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
6739166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getiOSVersion(Major, Minor, Micro);
67436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ((unsigned)5, Major);
6759166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Minor);
6769166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
6779166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier
6789166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T = Triple("x86_64-apple-darwin9");
67969f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isMacOSX());
68069f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isiOS());
68169f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch16Bit());
68269f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch32Bit());
68369f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isArch64Bit());
6849166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getMacOSXVersion(Major, Minor, Micro);
6859166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)10, Major);
6869166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)5, Minor);
6879166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
6889166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getiOSVersion(Major, Minor, Micro);
68936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ((unsigned)5, Major);
6909166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Minor);
6919166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
6929166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier
6939166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T = Triple("x86_64-apple-macosx");
69469f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isMacOSX());
69569f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isiOS());
69669f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch16Bit());
69769f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch32Bit());
69869f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isArch64Bit());
6999166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getMacOSXVersion(Major, Minor, Micro);
7009166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)10, Major);
7019166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)4, Minor);
7029166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
7039166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getiOSVersion(Major, Minor, Micro);
70436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ((unsigned)5, Major);
7059166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Minor);
7069166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
7079166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier
7089166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T = Triple("x86_64-apple-macosx10.7");
70969f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isMacOSX());
71069f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isiOS());
71169f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch16Bit());
71269f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch32Bit());
71369f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isArch64Bit());
7149166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getMacOSXVersion(Major, Minor, Micro);
7159166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)10, Major);
7169166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)7, Minor);
7179166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
7189166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getiOSVersion(Major, Minor, Micro);
71936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ((unsigned)5, Major);
7209166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Minor);
7219166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
7229166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier
7239166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T = Triple("armv7-apple-ios");
72469f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isMacOSX());
72569f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isiOS());
72669f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch16Bit());
72769f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isArch32Bit());
72869f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch64Bit());
7299166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getMacOSXVersion(Major, Minor, Micro);
7309166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)10, Major);
7319166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)4, Minor);
7329166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
7339166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getiOSVersion(Major, Minor, Micro);
73436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ((unsigned)5, Major);
7359166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Minor);
7369166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
7379166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier
73836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  T = Triple("armv7-apple-ios7.0");
73969f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isMacOSX());
74069f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isiOS());
74169f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch16Bit());
74269f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_TRUE(T.isArch32Bit());
74369f60e7c4a77866b3d0a5907e4955baa05216a20Michael Gottesman  EXPECT_FALSE(T.isArch64Bit());
7449166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getMacOSXVersion(Major, Minor, Micro);
7459166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)10, Major);
7469166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)4, Minor);
7479166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
7489166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  T.getiOSVersion(Major, Minor, Micro);
74936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ((unsigned)7, Major);
7509166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Minor);
7519166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier  EXPECT_EQ((unsigned)0, Micro);
7529166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier}
7539166d23327c8dfb5b600795715e75e8b446b5690Chad Rosier
75436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen HinesTEST(TripleTest, FileFormat) {
75536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, Triple("i686-unknown-linux-gnu").getObjectFormat());
75636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, Triple("i686-unknown-freebsd").getObjectFormat());
75736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, Triple("i686-unknown-netbsd").getObjectFormat());
75836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, Triple("i686--win32-elf").getObjectFormat());
75936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, Triple("i686---elf").getObjectFormat());
76036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
76136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::MachO, Triple("i686-apple-macosx").getObjectFormat());
76236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::MachO, Triple("i686-apple-ios").getObjectFormat());
76336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::MachO, Triple("i686---macho").getObjectFormat());
76436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
76536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::COFF, Triple("i686--win32").getObjectFormat());
76636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
76736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
76836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, Triple("i686-pc-cygwin-elf").getObjectFormat());
76936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
77036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
77136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
77236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
77336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  Triple GNUWindowsNormalized(Triple::normalize("i686-pc-windows-gnu-elf"));
77436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, GNUWindowsNormalized.getObjectFormat());
77536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
77636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  Triple CygnusNormalised(Triple::normalize("i686-pc-windows-cygnus-elf"));
77736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, CygnusNormalised.getObjectFormat());
77836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
77936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  Triple CygwinNormalized(Triple::normalize("i686-pc-cygwin-elf"));
78036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, CygwinNormalized.getObjectFormat());
78136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
78236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  Triple T = Triple("");
78336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  T.setObjectFormat(Triple::ELF);
78436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ(Triple::ELF, T.getObjectFormat());
78536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines}
78636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
78736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen HinesTEST(TripleTest, NormalizeWindows) {
78836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-win32"));
78936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686--windows-msvc", Triple::normalize("i686-win32"));
79036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32"));
79136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686--windows-gnu", Triple::normalize("i686-mingw32"));
79236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32-w64"));
79336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686--windows-gnu", Triple::normalize("i686-mingw32-w64"));
79436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-cygwin"));
79536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686--windows-cygnus", Triple::normalize("i686-cygwin"));
79636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
79736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("x86_64-pc-windows-msvc", Triple::normalize("x86_64-pc-win32"));
79836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("x86_64--windows-msvc", Triple::normalize("x86_64-win32"));
79936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("x86_64-pc-windows-gnu", Triple::normalize("x86_64-pc-mingw32"));
80036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("x86_64--windows-gnu", Triple::normalize("x86_64-mingw32"));
80136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("x86_64-pc-windows-gnu", Triple::normalize("x86_64-pc-mingw32-w64"));
80236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("x86_64--windows-gnu", Triple::normalize("x86_64-mingw32-w64"));
80336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
80436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-win32-elf"));
80536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686--windows-elf", Triple::normalize("i686-win32-elf"));
80636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686-pc-windows-macho", Triple::normalize("i686-pc-win32-macho"));
80736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686--windows-macho", Triple::normalize("i686-win32-macho"));
80836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
80936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("x86_64-pc-windows-elf", Triple::normalize("x86_64-pc-win32-elf"));
81036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("x86_64--windows-elf", Triple::normalize("x86_64-win32-elf"));
81136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("x86_64-pc-windows-macho", Triple::normalize("x86_64-pc-win32-macho"));
81236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("x86_64--windows-macho", Triple::normalize("x86_64-win32-macho"));
81336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
81436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686-pc-windows-cygnus",
81536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines            Triple::normalize("i686-pc-windows-cygnus"));
81636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-windows-gnu"));
81736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686-pc-windows-itanium", Triple::normalize("i686-pc-windows-itanium"));
81836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-windows-msvc"));
81936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
82036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-windows-elf-elf"));
82136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines}
82237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
82337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen HinesTEST(TripleTest, getARMCPUForArch) {
8246948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  // Standard ARM Architectures.
8256948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8266948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv4-unknown-eabi");
827cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("strongarm", Triple.getARMCPUForArch());
8286948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8296948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8306948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv4t-unknown-eabi");
831cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm7tdmi", Triple.getARMCPUForArch());
8326948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8336948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8346948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv5-unknown-eabi");
835cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm10tdmi", Triple.getARMCPUForArch());
8366948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8376948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8386948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv5t-unknown-eabi");
839cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm10tdmi", Triple.getARMCPUForArch());
8406948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8416948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8426948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv5e-unknown-eabi");
843cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1022e", Triple.getARMCPUForArch());
8446948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8456948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8466948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv5tej-unknown-eabi");
847cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm926ej-s", Triple.getARMCPUForArch());
8486948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8496948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8506948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv6-unknown-eabi");
851cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1136jf-s", Triple.getARMCPUForArch());
8526948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8536948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8546948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv6j-unknown-eabi");
855cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1136jf-s", Triple.getARMCPUForArch());
8566948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8576948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8586948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv6k-unknown-eabi");
859cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1176j-s", Triple.getARMCPUForArch());
860cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  }
861cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar  {
862cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    llvm::Triple Triple("armv6kz-unknown-eabi");
863cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
8646948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8656948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8666948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv6zk-unknown-eabi");
867cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
8686948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8696948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8706948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv6t2-unknown-eabi");
871cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1156t2-s", Triple.getARMCPUForArch());
8726948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8736948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8746948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv6m-unknown-eabi");
875cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-m0", Triple.getARMCPUForArch());
8766948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8776948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8786948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv7-unknown-eabi");
879cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
8806948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8816948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8826948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv7a-unknown-eabi");
883cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
8846948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8856948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8866948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv7m-unknown-eabi");
887cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-m3", Triple.getARMCPUForArch());
8886948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8896948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8906948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv7r-unknown-eabi");
891cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-r4", Triple.getARMCPUForArch());
8926948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8936948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8946948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv7r-unknown-eabi");
895cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-r4", Triple.getARMCPUForArch());
8966948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
8976948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
8986948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv7r-unknown-eabi");
899cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-r4", Triple.getARMCPUForArch());
9006948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9016948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9026948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv7r-unknown-eabi");
903cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-r4", Triple.getARMCPUForArch());
9046948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9056948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9066948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv8a-unknown-eabi");
907cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-a53", Triple.getARMCPUForArch());
9086948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9096948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9106948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv8.1a-unknown-eabi");
911cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("generic", Triple.getARMCPUForArch());
9126948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9136948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  // Non-synonym names, using -march style, not default arch.
9146948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9156948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("arm");
916cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch("armv7-a"));
9176948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9186948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9196948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("arm");
920cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-m3", Triple.getARMCPUForArch("armv7-m"));
9216948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9226948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9236948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("arm");
924cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-a53", Triple.getARMCPUForArch("armv8"));
9256948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9266948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9276948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("arm");
928cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-a53", Triple.getARMCPUForArch("armv8-a"));
9296948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9306948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  // Platform specific defaults.
9316948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9326948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("arm--nacl");
933cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
9346948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
93537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  {
93637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    llvm::Triple Triple("armv6-unknown-freebsd");
937cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
93837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  }
93937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  {
9406948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("thumbv6-unknown-freebsd");
941cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
9426948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9436948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9446948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armebv6-unknown-freebsd");
945cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
9466948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9476948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9486948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("arm--win32");
949cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-a9", Triple.getARMCPUForArch());
9506948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9516948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  // Some alternative architectures
9526948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9536948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("xscale-unknown-eabi");
954cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("xscale", Triple.getARMCPUForArch());
9556948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9566948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9576948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("iwmmxt-unknown-eabi");
958cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("iwmmxt", Triple.getARMCPUForArch());
9596948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9606948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
96137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    llvm::Triple Triple("armv7s-apple-ios7");
962cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("swift", Triple.getARMCPUForArch());
96337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  }
96437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  {
9656948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv7em-apple-ios7");
966cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-m4", Triple.getARMCPUForArch());
9676948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9686948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9696948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv7l-linux-gnueabihf");
970cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
97137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  }
9724c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar  {
9736948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv6sm-apple-ios7");
974cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("cortex-m0", Triple.getARMCPUForArch());
9756948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9766948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  // armeb is permitted, but armebeb is not
9776948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9786948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armeb-none-eabi");
979cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm7tdmi", Triple.getARMCPUForArch());
9806948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9816948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9826948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armebeb-none-eabi");
983cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("", Triple.getARMCPUForArch());
9846948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9856948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9866948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armebv6eb-none-eabi");
987cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("", Triple.getARMCPUForArch());
9886948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9896948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  // armebv6 and armv6eb are permitted, but armebv6eb is not
9906948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9916948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armebv6-non-eabi");
992cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1136jf-s", Triple.getARMCPUForArch());
9936948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9946948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
9956948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armv6eb-none-eabi");
996cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("arm1136jf-s", Triple.getARMCPUForArch());
9976948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
9986948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  // xscaleeb is permitted, but armebxscale is not
9996948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10006948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("xscaleeb-none-eabi");
1001cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("xscale", Triple.getARMCPUForArch());
10026948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10036948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10046948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    llvm::Triple Triple("armebxscale-none-eabi");
1005cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar    EXPECT_EQ("", Triple.getARMCPUForArch());
10064c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar  }
100723e97b05da7b31ed97e5ccc6330670da0173ca2eDaniel Dunbar}
1008ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines
1009ebe69fe11e48d322045d5949c83283927a0d790bStephen HinesTEST(TripleTest, NormalizeARM) {
1010ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  EXPECT_EQ("armv6--netbsd-eabi", Triple::normalize("armv6-netbsd-eabi"));
1011ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  EXPECT_EQ("armv7--netbsd-eabi", Triple::normalize("armv7-netbsd-eabi"));
1012ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  EXPECT_EQ("armv6eb--netbsd-eabi", Triple::normalize("armv6eb-netbsd-eabi"));
1013ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  EXPECT_EQ("armv7eb--netbsd-eabi", Triple::normalize("armv7eb-netbsd-eabi"));
1014ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  EXPECT_EQ("armv6--netbsd-eabihf", Triple::normalize("armv6-netbsd-eabihf"));
1015ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  EXPECT_EQ("armv7--netbsd-eabihf", Triple::normalize("armv7-netbsd-eabihf"));
1016ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  EXPECT_EQ("armv6eb--netbsd-eabihf", Triple::normalize("armv6eb-netbsd-eabihf"));
1017ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  EXPECT_EQ("armv7eb--netbsd-eabihf", Triple::normalize("armv7eb-netbsd-eabihf"));
1018ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines
1019ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  Triple T;
1020ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  T = Triple("armv6--netbsd-eabi");
1021ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  EXPECT_EQ(Triple::arm, T.getArch());
1022ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  T = Triple("armv6eb--netbsd-eabi");
1023ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines  EXPECT_EQ(Triple::armeb, T.getArch());
1024ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines}
10256948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar
10266948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga NainarTEST(TripleTest, ParseARMArch) {
10276948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  // ARM
10286948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10296948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("arm");
10306948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::arm, T.getArch());
10316948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10326948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10336948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("armv6t2");
10346948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::arm, T.getArch());
10356948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10366948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10376948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("armv8");
10386948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::arm, T.getArch());
10396948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10406948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10416948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("armeb");
10426948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::armeb, T.getArch());
10436948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10446948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10456948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("armv5eb");
10466948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::armeb, T.getArch());
10476948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10486948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10496948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("armebv7m");
10506948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::armeb, T.getArch());
10516948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10526948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10536948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("armv7eb");
10546948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::armeb, T.getArch());
10556948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10566948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  // THUMB
10576948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10586948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("thumb");
10596948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::thumb, T.getArch());
10606948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10616948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10626948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("thumbv7a");
10636948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::thumb, T.getArch());
10646948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10656948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10666948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("thumbeb");
10676948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::thumbeb, T.getArch());
10686948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10696948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10706948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("thumbv4teb");
10716948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::thumbeb, T.getArch());
10726948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10736948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10746948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("thumbebv7");
10756948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::thumbeb, T.getArch());
10766948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10776948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10786948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("armv6m");
10796948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::thumb, T.getArch());
10806948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10816948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10826948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("thumbv2");
10836948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::UnknownArch, T.getArch());
10846948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10856948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10866948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("thumbebv6eb");
10876948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::UnknownArch, T.getArch());
10886948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10896948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  // AARCH64
10906948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10916948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("arm64");
10926948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::aarch64, T.getArch());
10936948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10946948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10956948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("aarch64");
10966948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::aarch64, T.getArch());
10976948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
10986948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
10996948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("aarch64_be");
11006948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::aarch64_be, T.getArch());
11016948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
11026948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
11036948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("aarch64be");
11046948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::UnknownArch, T.getArch());
11056948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
11066948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  {
11076948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    Triple T = Triple("arm64be");
11086948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar    EXPECT_EQ(Triple::UnknownArch, T.getArch());
11096948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar  }
11106948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar}
11116948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar} // end anonymous namespace
1112