Fix test failures introduced by PR #113697 (#116941)
[llvm-project.git] / llvm / unittests / TargetParser / TripleTest.cpp
blobcb2fa95d431c66f76da817dcedc46efa342f900e
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/TargetParser/Triple.h"
10 #include "llvm/Support/VersionTuple.h"
11 #include "gtest/gtest.h"
13 using namespace llvm;
15 namespace {
17 TEST(TripleTest, BasicParsing) {
18 Triple T;
20 T = Triple("");
21 EXPECT_EQ("", T.getArchName().str());
22 EXPECT_EQ("", T.getVendorName().str());
23 EXPECT_EQ("", T.getOSName().str());
24 EXPECT_EQ("", T.getEnvironmentName().str());
26 T = Triple("-");
27 EXPECT_EQ("", T.getArchName().str());
28 EXPECT_EQ("", T.getVendorName().str());
29 EXPECT_EQ("", T.getOSName().str());
30 EXPECT_EQ("", T.getEnvironmentName().str());
32 T = Triple("--");
33 EXPECT_EQ("", T.getArchName().str());
34 EXPECT_EQ("", T.getVendorName().str());
35 EXPECT_EQ("", T.getOSName().str());
36 EXPECT_EQ("", T.getEnvironmentName().str());
38 T = Triple("---");
39 EXPECT_EQ("", T.getArchName().str());
40 EXPECT_EQ("", T.getVendorName().str());
41 EXPECT_EQ("", T.getOSName().str());
42 EXPECT_EQ("", T.getEnvironmentName().str());
44 T = Triple("----");
45 EXPECT_EQ("", T.getArchName().str());
46 EXPECT_EQ("", T.getVendorName().str());
47 EXPECT_EQ("", T.getOSName().str());
48 EXPECT_EQ("-", T.getEnvironmentName().str());
50 T = Triple("a");
51 EXPECT_EQ("a", T.getArchName().str());
52 EXPECT_EQ("", T.getVendorName().str());
53 EXPECT_EQ("", T.getOSName().str());
54 EXPECT_EQ("", T.getEnvironmentName().str());
56 T = Triple("a-b");
57 EXPECT_EQ("a", T.getArchName().str());
58 EXPECT_EQ("b", T.getVendorName().str());
59 EXPECT_EQ("", T.getOSName().str());
60 EXPECT_EQ("", T.getEnvironmentName().str());
62 T = Triple("a-b-c");
63 EXPECT_EQ("a", T.getArchName().str());
64 EXPECT_EQ("b", T.getVendorName().str());
65 EXPECT_EQ("c", T.getOSName().str());
66 EXPECT_EQ("", T.getEnvironmentName().str());
68 T = Triple("a-b-c-d");
69 EXPECT_EQ("a", T.getArchName().str());
70 EXPECT_EQ("b", T.getVendorName().str());
71 EXPECT_EQ("c", T.getOSName().str());
72 EXPECT_EQ("d", T.getEnvironmentName().str());
75 TEST(TripleTest, ParsedIDs) {
76 Triple T;
78 T = Triple("i386-apple-darwin");
79 EXPECT_EQ(Triple::x86, T.getArch());
80 EXPECT_EQ(Triple::Apple, T.getVendor());
81 EXPECT_EQ(Triple::Darwin, T.getOS());
82 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
84 T = Triple("i386-pc-elfiamcu");
85 EXPECT_EQ(Triple::x86, T.getArch());
86 EXPECT_EQ(Triple::PC, T.getVendor());
87 EXPECT_EQ(Triple::ELFIAMCU, T.getOS());
88 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
90 T = Triple("i386-pc-hurd-gnu");
91 EXPECT_EQ(Triple::x86, T.getArch());
92 EXPECT_EQ(Triple::PC, T.getVendor());
93 EXPECT_EQ(Triple::Hurd, T.getOS());
94 EXPECT_EQ(Triple::GNU, T.getEnvironment());
96 T = Triple("i686-pc-linux-gnu");
97 EXPECT_EQ(Triple::x86, T.getArch());
98 EXPECT_EQ(Triple::PC, T.getVendor());
99 EXPECT_EQ(Triple::Linux, T.getOS());
100 EXPECT_EQ(Triple::GNU, T.getEnvironment());
101 EXPECT_FALSE(T.isTime64ABI());
103 T = Triple("x86_64-pc-linux-gnu");
104 EXPECT_EQ(Triple::x86_64, T.getArch());
105 EXPECT_EQ(Triple::PC, T.getVendor());
106 EXPECT_EQ(Triple::Linux, T.getOS());
107 EXPECT_EQ(Triple::GNU, T.getEnvironment());
109 T = Triple("x86_64-pc-linux-musl");
110 EXPECT_EQ(Triple::x86_64, T.getArch());
111 EXPECT_EQ(Triple::PC, T.getVendor());
112 EXPECT_EQ(Triple::Linux, T.getOS());
113 EXPECT_EQ(Triple::Musl, T.getEnvironment());
115 T = Triple("x86_64-pc-linux-muslx32");
116 EXPECT_EQ(Triple::x86_64, T.getArch());
117 EXPECT_EQ(Triple::PC, T.getVendor());
118 EXPECT_EQ(Triple::Linux, T.getOS());
119 EXPECT_EQ(Triple::MuslX32, T.getEnvironment());
121 T = Triple("x86_64-pc-hurd-gnu");
122 EXPECT_EQ(Triple::x86_64, T.getArch());
123 EXPECT_EQ(Triple::PC, T.getVendor());
124 EXPECT_EQ(Triple::Hurd, T.getOS());
125 EXPECT_EQ(Triple::GNU, T.getEnvironment());
127 T = Triple("arm-unknown-linux-android16");
128 EXPECT_EQ(Triple::arm, T.getArch());
129 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
130 EXPECT_EQ(Triple::Linux, T.getOS());
131 EXPECT_EQ(Triple::Android, T.getEnvironment());
133 T = Triple("aarch64-unknown-linux-android21");
134 EXPECT_EQ(Triple::aarch64, T.getArch());
135 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
136 EXPECT_EQ(Triple::Linux, T.getOS());
137 EXPECT_EQ(Triple::Android, T.getEnvironment());
139 // PS4 has two spellings for the vendor.
140 T = Triple("x86_64-scei-ps4");
141 EXPECT_EQ(Triple::x86_64, T.getArch());
142 EXPECT_EQ(Triple::SCEI, T.getVendor());
143 EXPECT_EQ(Triple::PS4, T.getOS());
145 T = Triple("x86_64-sie-ps4");
146 EXPECT_EQ(Triple::x86_64, T.getArch());
147 EXPECT_EQ(Triple::SCEI, T.getVendor());
148 EXPECT_EQ(Triple::PS4, T.getOS());
150 T = Triple("x86_64-sie-ps5");
151 EXPECT_EQ(Triple::x86_64, T.getArch());
152 EXPECT_EQ(Triple::SCEI, T.getVendor());
153 EXPECT_EQ(Triple::PS5, T.getOS());
155 T = Triple("powerpc-ibm-aix");
156 EXPECT_EQ(Triple::ppc, T.getArch());
157 EXPECT_EQ(Triple::IBM, T.getVendor());
158 EXPECT_EQ(Triple::AIX, T.getOS());
159 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
161 T = Triple("powerpc64-ibm-aix");
162 EXPECT_EQ(Triple::ppc64, T.getArch());
163 EXPECT_EQ(Triple::IBM, T.getVendor());
164 EXPECT_EQ(Triple::AIX, T.getOS());
165 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
167 T = Triple("powerpc-dunno-notsure");
168 EXPECT_EQ(Triple::ppc, T.getArch());
169 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
170 EXPECT_EQ(Triple::UnknownOS, T.getOS());
171 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
173 T = Triple("powerpcspe-unknown-freebsd");
174 EXPECT_EQ(Triple::ppc, T.getArch());
175 EXPECT_EQ(Triple::PPCSubArch_spe, T.getSubArch());
176 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
177 EXPECT_EQ(Triple::FreeBSD, T.getOS());
178 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
180 T = Triple("s390x-ibm-zos");
181 EXPECT_EQ(Triple::systemz, T.getArch());
182 EXPECT_EQ(Triple::IBM, T.getVendor());
183 EXPECT_EQ(Triple::ZOS, T.getOS());
184 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
186 T = Triple("systemz-ibm-zos");
187 EXPECT_EQ(Triple::systemz, T.getArch());
188 EXPECT_EQ(Triple::IBM, T.getVendor());
189 EXPECT_EQ(Triple::ZOS, T.getOS());
190 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
192 T = Triple("arm-none-none-eabi");
193 EXPECT_EQ(Triple::arm, T.getArch());
194 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
195 EXPECT_EQ(Triple::UnknownOS, T.getOS());
196 EXPECT_EQ(Triple::EABI, T.getEnvironment());
197 EXPECT_FALSE(T.isHardFloatABI());
199 T = Triple("arm-none-none-eabihf");
200 EXPECT_EQ(Triple::arm, T.getArch());
201 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
202 EXPECT_EQ(Triple::UnknownOS, T.getOS());
203 EXPECT_EQ(Triple::EABIHF, T.getEnvironment());
204 EXPECT_TRUE(T.isHardFloatABI());
206 T = Triple("arm-none-linux-musleabi");
207 EXPECT_EQ(Triple::arm, T.getArch());
208 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
209 EXPECT_EQ(Triple::Linux, T.getOS());
210 EXPECT_EQ(Triple::MuslEABI, T.getEnvironment());
211 EXPECT_FALSE(T.isHardFloatABI());
213 T = Triple("arm-none-linux-musleabihf");
214 EXPECT_EQ(Triple::arm, T.getArch());
215 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
216 EXPECT_EQ(Triple::Linux, T.getOS());
217 EXPECT_EQ(Triple::MuslEABIHF, T.getEnvironment());
218 EXPECT_TRUE(T.isHardFloatABI());
220 T = Triple("armv6hl-none-linux-gnueabi");
221 EXPECT_EQ(Triple::arm, T.getArch());
222 EXPECT_EQ(Triple::Linux, T.getOS());
223 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
224 EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
225 EXPECT_FALSE(T.isTime64ABI());
226 EXPECT_FALSE(T.isHardFloatABI());
228 T = Triple("armv7hl-none-linux-gnueabi");
229 EXPECT_EQ(Triple::arm, T.getArch());
230 EXPECT_EQ(Triple::Linux, T.getOS());
231 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
232 EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
233 EXPECT_FALSE(T.isTime64ABI());
234 EXPECT_FALSE(T.isHardFloatABI());
236 T = Triple("armv7hl-none-linux-gnueabihf");
237 EXPECT_EQ(Triple::arm, T.getArch());
238 EXPECT_EQ(Triple::Linux, T.getOS());
239 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
240 EXPECT_EQ(Triple::GNUEABIHF, T.getEnvironment());
241 EXPECT_FALSE(T.isTime64ABI());
242 EXPECT_TRUE(T.isHardFloatABI());
244 T = Triple("amdil-unknown-unknown");
245 EXPECT_EQ(Triple::amdil, T.getArch());
246 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
247 EXPECT_EQ(Triple::UnknownOS, T.getOS());
249 T = Triple("amdil64-unknown-unknown");
250 EXPECT_EQ(Triple::amdil64, T.getArch());
251 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
252 EXPECT_EQ(Triple::UnknownOS, T.getOS());
254 T = Triple("hsail-unknown-unknown");
255 EXPECT_EQ(Triple::hsail, T.getArch());
256 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
257 EXPECT_EQ(Triple::UnknownOS, T.getOS());
259 T = Triple("hsail64-unknown-unknown");
260 EXPECT_EQ(Triple::hsail64, T.getArch());
261 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
262 EXPECT_EQ(Triple::UnknownOS, T.getOS());
264 T = Triple("sparcel-unknown-unknown");
265 EXPECT_EQ(Triple::sparcel, T.getArch());
266 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
267 EXPECT_EQ(Triple::UnknownOS, T.getOS());
269 T = Triple("spir-unknown-unknown");
270 EXPECT_EQ(Triple::spir, T.getArch());
271 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
272 EXPECT_EQ(Triple::UnknownOS, T.getOS());
274 T = Triple("spir64-unknown-unknown");
275 EXPECT_EQ(Triple::spir64, T.getArch());
276 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
277 EXPECT_EQ(Triple::UnknownOS, T.getOS());
279 T = Triple("spirv32-unknown-unknown");
280 EXPECT_EQ(Triple::spirv32, T.getArch());
281 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
282 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
283 EXPECT_EQ(Triple::UnknownOS, T.getOS());
285 T = Triple("spirv32v1.0-unknown-unknown");
286 EXPECT_EQ(Triple::spirv32, T.getArch());
287 EXPECT_EQ(Triple::SPIRVSubArch_v10, T.getSubArch());
288 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
289 EXPECT_EQ(Triple::UnknownOS, T.getOS());
291 T = Triple("spirv32v1.1-unknown-unknown");
292 EXPECT_EQ(Triple::spirv32, T.getArch());
293 EXPECT_EQ(Triple::SPIRVSubArch_v11, T.getSubArch());
294 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
295 EXPECT_EQ(Triple::UnknownOS, T.getOS());
297 T = Triple("spirv32v1.2-unknown-unknown");
298 EXPECT_EQ(Triple::spirv32, T.getArch());
299 EXPECT_EQ(Triple::SPIRVSubArch_v12, T.getSubArch());
300 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
301 EXPECT_EQ(Triple::UnknownOS, T.getOS());
303 T = Triple("spirv32v1.3-unknown-unknown");
304 EXPECT_EQ(Triple::spirv32, T.getArch());
305 EXPECT_EQ(Triple::SPIRVSubArch_v13, T.getSubArch());
306 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
307 EXPECT_EQ(Triple::UnknownOS, T.getOS());
309 T = Triple("spirv32v1.4-unknown-unknown");
310 EXPECT_EQ(Triple::spirv32, T.getArch());
311 EXPECT_EQ(Triple::SPIRVSubArch_v14, T.getSubArch());
312 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
313 EXPECT_EQ(Triple::UnknownOS, T.getOS());
315 T = Triple("spirv32v1.5-unknown-unknown");
316 EXPECT_EQ(Triple::spirv32, T.getArch());
317 EXPECT_EQ(Triple::SPIRVSubArch_v15, T.getSubArch());
318 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
319 EXPECT_EQ(Triple::UnknownOS, T.getOS());
321 T = Triple("spirv64-unknown-unknown");
322 EXPECT_EQ(Triple::spirv64, T.getArch());
323 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
324 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
325 EXPECT_EQ(Triple::UnknownOS, T.getOS());
327 T = Triple("spirv64v1.0-unknown-unknown");
328 EXPECT_EQ(Triple::spirv64, T.getArch());
329 EXPECT_EQ(Triple::SPIRVSubArch_v10, T.getSubArch());
330 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
331 EXPECT_EQ(Triple::UnknownOS, T.getOS());
333 T = Triple("spirv64v1.1-unknown-unknown");
334 EXPECT_EQ(Triple::spirv64, T.getArch());
335 EXPECT_EQ(Triple::SPIRVSubArch_v11, T.getSubArch());
336 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
337 EXPECT_EQ(Triple::UnknownOS, T.getOS());
339 T = Triple("spirv64v1.2-unknown-unknown");
340 EXPECT_EQ(Triple::spirv64, T.getArch());
341 EXPECT_EQ(Triple::SPIRVSubArch_v12, T.getSubArch());
342 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
343 EXPECT_EQ(Triple::UnknownOS, T.getOS());
345 T = Triple("spirv64v1.3-unknown-unknown");
346 EXPECT_EQ(Triple::spirv64, T.getArch());
347 EXPECT_EQ(Triple::SPIRVSubArch_v13, T.getSubArch());
348 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
349 EXPECT_EQ(Triple::UnknownOS, T.getOS());
351 T = Triple("spirv64v1.4-unknown-unknown");
352 EXPECT_EQ(Triple::spirv64, T.getArch());
353 EXPECT_EQ(Triple::SPIRVSubArch_v14, T.getSubArch());
354 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
355 EXPECT_EQ(Triple::UnknownOS, T.getOS());
357 T = Triple("spirv64v1.5-unknown-unknown");
358 EXPECT_EQ(Triple::spirv64, T.getArch());
359 EXPECT_EQ(Triple::SPIRVSubArch_v15, T.getSubArch());
360 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
361 EXPECT_EQ(Triple::UnknownOS, T.getOS());
363 T = Triple("spirv-unknown-vulkan-pixel");
364 EXPECT_EQ(Triple::spirv, T.getArch());
365 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
366 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
367 EXPECT_EQ(Triple::Vulkan, T.getOS());
368 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
369 EXPECT_EQ(Triple::Pixel, T.getEnvironment());
371 T = Triple("spirv-unknown-vulkan-vertex");
372 EXPECT_EQ(Triple::spirv, T.getArch());
373 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
374 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
375 EXPECT_EQ(Triple::Vulkan, T.getOS());
376 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
377 EXPECT_EQ(Triple::Vertex, T.getEnvironment());
379 T = Triple("spirv-unknown-vulkan-geometry");
380 EXPECT_EQ(Triple::spirv, T.getArch());
381 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
382 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
383 EXPECT_EQ(Triple::Vulkan, T.getOS());
384 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
385 EXPECT_EQ(Triple::Geometry, T.getEnvironment());
387 T = Triple("spirv-unknown-vulkan-library");
388 EXPECT_EQ(Triple::spirv, T.getArch());
389 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
390 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
391 EXPECT_EQ(Triple::Vulkan, T.getOS());
392 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
393 EXPECT_EQ(Triple::Library, T.getEnvironment());
395 T = Triple("spirv-unknown-vulkan-raygeneration");
396 EXPECT_EQ(Triple::spirv, T.getArch());
397 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
398 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
399 EXPECT_EQ(Triple::Vulkan, T.getOS());
400 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
401 EXPECT_EQ(Triple::RayGeneration, T.getEnvironment());
403 T = Triple("spirv-unknown-vulkan-intersection");
404 EXPECT_EQ(Triple::spirv, T.getArch());
405 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
406 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
407 EXPECT_EQ(Triple::Vulkan, T.getOS());
408 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
409 EXPECT_EQ(Triple::Intersection, T.getEnvironment());
411 T = Triple("spirv-unknown-vulkan-anyhit");
412 EXPECT_EQ(Triple::spirv, T.getArch());
413 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
414 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
415 EXPECT_EQ(Triple::Vulkan, T.getOS());
416 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
417 EXPECT_EQ(Triple::AnyHit, T.getEnvironment());
419 T = Triple("spirv-unknown-vulkan-closesthit");
420 EXPECT_EQ(Triple::spirv, T.getArch());
421 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
422 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
423 EXPECT_EQ(Triple::Vulkan, T.getOS());
424 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
425 EXPECT_EQ(Triple::ClosestHit, T.getEnvironment());
427 T = Triple("spirv-unknown-vulkan-miss");
428 EXPECT_EQ(Triple::spirv, T.getArch());
429 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
430 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
431 EXPECT_EQ(Triple::Vulkan, T.getOS());
432 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
433 EXPECT_EQ(Triple::Miss, T.getEnvironment());
435 T = Triple("spirv-unknown-vulkan-callable");
436 EXPECT_EQ(Triple::spirv, T.getArch());
437 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
438 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
439 EXPECT_EQ(Triple::Vulkan, T.getOS());
440 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
441 EXPECT_EQ(Triple::Callable, T.getEnvironment());
443 T = Triple("spirv-unknown-vulkan-mesh");
444 EXPECT_EQ(Triple::spirv, T.getArch());
445 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
446 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
447 EXPECT_EQ(Triple::Vulkan, T.getOS());
448 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
449 EXPECT_EQ(Triple::Mesh, T.getEnvironment());
451 T = Triple("spirv-unknown-vulkan-amplification");
452 EXPECT_EQ(Triple::spirv, T.getArch());
453 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
454 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
455 EXPECT_EQ(Triple::Vulkan, T.getOS());
456 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
457 EXPECT_EQ(Triple::Amplification, T.getEnvironment());
459 T = Triple("spirv1.5-unknown-vulkan1.2-compute");
460 EXPECT_EQ(Triple::spirv, T.getArch());
461 EXPECT_EQ(Triple::SPIRVSubArch_v15, T.getSubArch());
462 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
463 EXPECT_EQ(Triple::Vulkan, T.getOS());
464 EXPECT_EQ(VersionTuple(1, 2), T.getVulkanVersion());
465 EXPECT_EQ(Triple::Compute, T.getEnvironment());
467 T = Triple("spirv1.6-unknown-vulkan1.3-compute");
468 EXPECT_EQ(Triple::spirv, T.getArch());
469 EXPECT_EQ(Triple::SPIRVSubArch_v16, T.getSubArch());
470 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
471 EXPECT_EQ(Triple::Vulkan, T.getOS());
472 EXPECT_EQ(VersionTuple(1, 3), T.getVulkanVersion());
473 EXPECT_EQ(Triple::Compute, T.getEnvironment());
475 T = Triple("dxilv1.0--shadermodel6.0-pixel");
476 EXPECT_EQ(Triple::dxil, T.getArch());
477 EXPECT_EQ(Triple::DXILSubArch_v1_0, T.getSubArch());
478 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
479 EXPECT_EQ(Triple::ShaderModel, T.getOS());
480 EXPECT_EQ(VersionTuple(1, 0), T.getDXILVersion());
481 EXPECT_EQ(Triple::Pixel, T.getEnvironment());
483 T = Triple("dxilv1.1--shadermodel6.1-vertex");
484 EXPECT_EQ(Triple::dxil, T.getArch());
485 EXPECT_EQ(Triple::DXILSubArch_v1_1, T.getSubArch());
486 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
487 EXPECT_EQ(Triple::ShaderModel, T.getOS());
488 EXPECT_EQ(VersionTuple(1, 1), T.getDXILVersion());
489 EXPECT_EQ(Triple::Vertex, T.getEnvironment());
491 T = Triple("dxilv1.2--shadermodel6.2-geometry");
492 EXPECT_EQ(Triple::dxil, T.getArch());
493 EXPECT_EQ(Triple::DXILSubArch_v1_2, T.getSubArch());
494 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
495 EXPECT_EQ(Triple::ShaderModel, T.getOS());
496 EXPECT_EQ(VersionTuple(1, 2), T.getDXILVersion());
497 EXPECT_EQ(Triple::Geometry, T.getEnvironment());
499 T = Triple("dxilv1.3--shadermodel6.3-library");
500 EXPECT_EQ(Triple::dxil, T.getArch());
501 EXPECT_EQ(Triple::DXILSubArch_v1_3, T.getSubArch());
502 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
503 EXPECT_EQ(Triple::ShaderModel, T.getOS());
504 EXPECT_EQ(VersionTuple(1, 3), T.getDXILVersion());
505 EXPECT_EQ(Triple::Library, T.getEnvironment());
507 T = Triple("dxilv1.4--shadermodel6.4-hull");
508 EXPECT_EQ(Triple::dxil, T.getArch());
509 EXPECT_EQ(Triple::DXILSubArch_v1_4, T.getSubArch());
510 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
511 EXPECT_EQ(Triple::ShaderModel, T.getOS());
512 EXPECT_EQ(VersionTuple(1, 4), T.getDXILVersion());
513 EXPECT_EQ(Triple::Hull, T.getEnvironment());
515 T = Triple("dxilv1.5--shadermodel6.5-domain");
516 EXPECT_EQ(Triple::dxil, T.getArch());
517 EXPECT_EQ(Triple::DXILSubArch_v1_5, T.getSubArch());
518 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
519 EXPECT_EQ(Triple::ShaderModel, T.getOS());
520 EXPECT_EQ(VersionTuple(1, 5), T.getDXILVersion());
521 EXPECT_EQ(Triple::Domain, T.getEnvironment());
523 T = Triple("dxilv1.6--shadermodel6.6-compute");
524 EXPECT_EQ(Triple::dxil, T.getArch());
525 EXPECT_EQ(Triple::DXILSubArch_v1_6, T.getSubArch());
526 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
527 EXPECT_EQ(Triple::ShaderModel, T.getOS());
528 EXPECT_EQ(VersionTuple(1, 6), T.getDXILVersion());
529 EXPECT_EQ(Triple::Compute, T.getEnvironment());
531 T = Triple("dxilv1.7-unknown-shadermodel6.7-mesh");
532 EXPECT_EQ(Triple::dxil, T.getArch());
533 EXPECT_EQ(Triple::DXILSubArch_v1_7, T.getSubArch());
534 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
535 EXPECT_EQ(Triple::ShaderModel, T.getOS());
536 EXPECT_EQ(VersionTuple(1, 7), T.getDXILVersion());
537 EXPECT_EQ(Triple::Mesh, T.getEnvironment());
539 T = Triple("dxilv1.8-unknown-shadermodel6.8-amplification");
540 EXPECT_EQ(Triple::dxil, T.getArch());
541 EXPECT_EQ(Triple::DXILSubArch_v1_8, T.getSubArch());
542 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
543 EXPECT_EQ(Triple::ShaderModel, T.getOS());
544 EXPECT_EQ(VersionTuple(1, 8), T.getDXILVersion());
545 EXPECT_EQ(Triple::Amplification, T.getEnvironment());
547 T = Triple("dxilv1.8-unknown-shadermodel6.15-library");
548 EXPECT_EQ(Triple::dxil, T.getArch());
549 EXPECT_EQ(Triple::DXILSubArch_v1_8, T.getSubArch());
550 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
551 EXPECT_EQ(Triple::ShaderModel, T.getOS());
552 EXPECT_EQ(VersionTuple(1, 8), T.getDXILVersion());
554 T = Triple("x86_64-unknown-fuchsia");
555 EXPECT_EQ(Triple::x86_64, T.getArch());
556 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
557 EXPECT_EQ(Triple::Fuchsia, T.getOS());
558 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
560 T = Triple("x86_64-unknown-hermit");
561 EXPECT_EQ(Triple::x86_64, T.getArch());
562 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
563 EXPECT_EQ(Triple::HermitCore, T.getOS());
564 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
566 T = Triple("x86_64-unknown-uefi");
567 EXPECT_EQ(Triple::x86_64, T.getArch());
568 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
569 EXPECT_EQ(Triple::UEFI, T.getOS());
570 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
571 EXPECT_EQ(Triple::COFF, T.getObjectFormat());
573 T = Triple("wasm32-unknown-unknown");
574 EXPECT_EQ(Triple::wasm32, T.getArch());
575 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
576 EXPECT_EQ(Triple::UnknownOS, T.getOS());
577 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
579 T = Triple("wasm32-unknown-wasi");
580 EXPECT_EQ(Triple::wasm32, T.getArch());
581 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
582 EXPECT_EQ(Triple::WASI, T.getOS());
583 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
585 T = Triple("wasm64-unknown-unknown");
586 EXPECT_EQ(Triple::wasm64, T.getArch());
587 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
588 EXPECT_EQ(Triple::UnknownOS, T.getOS());
589 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
591 T = Triple("wasm64-unknown-wasi");
592 EXPECT_EQ(Triple::wasm64, T.getArch());
593 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
594 EXPECT_EQ(Triple::WASI, T.getOS());
595 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
597 T = Triple("avr-unknown-unknown");
598 EXPECT_EQ(Triple::avr, T.getArch());
599 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
600 EXPECT_EQ(Triple::UnknownOS, T.getOS());
601 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
603 T = Triple("avr");
604 EXPECT_EQ(Triple::avr, T.getArch());
605 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
606 EXPECT_EQ(Triple::UnknownOS, T.getOS());
607 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
609 T = Triple("lanai-unknown-unknown");
610 EXPECT_EQ(Triple::lanai, T.getArch());
611 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
612 EXPECT_EQ(Triple::UnknownOS, T.getOS());
613 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
615 T = Triple("lanai");
616 EXPECT_EQ(Triple::lanai, T.getArch());
617 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
618 EXPECT_EQ(Triple::UnknownOS, T.getOS());
619 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
621 T = Triple("amdgcn-mesa-mesa3d");
622 EXPECT_EQ(Triple::amdgcn, T.getArch());
623 EXPECT_EQ(Triple::Mesa, T.getVendor());
624 EXPECT_EQ(Triple::Mesa3D, T.getOS());
625 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
627 T = Triple("amdgcn-amd-amdhsa");
628 EXPECT_EQ(Triple::amdgcn, T.getArch());
629 EXPECT_EQ(Triple::AMD, T.getVendor());
630 EXPECT_EQ(Triple::AMDHSA, T.getOS());
631 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
633 T = Triple("amdgcn-amd-amdpal");
634 EXPECT_EQ(Triple::amdgcn, T.getArch());
635 EXPECT_EQ(Triple::AMD, T.getVendor());
636 EXPECT_EQ(Triple::AMDPAL, T.getOS());
637 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
639 T = Triple("ve-unknown-linux");
640 EXPECT_EQ(Triple::ve, T.getArch());
641 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
642 EXPECT_EQ(Triple::Linux, T.getOS());
643 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
645 T = Triple("csky-unknown-unknown");
646 EXPECT_EQ(Triple::csky, T.getArch());
647 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
648 EXPECT_EQ(Triple::UnknownOS, T.getOS());
649 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
651 T = Triple("csky-unknown-linux");
652 EXPECT_EQ(Triple::csky, T.getArch());
653 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
654 EXPECT_EQ(Triple::Linux, T.getOS());
655 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
657 T = Triple("loongarch32-unknown-unknown");
658 EXPECT_EQ(Triple::loongarch32, T.getArch());
659 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
660 EXPECT_EQ(Triple::UnknownOS, T.getOS());
661 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
663 T = Triple("loongarch32-unknown-linux-gnu");
664 EXPECT_EQ(Triple::loongarch32, T.getArch());
665 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
666 EXPECT_EQ(Triple::Linux, T.getOS());
667 EXPECT_EQ(Triple::GNU, T.getEnvironment());
669 T = Triple("loongarch32-unknown-linux-gnuf32");
670 EXPECT_EQ(Triple::loongarch32, T.getArch());
671 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
672 EXPECT_EQ(Triple::Linux, T.getOS());
673 EXPECT_EQ(Triple::GNUF32, T.getEnvironment());
675 T = Triple("loongarch32-unknown-linux-gnuf64");
676 EXPECT_EQ(Triple::loongarch32, T.getArch());
677 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
678 EXPECT_EQ(Triple::Linux, T.getOS());
679 EXPECT_EQ(Triple::GNUF64, T.getEnvironment());
681 T = Triple("loongarch32-unknown-linux-gnusf");
682 EXPECT_EQ(Triple::loongarch32, T.getArch());
683 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
684 EXPECT_EQ(Triple::Linux, T.getOS());
685 EXPECT_EQ(Triple::GNUSF, T.getEnvironment());
687 T = Triple("loongarch32-unknown-linux-musl");
688 EXPECT_EQ(Triple::loongarch32, T.getArch());
689 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
690 EXPECT_EQ(Triple::Linux, T.getOS());
691 EXPECT_EQ(Triple::Musl, T.getEnvironment());
693 T = Triple("loongarch32-unknown-linux-muslf32");
694 EXPECT_EQ(Triple::loongarch32, T.getArch());
695 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
696 EXPECT_EQ(Triple::Linux, T.getOS());
697 EXPECT_EQ(Triple::MuslF32, T.getEnvironment());
699 T = Triple("loongarch32-unknown-linux-muslsf");
700 EXPECT_EQ(Triple::loongarch32, T.getArch());
701 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
702 EXPECT_EQ(Triple::Linux, T.getOS());
703 EXPECT_EQ(Triple::MuslSF, T.getEnvironment());
705 T = Triple("loongarch64-unknown-linux");
706 EXPECT_EQ(Triple::loongarch64, T.getArch());
707 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
708 EXPECT_EQ(Triple::Linux, T.getOS());
709 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
711 T = Triple("loongarch64-unknown-linux-gnu");
712 EXPECT_EQ(Triple::loongarch64, T.getArch());
713 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
714 EXPECT_EQ(Triple::Linux, T.getOS());
715 EXPECT_EQ(Triple::GNU, T.getEnvironment());
717 T = Triple("loongarch64-unknown-linux-gnuf32");
718 EXPECT_EQ(Triple::loongarch64, T.getArch());
719 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
720 EXPECT_EQ(Triple::Linux, T.getOS());
721 EXPECT_EQ(Triple::GNUF32, T.getEnvironment());
723 T = Triple("loongarch64-unknown-linux-gnuf64");
724 EXPECT_EQ(Triple::loongarch64, T.getArch());
725 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
726 EXPECT_EQ(Triple::Linux, T.getOS());
727 EXPECT_EQ(Triple::GNUF64, T.getEnvironment());
729 T = Triple("loongarch64-unknown-linux-gnusf");
730 EXPECT_EQ(Triple::loongarch64, T.getArch());
731 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
732 EXPECT_EQ(Triple::Linux, T.getOS());
733 EXPECT_EQ(Triple::GNUSF, T.getEnvironment());
735 T = Triple("loongarch64-unknown-linux-musl");
736 EXPECT_EQ(Triple::loongarch64, T.getArch());
737 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
738 EXPECT_EQ(Triple::Linux, T.getOS());
739 EXPECT_EQ(Triple::Musl, T.getEnvironment());
741 T = Triple("loongarch64-unknown-linux-muslf32");
742 EXPECT_EQ(Triple::loongarch64, T.getArch());
743 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
744 EXPECT_EQ(Triple::Linux, T.getOS());
745 EXPECT_EQ(Triple::MuslF32, T.getEnvironment());
747 T = Triple("loongarch64-unknown-linux-muslsf");
748 EXPECT_EQ(Triple::loongarch64, T.getArch());
749 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
750 EXPECT_EQ(Triple::Linux, T.getOS());
751 EXPECT_EQ(Triple::MuslSF, T.getEnvironment());
753 T = Triple("riscv32-unknown-unknown");
754 EXPECT_EQ(Triple::riscv32, T.getArch());
755 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
756 EXPECT_EQ(Triple::UnknownOS, T.getOS());
757 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
759 T = Triple("riscv64-unknown-linux");
760 EXPECT_EQ(Triple::riscv64, T.getArch());
761 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
762 EXPECT_EQ(Triple::Linux, T.getOS());
763 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
765 T = Triple("riscv64-unknown-freebsd");
766 EXPECT_EQ(Triple::riscv64, T.getArch());
767 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
768 EXPECT_EQ(Triple::FreeBSD, T.getOS());
769 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
771 T = Triple("riscv64-suse-linux");
772 EXPECT_EQ(Triple::riscv64, T.getArch());
773 EXPECT_EQ(Triple::SUSE, T.getVendor());
774 EXPECT_EQ(Triple::Linux, T.getOS());
775 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
777 T = Triple("armv7hl-suse-linux-gnueabi");
778 EXPECT_EQ(Triple::arm, T.getArch());
779 EXPECT_EQ(Triple::SUSE, T.getVendor());
780 EXPECT_EQ(Triple::Linux, T.getOS());
781 EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
783 T = Triple("i586-pc-haiku");
784 EXPECT_EQ(Triple::x86, T.getArch());
785 EXPECT_EQ(Triple::PC, T.getVendor());
786 EXPECT_EQ(Triple::Haiku, T.getOS());
787 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
789 T = Triple("x86_64-unknown-haiku");
790 EXPECT_EQ(Triple::x86_64, T.getArch());
791 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
792 EXPECT_EQ(Triple::Haiku, T.getOS());
793 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
795 T = Triple("mips-mti-linux-gnu");
796 EXPECT_EQ(Triple::mips, T.getArch());
797 EXPECT_EQ(Triple::MipsTechnologies, T.getVendor());
798 EXPECT_EQ(Triple::Linux, T.getOS());
799 EXPECT_EQ(Triple::GNU, T.getEnvironment());
801 T = Triple("mipsel-img-linux-gnu");
802 EXPECT_EQ(Triple::mipsel, T.getArch());
803 EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor());
804 EXPECT_EQ(Triple::Linux, T.getOS());
805 EXPECT_EQ(Triple::GNU, T.getEnvironment());
807 T = Triple("mips64-mti-linux-gnu");
808 EXPECT_EQ(Triple::mips64, T.getArch());
809 EXPECT_EQ(Triple::MipsTechnologies, T.getVendor());
810 EXPECT_EQ(Triple::Linux, T.getOS());
811 EXPECT_EQ(Triple::GNU, T.getEnvironment());
813 T = Triple("mips64el-img-linux-gnu");
814 EXPECT_EQ(Triple::mips64el, T.getArch());
815 EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor());
816 EXPECT_EQ(Triple::Linux, T.getOS());
817 EXPECT_EQ(Triple::GNU, T.getEnvironment());
819 T = Triple("mips64el-img-linux-gnuabin32");
820 EXPECT_EQ(Triple::mips64el, T.getArch());
821 EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor());
822 EXPECT_EQ(Triple::Linux, T.getOS());
823 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
825 T = Triple("mips64el-unknown-linux-gnuabi64");
826 EXPECT_EQ(Triple::mips64el, T.getArch());
827 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
828 EXPECT_EQ(Triple::Linux, T.getOS());
829 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
830 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
831 T = Triple("mips64el");
832 EXPECT_EQ(Triple::mips64el, T.getArch());
833 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
834 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
835 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
837 T = Triple("mips64-unknown-linux-gnuabi64");
838 EXPECT_EQ(Triple::mips64, T.getArch());
839 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
840 EXPECT_EQ(Triple::Linux, T.getOS());
841 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
842 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
843 T = Triple("mips64");
844 EXPECT_EQ(Triple::mips64, T.getArch());
845 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
846 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
847 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
849 T = Triple("mipsisa64r6el-unknown-linux-gnuabi64");
850 EXPECT_EQ(Triple::mips64el, T.getArch());
851 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
852 EXPECT_EQ(Triple::Linux, T.getOS());
853 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
854 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
855 T = Triple("mips64r6el");
856 EXPECT_EQ(Triple::mips64el, T.getArch());
857 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
858 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
859 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
860 T = Triple("mipsisa64r6el");
861 EXPECT_EQ(Triple::mips64el, T.getArch());
862 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
863 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
864 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
866 T = Triple("mipsisa64r6-unknown-linux-gnuabi64");
867 EXPECT_EQ(Triple::mips64, T.getArch());
868 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
869 EXPECT_EQ(Triple::Linux, T.getOS());
870 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
871 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
872 T = Triple("mips64r6");
873 EXPECT_EQ(Triple::mips64, T.getArch());
874 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
875 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
876 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
877 T = Triple("mipsisa64r6");
878 EXPECT_EQ(Triple::mips64, T.getArch());
879 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
880 EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
881 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
883 T = Triple("mips64el-unknown-linux-gnuabin32");
884 EXPECT_EQ(Triple::mips64el, T.getArch());
885 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
886 EXPECT_EQ(Triple::Linux, T.getOS());
887 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
888 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
889 T = Triple("mipsn32el");
890 EXPECT_EQ(Triple::mips64el, T.getArch());
891 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
892 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
893 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
895 T = Triple("mips64-unknown-linux-gnuabin32");
896 EXPECT_EQ(Triple::mips64, T.getArch());
897 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
898 EXPECT_EQ(Triple::Linux, T.getOS());
899 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
900 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
901 T = Triple("mipsn32");
902 EXPECT_EQ(Triple::mips64, T.getArch());
903 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
904 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
905 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
907 T = Triple("mipsisa64r6el-unknown-linux-gnuabin32");
908 EXPECT_EQ(Triple::mips64el, T.getArch());
909 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
910 EXPECT_EQ(Triple::Linux, T.getOS());
911 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
912 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
913 T = Triple("mipsn32r6el");
914 EXPECT_EQ(Triple::mips64el, T.getArch());
915 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
916 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
917 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
919 T = Triple("mipsisa64r6-unknown-linux-gnuabin32");
920 EXPECT_EQ(Triple::mips64, T.getArch());
921 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
922 EXPECT_EQ(Triple::Linux, T.getOS());
923 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
924 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
925 T = Triple("mipsn32r6");
926 EXPECT_EQ(Triple::mips64, T.getArch());
927 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
928 EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
929 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
931 T = Triple("mipsel-unknown-linux-gnu");
932 EXPECT_EQ(Triple::mipsel, T.getArch());
933 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
934 EXPECT_EQ(Triple::Linux, T.getOS());
935 EXPECT_EQ(Triple::GNU, T.getEnvironment());
936 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
937 T = Triple("mipsel");
938 EXPECT_EQ(Triple::mipsel, T.getArch());
939 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
940 EXPECT_EQ(Triple::GNU, T.getEnvironment());
941 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
943 T = Triple("mips-unknown-linux-gnu");
944 EXPECT_EQ(Triple::mips, T.getArch());
945 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
946 EXPECT_EQ(Triple::Linux, T.getOS());
947 EXPECT_EQ(Triple::GNU, T.getEnvironment());
948 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
949 T = Triple("mips");
950 EXPECT_EQ(Triple::mips, T.getArch());
951 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
952 EXPECT_EQ(Triple::GNU, T.getEnvironment());
953 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
955 T = Triple("mipsisa32r6el-unknown-linux-gnu");
956 EXPECT_EQ(Triple::mipsel, T.getArch());
957 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
958 EXPECT_EQ(Triple::Linux, T.getOS());
959 EXPECT_EQ(Triple::GNU, T.getEnvironment());
960 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
961 T = Triple("mipsr6el");
962 EXPECT_EQ(Triple::mipsel, T.getArch());
963 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
964 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
965 T = Triple("mipsisa32r6el");
966 EXPECT_EQ(Triple::mipsel, T.getArch());
967 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
968 EXPECT_EQ(Triple::GNU, T.getEnvironment());
969 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
971 T = Triple("mipsisa32r6-unknown-linux-gnu");
972 EXPECT_EQ(Triple::mips, T.getArch());
973 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
974 EXPECT_EQ(Triple::Linux, T.getOS());
975 EXPECT_EQ(Triple::GNU, T.getEnvironment());
976 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
977 T = Triple("mipsr6");
978 EXPECT_EQ(Triple::mips, T.getArch());
979 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
980 EXPECT_EQ(Triple::GNU, T.getEnvironment());
981 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
982 T = Triple("mipsisa32r6");
983 EXPECT_EQ(Triple::mips, T.getArch());
984 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
985 EXPECT_EQ(Triple::GNU, T.getEnvironment());
986 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
988 T = Triple("mips64el-unknown-linux-muslabi64");
989 EXPECT_EQ(Triple::mips64el, T.getArch());
990 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
991 EXPECT_EQ(Triple::Linux, T.getOS());
992 EXPECT_EQ(Triple::MuslABI64, T.getEnvironment());
993 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
995 T = Triple("mips64-unknown-linux-muslabi64");
996 EXPECT_EQ(Triple::mips64, T.getArch());
997 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
998 EXPECT_EQ(Triple::Linux, T.getOS());
999 EXPECT_EQ(Triple::MuslABI64, T.getEnvironment());
1000 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1002 T = Triple("mipsisa64r6el-unknown-linux-muslabi64");
1003 EXPECT_EQ(Triple::mips64el, T.getArch());
1004 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1005 EXPECT_EQ(Triple::Linux, T.getOS());
1006 EXPECT_EQ(Triple::MuslABI64, T.getEnvironment());
1007 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
1009 T = Triple("mipsisa64r6-unknown-linux-muslabi64");
1010 EXPECT_EQ(Triple::mips64, T.getArch());
1011 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1012 EXPECT_EQ(Triple::Linux, T.getOS());
1013 EXPECT_EQ(Triple::MuslABI64, T.getEnvironment());
1014 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
1016 T = Triple("mips64el-unknown-linux-muslabin32");
1017 EXPECT_EQ(Triple::mips64el, T.getArch());
1018 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1019 EXPECT_EQ(Triple::Linux, T.getOS());
1020 EXPECT_EQ(Triple::MuslABIN32, T.getEnvironment());
1021 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1023 T = Triple("mips64-unknown-linux-muslabin32");
1024 EXPECT_EQ(Triple::mips64, T.getArch());
1025 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1026 EXPECT_EQ(Triple::Linux, T.getOS());
1027 EXPECT_EQ(Triple::MuslABIN32, T.getEnvironment());
1028 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1030 T = Triple("mipsisa64r6el-unknown-linux-muslabin32");
1031 EXPECT_EQ(Triple::mips64el, T.getArch());
1032 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1033 EXPECT_EQ(Triple::Linux, T.getOS());
1034 EXPECT_EQ(Triple::MuslABIN32, T.getEnvironment());
1035 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
1037 T = Triple("mipsisa64r6-unknown-linux-muslabin32");
1038 EXPECT_EQ(Triple::mips64, T.getArch());
1039 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1040 EXPECT_EQ(Triple::Linux, T.getOS());
1041 EXPECT_EQ(Triple::MuslABIN32, T.getEnvironment());
1042 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
1044 T = Triple("mipsel-unknown-linux-musl");
1045 EXPECT_EQ(Triple::mipsel, T.getArch());
1046 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1047 EXPECT_EQ(Triple::Linux, T.getOS());
1048 EXPECT_EQ(Triple::Musl, T.getEnvironment());
1049 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1051 T = Triple("mips-unknown-linux-musl");
1052 EXPECT_EQ(Triple::mips, T.getArch());
1053 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1054 EXPECT_EQ(Triple::Linux, T.getOS());
1055 EXPECT_EQ(Triple::Musl, T.getEnvironment());
1056 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1058 T = Triple("mipsisa32r6el-unknown-linux-musl");
1059 EXPECT_EQ(Triple::mipsel, T.getArch());
1060 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1061 EXPECT_EQ(Triple::Linux, T.getOS());
1062 EXPECT_EQ(Triple::Musl, T.getEnvironment());
1063 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
1065 T = Triple("mipsisa32r6-unknown-linux-musl");
1066 EXPECT_EQ(Triple::mips, T.getArch());
1067 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1068 EXPECT_EQ(Triple::Linux, T.getOS());
1069 EXPECT_EQ(Triple::Musl, T.getEnvironment());
1070 EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
1072 T = Triple("arm-oe-linux-gnueabi");
1073 EXPECT_EQ(Triple::arm, T.getArch());
1074 EXPECT_EQ(Triple::OpenEmbedded, T.getVendor());
1075 EXPECT_EQ(Triple::Linux, T.getOS());
1076 EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
1078 T = Triple("aarch64-oe-linux");
1079 EXPECT_EQ(Triple::aarch64, T.getArch());
1080 EXPECT_EQ(Triple::OpenEmbedded, T.getVendor());
1081 EXPECT_EQ(Triple::Linux, T.getOS());
1082 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
1083 EXPECT_TRUE(T.isArch64Bit());
1085 T = Triple("arm64_32-apple-ios");
1086 EXPECT_EQ(Triple::aarch64_32, T.getArch());
1087 EXPECT_EQ(Triple::IOS, T.getOS());
1088 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
1089 EXPECT_TRUE(T.isArch32Bit());
1091 T = Triple("dxil-unknown-shadermodel-pixel");
1092 EXPECT_EQ(Triple::dxil, T.getArch());
1093 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1094 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1095 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1096 EXPECT_EQ(Triple::Pixel, T.getEnvironment());
1097 EXPECT_FALSE(T.supportsCOMDAT());
1099 T = Triple("dxil-unknown-shadermodel-vertex");
1100 EXPECT_EQ(Triple::dxil, T.getArch());
1101 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1102 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1103 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1104 EXPECT_EQ(Triple::Vertex, T.getEnvironment());
1105 EXPECT_FALSE(T.supportsCOMDAT());
1107 T = Triple("dxil-unknown-shadermodel-geometry");
1108 EXPECT_EQ(Triple::dxil, T.getArch());
1109 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1110 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1111 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1112 EXPECT_EQ(Triple::Geometry, T.getEnvironment());
1113 EXPECT_FALSE(T.supportsCOMDAT());
1115 T = Triple("dxil-unknown-shadermodel-hull");
1116 EXPECT_EQ(Triple::dxil, T.getArch());
1117 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1118 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1119 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1120 EXPECT_EQ(Triple::Hull, T.getEnvironment());
1121 EXPECT_FALSE(T.supportsCOMDAT());
1123 T = Triple("dxil-unknown-shadermodel-domain");
1124 EXPECT_EQ(Triple::dxil, T.getArch());
1125 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1126 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1127 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1128 EXPECT_EQ(Triple::Domain, T.getEnvironment());
1129 EXPECT_FALSE(T.supportsCOMDAT());
1131 T = Triple("dxil-unknown-shadermodel-compute");
1132 EXPECT_EQ(Triple::dxil, T.getArch());
1133 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1134 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1135 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1136 EXPECT_EQ(Triple::Compute, T.getEnvironment());
1137 EXPECT_FALSE(T.supportsCOMDAT());
1139 T = Triple("dxil-unknown-shadermodel-library");
1140 EXPECT_EQ(Triple::dxil, T.getArch());
1141 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1142 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1143 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1144 EXPECT_EQ(Triple::Library, T.getEnvironment());
1145 EXPECT_FALSE(T.supportsCOMDAT());
1147 T = Triple("dxil-unknown-shadermodel-raygeneration");
1148 EXPECT_EQ(Triple::dxil, T.getArch());
1149 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1150 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1151 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1152 EXPECT_EQ(Triple::RayGeneration, T.getEnvironment());
1153 EXPECT_FALSE(T.supportsCOMDAT());
1155 T = Triple("dxil-unknown-shadermodel-intersection");
1156 EXPECT_EQ(Triple::dxil, T.getArch());
1157 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1158 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1159 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1160 EXPECT_EQ(Triple::Intersection, T.getEnvironment());
1161 EXPECT_FALSE(T.supportsCOMDAT());
1163 T = Triple("dxil-unknown-shadermodel-anyhit");
1164 EXPECT_EQ(Triple::dxil, T.getArch());
1165 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1166 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1167 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1168 EXPECT_EQ(Triple::AnyHit, T.getEnvironment());
1169 EXPECT_FALSE(T.supportsCOMDAT());
1171 T = Triple("dxil-unknown-shadermodel-closesthit");
1172 EXPECT_EQ(Triple::dxil, T.getArch());
1173 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1174 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1175 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1176 EXPECT_EQ(Triple::ClosestHit, T.getEnvironment());
1177 EXPECT_FALSE(T.supportsCOMDAT());
1179 T = Triple("dxil-unknown-shadermodel-miss");
1180 EXPECT_EQ(Triple::dxil, T.getArch());
1181 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1182 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1183 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1184 EXPECT_EQ(Triple::Miss, T.getEnvironment());
1185 EXPECT_FALSE(T.supportsCOMDAT());
1187 T = Triple("dxil-unknown-shadermodel-callable");
1188 EXPECT_EQ(Triple::dxil, T.getArch());
1189 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1190 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1191 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1192 EXPECT_EQ(Triple::Callable, T.getEnvironment());
1193 EXPECT_FALSE(T.supportsCOMDAT());
1195 T = Triple("dxil-unknown-shadermodel-mesh");
1196 EXPECT_EQ(Triple::dxil, T.getArch());
1197 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1198 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1199 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1200 EXPECT_EQ(Triple::Mesh, T.getEnvironment());
1201 EXPECT_FALSE(T.supportsCOMDAT());
1203 T = Triple("dxil-unknown-shadermodel-amplification");
1204 EXPECT_EQ(Triple::dxil, T.getArch());
1205 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1206 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1207 EXPECT_EQ(Triple::ShaderModel, T.getOS());
1208 EXPECT_EQ(Triple::Amplification, T.getEnvironment());
1209 EXPECT_FALSE(T.supportsCOMDAT());
1211 T = Triple("dxilv1.0-unknown-unknown");
1212 EXPECT_EQ(Triple::dxil, T.getArch());
1213 EXPECT_EQ(Triple::DXILSubArch_v1_0, T.getSubArch());
1214 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1215 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1217 T = Triple("dxilv1.1-unknown-unknown");
1218 EXPECT_EQ(Triple::dxil, T.getArch());
1219 EXPECT_EQ(Triple::DXILSubArch_v1_1, T.getSubArch());
1220 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1221 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1223 T = Triple("dxilv1.2-unknown-unknown");
1224 EXPECT_EQ(Triple::dxil, T.getArch());
1225 EXPECT_EQ(Triple::DXILSubArch_v1_2, T.getSubArch());
1226 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1227 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1229 T = Triple("dxilv1.3-unknown-unknown");
1230 EXPECT_EQ(Triple::dxil, T.getArch());
1231 EXPECT_EQ(Triple::DXILSubArch_v1_3, T.getSubArch());
1232 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1233 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1235 T = Triple("dxilv1.4-unknown-unknown");
1236 EXPECT_EQ(Triple::dxil, T.getArch());
1237 EXPECT_EQ(Triple::DXILSubArch_v1_4, T.getSubArch());
1238 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1239 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1241 T = Triple("dxilv1.5-unknown-unknown");
1242 EXPECT_EQ(Triple::dxil, T.getArch());
1243 EXPECT_EQ(Triple::DXILSubArch_v1_5, T.getSubArch());
1244 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1245 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1247 T = Triple("dxilv1.6-unknown-unknown");
1248 EXPECT_EQ(Triple::dxil, T.getArch());
1249 EXPECT_EQ(Triple::DXILSubArch_v1_6, T.getSubArch());
1250 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1251 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1253 T = Triple("dxilv1.7-unknown-unknown");
1254 EXPECT_EQ(Triple::dxil, T.getArch());
1255 EXPECT_EQ(Triple::DXILSubArch_v1_7, T.getSubArch());
1256 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1257 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1259 T = Triple("dxilv1.8-unknown-unknown");
1260 EXPECT_EQ(Triple::dxil, T.getArch());
1261 EXPECT_EQ(Triple::DXILSubArch_v1_8, T.getSubArch());
1262 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1263 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1265 // Check specification of unknown SubArch results in
1266 // unknown architecture.
1267 T = Triple("dxilv1.999-unknown-unknown");
1268 EXPECT_EQ(Triple::UnknownArch, T.getArch());
1269 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1270 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1271 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1273 T = Triple("dxil-unknown-unknown");
1274 EXPECT_EQ(Triple::dxil, T.getArch());
1275 EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
1276 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1277 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1279 T = Triple("xtensa");
1280 EXPECT_EQ(Triple::xtensa, T.getArch());
1281 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1282 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1283 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
1285 T = Triple("xtensa-unknown-unknown");
1286 EXPECT_EQ(Triple::xtensa, T.getArch());
1287 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1288 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1289 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
1291 T = Triple("arm-unknown-linux-ohos");
1292 EXPECT_EQ(Triple::arm, T.getArch());
1293 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1294 EXPECT_EQ(Triple::Linux, T.getOS());
1295 EXPECT_EQ(Triple::OpenHOS, T.getEnvironment());
1297 T = Triple("arm-unknown-liteos");
1298 EXPECT_EQ(Triple::arm, T.getArch());
1299 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1300 EXPECT_EQ(Triple::LiteOS, T.getOS());
1301 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
1303 T = Triple("x86_64-pc-serenity");
1304 EXPECT_EQ(Triple::x86_64, T.getArch());
1305 EXPECT_EQ(Triple::PC, T.getVendor());
1306 EXPECT_EQ(Triple::Serenity, T.getOS());
1307 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
1309 T = Triple("aarch64-pc-serenity");
1310 EXPECT_EQ(Triple::aarch64, T.getArch());
1311 EXPECT_EQ(Triple::PC, T.getVendor());
1312 EXPECT_EQ(Triple::Serenity, T.getOS());
1313 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
1315 T = Triple("aarch64-unknown-linux-pauthtest");
1316 EXPECT_EQ(Triple::aarch64, T.getArch());
1317 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1318 EXPECT_EQ(Triple::Linux, T.getOS());
1319 EXPECT_EQ(Triple::PAuthTest, T.getEnvironment());
1321 // Gentoo time64 triples
1322 T = Triple("i686-pc-linux-gnut64");
1323 EXPECT_EQ(Triple::x86, T.getArch());
1324 EXPECT_EQ(Triple::PC, T.getVendor());
1325 EXPECT_EQ(Triple::Linux, T.getOS());
1326 EXPECT_EQ(Triple::GNUT64, T.getEnvironment());
1327 EXPECT_TRUE(T.isTime64ABI());
1329 T = Triple("armv5tel-softfloat-linux-gnueabit64");
1330 EXPECT_EQ(Triple::arm, T.getArch());
1331 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1332 EXPECT_EQ(Triple::Linux, T.getOS());
1333 EXPECT_EQ(Triple::GNUEABIT64, T.getEnvironment());
1334 EXPECT_TRUE(T.isTime64ABI());
1336 T = Triple("armv7a-unknown-linux-gnueabihft64");
1337 EXPECT_EQ(Triple::arm, T.getArch());
1338 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1339 EXPECT_EQ(Triple::Linux, T.getOS());
1340 EXPECT_EQ(Triple::GNUEABIHFT64, T.getEnvironment());
1341 EXPECT_TRUE(T.isTime64ABI());
1342 EXPECT_TRUE(T.isHardFloatABI());
1344 T = Triple("huh");
1345 EXPECT_EQ(Triple::UnknownArch, T.getArch());
1348 static std::string Join(StringRef A, StringRef B, StringRef C) {
1349 std::string Str = std::string(A);
1350 Str += '-';
1351 Str += B;
1352 Str += '-';
1353 Str += C;
1354 return Str;
1357 static std::string Join(StringRef A, StringRef B, StringRef C, StringRef D) {
1358 std::string Str = std::string(A);
1359 Str += '-';
1360 Str += B;
1361 Str += '-';
1362 Str += C;
1363 Str += '-';
1364 Str += D;
1365 return Str;
1368 TEST(TripleTest, Normalization) {
1370 EXPECT_EQ("unknown", Triple::normalize(""));
1371 EXPECT_EQ("unknown-unknown", Triple::normalize("-"));
1372 EXPECT_EQ("unknown-unknown-unknown", Triple::normalize("--"));
1373 EXPECT_EQ("unknown-unknown-unknown-unknown", Triple::normalize("---"));
1374 EXPECT_EQ("unknown-unknown-unknown-unknown-unknown",
1375 Triple::normalize("----"));
1377 EXPECT_EQ("a", Triple::normalize("a"));
1378 EXPECT_EQ("a-b", Triple::normalize("a-b"));
1379 EXPECT_EQ("a-b-c", Triple::normalize("a-b-c"));
1380 EXPECT_EQ("a-b-c-d", Triple::normalize("a-b-c-d"));
1382 EXPECT_EQ("i386-b-c", Triple::normalize("i386-b-c"));
1383 EXPECT_EQ("i386-a-c", Triple::normalize("a-i386-c"));
1384 EXPECT_EQ("i386-a-b", Triple::normalize("a-b-i386"));
1385 EXPECT_EQ("i386-a-b-c", Triple::normalize("a-b-c-i386"));
1387 EXPECT_EQ("a-pc-c", Triple::normalize("a-pc-c"));
1388 EXPECT_EQ("unknown-pc-b-c", Triple::normalize("pc-b-c"));
1389 EXPECT_EQ("a-pc-b", Triple::normalize("a-b-pc"));
1390 EXPECT_EQ("a-pc-b-c", Triple::normalize("a-b-c-pc"));
1392 EXPECT_EQ("a-b-linux", Triple::normalize("a-b-linux"));
1393 EXPECT_EQ("unknown-unknown-linux-b-c", Triple::normalize("linux-b-c"));
1394 EXPECT_EQ("a-unknown-linux-c", Triple::normalize("a-linux-c"));
1396 EXPECT_EQ("i386-pc-a", Triple::normalize("a-pc-i386"));
1397 EXPECT_EQ("i386-pc-unknown", Triple::normalize("-pc-i386"));
1398 EXPECT_EQ("unknown-pc-linux-c", Triple::normalize("linux-pc-c"));
1399 EXPECT_EQ("unknown-pc-linux", Triple::normalize("linux-pc-"));
1401 EXPECT_EQ("i386", Triple::normalize("i386"));
1402 EXPECT_EQ("unknown-pc", Triple::normalize("pc"));
1403 EXPECT_EQ("unknown-unknown-linux", Triple::normalize("linux"));
1405 EXPECT_EQ("x86_64-unknown-linux-gnu", Triple::normalize("x86_64-gnu-linux"));
1407 // Check that normalizing a permutated set of valid components returns a
1408 // triple with the unpermuted components.
1410 // We don't check every possible combination. For the set of architectures A,
1411 // vendors V, operating systems O, and environments E, that would require |A|
1412 // * |V| * |O| * |E| * 4! tests. Instead we check every option for any given
1413 // slot and make sure it gets normalized to the correct position from every
1414 // permutation. This should cover the core logic while being a tractable
1415 // number of tests at (|A| + |V| + |O| + |E|) * 4!.
1416 auto FirstArchType = Triple::ArchType(Triple::UnknownArch + 1);
1417 auto FirstVendorType = Triple::VendorType(Triple::UnknownVendor + 1);
1418 auto FirstOSType = Triple::OSType(Triple::UnknownOS + 1);
1419 auto FirstEnvType = Triple::EnvironmentType(Triple::UnknownEnvironment + 1);
1420 StringRef InitialC[] = {Triple::getArchTypeName(FirstArchType),
1421 Triple::getVendorTypeName(FirstVendorType),
1422 Triple::getOSTypeName(FirstOSType),
1423 Triple::getEnvironmentTypeName(FirstEnvType)};
1424 for (int Arch = FirstArchType; Arch <= Triple::LastArchType; ++Arch) {
1425 StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
1426 C[0] = Triple::getArchTypeName(Triple::ArchType(Arch));
1427 std::string E = Join(C[0], C[1], C[2]);
1428 int I[] = {0, 1, 2};
1429 do {
1430 EXPECT_EQ(E, Triple::normalize(Join(C[I[0]], C[I[1]], C[I[2]])));
1431 } while (std::next_permutation(std::begin(I), std::end(I)));
1432 std::string F = Join(C[0], C[1], C[2], C[3]);
1433 int J[] = {0, 1, 2, 3};
1434 do {
1435 EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
1436 } while (std::next_permutation(std::begin(J), std::end(J)));
1438 for (int Vendor = FirstVendorType; Vendor <= Triple::LastVendorType;
1439 ++Vendor) {
1440 StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
1441 C[1] = Triple::getVendorTypeName(Triple::VendorType(Vendor));
1442 std::string E = Join(C[0], C[1], C[2]);
1443 int I[] = {0, 1, 2};
1444 do {
1445 EXPECT_EQ(E, Triple::normalize(Join(C[I[0]], C[I[1]], C[I[2]])));
1446 } while (std::next_permutation(std::begin(I), std::end(I)));
1447 std::string F = Join(C[0], C[1], C[2], C[3]);
1448 int J[] = {0, 1, 2, 3};
1449 do {
1450 EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
1451 } while (std::next_permutation(std::begin(J), std::end(J)));
1453 for (int OS = FirstOSType; OS <= Triple::LastOSType; ++OS) {
1454 if (OS == Triple::Win32)
1455 continue;
1456 StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
1457 C[2] = Triple::getOSTypeName(Triple::OSType(OS));
1458 std::string E = Join(C[0], C[1], C[2]);
1459 int I[] = {0, 1, 2};
1460 do {
1461 EXPECT_EQ(E, Triple::normalize(Join(C[I[0]], C[I[1]], C[I[2]])));
1462 } while (std::next_permutation(std::begin(I), std::end(I)));
1463 std::string F = Join(C[0], C[1], C[2], C[3]);
1464 int J[] = {0, 1, 2, 3};
1465 do {
1466 EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
1467 } while (std::next_permutation(std::begin(J), std::end(J)));
1469 for (int Env = FirstEnvType; Env <= Triple::LastEnvironmentType; ++Env) {
1470 StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]};
1471 C[3] = Triple::getEnvironmentTypeName(Triple::EnvironmentType(Env));
1472 std::string F = Join(C[0], C[1], C[2], C[3]);
1473 int J[] = {0, 1, 2, 3};
1474 do {
1475 EXPECT_EQ(F, Triple::normalize(Join(C[J[0]], C[J[1]], C[J[2]], C[J[3]])));
1476 } while (std::next_permutation(std::begin(J), std::end(J)));
1479 // Various real-world funky triples. The value returned by GCC's config.sub
1480 // is given in the comment.
1481 EXPECT_EQ("i386-unknown-windows-gnu",
1482 Triple::normalize("i386-mingw32")); // i386-pc-mingw32
1483 EXPECT_EQ("x86_64-unknown-linux-gnu",
1484 Triple::normalize("x86_64-linux-gnu")); // x86_64-pc-linux-gnu
1485 EXPECT_EQ("i486-unknown-linux-gnu",
1486 Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu
1487 EXPECT_EQ("i386-redhat-linux",
1488 Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu
1489 EXPECT_EQ("i686-unknown-linux",
1490 Triple::normalize("i686-linux")); // i686-pc-linux-gnu
1491 EXPECT_EQ("arm-unknown-none-eabi",
1492 Triple::normalize("arm-none-eabi")); // arm-none-eabi
1493 EXPECT_EQ("ve-unknown-linux",
1494 Triple::normalize("ve-linux")); // ve-linux
1495 EXPECT_EQ("wasm32-unknown-wasi",
1496 Triple::normalize("wasm32-wasi")); // wasm32-unknown-wasi
1497 EXPECT_EQ("wasm64-unknown-wasi",
1498 Triple::normalize("wasm64-wasi")); // wasm64-unknown-wasi
1501 TEST(TripleTest, MutateName) {
1502 Triple T;
1503 EXPECT_EQ(Triple::UnknownArch, T.getArch());
1504 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
1505 EXPECT_EQ(Triple::UnknownOS, T.getOS());
1506 EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
1508 T.setArchName("i386");
1509 EXPECT_EQ(Triple::x86, T.getArch());
1510 EXPECT_EQ("i386--", T.getTriple());
1512 T.setVendorName("pc");
1513 EXPECT_EQ(Triple::x86, T.getArch());
1514 EXPECT_EQ(Triple::PC, T.getVendor());
1515 EXPECT_EQ("i386-pc-", T.getTriple());
1517 T.setOSName("linux");
1518 EXPECT_EQ(Triple::x86, T.getArch());
1519 EXPECT_EQ(Triple::PC, T.getVendor());
1520 EXPECT_EQ(Triple::Linux, T.getOS());
1521 EXPECT_EQ("i386-pc-linux", T.getTriple());
1523 T.setEnvironmentName("gnu");
1524 EXPECT_EQ(Triple::x86, T.getArch());
1525 EXPECT_EQ(Triple::PC, T.getVendor());
1526 EXPECT_EQ(Triple::Linux, T.getOS());
1527 EXPECT_EQ("i386-pc-linux-gnu", T.getTriple());
1529 T.setOSName("freebsd");
1530 EXPECT_EQ(Triple::x86, T.getArch());
1531 EXPECT_EQ(Triple::PC, T.getVendor());
1532 EXPECT_EQ(Triple::FreeBSD, T.getOS());
1533 EXPECT_EQ("i386-pc-freebsd-gnu", T.getTriple());
1535 T.setOSAndEnvironmentName("darwin");
1536 EXPECT_EQ(Triple::x86, T.getArch());
1537 EXPECT_EQ(Triple::PC, T.getVendor());
1538 EXPECT_EQ(Triple::Darwin, T.getOS());
1539 EXPECT_EQ("i386-pc-darwin", T.getTriple());
1542 TEST(TripleTest, BitWidthChecks) {
1543 Triple T;
1544 EXPECT_FALSE(T.isArch16Bit());
1545 EXPECT_FALSE(T.isArch32Bit());
1546 EXPECT_FALSE(T.isArch64Bit());
1547 EXPECT_EQ(T.getArchPointerBitWidth(), 0U);
1549 T.setArch(Triple::arm);
1550 EXPECT_FALSE(T.isArch16Bit());
1551 EXPECT_TRUE(T.isArch32Bit());
1552 EXPECT_FALSE(T.isArch64Bit());
1553 EXPECT_EQ(T.getArchPointerBitWidth(), 32U);
1555 T.setArch(Triple::hexagon);
1556 EXPECT_FALSE(T.isArch16Bit());
1557 EXPECT_TRUE(T.isArch32Bit());
1558 EXPECT_FALSE(T.isArch64Bit());
1559 EXPECT_EQ(T.getArchPointerBitWidth(), 32U);
1561 T.setArch(Triple::mips);
1562 EXPECT_FALSE(T.isArch16Bit());
1563 EXPECT_TRUE(T.isArch32Bit());
1564 EXPECT_FALSE(T.isArch64Bit());
1565 EXPECT_EQ(T.getArchPointerBitWidth(), 32U);
1567 T.setArch(Triple::mips64);
1568 EXPECT_FALSE(T.isArch16Bit());
1569 EXPECT_FALSE(T.isArch32Bit());
1570 EXPECT_TRUE(T.isArch64Bit());
1571 EXPECT_EQ(T.getArchPointerBitWidth(), 64U);
1573 T.setArch(Triple::msp430);
1574 EXPECT_TRUE(T.isArch16Bit());
1575 EXPECT_FALSE(T.isArch32Bit());
1576 EXPECT_FALSE(T.isArch64Bit());
1577 EXPECT_EQ(T.getArchPointerBitWidth(), 16U);
1579 T.setArch(Triple::ppc);
1580 EXPECT_FALSE(T.isArch16Bit());
1581 EXPECT_TRUE(T.isArch32Bit());
1582 EXPECT_FALSE(T.isArch64Bit());
1583 EXPECT_EQ(T.getArchPointerBitWidth(), 32U);
1585 T.setArch(Triple::ppc64);
1586 EXPECT_FALSE(T.isArch16Bit());
1587 EXPECT_FALSE(T.isArch32Bit());
1588 EXPECT_TRUE(T.isArch64Bit());
1589 EXPECT_EQ(T.getArchPointerBitWidth(), 64U);
1591 T.setArch(Triple::x86);
1592 EXPECT_FALSE(T.isArch16Bit());
1593 EXPECT_TRUE(T.isArch32Bit());
1594 EXPECT_FALSE(T.isArch64Bit());
1595 EXPECT_EQ(T.getArchPointerBitWidth(), 32U);
1597 T.setArch(Triple::x86_64);
1598 EXPECT_FALSE(T.isArch16Bit());
1599 EXPECT_FALSE(T.isArch32Bit());
1600 EXPECT_TRUE(T.isArch64Bit());
1601 EXPECT_EQ(T.getArchPointerBitWidth(), 64U);
1603 T.setArch(Triple::amdil);
1604 EXPECT_FALSE(T.isArch16Bit());
1605 EXPECT_TRUE(T.isArch32Bit());
1606 EXPECT_FALSE(T.isArch64Bit());
1607 EXPECT_EQ(T.getArchPointerBitWidth(), 32U);
1609 T.setArch(Triple::amdil64);
1610 EXPECT_FALSE(T.isArch16Bit());
1611 EXPECT_FALSE(T.isArch32Bit());
1612 EXPECT_TRUE(T.isArch64Bit());
1613 EXPECT_EQ(T.getArchPointerBitWidth(), 64U);
1615 T.setArch(Triple::hsail);
1616 EXPECT_FALSE(T.isArch16Bit());
1617 EXPECT_TRUE(T.isArch32Bit());
1618 EXPECT_FALSE(T.isArch64Bit());
1619 EXPECT_EQ(T.getArchPointerBitWidth(), 32U);
1621 T.setArch(Triple::hsail64);
1622 EXPECT_FALSE(T.isArch16Bit());
1623 EXPECT_FALSE(T.isArch32Bit());
1624 EXPECT_TRUE(T.isArch64Bit());
1625 EXPECT_EQ(T.getArchPointerBitWidth(), 64U);
1627 T.setArch(Triple::spir);
1628 EXPECT_FALSE(T.isArch16Bit());
1629 EXPECT_TRUE(T.isArch32Bit());
1630 EXPECT_FALSE(T.isArch64Bit());
1631 EXPECT_EQ(T.getArchPointerBitWidth(), 32U);
1633 T.setArch(Triple::spir64);
1634 EXPECT_FALSE(T.isArch16Bit());
1635 EXPECT_FALSE(T.isArch32Bit());
1636 EXPECT_TRUE(T.isArch64Bit());
1637 EXPECT_EQ(T.getArchPointerBitWidth(), 64U);
1639 T.setArch(Triple::spirv);
1640 EXPECT_FALSE(T.isArch16Bit());
1641 EXPECT_FALSE(T.isArch32Bit());
1642 EXPECT_TRUE(T.isArch64Bit());
1643 EXPECT_TRUE(T.isSPIRV());
1645 T.setArch(Triple::spirv32);
1646 EXPECT_FALSE(T.isArch16Bit());
1647 EXPECT_TRUE(T.isArch32Bit());
1648 EXPECT_FALSE(T.isArch64Bit());
1649 EXPECT_TRUE(T.isSPIRV());
1651 T.setArch(Triple::spirv64);
1652 EXPECT_FALSE(T.isArch16Bit());
1653 EXPECT_FALSE(T.isArch32Bit());
1654 EXPECT_TRUE(T.isArch64Bit());
1655 EXPECT_TRUE(T.isSPIRV());
1657 T.setArch(Triple::sparc);
1658 EXPECT_FALSE(T.isArch16Bit());
1659 EXPECT_TRUE(T.isArch32Bit());
1660 EXPECT_FALSE(T.isArch64Bit());
1662 T.setArch(Triple::sparcel);
1663 EXPECT_FALSE(T.isArch16Bit());
1664 EXPECT_TRUE(T.isArch32Bit());
1665 EXPECT_FALSE(T.isArch64Bit());
1667 T.setArch(Triple::sparcv9);
1668 EXPECT_FALSE(T.isArch16Bit());
1669 EXPECT_FALSE(T.isArch32Bit());
1670 EXPECT_TRUE(T.isArch64Bit());
1672 T.setArch(Triple::wasm32);
1673 EXPECT_FALSE(T.isArch16Bit());
1674 EXPECT_TRUE(T.isArch32Bit());
1675 EXPECT_FALSE(T.isArch64Bit());
1677 T.setArch(Triple::wasm64);
1678 EXPECT_FALSE(T.isArch16Bit());
1679 EXPECT_FALSE(T.isArch32Bit());
1680 EXPECT_TRUE(T.isArch64Bit());
1682 T.setArch(Triple::avr);
1683 EXPECT_TRUE(T.isArch16Bit());
1684 EXPECT_FALSE(T.isArch32Bit());
1685 EXPECT_FALSE(T.isArch64Bit());
1687 T.setArch(Triple::lanai);
1688 EXPECT_FALSE(T.isArch16Bit());
1689 EXPECT_TRUE(T.isArch32Bit());
1690 EXPECT_FALSE(T.isArch64Bit());
1692 T.setArch(Triple::riscv32);
1693 EXPECT_FALSE(T.isArch16Bit());
1694 EXPECT_TRUE(T.isArch32Bit());
1695 EXPECT_FALSE(T.isArch64Bit());
1696 EXPECT_TRUE(T.isRISCV());
1698 T.setArch(Triple::riscv64);
1699 EXPECT_FALSE(T.isArch16Bit());
1700 EXPECT_FALSE(T.isArch32Bit());
1701 EXPECT_TRUE(T.isArch64Bit());
1702 EXPECT_TRUE(T.isRISCV());
1704 T.setArch(Triple::csky);
1705 EXPECT_FALSE(T.isArch16Bit());
1706 EXPECT_TRUE(T.isArch32Bit());
1707 EXPECT_FALSE(T.isArch64Bit());
1708 EXPECT_TRUE(T.isCSKY());
1710 T.setArch(Triple::loongarch32);
1711 EXPECT_FALSE(T.isArch16Bit());
1712 EXPECT_TRUE(T.isArch32Bit());
1713 EXPECT_FALSE(T.isArch64Bit());
1714 EXPECT_TRUE(T.isLoongArch());
1715 EXPECT_TRUE(T.isLoongArch32());
1717 T.setArch(Triple::loongarch64);
1718 EXPECT_FALSE(T.isArch16Bit());
1719 EXPECT_FALSE(T.isArch32Bit());
1720 EXPECT_TRUE(T.isArch64Bit());
1721 EXPECT_TRUE(T.isLoongArch());
1722 EXPECT_TRUE(T.isLoongArch64());
1724 T.setArch(Triple::dxil);
1725 EXPECT_FALSE(T.isArch16Bit());
1726 EXPECT_TRUE(T.isArch32Bit());
1727 EXPECT_FALSE(T.isArch64Bit());
1728 EXPECT_TRUE(T.isDXIL());
1730 T.setArch(Triple::xtensa);
1731 EXPECT_FALSE(T.isArch16Bit());
1732 EXPECT_TRUE(T.isArch32Bit());
1733 EXPECT_FALSE(T.isArch64Bit());
1736 TEST(TripleTest, BitWidthArchVariants) {
1737 Triple T;
1738 EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
1739 EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
1741 T.setArch(Triple::UnknownArch);
1742 EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
1743 EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
1745 T.setArch(Triple::mips);
1746 EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
1747 EXPECT_EQ(Triple::NoSubArch, T.get32BitArchVariant().getSubArch());
1748 EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
1749 EXPECT_EQ(Triple::NoSubArch, T.get64BitArchVariant().getSubArch());
1751 T.setArch(Triple::mips, Triple::MipsSubArch_r6);
1752 EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
1753 EXPECT_EQ(Triple::MipsSubArch_r6, T.get32BitArchVariant().getSubArch());
1754 EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
1755 EXPECT_EQ(Triple::MipsSubArch_r6, T.get64BitArchVariant().getSubArch());
1757 T.setArch(Triple::mipsel);
1758 EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
1759 EXPECT_EQ(Triple::NoSubArch, T.get32BitArchVariant().getSubArch());
1760 EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
1761 EXPECT_EQ(Triple::NoSubArch, T.get64BitArchVariant().getSubArch());
1763 T.setArch(Triple::mipsel, Triple::MipsSubArch_r6);
1764 EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
1765 EXPECT_EQ(Triple::MipsSubArch_r6, T.get32BitArchVariant().getSubArch());
1766 EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
1767 EXPECT_EQ(Triple::MipsSubArch_r6, T.get64BitArchVariant().getSubArch());
1769 T.setArch(Triple::ppc);
1770 EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
1771 EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
1773 T.setArch(Triple::nvptx);
1774 EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
1775 EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
1777 T.setArch(Triple::sparc);
1778 EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
1779 EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
1781 T.setArch(Triple::x86);
1782 EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
1783 EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
1785 T.setArch(Triple::mips64);
1786 EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
1787 EXPECT_EQ(Triple::NoSubArch, T.get32BitArchVariant().getSubArch());
1788 EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
1789 EXPECT_EQ(Triple::NoSubArch, T.get64BitArchVariant().getSubArch());
1791 T.setArch(Triple::mips64, Triple::MipsSubArch_r6);
1792 EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
1793 EXPECT_EQ(Triple::MipsSubArch_r6, T.get32BitArchVariant().getSubArch());
1794 EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
1795 EXPECT_EQ(Triple::MipsSubArch_r6, T.get64BitArchVariant().getSubArch());
1797 T.setArch(Triple::mips64el);
1798 EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
1799 EXPECT_EQ(Triple::NoSubArch, T.get32BitArchVariant().getSubArch());
1800 EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
1801 EXPECT_EQ(Triple::NoSubArch, T.get64BitArchVariant().getSubArch());
1803 T.setArch(Triple::mips64el, Triple::MipsSubArch_r6);
1804 EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
1805 EXPECT_EQ(Triple::MipsSubArch_r6, T.get32BitArchVariant().getSubArch());
1806 EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
1807 EXPECT_EQ(Triple::MipsSubArch_r6, T.get64BitArchVariant().getSubArch());
1809 T.setArch(Triple::ppc64);
1810 EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
1811 EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
1813 T.setArch(Triple::nvptx64);
1814 EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
1815 EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
1817 T.setArch(Triple::sparcv9);
1818 EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
1819 EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
1821 T.setArch(Triple::x86_64);
1822 EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
1823 EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
1825 T.setArch(Triple::amdil);
1826 EXPECT_EQ(Triple::amdil, T.get32BitArchVariant().getArch());
1827 EXPECT_EQ(Triple::amdil64, T.get64BitArchVariant().getArch());
1829 T.setArch(Triple::amdil64);
1830 EXPECT_EQ(Triple::amdil, T.get32BitArchVariant().getArch());
1831 EXPECT_EQ(Triple::amdil64, T.get64BitArchVariant().getArch());
1833 T.setArch(Triple::hsail);
1834 EXPECT_EQ(Triple::hsail, T.get32BitArchVariant().getArch());
1835 EXPECT_EQ(Triple::hsail64, T.get64BitArchVariant().getArch());
1837 T.setArch(Triple::hsail64);
1838 EXPECT_EQ(Triple::hsail, T.get32BitArchVariant().getArch());
1839 EXPECT_EQ(Triple::hsail64, T.get64BitArchVariant().getArch());
1841 T.setArch(Triple::spir);
1842 EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
1843 EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
1845 T.setArch(Triple::spir64);
1846 EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
1847 EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
1849 T.setArch(Triple::spirv);
1850 EXPECT_EQ(Triple::spirv32, T.get32BitArchVariant().getArch());
1851 EXPECT_EQ(Triple::spirv64, T.get64BitArchVariant().getArch());
1853 T.setArch(Triple::spirv32);
1854 EXPECT_EQ(Triple::spirv32, T.get32BitArchVariant().getArch());
1855 EXPECT_EQ(Triple::spirv64, T.get64BitArchVariant().getArch());
1857 T.setArch(Triple::spirv64);
1858 EXPECT_EQ(Triple::spirv32, T.get32BitArchVariant().getArch());
1859 EXPECT_EQ(Triple::spirv64, T.get64BitArchVariant().getArch());
1861 T.setArch(Triple::wasm32);
1862 EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
1863 EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
1865 T.setArch(Triple::wasm64);
1866 EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
1867 EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
1869 T.setArch(Triple::riscv32);
1870 EXPECT_EQ(Triple::riscv32, T.get32BitArchVariant().getArch());
1871 EXPECT_EQ(Triple::riscv64, T.get64BitArchVariant().getArch());
1873 T.setArch(Triple::riscv64);
1874 EXPECT_EQ(Triple::riscv32, T.get32BitArchVariant().getArch());
1875 EXPECT_EQ(Triple::riscv64, T.get64BitArchVariant().getArch());
1877 T.setArch(Triple::csky);
1878 EXPECT_EQ(Triple::csky, T.get32BitArchVariant().getArch());
1879 EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
1881 T.setArch(Triple::loongarch32);
1882 EXPECT_EQ(Triple::loongarch32, T.get32BitArchVariant().getArch());
1883 EXPECT_EQ(Triple::loongarch64, T.get64BitArchVariant().getArch());
1885 T.setArch(Triple::loongarch64);
1886 EXPECT_EQ(Triple::loongarch32, T.get32BitArchVariant().getArch());
1887 EXPECT_EQ(Triple::loongarch64, T.get64BitArchVariant().getArch());
1889 T.setArch(Triple::thumbeb);
1890 EXPECT_EQ(Triple::thumbeb, T.get32BitArchVariant().getArch());
1891 EXPECT_EQ(Triple::aarch64_be, T.get64BitArchVariant().getArch());
1893 T.setArch(Triple::thumb);
1894 EXPECT_EQ(Triple::thumb, T.get32BitArchVariant().getArch());
1895 EXPECT_EQ(Triple::aarch64, T.get64BitArchVariant().getArch());
1897 T.setArch(Triple::aarch64);
1898 EXPECT_EQ(Triple::arm, T.get32BitArchVariant().getArch());
1899 EXPECT_EQ(Triple::aarch64, T.get64BitArchVariant().getArch());
1901 T.setArch(Triple::aarch64_be);
1902 EXPECT_EQ(Triple::armeb, T.get32BitArchVariant().getArch());
1903 EXPECT_EQ(Triple::aarch64_be, T.get64BitArchVariant().getArch());
1905 T.setArch(Triple::renderscript32);
1906 EXPECT_EQ(Triple::renderscript32, T.get32BitArchVariant().getArch());
1907 EXPECT_EQ(Triple::renderscript64, T.get64BitArchVariant().getArch());
1909 T.setArch(Triple::renderscript64);
1910 EXPECT_EQ(Triple::renderscript32, T.get32BitArchVariant().getArch());
1911 EXPECT_EQ(Triple::renderscript64, T.get64BitArchVariant().getArch());
1913 T.setArch(Triple::armeb);
1914 EXPECT_EQ(Triple::armeb, T.get32BitArchVariant().getArch());
1915 EXPECT_EQ(Triple::aarch64_be, T.get64BitArchVariant().getArch());
1917 T.setArch(Triple::arm);
1918 EXPECT_EQ(Triple::arm, T.get32BitArchVariant().getArch());
1919 EXPECT_EQ(Triple::aarch64, T.get64BitArchVariant().getArch());
1921 T.setArch(Triple::systemz);
1922 EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
1923 EXPECT_EQ(Triple::systemz, T.get64BitArchVariant().getArch());
1925 T.setArch(Triple::xcore);
1926 EXPECT_EQ(Triple::xcore, T.get32BitArchVariant().getArch());
1927 EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
1929 T.setArch(Triple::dxil);
1930 EXPECT_EQ(Triple::dxil, T.get32BitArchVariant().getArch());
1931 EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
1933 T.setArch(Triple::xtensa);
1934 EXPECT_EQ(Triple::xtensa, T.get32BitArchVariant().getArch());
1935 EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
1938 TEST(TripleTest, EndianArchVariants) {
1939 Triple T;
1940 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
1941 EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
1943 T.setArch(Triple::UnknownArch);
1944 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
1945 EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
1947 T.setArch(Triple::aarch64_be);
1948 EXPECT_EQ(Triple::aarch64_be, T.getBigEndianArchVariant().getArch());
1949 EXPECT_EQ(Triple::aarch64, T.getLittleEndianArchVariant().getArch());
1951 T.setArch(Triple::aarch64);
1952 EXPECT_EQ(Triple::aarch64_be, T.getBigEndianArchVariant().getArch());
1953 EXPECT_EQ(Triple::aarch64, T.getLittleEndianArchVariant().getArch());
1955 T.setArch(Triple::armeb);
1956 EXPECT_EQ(Triple::armeb, T.getBigEndianArchVariant().getArch());
1957 EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
1959 T.setArch(Triple::arm);
1960 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
1961 EXPECT_EQ(Triple::arm, T.getLittleEndianArchVariant().getArch());
1962 T = Triple("arm");
1963 EXPECT_TRUE(T.isLittleEndian());
1964 T = Triple("thumb");
1965 EXPECT_TRUE(T.isLittleEndian());
1966 T = Triple("armeb");
1967 EXPECT_FALSE(T.isLittleEndian());
1968 T = Triple("thumbeb");
1969 EXPECT_FALSE(T.isLittleEndian());
1971 T.setArch(Triple::bpfeb);
1972 EXPECT_EQ(Triple::bpfeb, T.getBigEndianArchVariant().getArch());
1973 EXPECT_EQ(Triple::bpfel, T.getLittleEndianArchVariant().getArch());
1975 T.setArch(Triple::bpfel);
1976 EXPECT_EQ(Triple::bpfeb, T.getBigEndianArchVariant().getArch());
1977 EXPECT_EQ(Triple::bpfel, T.getLittleEndianArchVariant().getArch());
1979 T.setArch(Triple::mips64);
1980 EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
1981 EXPECT_EQ(Triple::NoSubArch, T.getBigEndianArchVariant().getSubArch());
1982 EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
1983 EXPECT_EQ(Triple::NoSubArch, T.getLittleEndianArchVariant().getSubArch());
1985 T.setArch(Triple::mips64, Triple::MipsSubArch_r6);
1986 EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
1987 EXPECT_EQ(Triple::MipsSubArch_r6, T.getBigEndianArchVariant().getSubArch());
1988 EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
1989 EXPECT_EQ(Triple::MipsSubArch_r6,
1990 T.getLittleEndianArchVariant().getSubArch());
1992 T.setArch(Triple::mips64el);
1993 EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
1994 EXPECT_EQ(Triple::NoSubArch, T.getBigEndianArchVariant().getSubArch());
1995 EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
1996 EXPECT_EQ(Triple::NoSubArch, T.getLittleEndianArchVariant().getSubArch());
1998 T.setArch(Triple::mips64el, Triple::MipsSubArch_r6);
1999 EXPECT_EQ(Triple::mips64, T.getBigEndianArchVariant().getArch());
2000 EXPECT_EQ(Triple::MipsSubArch_r6, T.getBigEndianArchVariant().getSubArch());
2001 EXPECT_EQ(Triple::mips64el, T.getLittleEndianArchVariant().getArch());
2002 EXPECT_EQ(Triple::MipsSubArch_r6,
2003 T.getLittleEndianArchVariant().getSubArch());
2005 T.setArch(Triple::mips);
2006 EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
2007 EXPECT_EQ(Triple::NoSubArch, T.getBigEndianArchVariant().getSubArch());
2008 EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
2009 EXPECT_EQ(Triple::NoSubArch, T.getLittleEndianArchVariant().getSubArch());
2011 T.setArch(Triple::mips, Triple::MipsSubArch_r6);
2012 EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
2013 EXPECT_EQ(Triple::MipsSubArch_r6, T.getBigEndianArchVariant().getSubArch());
2014 EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
2015 EXPECT_EQ(Triple::MipsSubArch_r6,
2016 T.getLittleEndianArchVariant().getSubArch());
2018 T.setArch(Triple::mipsel);
2019 EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
2020 EXPECT_EQ(Triple::NoSubArch, T.getBigEndianArchVariant().getSubArch());
2021 EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
2022 EXPECT_EQ(Triple::NoSubArch, T.getLittleEndianArchVariant().getSubArch());
2024 T.setArch(Triple::mipsel, Triple::MipsSubArch_r6);
2025 EXPECT_EQ(Triple::mips, T.getBigEndianArchVariant().getArch());
2026 EXPECT_EQ(Triple::MipsSubArch_r6, T.getBigEndianArchVariant().getSubArch());
2027 EXPECT_EQ(Triple::mipsel, T.getLittleEndianArchVariant().getArch());
2028 EXPECT_EQ(Triple::MipsSubArch_r6,
2029 T.getLittleEndianArchVariant().getSubArch());
2031 T.setArch(Triple::ppc);
2032 EXPECT_EQ(Triple::ppc, T.getBigEndianArchVariant().getArch());
2033 EXPECT_EQ(Triple::ppcle, T.getLittleEndianArchVariant().getArch());
2035 T.setArch(Triple::ppc64);
2036 EXPECT_EQ(Triple::ppc64, T.getBigEndianArchVariant().getArch());
2037 EXPECT_EQ(Triple::ppc64le, T.getLittleEndianArchVariant().getArch());
2039 T.setArch(Triple::ppc64le);
2040 EXPECT_EQ(Triple::ppc64, T.getBigEndianArchVariant().getArch());
2041 EXPECT_EQ(Triple::ppc64le, T.getLittleEndianArchVariant().getArch());
2043 T.setArch(Triple::sparc);
2044 EXPECT_EQ(Triple::sparc, T.getBigEndianArchVariant().getArch());
2045 EXPECT_EQ(Triple::sparcel, T.getLittleEndianArchVariant().getArch());
2047 T.setArch(Triple::sparcel);
2048 EXPECT_EQ(Triple::sparc, T.getBigEndianArchVariant().getArch());
2049 EXPECT_EQ(Triple::sparcel, T.getLittleEndianArchVariant().getArch());
2051 T.setArch(Triple::thumb);
2052 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
2053 EXPECT_EQ(Triple::thumb, T.getLittleEndianArchVariant().getArch());
2055 T.setArch(Triple::thumbeb);
2056 EXPECT_EQ(Triple::thumbeb, T.getBigEndianArchVariant().getArch());
2057 EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
2059 T.setArch(Triple::lanai);
2060 EXPECT_EQ(Triple::lanai, T.getBigEndianArchVariant().getArch());
2061 EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch());
2063 T.setArch(Triple::tcele);
2064 EXPECT_EQ(Triple::tce, T.getBigEndianArchVariant().getArch());
2065 EXPECT_EQ(Triple::tcele, T.getLittleEndianArchVariant().getArch());
2067 T.setArch(Triple::tce);
2068 EXPECT_EQ(Triple::tce, T.getBigEndianArchVariant().getArch());
2069 EXPECT_EQ(Triple::tcele, T.getLittleEndianArchVariant().getArch());
2071 T.setArch(Triple::csky);
2072 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
2073 EXPECT_EQ(Triple::csky, T.getLittleEndianArchVariant().getArch());
2075 T.setArch(Triple::loongarch32);
2076 EXPECT_TRUE(T.isLittleEndian());
2077 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
2078 EXPECT_EQ(Triple::loongarch32, T.getLittleEndianArchVariant().getArch());
2080 T.setArch(Triple::loongarch64);
2081 EXPECT_TRUE(T.isLittleEndian());
2082 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
2083 EXPECT_EQ(Triple::loongarch64, T.getLittleEndianArchVariant().getArch());
2085 T.setArch(Triple::dxil);
2086 EXPECT_TRUE(T.isLittleEndian());
2087 EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch());
2088 EXPECT_EQ(Triple::dxil, T.getLittleEndianArchVariant().getArch());
2091 TEST(TripleTest, XROS) {
2092 Triple T;
2093 VersionTuple Version;
2095 T = Triple("arm64-apple-xros");
2096 EXPECT_TRUE(T.isXROS());
2097 EXPECT_TRUE(T.isOSDarwin());
2098 EXPECT_FALSE(T.isiOS());
2099 EXPECT_FALSE(T.isMacOSX());
2100 EXPECT_FALSE(T.isSimulatorEnvironment());
2101 EXPECT_EQ(T.getOSName(), "xros");
2102 Version = T.getOSVersion();
2103 EXPECT_EQ(VersionTuple(0), Version);
2105 T = Triple("arm64-apple-visionos1.2");
2106 EXPECT_TRUE(T.isXROS());
2107 EXPECT_TRUE(T.isOSDarwin());
2108 EXPECT_FALSE(T.isiOS());
2109 EXPECT_FALSE(T.isMacOSX());
2110 EXPECT_FALSE(T.isSimulatorEnvironment());
2111 EXPECT_EQ(T.getOSName(), "visionos1.2");
2112 Version = T.getOSVersion();
2113 EXPECT_EQ(VersionTuple(1, 2), Version);
2115 T = Triple("arm64-apple-xros1-simulator");
2116 EXPECT_TRUE(T.isXROS());
2117 EXPECT_TRUE(T.isOSDarwin());
2118 EXPECT_FALSE(T.isiOS());
2119 EXPECT_FALSE(T.isMacOSX());
2120 EXPECT_TRUE(T.isSimulatorEnvironment());
2121 Version = T.getOSVersion();
2122 EXPECT_EQ(VersionTuple(1), Version);
2123 Version = T.getiOSVersion();
2124 EXPECT_EQ(VersionTuple(17), Version);
2127 TEST(TripleTest, getOSVersion) {
2128 Triple T;
2129 VersionTuple Version;
2131 T = Triple("i386-apple-darwin9");
2132 EXPECT_TRUE(T.isMacOSX());
2133 EXPECT_FALSE(T.isiOS());
2134 EXPECT_FALSE(T.isArch16Bit());
2135 EXPECT_TRUE(T.isArch32Bit());
2136 EXPECT_FALSE(T.isArch64Bit());
2137 T.getMacOSXVersion(Version);
2138 EXPECT_EQ(VersionTuple(10, 5), Version);
2139 Version = T.getiOSVersion();
2140 EXPECT_EQ(VersionTuple(5), Version);
2142 T = Triple("x86_64-apple-darwin9");
2143 EXPECT_TRUE(T.isMacOSX());
2144 EXPECT_FALSE(T.isiOS());
2145 EXPECT_FALSE(T.isArch16Bit());
2146 EXPECT_FALSE(T.isArch32Bit());
2147 EXPECT_TRUE(T.isArch64Bit());
2148 T.getMacOSXVersion(Version);
2149 EXPECT_EQ(VersionTuple(10, 5), Version);
2150 Version = T.getiOSVersion();
2151 EXPECT_EQ(VersionTuple(5), Version);
2153 T = Triple("x86_64-apple-macosx");
2154 EXPECT_TRUE(T.isMacOSX());
2155 EXPECT_FALSE(T.isiOS());
2156 EXPECT_FALSE(T.isArch16Bit());
2157 EXPECT_FALSE(T.isArch32Bit());
2158 EXPECT_TRUE(T.isArch64Bit());
2159 T.getMacOSXVersion(Version);
2160 EXPECT_EQ(VersionTuple(10, 4), Version);
2161 Version = T.getiOSVersion();
2162 EXPECT_EQ(VersionTuple(5), Version);
2164 T = Triple("x86_64-apple-macosx10.7");
2165 EXPECT_TRUE(T.isMacOSX());
2166 EXPECT_FALSE(T.isiOS());
2167 EXPECT_FALSE(T.isArch16Bit());
2168 EXPECT_FALSE(T.isArch32Bit());
2169 EXPECT_TRUE(T.isArch64Bit());
2170 T.getMacOSXVersion(Version);
2171 EXPECT_EQ(VersionTuple(10, 7), Version);
2172 Version = T.getiOSVersion();
2173 EXPECT_EQ(VersionTuple(5), Version);
2175 T = Triple("x86_64-apple-macos11.0");
2176 EXPECT_TRUE(T.isMacOSX());
2177 EXPECT_FALSE(T.isiOS());
2178 EXPECT_FALSE(T.isArch16Bit());
2179 EXPECT_FALSE(T.isArch32Bit());
2180 EXPECT_TRUE(T.isArch64Bit());
2181 T.getMacOSXVersion(Version);
2182 EXPECT_EQ(VersionTuple(11, 0), Version);
2184 T = Triple("arm64-apple-macosx11.5.8");
2185 EXPECT_TRUE(T.isMacOSX());
2186 EXPECT_FALSE(T.isiOS());
2187 EXPECT_FALSE(T.isArch16Bit());
2188 EXPECT_FALSE(T.isArch32Bit());
2189 EXPECT_TRUE(T.isArch64Bit());
2190 T.getMacOSXVersion(Version);
2191 EXPECT_EQ(VersionTuple(11, 5, 8), Version);
2193 // 10.16 forms a valid triple, even though it's not
2194 // a version of a macOS.
2195 T = Triple("x86_64-apple-macos10.16");
2196 EXPECT_TRUE(T.isMacOSX());
2197 T.getMacOSXVersion(Version);
2198 EXPECT_EQ(VersionTuple(10, 16), Version);
2200 T = Triple("x86_64-apple-darwin20");
2201 EXPECT_TRUE(T.isMacOSX());
2202 T.getMacOSXVersion(Version);
2203 EXPECT_EQ(VersionTuple(11), Version);
2205 // For darwin triples on macOS 11, only compare the major version.
2206 T = Triple("x86_64-apple-darwin20.2");
2207 EXPECT_TRUE(T.isMacOSX());
2208 T.getMacOSXVersion(Version);
2209 EXPECT_EQ(VersionTuple(11), Version);
2211 T = Triple("armv7-apple-ios");
2212 EXPECT_FALSE(T.isMacOSX());
2213 EXPECT_TRUE(T.isiOS());
2214 EXPECT_FALSE(T.isArch16Bit());
2215 EXPECT_TRUE(T.isArch32Bit());
2216 EXPECT_FALSE(T.isArch64Bit());
2217 T.getMacOSXVersion(Version);
2218 EXPECT_EQ(VersionTuple(10, 4), Version);
2219 Version = T.getiOSVersion();
2220 EXPECT_EQ(VersionTuple(5), Version);
2222 T = Triple("armv7-apple-ios7.0");
2223 EXPECT_FALSE(T.isMacOSX());
2224 EXPECT_TRUE(T.isiOS());
2225 EXPECT_FALSE(T.isArch16Bit());
2226 EXPECT_TRUE(T.isArch32Bit());
2227 EXPECT_FALSE(T.isArch64Bit());
2228 T.getMacOSXVersion(Version);
2229 EXPECT_EQ(VersionTuple(10, 4), Version);
2230 Version = T.getiOSVersion();
2231 EXPECT_EQ(VersionTuple(7, 0), Version);
2232 EXPECT_FALSE(T.isSimulatorEnvironment());
2234 T = Triple("x86_64-apple-ios10.3-simulator");
2235 EXPECT_TRUE(T.isiOS());
2236 Version = T.getiOSVersion();
2237 EXPECT_EQ(VersionTuple(10, 3), Version);
2238 EXPECT_TRUE(T.isSimulatorEnvironment());
2239 EXPECT_FALSE(T.isMacCatalystEnvironment());
2241 T = Triple("x86_64-apple-ios13.0-macabi");
2242 EXPECT_TRUE(T.isiOS());
2243 Version = T.getiOSVersion();
2244 EXPECT_EQ(VersionTuple(13, 0), Version);
2245 EXPECT_TRUE(T.getEnvironment() == Triple::MacABI);
2246 EXPECT_TRUE(T.isMacCatalystEnvironment());
2247 EXPECT_FALSE(T.isSimulatorEnvironment());
2249 T = Triple("x86_64-apple-driverkit20.1.0");
2250 EXPECT_TRUE(T.isDriverKit());
2251 EXPECT_TRUE(T.isOSDarwin());
2252 EXPECT_FALSE(T.isMacOSX());
2253 EXPECT_FALSE(T.isiOS());
2254 Version = T.getDriverKitVersion();
2255 EXPECT_EQ(VersionTuple(20, 1), Version);
2257 T = Triple("x86_64-apple-driverkit20");
2258 Version = T.getDriverKitVersion();
2259 EXPECT_EQ(VersionTuple(20, 0), Version);
2261 // DriverKit version should default to 19.0.
2262 T = Triple("x86_64-apple-driverkit");
2263 Version = T.getDriverKitVersion();
2264 EXPECT_EQ(VersionTuple(19, 0), Version);
2266 T = Triple("dxil-unknown-shadermodel6.6-pixel");
2267 EXPECT_EQ(Triple::dxil, T.getArch());
2268 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
2269 EXPECT_EQ(Triple::ShaderModel, T.getOS());
2270 Version = T.getOSVersion();
2271 EXPECT_EQ(VersionTuple(6, 6), Version);
2272 EXPECT_EQ(Triple::Pixel, T.getEnvironment());
2274 T = Triple("dxil-unknown-shadermodel6.0-pixel");
2275 EXPECT_EQ(Triple::dxil, T.getArch());
2276 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
2277 EXPECT_EQ(Triple::ShaderModel, T.getOS());
2278 Version = T.getOSVersion();
2279 EXPECT_EQ(VersionTuple(6, 0), Version);
2280 EXPECT_EQ(Triple::Pixel, T.getEnvironment());
2283 TEST(TripleTest, getEnvironmentVersion) {
2284 Triple T;
2285 VersionTuple Version;
2287 T = Triple("arm-unknown-linux-android16");
2288 EXPECT_TRUE(T.isAndroid());
2289 Version = T.getEnvironmentVersion();
2290 EXPECT_EQ(VersionTuple(16), Version);
2291 EXPECT_EQ(Triple::Android, T.getEnvironment());
2293 T = Triple("aarch64-unknown-linux-android21");
2294 EXPECT_TRUE(T.isAndroid());
2295 Version = T.getEnvironmentVersion();
2296 EXPECT_EQ(VersionTuple(21), Version);
2297 EXPECT_EQ(Triple::Android, T.getEnvironment());
2300 TEST(TripleTest, isMacOSVersionLT) {
2301 Triple T = Triple("x86_64-apple-macos11");
2302 EXPECT_TRUE(T.isMacOSXVersionLT(11, 1, 0));
2303 EXPECT_FALSE(T.isMacOSXVersionLT(10, 15, 0));
2305 T = Triple("x86_64-apple-darwin20");
2306 EXPECT_TRUE(T.isMacOSXVersionLT(11, 1, 0));
2307 EXPECT_FALSE(T.isMacOSXVersionLT(11, 0, 0));
2308 EXPECT_FALSE(T.isMacOSXVersionLT(10, 15, 0));
2311 TEST(TripleTest, CanonicalizeOSVersion) {
2312 EXPECT_EQ(VersionTuple(10, 15, 4),
2313 Triple::getCanonicalVersionForOS(Triple::MacOSX,
2314 VersionTuple(10, 15, 4)));
2315 EXPECT_EQ(VersionTuple(11, 0), Triple::getCanonicalVersionForOS(
2316 Triple::MacOSX, VersionTuple(10, 16)));
2317 EXPECT_EQ(VersionTuple(20),
2318 Triple::getCanonicalVersionForOS(Triple::Darwin, VersionTuple(20)));
2321 TEST(TripleTest, FileFormat) {
2322 EXPECT_EQ(Triple::ELF, Triple("i686-unknown-linux-gnu").getObjectFormat());
2323 EXPECT_EQ(Triple::ELF, Triple("i686-unknown-freebsd").getObjectFormat());
2324 EXPECT_EQ(Triple::ELF, Triple("i686-unknown-netbsd").getObjectFormat());
2325 EXPECT_EQ(Triple::ELF, Triple("i686--win32-elf").getObjectFormat());
2326 EXPECT_EQ(Triple::ELF, Triple("i686---elf").getObjectFormat());
2328 EXPECT_EQ(Triple::MachO, Triple("i686-apple-macosx").getObjectFormat());
2329 EXPECT_EQ(Triple::MachO, Triple("i686-apple-ios").getObjectFormat());
2330 EXPECT_EQ(Triple::MachO, Triple("i686---macho").getObjectFormat());
2331 EXPECT_EQ(Triple::MachO, Triple("powerpc-apple-macosx").getObjectFormat());
2333 EXPECT_EQ(Triple::COFF, Triple("i686--win32").getObjectFormat());
2335 EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
2336 EXPECT_EQ(Triple::ELF, Triple("i686-pc-cygwin-elf").getObjectFormat());
2338 EXPECT_EQ(Triple::ELF, Triple("systemz-ibm-linux").getObjectFormat());
2339 EXPECT_EQ(Triple::ELF, Triple("systemz-ibm-unknown").getObjectFormat());
2341 EXPECT_EQ(Triple::GOFF, Triple("s390x-ibm-zos").getObjectFormat());
2342 EXPECT_EQ(Triple::GOFF, Triple("systemz-ibm-zos").getObjectFormat());
2343 EXPECT_EQ(Triple::GOFF, Triple("s390x-ibm-zos-goff").getObjectFormat());
2344 EXPECT_EQ(Triple::GOFF, Triple("s390x-unknown-zos-goff").getObjectFormat());
2345 EXPECT_EQ(Triple::GOFF, Triple("s390x---goff").getObjectFormat());
2347 EXPECT_EQ(Triple::Wasm, Triple("wasm32-unknown-unknown").getObjectFormat());
2348 EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-unknown").getObjectFormat());
2349 EXPECT_EQ(Triple::Wasm, Triple("wasm32-wasi").getObjectFormat());
2350 EXPECT_EQ(Triple::Wasm, Triple("wasm64-wasi").getObjectFormat());
2351 EXPECT_EQ(Triple::Wasm, Triple("wasm32-unknown-wasi").getObjectFormat());
2352 EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-wasi").getObjectFormat());
2354 EXPECT_EQ(Triple::Wasm,
2355 Triple("wasm32-unknown-unknown-wasm").getObjectFormat());
2356 EXPECT_EQ(Triple::Wasm,
2357 Triple("wasm64-unknown-unknown-wasm").getObjectFormat());
2358 EXPECT_EQ(Triple::Wasm,
2359 Triple("wasm32-wasi-wasm").getObjectFormat());
2360 EXPECT_EQ(Triple::Wasm,
2361 Triple("wasm64-wasi-wasm").getObjectFormat());
2362 EXPECT_EQ(Triple::Wasm,
2363 Triple("wasm32-unknown-wasi-wasm").getObjectFormat());
2364 EXPECT_EQ(Triple::Wasm,
2365 Triple("wasm64-unknown-wasi-wasm").getObjectFormat());
2367 EXPECT_EQ(Triple::XCOFF, Triple("powerpc-ibm-aix").getObjectFormat());
2368 EXPECT_EQ(Triple::XCOFF, Triple("powerpc64-ibm-aix").getObjectFormat());
2369 EXPECT_EQ(Triple::XCOFF, Triple("powerpc---xcoff").getObjectFormat());
2370 EXPECT_EQ(Triple::XCOFF, Triple("powerpc64---xcoff").getObjectFormat());
2372 EXPECT_EQ(Triple::ELF, Triple("csky-unknown-unknown").getObjectFormat());
2373 EXPECT_EQ(Triple::ELF, Triple("csky-unknown-linux").getObjectFormat());
2375 EXPECT_EQ(Triple::SPIRV, Triple("spirv-unknown-unknown").getObjectFormat());
2376 EXPECT_EQ(Triple::SPIRV, Triple("spirv32-unknown-unknown").getObjectFormat());
2377 EXPECT_EQ(Triple::SPIRV, Triple("spirv64-unknown-unknown").getObjectFormat());
2379 EXPECT_EQ(Triple::ELF,
2380 Triple("loongarch32-unknown-unknown").getObjectFormat());
2381 EXPECT_EQ(Triple::ELF, Triple("loongarch64-unknown-linux").getObjectFormat());
2383 Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
2384 EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
2386 Triple GNUWindowsNormalized(Triple::normalize("i686-pc-windows-gnu-elf"));
2387 EXPECT_EQ(Triple::ELF, GNUWindowsNormalized.getObjectFormat());
2389 Triple CygnusNormalised(Triple::normalize("i686-pc-windows-cygnus-elf"));
2390 EXPECT_EQ(Triple::ELF, CygnusNormalised.getObjectFormat());
2392 Triple CygwinNormalized(Triple::normalize("i686-pc-cygwin-elf"));
2393 EXPECT_EQ(Triple::ELF, CygwinNormalized.getObjectFormat());
2395 EXPECT_EQ(Triple::DXContainer,
2396 Triple("dxil-unknown-shadermodel").getObjectFormat());
2398 Triple T = Triple("");
2399 T.setObjectFormat(Triple::ELF);
2400 EXPECT_EQ(Triple::ELF, T.getObjectFormat());
2401 EXPECT_EQ("elf", Triple::getObjectFormatTypeName(T.getObjectFormat()));
2403 T.setObjectFormat(Triple::MachO);
2404 EXPECT_EQ(Triple::MachO, T.getObjectFormat());
2405 EXPECT_EQ("macho", Triple::getObjectFormatTypeName(T.getObjectFormat()));
2407 T.setObjectFormat(Triple::XCOFF);
2408 EXPECT_EQ(Triple::XCOFF, T.getObjectFormat());
2409 EXPECT_EQ("xcoff", Triple::getObjectFormatTypeName(T.getObjectFormat()));
2411 T.setObjectFormat(Triple::GOFF);
2412 EXPECT_EQ(Triple::GOFF, T.getObjectFormat());
2413 EXPECT_EQ("goff", Triple::getObjectFormatTypeName(T.getObjectFormat()));
2415 T.setObjectFormat(Triple::SPIRV);
2416 EXPECT_EQ(Triple::SPIRV, T.getObjectFormat());
2417 EXPECT_EQ("spirv", Triple::getObjectFormatTypeName(T.getObjectFormat()));
2419 EXPECT_EQ(Triple::ELF, Triple("amdgcn-apple-macosx").getObjectFormat());
2420 EXPECT_EQ(Triple::ELF, Triple("r600-apple-macosx").getObjectFormat());
2421 EXPECT_EQ(Triple::SPIRV, Triple("spirv-apple-macosx").getObjectFormat());
2422 EXPECT_EQ(Triple::SPIRV, Triple("spirv32-apple-macosx").getObjectFormat());
2423 EXPECT_EQ(Triple::SPIRV, Triple("spirv64-apple-macosx").getObjectFormat());
2424 EXPECT_EQ(Triple::DXContainer, Triple("dxil-apple-macosx").getObjectFormat());
2427 TEST(TripleTest, NormalizeWindows) {
2428 EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-win32"));
2429 EXPECT_EQ("i686-unknown-windows-msvc", Triple::normalize("i686-win32"));
2430 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32"));
2431 EXPECT_EQ("i686-unknown-windows-gnu", Triple::normalize("i686-mingw32"));
2432 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32-w64"));
2433 EXPECT_EQ("i686-unknown-windows-gnu", Triple::normalize("i686-mingw32-w64"));
2434 EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-cygwin"));
2435 EXPECT_EQ("i686-unknown-windows-cygnus", Triple::normalize("i686-cygwin"));
2437 EXPECT_EQ("x86_64-pc-windows-msvc", Triple::normalize("x86_64-pc-win32"));
2438 EXPECT_EQ("x86_64-unknown-windows-msvc", Triple::normalize("x86_64-win32"));
2439 EXPECT_EQ("x86_64-pc-windows-gnu", Triple::normalize("x86_64-pc-mingw32"));
2440 EXPECT_EQ("x86_64-unknown-windows-gnu", Triple::normalize("x86_64-mingw32"));
2441 EXPECT_EQ("x86_64-pc-windows-gnu",
2442 Triple::normalize("x86_64-pc-mingw32-w64"));
2443 EXPECT_EQ("x86_64-unknown-windows-gnu",
2444 Triple::normalize("x86_64-mingw32-w64"));
2446 EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-win32-elf"));
2447 EXPECT_EQ("i686-unknown-windows-elf", Triple::normalize("i686-win32-elf"));
2448 EXPECT_EQ("i686-pc-windows-macho", Triple::normalize("i686-pc-win32-macho"));
2449 EXPECT_EQ("i686-unknown-windows-macho",
2450 Triple::normalize("i686-win32-macho"));
2452 EXPECT_EQ("x86_64-pc-windows-elf", Triple::normalize("x86_64-pc-win32-elf"));
2453 EXPECT_EQ("x86_64-unknown-windows-elf",
2454 Triple::normalize("x86_64-win32-elf"));
2455 EXPECT_EQ("x86_64-pc-windows-macho",
2456 Triple::normalize("x86_64-pc-win32-macho"));
2457 EXPECT_EQ("x86_64-unknown-windows-macho",
2458 Triple::normalize("x86_64-win32-macho"));
2460 EXPECT_EQ("i686-pc-windows-cygnus",
2461 Triple::normalize("i686-pc-windows-cygnus"));
2462 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-windows-gnu"));
2463 EXPECT_EQ("i686-pc-windows-itanium",
2464 Triple::normalize("i686-pc-windows-itanium"));
2465 EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-windows-msvc"));
2467 EXPECT_EQ("i686-pc-windows-elf",
2468 Triple::normalize("i686-pc-windows-elf-elf"));
2470 EXPECT_TRUE(Triple("x86_64-pc-win32").isWindowsMSVCEnvironment());
2472 EXPECT_TRUE(Triple(Triple::normalize("mipsel-windows-msvccoff")).isOSBinFormatCOFF());
2473 EXPECT_TRUE(Triple(Triple::normalize("mipsel-windows-msvc")).isOSBinFormatCOFF());
2474 EXPECT_TRUE(Triple(Triple::normalize("mipsel-windows-gnu")).isOSBinFormatCOFF());
2477 TEST(TripleTest, NormalizeAndroid) {
2478 EXPECT_EQ("arm-unknown-linux-android16",
2479 Triple::normalize("arm-linux-androideabi16"));
2480 EXPECT_EQ("armv7a-unknown-linux-android",
2481 Triple::normalize("armv7a-linux-androideabi"));
2482 EXPECT_EQ("aarch64-unknown-linux-android21",
2483 Triple::normalize("aarch64-linux-android21"));
2486 TEST(TripleTest, NormalizeARM) {
2487 EXPECT_EQ("armv6-unknown-netbsd-eabi",
2488 Triple::normalize("armv6-netbsd-eabi"));
2489 EXPECT_EQ("armv7-unknown-netbsd-eabi",
2490 Triple::normalize("armv7-netbsd-eabi"));
2491 EXPECT_EQ("armv6eb-unknown-netbsd-eabi",
2492 Triple::normalize("armv6eb-netbsd-eabi"));
2493 EXPECT_EQ("armv7eb-unknown-netbsd-eabi",
2494 Triple::normalize("armv7eb-netbsd-eabi"));
2495 EXPECT_EQ("armv6-unknown-netbsd-eabihf",
2496 Triple::normalize("armv6-netbsd-eabihf"));
2497 EXPECT_EQ("armv7-unknown-netbsd-eabihf",
2498 Triple::normalize("armv7-netbsd-eabihf"));
2499 EXPECT_EQ("armv6eb-unknown-netbsd-eabihf",
2500 Triple::normalize("armv6eb-netbsd-eabihf"));
2501 EXPECT_EQ("armv7eb-unknown-netbsd-eabihf",
2502 Triple::normalize("armv7eb-netbsd-eabihf"));
2504 EXPECT_EQ("armv7-suse-linux-gnueabihf",
2505 Triple::normalize("armv7-suse-linux-gnueabi"));
2507 Triple T;
2508 T = Triple("armv6--netbsd-eabi");
2509 EXPECT_EQ(Triple::arm, T.getArch());
2510 T = Triple("armv6eb--netbsd-eabi");
2511 EXPECT_EQ(Triple::armeb, T.getArch());
2512 T = Triple("armv7-suse-linux-gnueabihf");
2513 EXPECT_EQ(Triple::GNUEABIHF, T.getEnvironment());
2516 TEST(TripleTest, ParseARMArch) {
2517 // ARM
2519 Triple T = Triple("arm");
2520 EXPECT_EQ(Triple::arm, T.getArch());
2523 Triple T = Triple("armeb");
2524 EXPECT_EQ(Triple::armeb, T.getArch());
2526 // THUMB
2528 Triple T = Triple("thumb");
2529 EXPECT_EQ(Triple::thumb, T.getArch());
2532 Triple T = Triple("thumbeb");
2533 EXPECT_EQ(Triple::thumbeb, T.getArch());
2535 // AARCH64
2537 Triple T = Triple("arm64");
2538 EXPECT_EQ(Triple::aarch64, T.getArch());
2541 Triple T = Triple("arm64_32");
2542 EXPECT_EQ(Triple::aarch64_32, T.getArch());
2545 Triple T = Triple("aarch64");
2546 EXPECT_EQ(Triple::aarch64, T.getArch());
2549 Triple T = Triple("aarch64_be");
2550 EXPECT_EQ(Triple::aarch64_be, T.getArch());
2553 Triple T = Triple("arm64e");
2554 EXPECT_EQ(Triple::aarch64, T.getArch());
2555 EXPECT_EQ(Triple::AArch64SubArch_arm64e, T.getSubArch());
2558 Triple T = Triple("arm64ec");
2559 EXPECT_EQ(Triple::aarch64, T.getArch());
2560 EXPECT_EQ(Triple::AArch64SubArch_arm64ec, T.getSubArch());
2563 Triple T;
2564 T.setArch(Triple::aarch64, Triple::AArch64SubArch_arm64ec);
2565 EXPECT_EQ("arm64ec", T.getArchName());
2569 TEST(TripleTest, isArmT32) {
2570 // Not isArmT32
2572 Triple T = Triple("thumbv6m");
2573 EXPECT_FALSE(T.isArmT32());
2576 Triple T = Triple("armv8m.base");
2577 EXPECT_FALSE(T.isArmT32());
2580 Triple T = Triple("armv7s");
2581 EXPECT_FALSE(T.isArmT32());
2584 Triple T = Triple("armv7k");
2585 EXPECT_FALSE(T.isArmT32());
2588 Triple T = Triple("armv7ve");
2589 EXPECT_FALSE(T.isArmT32());
2592 Triple T = Triple("armv6");
2593 EXPECT_FALSE(T.isArmT32());
2596 Triple T = Triple("armv6m");
2597 EXPECT_FALSE(T.isArmT32());
2600 Triple T = Triple("armv6k");
2601 EXPECT_FALSE(T.isArmT32());
2604 Triple T = Triple("armv6t2");
2605 EXPECT_FALSE(T.isArmT32());
2608 Triple T = Triple("armv5");
2609 EXPECT_FALSE(T.isArmT32());
2612 Triple T = Triple("armv5te");
2613 EXPECT_FALSE(T.isArmT32());
2616 Triple T = Triple("armv4t");
2617 EXPECT_FALSE(T.isArmT32());
2620 // isArmT32
2622 Triple T = Triple("arm");
2623 EXPECT_TRUE(T.isArmT32());
2626 Triple T = Triple("armv7m");
2627 EXPECT_TRUE(T.isArmT32());
2630 Triple T = Triple("armv7em");
2631 EXPECT_TRUE(T.isArmT32());
2634 Triple T = Triple("armv8m.main");
2635 EXPECT_TRUE(T.isArmT32());
2638 Triple T = Triple("armv8.1m.main");
2639 EXPECT_TRUE(T.isArmT32());
2643 TEST(TripleTest, isArmMClass) {
2644 // not M-class
2646 Triple T = Triple("armv7s");
2647 EXPECT_FALSE(T.isArmMClass());
2650 Triple T = Triple("armv7k");
2651 EXPECT_FALSE(T.isArmMClass());
2654 Triple T = Triple("armv7ve");
2655 EXPECT_FALSE(T.isArmMClass());
2658 Triple T = Triple("armv6");
2659 EXPECT_FALSE(T.isArmMClass());
2662 Triple T = Triple("armv6k");
2663 EXPECT_FALSE(T.isArmMClass());
2666 Triple T = Triple("armv6t2");
2667 EXPECT_FALSE(T.isArmMClass());
2670 Triple T = Triple("armv5");
2671 EXPECT_FALSE(T.isArmMClass());
2674 Triple T = Triple("armv5te");
2675 EXPECT_FALSE(T.isArmMClass());
2678 Triple T = Triple("armv4t");
2679 EXPECT_FALSE(T.isArmMClass());
2682 Triple T = Triple("arm");
2683 EXPECT_FALSE(T.isArmMClass());
2686 // is M-class
2688 Triple T = Triple("armv6m");
2689 EXPECT_TRUE(T.isArmMClass());
2692 Triple T = Triple("armv7m");
2693 EXPECT_TRUE(T.isArmMClass());
2696 Triple T = Triple("armv7em");
2697 EXPECT_TRUE(T.isArmMClass());
2700 Triple T = Triple("armv8m.base");
2701 EXPECT_TRUE(T.isArmMClass());
2704 Triple T = Triple("armv8m.main");
2705 EXPECT_TRUE(T.isArmMClass());
2708 Triple T = Triple("armv8.1m.main");
2709 EXPECT_TRUE(T.isArmMClass());
2713 TEST(TripleTest, DXILNormaizeWithVersion) {
2714 EXPECT_EQ("dxilv1.0-unknown-shadermodel6.0",
2715 Triple::normalize("dxilv1.0--shadermodel6.0"));
2716 EXPECT_EQ("dxilv1.0-unknown-shadermodel6.0",
2717 Triple::normalize("dxil--shadermodel6.0"));
2718 EXPECT_EQ("dxilv1.1-unknown-shadermodel6.1-library",
2719 Triple::normalize("dxil-shadermodel6.1-unknown-library"));
2720 EXPECT_EQ("dxilv1.8-unknown-shadermodel6.x-unknown",
2721 Triple::normalize("dxil-unknown-shadermodel6.x-unknown"));
2722 EXPECT_EQ("dxilv1.8-unknown-shadermodel6.x-unknown",
2723 Triple::normalize("dxil-unknown-shadermodel6.x-unknown"));
2724 EXPECT_EQ("dxil-unknown-unknown-unknown", Triple::normalize("dxil---"));
2725 EXPECT_EQ("dxilv1.0-pc-shadermodel5.0-compute",
2726 Triple::normalize("dxil-shadermodel5.0-pc-compute"));
2728 } // end anonymous namespace