[LLVM][NFC] remove unused fields
[llvm-complete.git] / unittests / ADT / TripleTest.cpp
blobd8123bbbfdf7a672a124bcdeca84ff94406f696b
1 //===----------- Triple.cpp - Triple unit tests ---------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ADT/Triple.h"
10 #include "gtest/gtest.h"
12 using namespace llvm;
14 namespace {
16 TEST(TripleTest, BasicParsing) {
17 Triple T;
19 T = Triple("");
20 EXPECT_EQ("", T.getArchName().str());
21 EXPECT_EQ("", T.getVendorName().str());
22 EXPECT_EQ("", T.getOSName().str());
23 EXPECT_EQ("", T.getEnvironmentName().str());
25 T = Triple("-");
26 EXPECT_EQ("", T.getArchName().str());
27 EXPECT_EQ("", T.getVendorName().str());
28 EXPECT_EQ("", T.getOSName().str());
29 EXPECT_EQ("", T.getEnvironmentName().str());
31 T = Triple("--");
32 EXPECT_EQ("", T.getArchName().str());
33 EXPECT_EQ("", T.getVendorName().str());
34 EXPECT_EQ("", T.getOSName().str());
35 EXPECT_EQ("", T.getEnvironmentName().str());
37 T = Triple("---");
38 EXPECT_EQ("", T.getArchName().str());
39 EXPECT_EQ("", T.getVendorName().str());
40 EXPECT_EQ("", T.getOSName().str());
41 EXPECT_EQ("", T.getEnvironmentName().str());
43 T = Triple("----");
44 EXPECT_EQ("", T.getArchName().str());
45 EXPECT_EQ("", T.getVendorName().str());
46 EXPECT_EQ("", T.getOSName().str());
47 EXPECT_EQ("-", T.getEnvironmentName().str());
49 T = Triple("a");
50 EXPECT_EQ("a", T.getArchName().str());
51 EXPECT_EQ("", T.getVendorName().str());
52 EXPECT_EQ("", T.getOSName().str());
53 EXPECT_EQ("", T.getEnvironmentName().str());
55 T = Triple("a-b");
56 EXPECT_EQ("a", T.getArchName().str());
57 EXPECT_EQ("b", T.getVendorName().str());
58 EXPECT_EQ("", T.getOSName().str());
59 EXPECT_EQ("", T.getEnvironmentName().str());
61 T = Triple("a-b-c");
62 EXPECT_EQ("a", T.getArchName().str());
63 EXPECT_EQ("b", T.getVendorName().str());
64 EXPECT_EQ("c", T.getOSName().str());
65 EXPECT_EQ("", T.getEnvironmentName().str());
67 T = Triple("a-b-c-d");
68 EXPECT_EQ("a", T.getArchName().str());
69 EXPECT_EQ("b", T.getVendorName().str());
70 EXPECT_EQ("c", T.getOSName().str());
71 EXPECT_EQ("d", T.getEnvironmentName().str());
74 TEST(TripleTest, ParsedIDs) {
75 Triple T;
77 T = Triple("i386-apple-darwin");
78 EXPECT_EQ(Triple::x86, T.getArch());
79 EXPECT_EQ(Triple::Apple, T.getVendor());
80 EXPECT_EQ(Triple::Darwin, T.getOS());
81 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
83 T = Triple("i386-pc-elfiamcu");
84 EXPECT_EQ(Triple::x86, T.getArch());
85 EXPECT_EQ(Triple::PC, T.getVendor());
86 EXPECT_EQ(Triple::ELFIAMCU, T.getOS());
87 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
89 T = Triple("i386-pc-contiki-unknown");
90 EXPECT_EQ(Triple::x86, T.getArch());
91 EXPECT_EQ(Triple::PC, T.getVendor());
92 EXPECT_EQ(Triple::Contiki, T.getOS());
93 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
95 T = Triple("i386-pc-hurd-gnu");
96 EXPECT_EQ(Triple::x86, T.getArch());
97 EXPECT_EQ(Triple::PC, T.getVendor());
98 EXPECT_EQ(Triple::Hurd, T.getOS());
99 EXPECT_EQ(Triple::GNU, T.getEnvironment());
101 T = Triple("x86_64-pc-linux-gnu");
102 EXPECT_EQ(Triple::x86_64, T.getArch());
103 EXPECT_EQ(Triple::PC, T.getVendor());
104 EXPECT_EQ(Triple::Linux, T.getOS());
105 EXPECT_EQ(Triple::GNU, T.getEnvironment());
107 T = Triple("x86_64-pc-linux-musl");
108 EXPECT_EQ(Triple::x86_64, T.getArch());
109 EXPECT_EQ(Triple::PC, T.getVendor());
110 EXPECT_EQ(Triple::Linux, T.getOS());
111 EXPECT_EQ(Triple::Musl, T.getEnvironment());
113 T = Triple("powerpc-bgp-linux");
114 EXPECT_EQ(Triple::ppc, T.getArch());
115 EXPECT_EQ(Triple::BGP, T.getVendor());
116 EXPECT_EQ(Triple::Linux, T.getOS());
117 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
119 T = Triple("powerpc-bgp-cnk");
120 EXPECT_EQ(Triple::ppc, T.getArch());
121 EXPECT_EQ(Triple::BGP, T.getVendor());
122 EXPECT_EQ(Triple::CNK, T.getOS());
123 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
125 T = Triple("ppc-bgp-linux");
126 EXPECT_EQ(Triple::ppc, T.getArch());
127 EXPECT_EQ(Triple::BGP, T.getVendor());
128 EXPECT_EQ(Triple::Linux, T.getOS());
129 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
131 T = Triple("ppc32-bgp-linux");
132 EXPECT_EQ(Triple::ppc, T.getArch());
133 EXPECT_EQ(Triple::BGP, T.getVendor());
134 EXPECT_EQ(Triple::Linux, T.getOS());
135 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
137 T = Triple("powerpc64-bgq-linux");
138 EXPECT_EQ(Triple::ppc64, T.getArch());
139 EXPECT_EQ(Triple::BGQ, T.getVendor());
140 EXPECT_EQ(Triple::Linux, T.getOS());
141 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
143 T = Triple("ppc64-bgq-linux");
144 EXPECT_EQ(Triple::ppc64, T.getArch());
145 EXPECT_EQ(Triple::BGQ, T.getVendor());
146 EXPECT_EQ(Triple::Linux, T.getOS());
148 T = Triple("powerpc-ibm-aix");
149 EXPECT_EQ(Triple::ppc, T.getArch());
150 EXPECT_EQ(Triple::IBM, T.getVendor());
151 EXPECT_EQ(Triple::AIX, T.getOS());
152 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
154 T = Triple("powerpc64-ibm-aix");
155 EXPECT_EQ(Triple::ppc64, T.getArch());
156 EXPECT_EQ(Triple::IBM, T.getVendor());
157 EXPECT_EQ(Triple::AIX, T.getOS());
158 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
160 T = Triple("powerpc-dunno-notsure");
161 EXPECT_EQ(Triple::ppc, T.getArch());
162 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
163 EXPECT_EQ(Triple::UnknownOS, T.getOS());
164 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
166 T = Triple("arm-none-none-eabi");
167 EXPECT_EQ(Triple::arm, T.getArch());
168 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
169 EXPECT_EQ(Triple::UnknownOS, T.getOS());
170 EXPECT_EQ(Triple::EABI, T.getEnvironment());
172 T = Triple("arm-none-linux-musleabi");
173 EXPECT_EQ(Triple::arm, T.getArch());
174 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
175 EXPECT_EQ(Triple::Linux, T.getOS());
176 EXPECT_EQ(Triple::MuslEABI, T.getEnvironment());
178 T = Triple("armv6hl-none-linux-gnueabi");
179 EXPECT_EQ(Triple::arm, T.getArch());
180 EXPECT_EQ(Triple::Linux, T.getOS());
181 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
182 EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
184 T = Triple("armv7hl-none-linux-gnueabi");
185 EXPECT_EQ(Triple::arm, T.getArch());
186 EXPECT_EQ(Triple::Linux, T.getOS());
187 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
188 EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
190 T = Triple("amdil-unknown-unknown");
191 EXPECT_EQ(Triple::amdil, T.getArch());
192 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
193 EXPECT_EQ(Triple::UnknownOS, T.getOS());
195 T = Triple("amdil64-unknown-unknown");
196 EXPECT_EQ(Triple::amdil64, T.getArch());
197 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
198 EXPECT_EQ(Triple::UnknownOS, T.getOS());
200 T = Triple("hsail-unknown-unknown");
201 EXPECT_EQ(Triple::hsail, T.getArch());
202 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
203 EXPECT_EQ(Triple::UnknownOS, T.getOS());
205 T = Triple("hsail64-unknown-unknown");
206 EXPECT_EQ(Triple::hsail64, T.getArch());
207 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
208 EXPECT_EQ(Triple::UnknownOS, T.getOS());
210 T = Triple("sparcel-unknown-unknown");
211 EXPECT_EQ(Triple::sparcel, T.getArch());
212 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
213 EXPECT_EQ(Triple::UnknownOS, T.getOS());
215 T = Triple("spir-unknown-unknown");
216 EXPECT_EQ(Triple::spir, T.getArch());
217 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
218 EXPECT_EQ(Triple::UnknownOS, T.getOS());
220 T = Triple("spir64-unknown-unknown");
221 EXPECT_EQ(Triple::spir64, T.getArch());
222 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
223 EXPECT_EQ(Triple::UnknownOS, T.getOS());
225 T = Triple("x86_64-unknown-ananas");
226 EXPECT_EQ(Triple::x86_64, T.getArch());
227 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
228 EXPECT_EQ(Triple::Ananas, T.getOS());
229 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
231 T = Triple("x86_64-unknown-cloudabi");
232 EXPECT_EQ(Triple::x86_64, T.getArch());
233 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
234 EXPECT_EQ(Triple::CloudABI, T.getOS());
235 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
237 T = Triple("x86_64-unknown-fuchsia");
238 EXPECT_EQ(Triple::x86_64, T.getArch());
239 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
240 EXPECT_EQ(Triple::Fuchsia, T.getOS());
241 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
243 T = Triple("x86_64-unknown-hermit");
244 EXPECT_EQ(Triple::x86_64, T.getArch());
245 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
246 EXPECT_EQ(Triple::HermitCore, T.getOS());
247 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
249 T = Triple("wasm32-unknown-unknown");
250 EXPECT_EQ(Triple::wasm32, T.getArch());
251 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
252 EXPECT_EQ(Triple::UnknownOS, T.getOS());
253 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
255 T = Triple("wasm32-unknown-wasi");
256 EXPECT_EQ(Triple::wasm32, T.getArch());
257 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
258 EXPECT_EQ(Triple::WASI, T.getOS());
259 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
261 T = Triple("wasm64-unknown-unknown");
262 EXPECT_EQ(Triple::wasm64, T.getArch());
263 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
264 EXPECT_EQ(Triple::UnknownOS, T.getOS());
265 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
267 T = Triple("wasm64-unknown-wasi");
268 EXPECT_EQ(Triple::wasm64, T.getArch());
269 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
270 EXPECT_EQ(Triple::WASI, T.getOS());
271 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
273 T = Triple("avr-unknown-unknown");
274 EXPECT_EQ(Triple::avr, T.getArch());
275 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
276 EXPECT_EQ(Triple::UnknownOS, T.getOS());
277 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
279 T = Triple("avr");
280 EXPECT_EQ(Triple::avr, T.getArch());
281 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
282 EXPECT_EQ(Triple::UnknownOS, T.getOS());
283 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
285 T = Triple("lanai-unknown-unknown");
286 EXPECT_EQ(Triple::lanai, T.getArch());
287 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
288 EXPECT_EQ(Triple::UnknownOS, T.getOS());
289 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
291 T = Triple("lanai");
292 EXPECT_EQ(Triple::lanai, T.getArch());
293 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
294 EXPECT_EQ(Triple::UnknownOS, T.getOS());
295 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
297 T = Triple("amdgcn-mesa-mesa3d");
298 EXPECT_EQ(Triple::amdgcn, T.getArch());
299 EXPECT_EQ(Triple::Mesa, T.getVendor());
300 EXPECT_EQ(Triple::Mesa3D, T.getOS());
301 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
303 T = Triple("amdgcn-amd-amdhsa");
304 EXPECT_EQ(Triple::amdgcn, T.getArch());
305 EXPECT_EQ(Triple::AMD, T.getVendor());
306 EXPECT_EQ(Triple::AMDHSA, T.getOS());
307 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
309 T = Triple("amdgcn-amd-amdpal");
310 EXPECT_EQ(Triple::amdgcn, T.getArch());
311 EXPECT_EQ(Triple::AMD, T.getVendor());
312 EXPECT_EQ(Triple::AMDPAL, T.getOS());
313 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
315 T = Triple("riscv32-unknown-unknown");
316 EXPECT_EQ(Triple::riscv32, T.getArch());
317 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
318 EXPECT_EQ(Triple::UnknownOS, T.getOS());
319 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
321 T = Triple("riscv64-unknown-linux");
322 EXPECT_EQ(Triple::riscv64, T.getArch());
323 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
324 EXPECT_EQ(Triple::Linux, T.getOS());
325 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
327 T = Triple("riscv64-unknown-freebsd");
328 EXPECT_EQ(Triple::riscv64, T.getArch());
329 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
330 EXPECT_EQ(Triple::FreeBSD, T.getOS());
331 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
333 T = Triple("riscv64-suse-linux");
334 EXPECT_EQ(Triple::riscv64, T.getArch());
335 EXPECT_EQ(Triple::SUSE, T.getVendor());
336 EXPECT_EQ(Triple::Linux, T.getOS());
337 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
339 T = Triple("armv7hl-suse-linux-gnueabi");
340 EXPECT_EQ(Triple::arm, T.getArch());
341 EXPECT_EQ(Triple::SUSE, T.getVendor());
342 EXPECT_EQ(Triple::Linux, T.getOS());
343 EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
345 T = Triple("i586-pc-haiku");
346 EXPECT_EQ(Triple::x86, T.getArch());
347 EXPECT_EQ(Triple::PC, T.getVendor());
348 EXPECT_EQ(Triple::Haiku, T.getOS());
349 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
351 T = Triple("x86_64-unknown-haiku");
352 EXPECT_EQ(Triple::x86_64, T.getArch());
353 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
354 EXPECT_EQ(Triple::Haiku, T.getOS());
355 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
357 T = Triple("mips-mti-linux-gnu");
358 EXPECT_EQ(Triple::mips, T.getArch());
359 EXPECT_EQ(Triple::MipsTechnologies, T.getVendor());
360 EXPECT_EQ(Triple::Linux, T.getOS());
361 EXPECT_EQ(Triple::GNU, T.getEnvironment());
363 T = Triple("mipsel-img-linux-gnu");
364 EXPECT_EQ(Triple::mipsel, T.getArch());
365 EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor());
366 EXPECT_EQ(Triple::Linux, T.getOS());
367 EXPECT_EQ(Triple::GNU, T.getEnvironment());
369 T = Triple("mips64-mti-linux-gnu");
370 EXPECT_EQ(Triple::mips64, T.getArch());
371 EXPECT_EQ(Triple::MipsTechnologies, T.getVendor());
372 EXPECT_EQ(Triple::Linux, T.getOS());
373 EXPECT_EQ(Triple::GNU, T.getEnvironment());
375 T = Triple("mips64el-img-linux-gnu");
376 EXPECT_EQ(Triple::mips64el, T.getArch());
377 EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor());
378 EXPECT_EQ(Triple::Linux, T.getOS());
379 EXPECT_EQ(Triple::GNU, T.getEnvironment());
381 T = Triple("mips64el-img-linux-gnuabin32");
382 EXPECT_EQ(Triple::mips64el, T.getArch());
383 EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor());
384 EXPECT_EQ(Triple::Linux, T.getOS());
385 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
387 T = Triple("mips64el-unknown-linux-gnuabi64");
388 EXPECT_EQ(Triple::mips64el, T.getArch());
389 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
390 EXPECT_EQ(Triple::Linux, T.getOS());
391 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
392 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
393 T = Triple("mips64el");
394 EXPECT_EQ(Triple::mips64el, T.getArch());
395 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
396 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
397 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
399 T = Triple("mips64-unknown-linux-gnuabi64");
400 EXPECT_EQ(Triple::mips64, T.getArch());
401 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
402 EXPECT_EQ(Triple::Linux, T.getOS());
403 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
404 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
405 T = Triple("mips64");
406 EXPECT_EQ(Triple::mips64, T.getArch());
407 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
408 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
409 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
411 T = Triple("mipsisa64r6el-unknown-linux-gnuabi64");
412 EXPECT_EQ(Triple::mips64el, T.getArch());
413 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
414 EXPECT_EQ(Triple::Linux, T.getOS());
415 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
416 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
417 T = Triple("mips64r6el");
418 EXPECT_EQ(Triple::mips64el, T.getArch());
419 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
420 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
421 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
422 T = Triple("mipsisa64r6el");
423 EXPECT_EQ(Triple::mips64el, T.getArch());
424 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
425 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
426 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
428 T = Triple("mipsisa64r6-unknown-linux-gnuabi64");
429 EXPECT_EQ(Triple::mips64, T.getArch());
430 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
431 EXPECT_EQ(Triple::Linux, T.getOS());
432 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
433 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
434 T = Triple("mips64r6");
435 EXPECT_EQ(Triple::mips64, T.getArch());
436 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
437 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
438 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
439 T = Triple("mipsisa64r6");
440 EXPECT_EQ(Triple::mips64, T.getArch());
441 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
442 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
443 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
445 T = Triple("mips64el-unknown-linux-gnuabin32");
446 EXPECT_EQ(Triple::mips64el, T.getArch());
447 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
448 EXPECT_EQ(Triple::Linux, T.getOS());
449 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
450 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
451 T = Triple("mipsn32el");
452 EXPECT_EQ(Triple::mips64el, T.getArch());
453 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
454 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
455 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
457 T = Triple("mips64-unknown-linux-gnuabin32");
458 EXPECT_EQ(Triple::mips64, T.getArch());
459 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
460 EXPECT_EQ(Triple::Linux, T.getOS());
461 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
462 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
463 T = Triple("mipsn32");
464 EXPECT_EQ(Triple::mips64, T.getArch());
465 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
466 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
467 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
469 T = Triple("mipsisa64r6el-unknown-linux-gnuabin32");
470 EXPECT_EQ(Triple::mips64el, T.getArch());
471 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
472 EXPECT_EQ(Triple::Linux, T.getOS());
473 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
474 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
475 T = Triple("mipsn32r6el");
476 EXPECT_EQ(Triple::mips64el, T.getArch());
477 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
478 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
479 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
481 T = Triple("mipsisa64r6-unknown-linux-gnuabin32");
482 EXPECT_EQ(Triple::mips64, T.getArch());
483 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
484 EXPECT_EQ(Triple::Linux, T.getOS());
485 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
486 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
487 T = Triple("mipsn32r6");
488 EXPECT_EQ(Triple::mips64, T.getArch());
489 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
490 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
491 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
493 T = Triple("mipsel-unknown-linux-gnu");
494 EXPECT_EQ(Triple::mipsel, T.getArch());
495 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
496 EXPECT_EQ(Triple::Linux, T.getOS());
497 EXPECT_EQ(Triple::GNU, T.getEnvironment());
498 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
499 T = Triple("mipsel");
500 EXPECT_EQ(Triple::mipsel, T.getArch());
501 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
502 EXPECT_EQ(Triple::GNU, T.getEnvironment());
503 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
505 T = Triple("mips-unknown-linux-gnu");
506 EXPECT_EQ(Triple::mips, T.getArch());
507 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
508 EXPECT_EQ(Triple::Linux, T.getOS());
509 EXPECT_EQ(Triple::GNU, T.getEnvironment());
510 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
511 T = Triple("mips");
512 EXPECT_EQ(Triple::mips, T.getArch());
513 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
514 EXPECT_EQ(Triple::GNU, T.getEnvironment());
515 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
517 T = Triple("mipsisa32r6el-unknown-linux-gnu");
518 EXPECT_EQ(Triple::mipsel, T.getArch());
519 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
520 EXPECT_EQ(Triple::Linux, T.getOS());
521 EXPECT_EQ(Triple::GNU, T.getEnvironment());
522 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
523 T = Triple("mipsr6el");
524 EXPECT_EQ(Triple::mipsel, T.getArch());
525 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
526 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
527 T = Triple("mipsisa32r6el");
528 EXPECT_EQ(Triple::mipsel, T.getArch());
529 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
530 EXPECT_EQ(Triple::GNU, T.getEnvironment());
531 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
533 T = Triple("mipsisa32r6-unknown-linux-gnu");
534 EXPECT_EQ(Triple::mips, T.getArch());
535 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
536 EXPECT_EQ(Triple::Linux, T.getOS());
537 EXPECT_EQ(Triple::GNU, T.getEnvironment());
538 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
539 T = Triple("mipsr6");
540 EXPECT_EQ(Triple::mips, T.getArch());
541 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
542 EXPECT_EQ(Triple::GNU, T.getEnvironment());
543 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
544 T = Triple("mipsisa32r6");
545 EXPECT_EQ(Triple::mips, T.getArch());
546 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
547 EXPECT_EQ(Triple::GNU, T.getEnvironment());
548 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
550 T = Triple("arm-oe-linux-gnueabi");
551 EXPECT_EQ(Triple::arm, T.getArch());
552 EXPECT_EQ(Triple::OpenEmbedded, T.getVendor());
553 EXPECT_EQ(Triple::Linux, T.getOS());
554 EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
556 T = Triple("aarch64-oe-linux");
557 EXPECT_EQ(Triple::aarch64, T.getArch());
558 EXPECT_EQ(Triple::OpenEmbedded, T.getVendor());
559 EXPECT_EQ(Triple::Linux, T.getOS());
560 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
561 EXPECT_TRUE(T.isArch64Bit());
563 T = Triple("arm64_32-apple-ios");
564 EXPECT_EQ(Triple::aarch64_32, T.getArch());
565 EXPECT_EQ(Triple::IOS, T.getOS());
566 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
567 EXPECT_TRUE(T.isArch32Bit());
569 T = Triple("huh");
570 EXPECT_EQ(Triple::UnknownArch, T.getArch());
573 static std::string Join(StringRef A, StringRef B, StringRef C) {
574 std::string Str = A;
575 Str += '-';
576 Str += B;
577 Str += '-';
578 Str += C;
579 return Str;
582 static std::string Join(StringRef A, StringRef B, StringRef C, StringRef D) {
583 std::string Str = A;
584 Str += '-';
585 Str += B;
586 Str += '-';
587 Str += C;
588 Str += '-';
589 Str += D;
590 return Str;
593 TEST(TripleTest, Normalization) {
595 EXPECT_EQ("unknown", Triple::normalize(""));
596 EXPECT_EQ("unknown-unknown", Triple::normalize("-"));
597 EXPECT_EQ("unknown-unknown-unknown", Triple::normalize("--"));
598 EXPECT_EQ("unknown-unknown-unknown-unknown", Triple::normalize("---"));
599 EXPECT_EQ("unknown-unknown-unknown-unknown-unknown",
600 Triple::normalize("----"));
602 EXPECT_EQ("a", Triple::normalize("a"));
603 EXPECT_EQ("a-b", Triple::normalize("a-b"));
604 EXPECT_EQ("a-b-c", Triple::normalize("a-b-c"));
605 EXPECT_EQ("a-b-c-d", Triple::normalize("a-b-c-d"));
607 EXPECT_EQ("i386-b-c", Triple::normalize("i386-b-c"));
608 EXPECT_EQ("i386-a-c", Triple::normalize("a-i386-c"));
609 EXPECT_EQ("i386-a-b", Triple::normalize("a-b-i386"));
610 EXPECT_EQ("i386-a-b-c", Triple::normalize("a-b-c-i386"));
612 EXPECT_EQ("a-pc-c", Triple::normalize("a-pc-c"));
613 EXPECT_EQ("unknown-pc-b-c", Triple::normalize("pc-b-c"));
614 EXPECT_EQ("a-pc-b", Triple::normalize("a-b-pc"));
615 EXPECT_EQ("a-pc-b-c", Triple::normalize("a-b-c-pc"));
617 EXPECT_EQ("a-b-linux", Triple::normalize("a-b-linux"));
618 EXPECT_EQ("unknown-unknown-linux-b-c", Triple::normalize("linux-b-c"));
619 EXPECT_EQ("a-unknown-linux-c", Triple::normalize("a-linux-c"));
621 EXPECT_EQ("i386-pc-a", Triple::normalize("a-pc-i386"));
622 EXPECT_EQ("i386-pc-unknown", Triple::normalize("-pc-i386"));
623 EXPECT_EQ("unknown-pc-linux-c", Triple::normalize("linux-pc-c"));
624 EXPECT_EQ("unknown-pc-linux", Triple::normalize("linux-pc-"));
626 EXPECT_EQ("i386", Triple::normalize("i386"));
627 EXPECT_EQ("unknown-pc", Triple::normalize("pc"));
628 EXPECT_EQ("unknown-unknown-linux", Triple::normalize("linux"));
630 EXPECT_EQ("x86_64-unknown-linux-gnu", Triple::normalize("x86_64-gnu-linux"));
632 // Check that normalizing a permutated set of valid components returns a
633 // triple with the unpermuted components.
635 // We don't check every possible combination. For the set of architectures A,
636 // vendors V, operating systems O, and environments E, that would require |A|
637 // * |V| * |O| * |E| * 4! tests. Instead we check every option for any given
638 // slot and make sure it gets normalized to the correct position from every
639 // permutation. This should cover the core logic while being a tractable
640 // number of tests at (|A| + |V| + |O| + |E|) * 4!.
641 auto FirstArchType = Triple::ArchType(Triple::UnknownArch + 1);
642 auto FirstVendorType = Triple::VendorType(Triple::UnknownVendor + 1);
643 auto FirstOSType = Triple::OSType(Triple::UnknownOS + 1);
644 auto FirstEnvType = Triple::EnvironmentType(Triple::UnknownEnvironment + 1);
645 StringRef InitialC[] = {Triple::getArchTypeName(FirstArchType),
646 Triple::getVendorTypeName(FirstVendorType),
647 Triple::getOSTypeName(FirstOSType),
648 Triple::getEnvironmentTypeName(FirstEnvType)};
649 for (int Arch = FirstArchType; Arch <= Triple::LastArchType; ++Arch) {
650 StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
651 C[0] = Triple::getArchTypeName(Triple::ArchType(Arch));
652 std::string E = Join(C[0], C[1], C[2]);
653 int I[] = {0, 1, 2};
654 do {
655 EXPECT_EQ(E, Triple::normalize(Join(C[I[0]], C[I[1]], C[I[2]])));
656 } while (std::next_permutation(std::begin(I), std::end(I)));
657 std::string F = Join(C[0], C[1], C[2], C[3]);
658 int J[] = {0, 1, 2, 3};
659 do {
660 EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
661 } while (std::next_permutation(std::begin(J), std::end(J)));
663 for (int Vendor = FirstVendorType; Vendor <= Triple::LastVendorType;
664 ++Vendor) {
665 StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
666 C[1] = Triple::getVendorTypeName(Triple::VendorType(Vendor));
667 std::string E = Join(C[0], C[1], C[2]);
668 int I[] = {0, 1, 2};
669 do {
670 EXPECT_EQ(E, Triple::normalize(Join(C[I[0]], C[I[1]], C[I[2]])));
671 } while (std::next_permutation(std::begin(I), std::end(I)));
672 std::string F = Join(C[0], C[1], C[2], C[3]);
673 int J[] = {0, 1, 2, 3};
674 do {
675 EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
676 } while (std::next_permutation(std::begin(J), std::end(J)));
678 for (int OS = FirstOSType; OS <= Triple::LastOSType; ++OS) {
679 if (OS == Triple::Win32)
680 continue;
681 StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
682 C[2] = Triple::getOSTypeName(Triple::OSType(OS));
683 std::string E = Join(C[0], C[1], C[2]);
684 int I[] = {0, 1, 2};
685 do {
686 EXPECT_EQ(E, Triple::normalize(Join(C[I[0]], C[I[1]], C[I[2]])));
687 } while (std::next_permutation(std::begin(I), std::end(I)));
688 std::string F = Join(C[0], C[1], C[2], C[3]);
689 int J[] = {0, 1, 2, 3};
690 do {
691 EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
692 } while (std::next_permutation(std::begin(J), std::end(J)));
694 for (int Env = FirstEnvType; Env <= Triple::LastEnvironmentType; ++Env) {
695 StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
696 C[3] = Triple::getEnvironmentTypeName(Triple::EnvironmentType(Env));
697 std::string F = Join(C[0], C[1], C[2], C[3]);
698 int J[] = {0, 1, 2, 3};
699 do {
700 EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
701 } while (std::next_permutation(std::begin(J), std::end(J)));
704 // Various real-world funky triples. The value returned by GCC's config.sub
705 // is given in the comment.
706 EXPECT_EQ("i386-unknown-windows-gnu",
707 Triple::normalize("i386-mingw32")); // i386-pc-mingw32
708 EXPECT_EQ("x86_64-unknown-linux-gnu",
709 Triple::normalize("x86_64-linux-gnu")); // x86_64-pc-linux-gnu
710 EXPECT_EQ("i486-unknown-linux-gnu",
711 Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu
712 EXPECT_EQ("i386-redhat-linux",
713 Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu
714 EXPECT_EQ("i686-unknown-linux",
715 Triple::normalize("i686-linux")); // i686-pc-linux-gnu
716 EXPECT_EQ("arm-none-unknown-eabi",
717 Triple::normalize("arm-none-eabi")); // arm-none-eabi
718 EXPECT_EQ("wasm32-unknown-wasi",
719 Triple::normalize("wasm32-wasi")); // wasm32-unknown-wasi
720 EXPECT_EQ("wasm64-unknown-wasi",
721 Triple::normalize("wasm64-wasi")); // wasm64-unknown-wasi
724 TEST(TripleTest, MutateName) {
725 Triple T;
726 EXPECT_EQ(Triple::UnknownArch, T.getArch());
727 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
728 EXPECT_EQ(Triple::UnknownOS, T.getOS());
729 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
731 T.setArchName("i386");
732 EXPECT_EQ(Triple::x86, T.getArch());
733 EXPECT_EQ("i386--", T.getTriple());
735 T.setVendorName("pc");
736 EXPECT_EQ(Triple::x86, T.getArch());
737 EXPECT_EQ(Triple::PC, T.getVendor());
738 EXPECT_EQ("i386-pc-", T.getTriple());
740 T.setOSName("linux");
741 EXPECT_EQ(Triple::x86, T.getArch());
742 EXPECT_EQ(Triple::PC, T.getVendor());
743 EXPECT_EQ(Triple::Linux, T.getOS());
744 EXPECT_EQ("i386-pc-linux", T.getTriple());
746 T.setEnvironmentName("gnu");
747 EXPECT_EQ(Triple::x86, T.getArch());
748 EXPECT_EQ(Triple::PC, T.getVendor());
749 EXPECT_EQ(Triple::Linux, T.getOS());
750 EXPECT_EQ("i386-pc-linux-gnu", T.getTriple());
752 T.setOSName("freebsd");
753 EXPECT_EQ(Triple::x86, T.getArch());
754 EXPECT_EQ(Triple::PC, T.getVendor());
755 EXPECT_EQ(Triple::FreeBSD, T.getOS());
756 EXPECT_EQ("i386-pc-freebsd-gnu", T.getTriple());
758 T.setOSAndEnvironmentName("darwin");
759 EXPECT_EQ(Triple::x86, T.getArch());
760 EXPECT_EQ(Triple::PC, T.getVendor());
761 EXPECT_EQ(Triple::Darwin, T.getOS());
762 EXPECT_EQ("i386-pc-darwin", T.getTriple());
765 TEST(TripleTest, BitWidthPredicates) {
766 Triple T;
767 EXPECT_FALSE(T.isArch16Bit());
768 EXPECT_FALSE(T.isArch32Bit());
769 EXPECT_FALSE(T.isArch64Bit());
771 T.setArch(Triple::arm);
772 EXPECT_FALSE(T.isArch16Bit());
773 EXPECT_TRUE(T.isArch32Bit());
774 EXPECT_FALSE(T.isArch64Bit());
776 T.setArch(Triple::hexagon);
777 EXPECT_FALSE(T.isArch16Bit());
778 EXPECT_TRUE(T.isArch32Bit());
779 EXPECT_FALSE(T.isArch64Bit());
781 T.setArch(Triple::mips);
782 EXPECT_FALSE(T.isArch16Bit());
783 EXPECT_TRUE(T.isArch32Bit());
784 EXPECT_FALSE(T.isArch64Bit());
786 T.setArch(Triple::mips64);
787 EXPECT_FALSE(T.isArch16Bit());
788 EXPECT_FALSE(T.isArch32Bit());
789 EXPECT_TRUE(T.isArch64Bit());
791 T.setArch(Triple::msp430);
792 EXPECT_TRUE(T.isArch16Bit());
793 EXPECT_FALSE(T.isArch32Bit());
794 EXPECT_FALSE(T.isArch64Bit());
796 T.setArch(Triple::ppc);
797 EXPECT_FALSE(T.isArch16Bit());
798 EXPECT_TRUE(T.isArch32Bit());
799 EXPECT_FALSE(T.isArch64Bit());
801 T.setArch(Triple::ppc64);
802 EXPECT_FALSE(T.isArch16Bit());
803 EXPECT_FALSE(T.isArch32Bit());
804 EXPECT_TRUE(T.isArch64Bit());
806 T.setArch(Triple::x86);
807 EXPECT_FALSE(T.isArch16Bit());
808 EXPECT_TRUE(T.isArch32Bit());
809 EXPECT_FALSE(T.isArch64Bit());
811 T.setArch(Triple::x86_64);
812 EXPECT_FALSE(T.isArch16Bit());
813 EXPECT_FALSE(T.isArch32Bit());
814 EXPECT_TRUE(T.isArch64Bit());
816 T.setArch(Triple::amdil);
817 EXPECT_FALSE(T.isArch16Bit());
818 EXPECT_TRUE(T.isArch32Bit());
819 EXPECT_FALSE(T.isArch64Bit());
821 T.setArch(Triple::amdil64);
822 EXPECT_FALSE(T.isArch16Bit());
823 EXPECT_FALSE(T.isArch32Bit());
824 EXPECT_TRUE(T.isArch64Bit());
826 T.setArch(Triple::hsail);
827 EXPECT_FALSE(T.isArch16Bit());
828 EXPECT_TRUE(T.isArch32Bit());
829 EXPECT_FALSE(T.isArch64Bit());
831 T.setArch(Triple::hsail64);
832 EXPECT_FALSE(T.isArch16Bit());
833 EXPECT_FALSE(T.isArch32Bit());
834 EXPECT_TRUE(T.isArch64Bit());
836 T.setArch(Triple::spir);
837 EXPECT_FALSE(T.isArch16Bit());
838 EXPECT_TRUE(T.isArch32Bit());
839 EXPECT_FALSE(T.isArch64Bit());
841 T.setArch(Triple::spir64);
842 EXPECT_FALSE(T.isArch16Bit());
843 EXPECT_FALSE(T.isArch32Bit());
844 EXPECT_TRUE(T.isArch64Bit());
846 T.setArch(Triple::sparc);
847 EXPECT_FALSE(T.isArch16Bit());
848 EXPECT_TRUE(T.isArch32Bit());
849 EXPECT_FALSE(T.isArch64Bit());
851 T.setArch(Triple::sparcel);
852 EXPECT_FALSE(T.isArch16Bit());
853 EXPECT_TRUE(T.isArch32Bit());
854 EXPECT_FALSE(T.isArch64Bit());
856 T.setArch(Triple::sparcv9);
857 EXPECT_FALSE(T.isArch16Bit());
858 EXPECT_FALSE(T.isArch32Bit());
859 EXPECT_TRUE(T.isArch64Bit());
861 T.setArch(Triple::wasm32);
862 EXPECT_FALSE(T.isArch16Bit());
863 EXPECT_TRUE(T.isArch32Bit());
864 EXPECT_FALSE(T.isArch64Bit());
866 T.setArch(Triple::wasm64);
867 EXPECT_FALSE(T.isArch16Bit());
868 EXPECT_FALSE(T.isArch32Bit());
869 EXPECT_TRUE(T.isArch64Bit());
871 T.setArch(Triple::avr);
872 EXPECT_TRUE(T.isArch16Bit());
873 EXPECT_FALSE(T.isArch32Bit());
874 EXPECT_FALSE(T.isArch64Bit());
876 T.setArch(Triple::lanai);
877 EXPECT_FALSE(T.isArch16Bit());
878 EXPECT_TRUE(T.isArch32Bit());
879 EXPECT_FALSE(T.isArch64Bit());
881 T.setArch(Triple::riscv32);
882 EXPECT_FALSE(T.isArch16Bit());
883 EXPECT_TRUE(T.isArch32Bit());
884 EXPECT_FALSE(T.isArch64Bit());
885 EXPECT_TRUE(T.isRISCV());
887 T.setArch(Triple::riscv64);
888 EXPECT_FALSE(T.isArch16Bit());
889 EXPECT_FALSE(T.isArch32Bit());
890 EXPECT_TRUE(T.isArch64Bit());
891 EXPECT_TRUE(T.isRISCV());
894 TEST(TripleTest, BitWidthArchVariants) {
895 Triple T;
896 EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
897 EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
899 T.setArch(Triple::UnknownArch);
900 EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
901 EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
903 T.setArch(Triple::mips);
904 EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
905 EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
907 T.setArch(Triple::mipsel);
908 EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
909 EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
911 T.setArch(Triple::ppc);
912 EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
913 EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
915 T.setArch(Triple::nvptx);
916 EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
917 EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
919 T.setArch(Triple::sparc);
920 EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
921 EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
923 T.setArch(Triple::x86);
924 EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
925 EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
927 T.setArch(Triple::mips64);
928 EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
929 EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
931 T.setArch(Triple::mips64el);
932 EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
933 EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
935 T.setArch(Triple::ppc64);
936 EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
937 EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
939 T.setArch(Triple::nvptx64);
940 EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
941 EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
943 T.setArch(Triple::sparcv9);
944 EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
945 EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
947 T.setArch(Triple::x86_64);
948 EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
949 EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
951 T.setArch(Triple::amdil);
952 EXPECT_EQ(Triple::amdil, T.get32BitArchVariant().getArch());
953 EXPECT_EQ(Triple::amdil64, T.get64BitArchVariant().getArch());
955 T.setArch(Triple::amdil64);
956 EXPECT_EQ(Triple::amdil, T.get32BitArchVariant().getArch());
957 EXPECT_EQ(Triple::amdil64, T.get64BitArchVariant().getArch());
959 T.setArch(Triple::hsail);
960 EXPECT_EQ(Triple::hsail, T.get32BitArchVariant().getArch());
961 EXPECT_EQ(Triple::hsail64, T.get64BitArchVariant().getArch());
963 T.setArch(Triple::hsail64);
964 EXPECT_EQ(Triple::hsail, T.get32BitArchVariant().getArch());
965 EXPECT_EQ(Triple::hsail64, T.get64BitArchVariant().getArch());
967 T.setArch(Triple::spir);
968 EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
969 EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
971 T.setArch(Triple::spir64);
972 EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
973 EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
975 T.setArch(Triple::wasm32);
976 EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
977 EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
979 T.setArch(Triple::wasm64);
980 EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
981 EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
983 T.setArch(Triple::riscv32);
984 EXPECT_EQ(Triple::riscv32, T.get32BitArchVariant().getArch());
985 EXPECT_EQ(Triple::riscv64, T.get64BitArchVariant().getArch());
987 T.setArch(Triple::riscv64);
988 EXPECT_EQ(Triple::riscv32, T.get32BitArchVariant().getArch());
989 EXPECT_EQ(Triple::riscv64, T.get64BitArchVariant().getArch());
991 T.setArch(Triple::thumbeb);
992 EXPECT_EQ(Triple::thumbeb, T.get32BitArchVariant().getArch());
993 EXPECT_EQ(Triple::aarch64_be, T.get64BitArchVariant().getArch());
995 T.setArch(Triple::thumb);
996 EXPECT_EQ(Triple::thumb, T.get32BitArchVariant().getArch());
997 EXPECT_EQ(Triple::aarch64, T.get64BitArchVariant().getArch());
999 T.setArch(Triple::aarch64);
1000 EXPECT_EQ(Triple::arm, T.get32BitArchVariant().getArch());
1001 EXPECT_EQ(Triple::aarch64, T.get64BitArchVariant().getArch());
1003 T.setArch(Triple::aarch64_be);
1004 EXPECT_EQ(Triple::armeb, T.get32BitArchVariant().getArch());
1005 EXPECT_EQ(Triple::aarch64_be, T.get64BitArchVariant().getArch());
1007 T.setArch(Triple::renderscript32);
1008 EXPECT_EQ(Triple::renderscript32, T.get32BitArchVariant().getArch());
1009 EXPECT_EQ(Triple::renderscript64, T.get64BitArchVariant().getArch());
1011 T.setArch(Triple::renderscript64);
1012 EXPECT_EQ(Triple::renderscript32, T.get32BitArchVariant().getArch());
1013 EXPECT_EQ(Triple::renderscript64, T.get64BitArchVariant().getArch());
1015 T.setArch(Triple::le32);
1016 EXPECT_EQ(Triple::le32, T.get32BitArchVariant().getArch());
1017 EXPECT_EQ(Triple::le64, T.get64BitArchVariant().getArch());
1019 T.setArch(Triple::le64);
1020 EXPECT_EQ(Triple::le32, T.get32BitArchVariant().getArch());
1021 EXPECT_EQ(Triple::le64, T.get64BitArchVariant().getArch());
1023 T.setArch(Triple::armeb);
1024 EXPECT_EQ(Triple::armeb, T.get32BitArchVariant().getArch());
1025 EXPECT_EQ(Triple::aarch64_be, T.get64BitArchVariant().getArch());
1027 T.setArch(Triple::arm);
1028 EXPECT_EQ(Triple::arm, T.get32BitArchVariant().getArch());
1029 EXPECT_EQ(Triple::aarch64, T.get64BitArchVariant().getArch());
1031 T.setArch(Triple::systemz);
1032 EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
1033 EXPECT_EQ(Triple::systemz, T.get64BitArchVariant().getArch());
1035 T.setArch(Triple::xcore);
1036 EXPECT_EQ(Triple::xcore, T.get32BitArchVariant().getArch());
1037 EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
1040 TEST(TripleTest, EndianArchVariants) {
1041 Triple T;
1042 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
1043 EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
1045 T.setArch(Triple::UnknownArch);
1046 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
1047 EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
1049 T.setArch(Triple::aarch64_be);
1050 EXPECT_EQ(Triple::aarch64_be, T.getBigEndianArchVariant().getArch());
1051 EXPECT_EQ(Triple::aarch64, T.getLittleEndianArchVariant().getArch());
1053 T.setArch(Triple::aarch64);
1054 EXPECT_EQ(Triple::aarch64_be, T.getBigEndianArchVariant().getArch());
1055 EXPECT_EQ(Triple::aarch64, T.getLittleEndianArchVariant().getArch());
1057 T.setArch(Triple::armeb);
1058 EXPECT_EQ(Triple::armeb, T.getBigEndianArchVariant().getArch());
1059 EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
1061 T.setArch(Triple::arm);
1062 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
1063 EXPECT_EQ(Triple::arm, T.getLittleEndianArchVariant().getArch());
1064 T = Triple("arm");
1065 EXPECT_TRUE(T.isLittleEndian());
1066 T = Triple("thumb");
1067 EXPECT_TRUE(T.isLittleEndian());
1068 T = Triple("armeb");
1069 EXPECT_FALSE(T.isLittleEndian());
1070 T = Triple("thumbeb");
1071 EXPECT_FALSE(T.isLittleEndian());
1073 T.setArch(Triple::bpfeb);
1074 EXPECT_EQ(Triple::bpfeb, T.getBigEndianArchVariant().getArch());
1075 EXPECT_EQ(Triple::bpfel, T.getLittleEndianArchVariant().getArch());
1077 T.setArch(Triple::bpfel);
1078 EXPECT_EQ(Triple::bpfeb, T.getBigEndianArchVariant().getArch());
1079 EXPECT_EQ(Triple::bpfel, T.getLittleEndianArchVariant().getArch());
1081 T.setArch(Triple::mips64);
1082 EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
1083 EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
1085 T.setArch(Triple::mips64el);
1086 EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
1087 EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
1089 T.setArch(Triple::mips);
1090 EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
1091 EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
1093 T.setArch(Triple::mipsel);
1094 EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
1095 EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
1097 T.setArch(Triple::ppc);
1098 EXPECT_EQ(Triple::ppc, T.getBigEndianArchVariant().getArch());
1099 EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
1101 T.setArch(Triple::ppc64);
1102 EXPECT_EQ(Triple::ppc64, T.getBigEndianArchVariant().getArch());
1103 EXPECT_EQ(Triple::ppc64le, T.getLittleEndianArchVariant().getArch());
1105 T.setArch(Triple::ppc64le);
1106 EXPECT_EQ(Triple::ppc64, T.getBigEndianArchVariant().getArch());
1107 EXPECT_EQ(Triple::ppc64le, T.getLittleEndianArchVariant().getArch());
1109 T.setArch(Triple::sparc);
1110 EXPECT_EQ(Triple::sparc, T.getBigEndianArchVariant().getArch());
1111 EXPECT_EQ(Triple::sparcel, T.getLittleEndianArchVariant().getArch());
1113 T.setArch(Triple::sparcel);
1114 EXPECT_EQ(Triple::sparc, T.getBigEndianArchVariant().getArch());
1115 EXPECT_EQ(Triple::sparcel, T.getLittleEndianArchVariant().getArch());
1117 T.setArch(Triple::thumb);
1118 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
1119 EXPECT_EQ(Triple::thumb, T.getLittleEndianArchVariant().getArch());
1121 T.setArch(Triple::thumbeb);
1122 EXPECT_EQ(Triple::thumbeb, T.getBigEndianArchVariant().getArch());
1123 EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
1125 T.setArch(Triple::lanai);
1126 EXPECT_EQ(Triple::lanai, T.getBigEndianArchVariant().getArch());
1127 EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
1129 T.setArch(Triple::tcele);
1130 EXPECT_EQ(Triple::tce, T.getBigEndianArchVariant().getArch());
1131 EXPECT_EQ(Triple::tcele, T.getLittleEndianArchVariant().getArch());
1133 T.setArch(Triple::tce);
1134 EXPECT_EQ(Triple::tce, T.getBigEndianArchVariant().getArch());
1135 EXPECT_EQ(Triple::tcele, T.getLittleEndianArchVariant().getArch());
1137 T.setArch(Triple::le32);
1138 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
1139 EXPECT_EQ(Triple::le32, T.getLittleEndianArchVariant().getArch());
1141 T.setArch(Triple::le64);
1142 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
1143 EXPECT_EQ(Triple::le64, T.getLittleEndianArchVariant().getArch());
1146 TEST(TripleTest, getOSVersion) {
1147 Triple T;
1148 unsigned Major, Minor, Micro;
1150 T = Triple("i386-apple-darwin9");
1151 EXPECT_TRUE(T.isMacOSX());
1152 EXPECT_FALSE(T.isiOS());
1153 EXPECT_FALSE(T.isArch16Bit());
1154 EXPECT_TRUE(T.isArch32Bit());
1155 EXPECT_FALSE(T.isArch64Bit());
1156 T.getMacOSXVersion(Major, Minor, Micro);
1157 EXPECT_EQ((unsigned)10, Major);
1158 EXPECT_EQ((unsigned)5, Minor);
1159 EXPECT_EQ((unsigned)0, Micro);
1160 T.getiOSVersion(Major, Minor, Micro);
1161 EXPECT_EQ((unsigned)5, Major);
1162 EXPECT_EQ((unsigned)0, Minor);
1163 EXPECT_EQ((unsigned)0, Micro);
1165 T = Triple("x86_64-apple-darwin9");
1166 EXPECT_TRUE(T.isMacOSX());
1167 EXPECT_FALSE(T.isiOS());
1168 EXPECT_FALSE(T.isArch16Bit());
1169 EXPECT_FALSE(T.isArch32Bit());
1170 EXPECT_TRUE(T.isArch64Bit());
1171 T.getMacOSXVersion(Major, Minor, Micro);
1172 EXPECT_EQ((unsigned)10, Major);
1173 EXPECT_EQ((unsigned)5, Minor);
1174 EXPECT_EQ((unsigned)0, Micro);
1175 T.getiOSVersion(Major, Minor, Micro);
1176 EXPECT_EQ((unsigned)5, Major);
1177 EXPECT_EQ((unsigned)0, Minor);
1178 EXPECT_EQ((unsigned)0, Micro);
1180 T = Triple("x86_64-apple-macosx");
1181 EXPECT_TRUE(T.isMacOSX());
1182 EXPECT_FALSE(T.isiOS());
1183 EXPECT_FALSE(T.isArch16Bit());
1184 EXPECT_FALSE(T.isArch32Bit());
1185 EXPECT_TRUE(T.isArch64Bit());
1186 T.getMacOSXVersion(Major, Minor, Micro);
1187 EXPECT_EQ((unsigned)10, Major);
1188 EXPECT_EQ((unsigned)4, Minor);
1189 EXPECT_EQ((unsigned)0, Micro);
1190 T.getiOSVersion(Major, Minor, Micro);
1191 EXPECT_EQ((unsigned)5, Major);
1192 EXPECT_EQ((unsigned)0, Minor);
1193 EXPECT_EQ((unsigned)0, Micro);
1195 T = Triple("x86_64-apple-macosx10.7");
1196 EXPECT_TRUE(T.isMacOSX());
1197 EXPECT_FALSE(T.isiOS());
1198 EXPECT_FALSE(T.isArch16Bit());
1199 EXPECT_FALSE(T.isArch32Bit());
1200 EXPECT_TRUE(T.isArch64Bit());
1201 T.getMacOSXVersion(Major, Minor, Micro);
1202 EXPECT_EQ((unsigned)10, Major);
1203 EXPECT_EQ((unsigned)7, Minor);
1204 EXPECT_EQ((unsigned)0, Micro);
1205 T.getiOSVersion(Major, Minor, Micro);
1206 EXPECT_EQ((unsigned)5, Major);
1207 EXPECT_EQ((unsigned)0, Minor);
1208 EXPECT_EQ((unsigned)0, Micro);
1210 T = Triple("armv7-apple-ios");
1211 EXPECT_FALSE(T.isMacOSX());
1212 EXPECT_TRUE(T.isiOS());
1213 EXPECT_FALSE(T.isArch16Bit());
1214 EXPECT_TRUE(T.isArch32Bit());
1215 EXPECT_FALSE(T.isArch64Bit());
1216 T.getMacOSXVersion(Major, Minor, Micro);
1217 EXPECT_EQ((unsigned)10, Major);
1218 EXPECT_EQ((unsigned)4, Minor);
1219 EXPECT_EQ((unsigned)0, Micro);
1220 T.getiOSVersion(Major, Minor, Micro);
1221 EXPECT_EQ((unsigned)5, Major);
1222 EXPECT_EQ((unsigned)0, Minor);
1223 EXPECT_EQ((unsigned)0, Micro);
1225 T = Triple("armv7-apple-ios7.0");
1226 EXPECT_FALSE(T.isMacOSX());
1227 EXPECT_TRUE(T.isiOS());
1228 EXPECT_FALSE(T.isArch16Bit());
1229 EXPECT_TRUE(T.isArch32Bit());
1230 EXPECT_FALSE(T.isArch64Bit());
1231 T.getMacOSXVersion(Major, Minor, Micro);
1232 EXPECT_EQ((unsigned)10, Major);
1233 EXPECT_EQ((unsigned)4, Minor);
1234 EXPECT_EQ((unsigned)0, Micro);
1235 T.getiOSVersion(Major, Minor, Micro);
1236 EXPECT_EQ((unsigned)7, Major);
1237 EXPECT_EQ((unsigned)0, Minor);
1238 EXPECT_EQ((unsigned)0, Micro);
1239 EXPECT_FALSE(T.isSimulatorEnvironment());
1241 T = Triple("x86_64-apple-ios10.3-simulator");
1242 EXPECT_TRUE(T.isiOS());
1243 T.getiOSVersion(Major, Minor, Micro);
1244 EXPECT_EQ((unsigned)10, Major);
1245 EXPECT_EQ((unsigned)3, Minor);
1246 EXPECT_EQ((unsigned)0, Micro);
1247 EXPECT_TRUE(T.isSimulatorEnvironment());
1248 EXPECT_FALSE(T.isMacCatalystEnvironment());
1250 T = Triple("x86_64-apple-ios13.0-macabi");
1251 EXPECT_TRUE(T.isiOS());
1252 T.getiOSVersion(Major, Minor, Micro);
1253 EXPECT_EQ((unsigned)13, Major);
1254 EXPECT_EQ((unsigned)0, Minor);
1255 EXPECT_EQ((unsigned)0, Micro);
1256 EXPECT_TRUE(T.getEnvironment() == Triple::MacABI);
1257 EXPECT_TRUE(T.isMacCatalystEnvironment());
1258 EXPECT_FALSE(T.isSimulatorEnvironment());
1261 TEST(TripleTest, FileFormat) {
1262 EXPECT_EQ(Triple::ELF, Triple("i686-unknown-linux-gnu").getObjectFormat());
1263 EXPECT_EQ(Triple::ELF, Triple("i686-unknown-freebsd").getObjectFormat());
1264 EXPECT_EQ(Triple::ELF, Triple("i686-unknown-netbsd").getObjectFormat());
1265 EXPECT_EQ(Triple::ELF, Triple("i686--win32-elf").getObjectFormat());
1266 EXPECT_EQ(Triple::ELF, Triple("i686---elf").getObjectFormat());
1268 EXPECT_EQ(Triple::MachO, Triple("i686-apple-macosx").getObjectFormat());
1269 EXPECT_EQ(Triple::MachO, Triple("i686-apple-ios").getObjectFormat());
1270 EXPECT_EQ(Triple::MachO, Triple("i686---macho").getObjectFormat());
1272 EXPECT_EQ(Triple::COFF, Triple("i686--win32").getObjectFormat());
1274 EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
1275 EXPECT_EQ(Triple::ELF, Triple("i686-pc-cygwin-elf").getObjectFormat());
1277 EXPECT_EQ(Triple::Wasm, Triple("wasm32-unknown-unknown").getObjectFormat());
1278 EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-unknown").getObjectFormat());
1279 EXPECT_EQ(Triple::Wasm, Triple("wasm32-wasi").getObjectFormat());
1280 EXPECT_EQ(Triple::Wasm, Triple("wasm64-wasi").getObjectFormat());
1281 EXPECT_EQ(Triple::Wasm, Triple("wasm32-unknown-wasi").getObjectFormat());
1282 EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-wasi").getObjectFormat());
1284 EXPECT_EQ(Triple::Wasm,
1285 Triple("wasm32-unknown-unknown-wasm").getObjectFormat());
1286 EXPECT_EQ(Triple::Wasm,
1287 Triple("wasm64-unknown-unknown-wasm").getObjectFormat());
1288 EXPECT_EQ(Triple::Wasm,
1289 Triple("wasm32-wasi-wasm").getObjectFormat());
1290 EXPECT_EQ(Triple::Wasm,
1291 Triple("wasm64-wasi-wasm").getObjectFormat());
1292 EXPECT_EQ(Triple::Wasm,
1293 Triple("wasm32-unknown-wasi-wasm").getObjectFormat());
1294 EXPECT_EQ(Triple::Wasm,
1295 Triple("wasm64-unknown-wasi-wasm").getObjectFormat());
1297 EXPECT_EQ(Triple::XCOFF, Triple("powerpc-ibm-aix").getObjectFormat());
1298 EXPECT_EQ(Triple::XCOFF, Triple("powerpc64-ibm-aix").getObjectFormat());
1299 EXPECT_EQ(Triple::XCOFF, Triple("powerpc---xcoff").getObjectFormat());
1300 EXPECT_EQ(Triple::XCOFF, Triple("powerpc64---xcoff").getObjectFormat());
1302 Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
1303 EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
1305 Triple GNUWindowsNormalized(Triple::normalize("i686-pc-windows-gnu-elf"));
1306 EXPECT_EQ(Triple::ELF, GNUWindowsNormalized.getObjectFormat());
1308 Triple CygnusNormalised(Triple::normalize("i686-pc-windows-cygnus-elf"));
1309 EXPECT_EQ(Triple::ELF, CygnusNormalised.getObjectFormat());
1311 Triple CygwinNormalized(Triple::normalize("i686-pc-cygwin-elf"));
1312 EXPECT_EQ(Triple::ELF, CygwinNormalized.getObjectFormat());
1314 Triple T = Triple("");
1315 T.setObjectFormat(Triple::ELF);
1316 EXPECT_EQ(Triple::ELF, T.getObjectFormat());
1318 T.setObjectFormat(Triple::MachO);
1319 EXPECT_EQ(Triple::MachO, T.getObjectFormat());
1321 T.setObjectFormat(Triple::XCOFF);
1322 EXPECT_EQ(Triple::XCOFF, T.getObjectFormat());
1325 TEST(TripleTest, NormalizeWindows) {
1326 EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-win32"));
1327 EXPECT_EQ("i686-unknown-windows-msvc", Triple::normalize("i686-win32"));
1328 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32"));
1329 EXPECT_EQ("i686-unknown-windows-gnu", Triple::normalize("i686-mingw32"));
1330 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32-w64"));
1331 EXPECT_EQ("i686-unknown-windows-gnu", Triple::normalize("i686-mingw32-w64"));
1332 EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-cygwin"));
1333 EXPECT_EQ("i686-unknown-windows-cygnus", Triple::normalize("i686-cygwin"));
1335 EXPECT_EQ("x86_64-pc-windows-msvc", Triple::normalize("x86_64-pc-win32"));
1336 EXPECT_EQ("x86_64-unknown-windows-msvc", Triple::normalize("x86_64-win32"));
1337 EXPECT_EQ("x86_64-pc-windows-gnu", Triple::normalize("x86_64-pc-mingw32"));
1338 EXPECT_EQ("x86_64-unknown-windows-gnu", Triple::normalize("x86_64-mingw32"));
1339 EXPECT_EQ("x86_64-pc-windows-gnu",
1340 Triple::normalize("x86_64-pc-mingw32-w64"));
1341 EXPECT_EQ("x86_64-unknown-windows-gnu",
1342 Triple::normalize("x86_64-mingw32-w64"));
1344 EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-win32-elf"));
1345 EXPECT_EQ("i686-unknown-windows-elf", Triple::normalize("i686-win32-elf"));
1346 EXPECT_EQ("i686-pc-windows-macho", Triple::normalize("i686-pc-win32-macho"));
1347 EXPECT_EQ("i686-unknown-windows-macho",
1348 Triple::normalize("i686-win32-macho"));
1350 EXPECT_EQ("x86_64-pc-windows-elf", Triple::normalize("x86_64-pc-win32-elf"));
1351 EXPECT_EQ("x86_64-unknown-windows-elf",
1352 Triple::normalize("x86_64-win32-elf"));
1353 EXPECT_EQ("x86_64-pc-windows-macho",
1354 Triple::normalize("x86_64-pc-win32-macho"));
1355 EXPECT_EQ("x86_64-unknown-windows-macho",
1356 Triple::normalize("x86_64-win32-macho"));
1358 EXPECT_EQ("i686-pc-windows-cygnus",
1359 Triple::normalize("i686-pc-windows-cygnus"));
1360 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-windows-gnu"));
1361 EXPECT_EQ("i686-pc-windows-itanium",
1362 Triple::normalize("i686-pc-windows-itanium"));
1363 EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-windows-msvc"));
1365 EXPECT_EQ("i686-pc-windows-elf",
1366 Triple::normalize("i686-pc-windows-elf-elf"));
1368 EXPECT_TRUE(Triple("x86_64-pc-win32").isWindowsMSVCEnvironment());
1371 TEST(TripleTest, getARMCPUForArch) {
1372 // Platform specific defaults.
1374 llvm::Triple Triple("arm--nacl");
1375 EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
1378 llvm::Triple Triple("arm--openbsd");
1379 EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
1382 llvm::Triple Triple("armv6-unknown-freebsd");
1383 EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
1386 llvm::Triple Triple("thumbv6-unknown-freebsd");
1387 EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
1390 llvm::Triple Triple("armebv6-unknown-freebsd");
1391 EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
1394 llvm::Triple Triple("arm--win32");
1395 EXPECT_EQ("cortex-a9", Triple.getARMCPUForArch());
1397 // Some alternative architectures
1399 llvm::Triple Triple("armv7k-apple-ios9");
1400 EXPECT_EQ("cortex-a7", Triple.getARMCPUForArch());
1403 llvm::Triple Triple("armv7k-apple-watchos3");
1404 EXPECT_EQ("cortex-a7", Triple.getARMCPUForArch());
1407 llvm::Triple Triple("armv7k-apple-tvos9");
1408 EXPECT_EQ("cortex-a7", Triple.getARMCPUForArch());
1410 // armeb is permitted, but armebeb is not
1412 llvm::Triple Triple("armeb-none-eabi");
1413 EXPECT_EQ("arm7tdmi", Triple.getARMCPUForArch());
1416 llvm::Triple Triple("armebeb-none-eabi");
1417 EXPECT_EQ("", Triple.getARMCPUForArch());
1420 llvm::Triple Triple("armebv6eb-none-eabi");
1421 EXPECT_EQ("", Triple.getARMCPUForArch());
1423 // xscaleeb is permitted, but armebxscale is not
1425 llvm::Triple Triple("xscaleeb-none-eabi");
1426 EXPECT_EQ("xscale", Triple.getARMCPUForArch());
1429 llvm::Triple Triple("armebxscale-none-eabi");
1430 EXPECT_EQ("", Triple.getARMCPUForArch());
1434 TEST(TripleTest, NormalizeARM) {
1435 EXPECT_EQ("armv6-unknown-netbsd-eabi",
1436 Triple::normalize("armv6-netbsd-eabi"));
1437 EXPECT_EQ("armv7-unknown-netbsd-eabi",
1438 Triple::normalize("armv7-netbsd-eabi"));
1439 EXPECT_EQ("armv6eb-unknown-netbsd-eabi",
1440 Triple::normalize("armv6eb-netbsd-eabi"));
1441 EXPECT_EQ("armv7eb-unknown-netbsd-eabi",
1442 Triple::normalize("armv7eb-netbsd-eabi"));
1443 EXPECT_EQ("armv6-unknown-netbsd-eabihf",
1444 Triple::normalize("armv6-netbsd-eabihf"));
1445 EXPECT_EQ("armv7-unknown-netbsd-eabihf",
1446 Triple::normalize("armv7-netbsd-eabihf"));
1447 EXPECT_EQ("armv6eb-unknown-netbsd-eabihf",
1448 Triple::normalize("armv6eb-netbsd-eabihf"));
1449 EXPECT_EQ("armv7eb-unknown-netbsd-eabihf",
1450 Triple::normalize("armv7eb-netbsd-eabihf"));
1452 EXPECT_EQ("armv7-suse-linux-gnueabihf",
1453 Triple::normalize("armv7-suse-linux-gnueabi"));
1455 Triple T;
1456 T = Triple("armv6--netbsd-eabi");
1457 EXPECT_EQ(Triple::arm, T.getArch());
1458 T = Triple("armv6eb--netbsd-eabi");
1459 EXPECT_EQ(Triple::armeb, T.getArch());
1460 T = Triple("armv7-suse-linux-gnueabihf");
1461 EXPECT_EQ(Triple::GNUEABIHF, T.getEnvironment());
1464 TEST(TripleTest, ParseARMArch) {
1465 // ARM
1467 Triple T = Triple("arm");
1468 EXPECT_EQ(Triple::arm, T.getArch());
1471 Triple T = Triple("armeb");
1472 EXPECT_EQ(Triple::armeb, T.getArch());
1474 // THUMB
1476 Triple T = Triple("thumb");
1477 EXPECT_EQ(Triple::thumb, T.getArch());
1480 Triple T = Triple("thumbeb");
1481 EXPECT_EQ(Triple::thumbeb, T.getArch());
1483 // AARCH64
1485 Triple T = Triple("arm64");
1486 EXPECT_EQ(Triple::aarch64, T.getArch());
1489 Triple T = Triple("arm64_32");
1490 EXPECT_EQ(Triple::aarch64_32, T.getArch());
1493 Triple T = Triple("aarch64");
1494 EXPECT_EQ(Triple::aarch64, T.getArch());
1497 Triple T = Triple("aarch64_be");
1498 EXPECT_EQ(Triple::aarch64_be, T.getArch());
1501 } // end anonymous namespace