1 //===----------- Triple.cpp - Triple unit tests ---------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/TargetParser/Triple.h"
10 #include "llvm/Support/VersionTuple.h"
11 #include "gtest/gtest.h"
17 TEST(TripleTest
, BasicParsing
) {
21 EXPECT_EQ("", T
.getArchName().str());
22 EXPECT_EQ("", T
.getVendorName().str());
23 EXPECT_EQ("", T
.getOSName().str());
24 EXPECT_EQ("", T
.getEnvironmentName().str());
27 EXPECT_EQ("", T
.getArchName().str());
28 EXPECT_EQ("", T
.getVendorName().str());
29 EXPECT_EQ("", T
.getOSName().str());
30 EXPECT_EQ("", T
.getEnvironmentName().str());
33 EXPECT_EQ("", T
.getArchName().str());
34 EXPECT_EQ("", T
.getVendorName().str());
35 EXPECT_EQ("", T
.getOSName().str());
36 EXPECT_EQ("", T
.getEnvironmentName().str());
39 EXPECT_EQ("", T
.getArchName().str());
40 EXPECT_EQ("", T
.getVendorName().str());
41 EXPECT_EQ("", T
.getOSName().str());
42 EXPECT_EQ("", T
.getEnvironmentName().str());
45 EXPECT_EQ("", T
.getArchName().str());
46 EXPECT_EQ("", T
.getVendorName().str());
47 EXPECT_EQ("", T
.getOSName().str());
48 EXPECT_EQ("-", T
.getEnvironmentName().str());
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());
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());
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
) {
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("x86_64-pc-linux-gnu");
97 EXPECT_EQ(Triple::x86_64
, T
.getArch());
98 EXPECT_EQ(Triple::PC
, T
.getVendor());
99 EXPECT_EQ(Triple::Linux
, T
.getOS());
100 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
102 T
= Triple("x86_64-pc-linux-musl");
103 EXPECT_EQ(Triple::x86_64
, T
.getArch());
104 EXPECT_EQ(Triple::PC
, T
.getVendor());
105 EXPECT_EQ(Triple::Linux
, T
.getOS());
106 EXPECT_EQ(Triple::Musl
, T
.getEnvironment());
108 T
= Triple("x86_64-pc-linux-muslx32");
109 EXPECT_EQ(Triple::x86_64
, T
.getArch());
110 EXPECT_EQ(Triple::PC
, T
.getVendor());
111 EXPECT_EQ(Triple::Linux
, T
.getOS());
112 EXPECT_EQ(Triple::MuslX32
, T
.getEnvironment());
114 T
= Triple("arm-unknown-linux-android16");
115 EXPECT_EQ(Triple::arm
, T
.getArch());
116 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
117 EXPECT_EQ(Triple::Linux
, T
.getOS());
118 EXPECT_EQ(Triple::Android
, T
.getEnvironment());
120 T
= Triple("aarch64-unknown-linux-android21");
121 EXPECT_EQ(Triple::aarch64
, T
.getArch());
122 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
123 EXPECT_EQ(Triple::Linux
, T
.getOS());
124 EXPECT_EQ(Triple::Android
, T
.getEnvironment());
126 // PS4 has two spellings for the vendor.
127 T
= Triple("x86_64-scei-ps4");
128 EXPECT_EQ(Triple::x86_64
, T
.getArch());
129 EXPECT_EQ(Triple::SCEI
, T
.getVendor());
130 EXPECT_EQ(Triple::PS4
, T
.getOS());
132 T
= Triple("x86_64-sie-ps4");
133 EXPECT_EQ(Triple::x86_64
, T
.getArch());
134 EXPECT_EQ(Triple::SCEI
, T
.getVendor());
135 EXPECT_EQ(Triple::PS4
, T
.getOS());
137 T
= Triple("x86_64-sie-ps5");
138 EXPECT_EQ(Triple::x86_64
, T
.getArch());
139 EXPECT_EQ(Triple::SCEI
, T
.getVendor());
140 EXPECT_EQ(Triple::PS5
, T
.getOS());
142 T
= Triple("powerpc-ibm-aix");
143 EXPECT_EQ(Triple::ppc
, T
.getArch());
144 EXPECT_EQ(Triple::IBM
, T
.getVendor());
145 EXPECT_EQ(Triple::AIX
, T
.getOS());
146 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
148 T
= Triple("powerpc64-ibm-aix");
149 EXPECT_EQ(Triple::ppc64
, T
.getArch());
150 EXPECT_EQ(Triple::IBM
, T
.getVendor());
151 EXPECT_EQ(Triple::AIX
, T
.getOS());
152 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
154 T
= Triple("powerpc-dunno-notsure");
155 EXPECT_EQ(Triple::ppc
, T
.getArch());
156 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
157 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
158 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
160 T
= Triple("powerpcspe-unknown-freebsd");
161 EXPECT_EQ(Triple::ppc
, T
.getArch());
162 EXPECT_EQ(Triple::PPCSubArch_spe
, T
.getSubArch());
163 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
164 EXPECT_EQ(Triple::FreeBSD
, T
.getOS());
165 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
167 T
= Triple("s390x-ibm-zos");
168 EXPECT_EQ(Triple::systemz
, T
.getArch());
169 EXPECT_EQ(Triple::IBM
, T
.getVendor());
170 EXPECT_EQ(Triple::ZOS
, T
.getOS());
171 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
173 T
= Triple("systemz-ibm-zos");
174 EXPECT_EQ(Triple::systemz
, T
.getArch());
175 EXPECT_EQ(Triple::IBM
, T
.getVendor());
176 EXPECT_EQ(Triple::ZOS
, T
.getOS());
177 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
179 T
= Triple("arm-none-none-eabi");
180 EXPECT_EQ(Triple::arm
, T
.getArch());
181 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
182 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
183 EXPECT_EQ(Triple::EABI
, T
.getEnvironment());
185 T
= Triple("arm-none-linux-musleabi");
186 EXPECT_EQ(Triple::arm
, T
.getArch());
187 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
188 EXPECT_EQ(Triple::Linux
, T
.getOS());
189 EXPECT_EQ(Triple::MuslEABI
, T
.getEnvironment());
191 T
= Triple("armv6hl-none-linux-gnueabi");
192 EXPECT_EQ(Triple::arm
, T
.getArch());
193 EXPECT_EQ(Triple::Linux
, T
.getOS());
194 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
195 EXPECT_EQ(Triple::GNUEABI
, T
.getEnvironment());
197 T
= Triple("armv7hl-none-linux-gnueabi");
198 EXPECT_EQ(Triple::arm
, T
.getArch());
199 EXPECT_EQ(Triple::Linux
, T
.getOS());
200 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
201 EXPECT_EQ(Triple::GNUEABI
, T
.getEnvironment());
203 T
= Triple("amdil-unknown-unknown");
204 EXPECT_EQ(Triple::amdil
, T
.getArch());
205 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
206 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
208 T
= Triple("amdil64-unknown-unknown");
209 EXPECT_EQ(Triple::amdil64
, T
.getArch());
210 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
211 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
213 T
= Triple("hsail-unknown-unknown");
214 EXPECT_EQ(Triple::hsail
, T
.getArch());
215 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
216 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
218 T
= Triple("hsail64-unknown-unknown");
219 EXPECT_EQ(Triple::hsail64
, T
.getArch());
220 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
221 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
223 T
= Triple("sparcel-unknown-unknown");
224 EXPECT_EQ(Triple::sparcel
, T
.getArch());
225 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
226 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
228 T
= Triple("spir-unknown-unknown");
229 EXPECT_EQ(Triple::spir
, T
.getArch());
230 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
231 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
233 T
= Triple("spir64-unknown-unknown");
234 EXPECT_EQ(Triple::spir64
, T
.getArch());
235 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
236 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
238 T
= Triple("spirv32-unknown-unknown");
239 EXPECT_EQ(Triple::spirv32
, T
.getArch());
240 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
241 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
242 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
244 T
= Triple("spirv32v1.0-unknown-unknown");
245 EXPECT_EQ(Triple::spirv32
, T
.getArch());
246 EXPECT_EQ(Triple::SPIRVSubArch_v10
, T
.getSubArch());
247 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
248 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
250 T
= Triple("spirv32v1.1-unknown-unknown");
251 EXPECT_EQ(Triple::spirv32
, T
.getArch());
252 EXPECT_EQ(Triple::SPIRVSubArch_v11
, T
.getSubArch());
253 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
254 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
256 T
= Triple("spirv32v1.2-unknown-unknown");
257 EXPECT_EQ(Triple::spirv32
, T
.getArch());
258 EXPECT_EQ(Triple::SPIRVSubArch_v12
, T
.getSubArch());
259 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
260 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
262 T
= Triple("spirv32v1.3-unknown-unknown");
263 EXPECT_EQ(Triple::spirv32
, T
.getArch());
264 EXPECT_EQ(Triple::SPIRVSubArch_v13
, T
.getSubArch());
265 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
266 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
268 T
= Triple("spirv32v1.4-unknown-unknown");
269 EXPECT_EQ(Triple::spirv32
, T
.getArch());
270 EXPECT_EQ(Triple::SPIRVSubArch_v14
, T
.getSubArch());
271 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
272 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
274 T
= Triple("spirv32v1.5-unknown-unknown");
275 EXPECT_EQ(Triple::spirv32
, T
.getArch());
276 EXPECT_EQ(Triple::SPIRVSubArch_v15
, T
.getSubArch());
277 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
278 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
280 T
= Triple("spirv64-unknown-unknown");
281 EXPECT_EQ(Triple::spirv64
, T
.getArch());
282 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
283 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
284 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
286 T
= Triple("spirv64v1.0-unknown-unknown");
287 EXPECT_EQ(Triple::spirv64
, T
.getArch());
288 EXPECT_EQ(Triple::SPIRVSubArch_v10
, T
.getSubArch());
289 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
290 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
292 T
= Triple("spirv64v1.1-unknown-unknown");
293 EXPECT_EQ(Triple::spirv64
, T
.getArch());
294 EXPECT_EQ(Triple::SPIRVSubArch_v11
, T
.getSubArch());
295 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
296 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
298 T
= Triple("spirv64v1.2-unknown-unknown");
299 EXPECT_EQ(Triple::spirv64
, T
.getArch());
300 EXPECT_EQ(Triple::SPIRVSubArch_v12
, T
.getSubArch());
301 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
302 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
304 T
= Triple("spirv64v1.3-unknown-unknown");
305 EXPECT_EQ(Triple::spirv64
, T
.getArch());
306 EXPECT_EQ(Triple::SPIRVSubArch_v13
, T
.getSubArch());
307 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
308 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
310 T
= Triple("spirv64v1.4-unknown-unknown");
311 EXPECT_EQ(Triple::spirv64
, T
.getArch());
312 EXPECT_EQ(Triple::SPIRVSubArch_v14
, T
.getSubArch());
313 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
314 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
316 T
= Triple("spirv64v1.5-unknown-unknown");
317 EXPECT_EQ(Triple::spirv64
, T
.getArch());
318 EXPECT_EQ(Triple::SPIRVSubArch_v15
, T
.getSubArch());
319 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
320 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
322 T
= Triple("spirv-unknown-shadermodel-pixel");
323 EXPECT_EQ(Triple::spirv
, T
.getArch());
324 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
325 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
326 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
327 EXPECT_EQ(Triple::Pixel
, T
.getEnvironment());
329 T
= Triple("spirv-unknown-shadermodel-vertex");
330 EXPECT_EQ(Triple::spirv
, T
.getArch());
331 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
332 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
333 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
334 EXPECT_EQ(Triple::Vertex
, T
.getEnvironment());
336 T
= Triple("spirv-unknown-shadermodel-geometry");
337 EXPECT_EQ(Triple::spirv
, T
.getArch());
338 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
339 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
340 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
341 EXPECT_EQ(Triple::Geometry
, T
.getEnvironment());
343 T
= Triple("spirv-unknown-shadermodel-library");
344 EXPECT_EQ(Triple::spirv
, T
.getArch());
345 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
346 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
347 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
348 EXPECT_EQ(Triple::Library
, T
.getEnvironment());
350 T
= Triple("spirv-unknown-shadermodel-raygeneration");
351 EXPECT_EQ(Triple::spirv
, T
.getArch());
352 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
353 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
354 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
355 EXPECT_EQ(Triple::RayGeneration
, T
.getEnvironment());
357 T
= Triple("spirv-unknown-shadermodel-intersection");
358 EXPECT_EQ(Triple::spirv
, T
.getArch());
359 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
360 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
361 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
362 EXPECT_EQ(Triple::Intersection
, T
.getEnvironment());
364 T
= Triple("spirv-unknown-shadermodel-anyhit");
365 EXPECT_EQ(Triple::spirv
, T
.getArch());
366 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
367 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
368 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
369 EXPECT_EQ(Triple::AnyHit
, T
.getEnvironment());
371 T
= Triple("spirv-unknown-shadermodel-closesthit");
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::ShaderModel
, T
.getOS());
376 EXPECT_EQ(Triple::ClosestHit
, T
.getEnvironment());
378 T
= Triple("spirv-unknown-shadermodel-miss");
379 EXPECT_EQ(Triple::spirv
, T
.getArch());
380 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
381 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
382 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
383 EXPECT_EQ(Triple::Miss
, T
.getEnvironment());
385 T
= Triple("spirv-unknown-shadermodel-callable");
386 EXPECT_EQ(Triple::spirv
, T
.getArch());
387 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
388 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
389 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
390 EXPECT_EQ(Triple::Callable
, T
.getEnvironment());
392 T
= Triple("spirv-unknown-shadermodel-mesh");
393 EXPECT_EQ(Triple::spirv
, T
.getArch());
394 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
395 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
396 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
397 EXPECT_EQ(Triple::Mesh
, T
.getEnvironment());
399 T
= Triple("spirv-unknown-shadermodel-amplification");
400 EXPECT_EQ(Triple::spirv
, T
.getArch());
401 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
402 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
403 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
404 EXPECT_EQ(Triple::Amplification
, T
.getEnvironment());
406 T
= Triple("spirv1.0-unknown-shadermodel-compute");
407 EXPECT_EQ(Triple::spirv
, T
.getArch());
408 EXPECT_EQ(Triple::SPIRVSubArch_v10
, T
.getSubArch());
409 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
410 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
411 EXPECT_EQ(Triple::Compute
, T
.getEnvironment());
413 T
= Triple("spirv1.1-unknown-shadermodel-compute");
414 EXPECT_EQ(Triple::spirv
, T
.getArch());
415 EXPECT_EQ(Triple::SPIRVSubArch_v11
, T
.getSubArch());
416 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
417 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
418 EXPECT_EQ(Triple::Compute
, T
.getEnvironment());
420 T
= Triple("spirv1.2-unknown-shadermodel-compute");
421 EXPECT_EQ(Triple::spirv
, T
.getArch());
422 EXPECT_EQ(Triple::SPIRVSubArch_v12
, T
.getSubArch());
423 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
424 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
425 EXPECT_EQ(Triple::Compute
, T
.getEnvironment());
427 T
= Triple("spirv1.3-unknown-shadermodel-compute");
428 EXPECT_EQ(Triple::spirv
, T
.getArch());
429 EXPECT_EQ(Triple::SPIRVSubArch_v13
, T
.getSubArch());
430 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
431 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
432 EXPECT_EQ(Triple::Compute
, T
.getEnvironment());
434 T
= Triple("spirv1.4-unknown-shadermodel-compute");
435 EXPECT_EQ(Triple::spirv
, T
.getArch());
436 EXPECT_EQ(Triple::SPIRVSubArch_v14
, T
.getSubArch());
437 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
438 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
439 EXPECT_EQ(Triple::Compute
, T
.getEnvironment());
441 T
= Triple("spirv1.5-unknown-shadermodel-compute");
442 EXPECT_EQ(Triple::spirv
, T
.getArch());
443 EXPECT_EQ(Triple::SPIRVSubArch_v15
, T
.getSubArch());
444 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
445 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
446 EXPECT_EQ(Triple::Compute
, T
.getEnvironment());
448 T
= Triple("x86_64-unknown-fuchsia");
449 EXPECT_EQ(Triple::x86_64
, T
.getArch());
450 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
451 EXPECT_EQ(Triple::Fuchsia
, T
.getOS());
452 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
454 T
= Triple("x86_64-unknown-hermit");
455 EXPECT_EQ(Triple::x86_64
, T
.getArch());
456 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
457 EXPECT_EQ(Triple::HermitCore
, T
.getOS());
458 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
460 T
= Triple("x86_64-unknown-uefi");
461 EXPECT_EQ(Triple::x86_64
, T
.getArch());
462 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
463 EXPECT_EQ(Triple::UEFI
, T
.getOS());
464 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
465 EXPECT_EQ(Triple::COFF
, T
.getObjectFormat());
467 T
= Triple("wasm32-unknown-unknown");
468 EXPECT_EQ(Triple::wasm32
, T
.getArch());
469 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
470 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
471 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
473 T
= Triple("wasm32-unknown-wasi");
474 EXPECT_EQ(Triple::wasm32
, T
.getArch());
475 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
476 EXPECT_EQ(Triple::WASI
, T
.getOS());
477 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
479 T
= Triple("wasm64-unknown-unknown");
480 EXPECT_EQ(Triple::wasm64
, T
.getArch());
481 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
482 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
483 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
485 T
= Triple("wasm64-unknown-wasi");
486 EXPECT_EQ(Triple::wasm64
, T
.getArch());
487 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
488 EXPECT_EQ(Triple::WASI
, T
.getOS());
489 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
491 T
= Triple("avr-unknown-unknown");
492 EXPECT_EQ(Triple::avr
, T
.getArch());
493 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
494 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
495 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
498 EXPECT_EQ(Triple::avr
, T
.getArch());
499 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
500 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
501 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
503 T
= Triple("lanai-unknown-unknown");
504 EXPECT_EQ(Triple::lanai
, T
.getArch());
505 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
506 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
507 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
510 EXPECT_EQ(Triple::lanai
, T
.getArch());
511 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
512 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
513 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
515 T
= Triple("amdgcn-mesa-mesa3d");
516 EXPECT_EQ(Triple::amdgcn
, T
.getArch());
517 EXPECT_EQ(Triple::Mesa
, T
.getVendor());
518 EXPECT_EQ(Triple::Mesa3D
, T
.getOS());
519 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
521 T
= Triple("amdgcn-amd-amdhsa");
522 EXPECT_EQ(Triple::amdgcn
, T
.getArch());
523 EXPECT_EQ(Triple::AMD
, T
.getVendor());
524 EXPECT_EQ(Triple::AMDHSA
, T
.getOS());
525 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
527 T
= Triple("amdgcn-amd-amdpal");
528 EXPECT_EQ(Triple::amdgcn
, T
.getArch());
529 EXPECT_EQ(Triple::AMD
, T
.getVendor());
530 EXPECT_EQ(Triple::AMDPAL
, T
.getOS());
531 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
533 T
= Triple("ve-unknown-linux");
534 EXPECT_EQ(Triple::ve
, T
.getArch());
535 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
536 EXPECT_EQ(Triple::Linux
, T
.getOS());
537 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
539 T
= Triple("csky-unknown-unknown");
540 EXPECT_EQ(Triple::csky
, T
.getArch());
541 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
542 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
543 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
545 T
= Triple("csky-unknown-linux");
546 EXPECT_EQ(Triple::csky
, T
.getArch());
547 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
548 EXPECT_EQ(Triple::Linux
, T
.getOS());
549 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
551 T
= Triple("loongarch32-unknown-unknown");
552 EXPECT_EQ(Triple::loongarch32
, T
.getArch());
553 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
554 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
555 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
557 T
= Triple("loongarch32-unknown-linux-gnu");
558 EXPECT_EQ(Triple::loongarch32
, T
.getArch());
559 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
560 EXPECT_EQ(Triple::Linux
, T
.getOS());
561 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
563 T
= Triple("loongarch32-unknown-linux-gnuf32");
564 EXPECT_EQ(Triple::loongarch32
, T
.getArch());
565 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
566 EXPECT_EQ(Triple::Linux
, T
.getOS());
567 EXPECT_EQ(Triple::GNUF32
, T
.getEnvironment());
569 T
= Triple("loongarch32-unknown-linux-gnuf64");
570 EXPECT_EQ(Triple::loongarch32
, T
.getArch());
571 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
572 EXPECT_EQ(Triple::Linux
, T
.getOS());
573 EXPECT_EQ(Triple::GNUF64
, T
.getEnvironment());
575 T
= Triple("loongarch32-unknown-linux-gnusf");
576 EXPECT_EQ(Triple::loongarch32
, T
.getArch());
577 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
578 EXPECT_EQ(Triple::Linux
, T
.getOS());
579 EXPECT_EQ(Triple::GNUSF
, T
.getEnvironment());
581 T
= Triple("loongarch32-unknown-linux-musl");
582 EXPECT_EQ(Triple::loongarch32
, T
.getArch());
583 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
584 EXPECT_EQ(Triple::Linux
, T
.getOS());
585 EXPECT_EQ(Triple::Musl
, T
.getEnvironment());
587 T
= Triple("loongarch64-unknown-linux");
588 EXPECT_EQ(Triple::loongarch64
, T
.getArch());
589 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
590 EXPECT_EQ(Triple::Linux
, T
.getOS());
591 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
593 T
= Triple("loongarch64-unknown-linux-gnu");
594 EXPECT_EQ(Triple::loongarch64
, T
.getArch());
595 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
596 EXPECT_EQ(Triple::Linux
, T
.getOS());
597 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
599 T
= Triple("loongarch64-unknown-linux-gnuf32");
600 EXPECT_EQ(Triple::loongarch64
, T
.getArch());
601 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
602 EXPECT_EQ(Triple::Linux
, T
.getOS());
603 EXPECT_EQ(Triple::GNUF32
, T
.getEnvironment());
605 T
= Triple("loongarch64-unknown-linux-gnuf64");
606 EXPECT_EQ(Triple::loongarch64
, T
.getArch());
607 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
608 EXPECT_EQ(Triple::Linux
, T
.getOS());
609 EXPECT_EQ(Triple::GNUF64
, T
.getEnvironment());
611 T
= Triple("loongarch64-unknown-linux-gnusf");
612 EXPECT_EQ(Triple::loongarch64
, T
.getArch());
613 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
614 EXPECT_EQ(Triple::Linux
, T
.getOS());
615 EXPECT_EQ(Triple::GNUSF
, T
.getEnvironment());
617 T
= Triple("loongarch64-unknown-linux-musl");
618 EXPECT_EQ(Triple::loongarch64
, T
.getArch());
619 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
620 EXPECT_EQ(Triple::Linux
, T
.getOS());
621 EXPECT_EQ(Triple::Musl
, T
.getEnvironment());
623 T
= Triple("riscv32-unknown-unknown");
624 EXPECT_EQ(Triple::riscv32
, T
.getArch());
625 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
626 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
627 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
629 T
= Triple("riscv64-unknown-linux");
630 EXPECT_EQ(Triple::riscv64
, T
.getArch());
631 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
632 EXPECT_EQ(Triple::Linux
, T
.getOS());
633 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
635 T
= Triple("riscv64-unknown-freebsd");
636 EXPECT_EQ(Triple::riscv64
, T
.getArch());
637 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
638 EXPECT_EQ(Triple::FreeBSD
, T
.getOS());
639 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
641 T
= Triple("riscv64-suse-linux");
642 EXPECT_EQ(Triple::riscv64
, T
.getArch());
643 EXPECT_EQ(Triple::SUSE
, T
.getVendor());
644 EXPECT_EQ(Triple::Linux
, T
.getOS());
645 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
647 T
= Triple("armv7hl-suse-linux-gnueabi");
648 EXPECT_EQ(Triple::arm
, T
.getArch());
649 EXPECT_EQ(Triple::SUSE
, T
.getVendor());
650 EXPECT_EQ(Triple::Linux
, T
.getOS());
651 EXPECT_EQ(Triple::GNUEABI
, T
.getEnvironment());
653 T
= Triple("i586-pc-haiku");
654 EXPECT_EQ(Triple::x86
, T
.getArch());
655 EXPECT_EQ(Triple::PC
, T
.getVendor());
656 EXPECT_EQ(Triple::Haiku
, T
.getOS());
657 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
659 T
= Triple("x86_64-unknown-haiku");
660 EXPECT_EQ(Triple::x86_64
, T
.getArch());
661 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
662 EXPECT_EQ(Triple::Haiku
, T
.getOS());
663 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
665 T
= Triple("mips-mti-linux-gnu");
666 EXPECT_EQ(Triple::mips
, T
.getArch());
667 EXPECT_EQ(Triple::MipsTechnologies
, T
.getVendor());
668 EXPECT_EQ(Triple::Linux
, T
.getOS());
669 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
671 T
= Triple("mipsel-img-linux-gnu");
672 EXPECT_EQ(Triple::mipsel
, T
.getArch());
673 EXPECT_EQ(Triple::ImaginationTechnologies
, T
.getVendor());
674 EXPECT_EQ(Triple::Linux
, T
.getOS());
675 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
677 T
= Triple("mips64-mti-linux-gnu");
678 EXPECT_EQ(Triple::mips64
, T
.getArch());
679 EXPECT_EQ(Triple::MipsTechnologies
, T
.getVendor());
680 EXPECT_EQ(Triple::Linux
, T
.getOS());
681 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
683 T
= Triple("mips64el-img-linux-gnu");
684 EXPECT_EQ(Triple::mips64el
, T
.getArch());
685 EXPECT_EQ(Triple::ImaginationTechnologies
, T
.getVendor());
686 EXPECT_EQ(Triple::Linux
, T
.getOS());
687 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
689 T
= Triple("mips64el-img-linux-gnuabin32");
690 EXPECT_EQ(Triple::mips64el
, T
.getArch());
691 EXPECT_EQ(Triple::ImaginationTechnologies
, T
.getVendor());
692 EXPECT_EQ(Triple::Linux
, T
.getOS());
693 EXPECT_EQ(Triple::GNUABIN32
, T
.getEnvironment());
695 T
= Triple("mips64el-unknown-linux-gnuabi64");
696 EXPECT_EQ(Triple::mips64el
, T
.getArch());
697 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
698 EXPECT_EQ(Triple::Linux
, T
.getOS());
699 EXPECT_EQ(Triple::GNUABI64
, T
.getEnvironment());
700 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
701 T
= Triple("mips64el");
702 EXPECT_EQ(Triple::mips64el
, T
.getArch());
703 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
704 EXPECT_EQ(Triple::GNUABI64
, T
.getEnvironment());
705 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
707 T
= Triple("mips64-unknown-linux-gnuabi64");
708 EXPECT_EQ(Triple::mips64
, T
.getArch());
709 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
710 EXPECT_EQ(Triple::Linux
, T
.getOS());
711 EXPECT_EQ(Triple::GNUABI64
, T
.getEnvironment());
712 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
713 T
= Triple("mips64");
714 EXPECT_EQ(Triple::mips64
, T
.getArch());
715 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
716 EXPECT_EQ(Triple::GNUABI64
, T
.getEnvironment());
717 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
719 T
= Triple("mipsisa64r6el-unknown-linux-gnuabi64");
720 EXPECT_EQ(Triple::mips64el
, T
.getArch());
721 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
722 EXPECT_EQ(Triple::Linux
, T
.getOS());
723 EXPECT_EQ(Triple::GNUABI64
, T
.getEnvironment());
724 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
725 T
= Triple("mips64r6el");
726 EXPECT_EQ(Triple::mips64el
, T
.getArch());
727 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
728 EXPECT_EQ(Triple::GNUABI64
, T
.getEnvironment());
729 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
730 T
= Triple("mipsisa64r6el");
731 EXPECT_EQ(Triple::mips64el
, T
.getArch());
732 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
733 EXPECT_EQ(Triple::GNUABI64
, T
.getEnvironment());
734 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
736 T
= Triple("mipsisa64r6-unknown-linux-gnuabi64");
737 EXPECT_EQ(Triple::mips64
, T
.getArch());
738 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
739 EXPECT_EQ(Triple::Linux
, T
.getOS());
740 EXPECT_EQ(Triple::GNUABI64
, T
.getEnvironment());
741 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
742 T
= Triple("mips64r6");
743 EXPECT_EQ(Triple::mips64
, T
.getArch());
744 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
745 EXPECT_EQ(Triple::GNUABI64
, T
.getEnvironment());
746 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
747 T
= Triple("mipsisa64r6");
748 EXPECT_EQ(Triple::mips64
, T
.getArch());
749 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
750 EXPECT_EQ(Triple::GNUABI64
, T
.getEnvironment());
751 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
753 T
= Triple("mips64el-unknown-linux-gnuabin32");
754 EXPECT_EQ(Triple::mips64el
, T
.getArch());
755 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
756 EXPECT_EQ(Triple::Linux
, T
.getOS());
757 EXPECT_EQ(Triple::GNUABIN32
, T
.getEnvironment());
758 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
759 T
= Triple("mipsn32el");
760 EXPECT_EQ(Triple::mips64el
, T
.getArch());
761 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
762 EXPECT_EQ(Triple::GNUABIN32
, T
.getEnvironment());
763 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
765 T
= Triple("mips64-unknown-linux-gnuabin32");
766 EXPECT_EQ(Triple::mips64
, T
.getArch());
767 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
768 EXPECT_EQ(Triple::Linux
, T
.getOS());
769 EXPECT_EQ(Triple::GNUABIN32
, T
.getEnvironment());
770 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
771 T
= Triple("mipsn32");
772 EXPECT_EQ(Triple::mips64
, T
.getArch());
773 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
774 EXPECT_EQ(Triple::GNUABIN32
, T
.getEnvironment());
775 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
777 T
= Triple("mipsisa64r6el-unknown-linux-gnuabin32");
778 EXPECT_EQ(Triple::mips64el
, T
.getArch());
779 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
780 EXPECT_EQ(Triple::Linux
, T
.getOS());
781 EXPECT_EQ(Triple::GNUABIN32
, T
.getEnvironment());
782 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
783 T
= Triple("mipsn32r6el");
784 EXPECT_EQ(Triple::mips64el
, T
.getArch());
785 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
786 EXPECT_EQ(Triple::GNUABIN32
, T
.getEnvironment());
787 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
789 T
= Triple("mipsisa64r6-unknown-linux-gnuabin32");
790 EXPECT_EQ(Triple::mips64
, T
.getArch());
791 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
792 EXPECT_EQ(Triple::Linux
, T
.getOS());
793 EXPECT_EQ(Triple::GNUABIN32
, T
.getEnvironment());
794 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
795 T
= Triple("mipsn32r6");
796 EXPECT_EQ(Triple::mips64
, T
.getArch());
797 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
798 EXPECT_EQ(Triple::GNUABIN32
, T
.getEnvironment());
799 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
801 T
= Triple("mipsel-unknown-linux-gnu");
802 EXPECT_EQ(Triple::mipsel
, T
.getArch());
803 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
804 EXPECT_EQ(Triple::Linux
, T
.getOS());
805 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
806 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
807 T
= Triple("mipsel");
808 EXPECT_EQ(Triple::mipsel
, T
.getArch());
809 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
810 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
811 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
813 T
= Triple("mips-unknown-linux-gnu");
814 EXPECT_EQ(Triple::mips
, T
.getArch());
815 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
816 EXPECT_EQ(Triple::Linux
, T
.getOS());
817 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
818 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
820 EXPECT_EQ(Triple::mips
, T
.getArch());
821 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
822 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
823 EXPECT_EQ(Triple::NoSubArch
, T
.getSubArch());
825 T
= Triple("mipsisa32r6el-unknown-linux-gnu");
826 EXPECT_EQ(Triple::mipsel
, T
.getArch());
827 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
828 EXPECT_EQ(Triple::Linux
, T
.getOS());
829 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
830 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
831 T
= Triple("mipsr6el");
832 EXPECT_EQ(Triple::mipsel
, T
.getArch());
833 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
834 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
835 T
= Triple("mipsisa32r6el");
836 EXPECT_EQ(Triple::mipsel
, T
.getArch());
837 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
838 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
839 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
841 T
= Triple("mipsisa32r6-unknown-linux-gnu");
842 EXPECT_EQ(Triple::mips
, T
.getArch());
843 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
844 EXPECT_EQ(Triple::Linux
, T
.getOS());
845 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
846 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
847 T
= Triple("mipsr6");
848 EXPECT_EQ(Triple::mips
, T
.getArch());
849 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
850 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
851 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
852 T
= Triple("mipsisa32r6");
853 EXPECT_EQ(Triple::mips
, T
.getArch());
854 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
855 EXPECT_EQ(Triple::GNU
, T
.getEnvironment());
856 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getSubArch());
858 T
= Triple("arm-oe-linux-gnueabi");
859 EXPECT_EQ(Triple::arm
, T
.getArch());
860 EXPECT_EQ(Triple::OpenEmbedded
, T
.getVendor());
861 EXPECT_EQ(Triple::Linux
, T
.getOS());
862 EXPECT_EQ(Triple::GNUEABI
, T
.getEnvironment());
864 T
= Triple("aarch64-oe-linux");
865 EXPECT_EQ(Triple::aarch64
, T
.getArch());
866 EXPECT_EQ(Triple::OpenEmbedded
, T
.getVendor());
867 EXPECT_EQ(Triple::Linux
, T
.getOS());
868 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
869 EXPECT_TRUE(T
.isArch64Bit());
871 T
= Triple("arm64_32-apple-ios");
872 EXPECT_EQ(Triple::aarch64_32
, T
.getArch());
873 EXPECT_EQ(Triple::IOS
, T
.getOS());
874 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
875 EXPECT_TRUE(T
.isArch32Bit());
877 T
= Triple("dxil-unknown-shadermodel-pixel");
878 EXPECT_EQ(Triple::dxil
, T
.getArch());
879 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
880 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
881 EXPECT_EQ(Triple::Pixel
, T
.getEnvironment());
882 EXPECT_FALSE(T
.supportsCOMDAT());
884 T
= Triple("dxil-unknown-shadermodel-vertex");
885 EXPECT_EQ(Triple::dxil
, T
.getArch());
886 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
887 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
888 EXPECT_EQ(Triple::Vertex
, T
.getEnvironment());
889 EXPECT_FALSE(T
.supportsCOMDAT());
891 T
= Triple("dxil-unknown-shadermodel-geometry");
892 EXPECT_EQ(Triple::dxil
, T
.getArch());
893 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
894 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
895 EXPECT_EQ(Triple::Geometry
, T
.getEnvironment());
896 EXPECT_FALSE(T
.supportsCOMDAT());
898 T
= Triple("dxil-unknown-shadermodel-hull");
899 EXPECT_EQ(Triple::dxil
, T
.getArch());
900 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
901 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
902 EXPECT_EQ(Triple::Hull
, T
.getEnvironment());
903 EXPECT_FALSE(T
.supportsCOMDAT());
905 T
= Triple("dxil-unknown-shadermodel-domain");
906 EXPECT_EQ(Triple::dxil
, T
.getArch());
907 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
908 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
909 EXPECT_EQ(Triple::Domain
, T
.getEnvironment());
910 EXPECT_FALSE(T
.supportsCOMDAT());
912 T
= Triple("dxil-unknown-shadermodel-compute");
913 EXPECT_EQ(Triple::dxil
, T
.getArch());
914 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
915 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
916 EXPECT_EQ(Triple::Compute
, T
.getEnvironment());
917 EXPECT_FALSE(T
.supportsCOMDAT());
919 T
= Triple("dxil-unknown-shadermodel-library");
920 EXPECT_EQ(Triple::dxil
, T
.getArch());
921 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
922 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
923 EXPECT_EQ(Triple::Library
, T
.getEnvironment());
924 EXPECT_FALSE(T
.supportsCOMDAT());
926 T
= Triple("dxil-unknown-shadermodel-raygeneration");
927 EXPECT_EQ(Triple::dxil
, T
.getArch());
928 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
929 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
930 EXPECT_EQ(Triple::RayGeneration
, T
.getEnvironment());
931 EXPECT_FALSE(T
.supportsCOMDAT());
933 T
= Triple("dxil-unknown-shadermodel-intersection");
934 EXPECT_EQ(Triple::dxil
, T
.getArch());
935 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
936 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
937 EXPECT_EQ(Triple::Intersection
, T
.getEnvironment());
938 EXPECT_FALSE(T
.supportsCOMDAT());
940 T
= Triple("dxil-unknown-shadermodel-anyhit");
941 EXPECT_EQ(Triple::dxil
, T
.getArch());
942 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
943 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
944 EXPECT_EQ(Triple::AnyHit
, T
.getEnvironment());
945 EXPECT_FALSE(T
.supportsCOMDAT());
947 T
= Triple("dxil-unknown-shadermodel-closesthit");
948 EXPECT_EQ(Triple::dxil
, T
.getArch());
949 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
950 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
951 EXPECT_EQ(Triple::ClosestHit
, T
.getEnvironment());
952 EXPECT_FALSE(T
.supportsCOMDAT());
954 T
= Triple("dxil-unknown-shadermodel-miss");
955 EXPECT_EQ(Triple::dxil
, T
.getArch());
956 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
957 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
958 EXPECT_EQ(Triple::Miss
, T
.getEnvironment());
959 EXPECT_FALSE(T
.supportsCOMDAT());
961 T
= Triple("dxil-unknown-shadermodel-callable");
962 EXPECT_EQ(Triple::dxil
, T
.getArch());
963 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
964 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
965 EXPECT_EQ(Triple::Callable
, T
.getEnvironment());
966 EXPECT_FALSE(T
.supportsCOMDAT());
968 T
= Triple("dxil-unknown-shadermodel-mesh");
969 EXPECT_EQ(Triple::dxil
, T
.getArch());
970 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
971 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
972 EXPECT_EQ(Triple::Mesh
, T
.getEnvironment());
973 EXPECT_FALSE(T
.supportsCOMDAT());
975 T
= Triple("dxil-unknown-shadermodel-amplification");
976 EXPECT_EQ(Triple::dxil
, T
.getArch());
977 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
978 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
979 EXPECT_EQ(Triple::Amplification
, T
.getEnvironment());
980 EXPECT_FALSE(T
.supportsCOMDAT());
982 T
= Triple("xtensa");
983 EXPECT_EQ(Triple::xtensa
, T
.getArch());
984 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
985 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
986 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
988 T
= Triple("xtensa-unknown-unknown");
989 EXPECT_EQ(Triple::xtensa
, T
.getArch());
990 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
991 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
992 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
994 T
= Triple("arm-unknown-linux-ohos");
995 EXPECT_EQ(Triple::arm
, T
.getArch());
996 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
997 EXPECT_EQ(Triple::Linux
, T
.getOS());
998 EXPECT_EQ(Triple::OpenHOS
, T
.getEnvironment());
1000 T
= Triple("arm-unknown-liteos");
1001 EXPECT_EQ(Triple::arm
, T
.getArch());
1002 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
1003 EXPECT_EQ(Triple::LiteOS
, T
.getOS());
1004 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
1007 EXPECT_EQ(Triple::UnknownArch
, T
.getArch());
1010 static std::string
Join(StringRef A
, StringRef B
, StringRef C
) {
1011 std::string Str
= std::string(A
);
1019 static std::string
Join(StringRef A
, StringRef B
, StringRef C
, StringRef D
) {
1020 std::string Str
= std::string(A
);
1030 TEST(TripleTest
, Normalization
) {
1032 EXPECT_EQ("unknown", Triple::normalize(""));
1033 EXPECT_EQ("unknown-unknown", Triple::normalize("-"));
1034 EXPECT_EQ("unknown-unknown-unknown", Triple::normalize("--"));
1035 EXPECT_EQ("unknown-unknown-unknown-unknown", Triple::normalize("---"));
1036 EXPECT_EQ("unknown-unknown-unknown-unknown-unknown",
1037 Triple::normalize("----"));
1039 EXPECT_EQ("a", Triple::normalize("a"));
1040 EXPECT_EQ("a-b", Triple::normalize("a-b"));
1041 EXPECT_EQ("a-b-c", Triple::normalize("a-b-c"));
1042 EXPECT_EQ("a-b-c-d", Triple::normalize("a-b-c-d"));
1044 EXPECT_EQ("i386-b-c", Triple::normalize("i386-b-c"));
1045 EXPECT_EQ("i386-a-c", Triple::normalize("a-i386-c"));
1046 EXPECT_EQ("i386-a-b", Triple::normalize("a-b-i386"));
1047 EXPECT_EQ("i386-a-b-c", Triple::normalize("a-b-c-i386"));
1049 EXPECT_EQ("a-pc-c", Triple::normalize("a-pc-c"));
1050 EXPECT_EQ("unknown-pc-b-c", Triple::normalize("pc-b-c"));
1051 EXPECT_EQ("a-pc-b", Triple::normalize("a-b-pc"));
1052 EXPECT_EQ("a-pc-b-c", Triple::normalize("a-b-c-pc"));
1054 EXPECT_EQ("a-b-linux", Triple::normalize("a-b-linux"));
1055 EXPECT_EQ("unknown-unknown-linux-b-c", Triple::normalize("linux-b-c"));
1056 EXPECT_EQ("a-unknown-linux-c", Triple::normalize("a-linux-c"));
1058 EXPECT_EQ("i386-pc-a", Triple::normalize("a-pc-i386"));
1059 EXPECT_EQ("i386-pc-unknown", Triple::normalize("-pc-i386"));
1060 EXPECT_EQ("unknown-pc-linux-c", Triple::normalize("linux-pc-c"));
1061 EXPECT_EQ("unknown-pc-linux", Triple::normalize("linux-pc-"));
1063 EXPECT_EQ("i386", Triple::normalize("i386"));
1064 EXPECT_EQ("unknown-pc", Triple::normalize("pc"));
1065 EXPECT_EQ("unknown-unknown-linux", Triple::normalize("linux"));
1067 EXPECT_EQ("x86_64-unknown-linux-gnu", Triple::normalize("x86_64-gnu-linux"));
1069 // Check that normalizing a permutated set of valid components returns a
1070 // triple with the unpermuted components.
1072 // We don't check every possible combination. For the set of architectures A,
1073 // vendors V, operating systems O, and environments E, that would require |A|
1074 // * |V| * |O| * |E| * 4! tests. Instead we check every option for any given
1075 // slot and make sure it gets normalized to the correct position from every
1076 // permutation. This should cover the core logic while being a tractable
1077 // number of tests at (|A| + |V| + |O| + |E|) * 4!.
1078 auto FirstArchType
= Triple::ArchType(Triple::UnknownArch
+ 1);
1079 auto FirstVendorType
= Triple::VendorType(Triple::UnknownVendor
+ 1);
1080 auto FirstOSType
= Triple::OSType(Triple::UnknownOS
+ 1);
1081 auto FirstEnvType
= Triple::EnvironmentType(Triple::UnknownEnvironment
+ 1);
1082 StringRef InitialC
[] = {Triple::getArchTypeName(FirstArchType
),
1083 Triple::getVendorTypeName(FirstVendorType
),
1084 Triple::getOSTypeName(FirstOSType
),
1085 Triple::getEnvironmentTypeName(FirstEnvType
)};
1086 for (int Arch
= FirstArchType
; Arch
<= Triple::LastArchType
; ++Arch
) {
1087 StringRef C
[] = {InitialC
[0], InitialC
[1], InitialC
[2], InitialC
[3]};
1088 C
[0] = Triple::getArchTypeName(Triple::ArchType(Arch
));
1089 std::string E
= Join(C
[0], C
[1], C
[2]);
1090 int I
[] = {0, 1, 2};
1092 EXPECT_EQ(E
, Triple::normalize(Join(C
[I
[0]], C
[I
[1]], C
[I
[2]])));
1093 } while (std::next_permutation(std::begin(I
), std::end(I
)));
1094 std::string F
= Join(C
[0], C
[1], C
[2], C
[3]);
1095 int J
[] = {0, 1, 2, 3};
1097 EXPECT_EQ(F
, Triple::normalize(Join(C
[J
[0]], C
[J
[1]], C
[J
[2]], C
[J
[3]])));
1098 } while (std::next_permutation(std::begin(J
), std::end(J
)));
1100 for (int Vendor
= FirstVendorType
; Vendor
<= Triple::LastVendorType
;
1102 StringRef C
[] = {InitialC
[0], InitialC
[1], InitialC
[2], InitialC
[3]};
1103 C
[1] = Triple::getVendorTypeName(Triple::VendorType(Vendor
));
1104 std::string E
= Join(C
[0], C
[1], C
[2]);
1105 int I
[] = {0, 1, 2};
1107 EXPECT_EQ(E
, Triple::normalize(Join(C
[I
[0]], C
[I
[1]], C
[I
[2]])));
1108 } while (std::next_permutation(std::begin(I
), std::end(I
)));
1109 std::string F
= Join(C
[0], C
[1], C
[2], C
[3]);
1110 int J
[] = {0, 1, 2, 3};
1112 EXPECT_EQ(F
, Triple::normalize(Join(C
[J
[0]], C
[J
[1]], C
[J
[2]], C
[J
[3]])));
1113 } while (std::next_permutation(std::begin(J
), std::end(J
)));
1115 for (int OS
= FirstOSType
; OS
<= Triple::LastOSType
; ++OS
) {
1116 if (OS
== Triple::Win32
)
1118 StringRef C
[] = {InitialC
[0], InitialC
[1], InitialC
[2], InitialC
[3]};
1119 C
[2] = Triple::getOSTypeName(Triple::OSType(OS
));
1120 std::string E
= Join(C
[0], C
[1], C
[2]);
1121 int I
[] = {0, 1, 2};
1123 EXPECT_EQ(E
, Triple::normalize(Join(C
[I
[0]], C
[I
[1]], C
[I
[2]])));
1124 } while (std::next_permutation(std::begin(I
), std::end(I
)));
1125 std::string F
= Join(C
[0], C
[1], C
[2], C
[3]);
1126 int J
[] = {0, 1, 2, 3};
1128 EXPECT_EQ(F
, Triple::normalize(Join(C
[J
[0]], C
[J
[1]], C
[J
[2]], C
[J
[3]])));
1129 } while (std::next_permutation(std::begin(J
), std::end(J
)));
1131 for (int Env
= FirstEnvType
; Env
<= Triple::LastEnvironmentType
; ++Env
) {
1132 StringRef C
[] = {InitialC
[0], InitialC
[1], InitialC
[2], InitialC
[3]};
1133 C
[3] = Triple::getEnvironmentTypeName(Triple::EnvironmentType(Env
));
1134 std::string F
= Join(C
[0], C
[1], C
[2], C
[3]);
1135 int J
[] = {0, 1, 2, 3};
1137 EXPECT_EQ(F
, Triple::normalize(Join(C
[J
[0]], C
[J
[1]], C
[J
[2]], C
[J
[3]])));
1138 } while (std::next_permutation(std::begin(J
), std::end(J
)));
1141 // Various real-world funky triples. The value returned by GCC's config.sub
1142 // is given in the comment.
1143 EXPECT_EQ("i386-unknown-windows-gnu",
1144 Triple::normalize("i386-mingw32")); // i386-pc-mingw32
1145 EXPECT_EQ("x86_64-unknown-linux-gnu",
1146 Triple::normalize("x86_64-linux-gnu")); // x86_64-pc-linux-gnu
1147 EXPECT_EQ("i486-unknown-linux-gnu",
1148 Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu
1149 EXPECT_EQ("i386-redhat-linux",
1150 Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu
1151 EXPECT_EQ("i686-unknown-linux",
1152 Triple::normalize("i686-linux")); // i686-pc-linux-gnu
1153 EXPECT_EQ("arm-none-unknown-eabi",
1154 Triple::normalize("arm-none-eabi")); // arm-none-eabi
1155 EXPECT_EQ("ve-unknown-linux",
1156 Triple::normalize("ve-linux")); // ve-linux
1157 EXPECT_EQ("wasm32-unknown-wasi",
1158 Triple::normalize("wasm32-wasi")); // wasm32-unknown-wasi
1159 EXPECT_EQ("wasm64-unknown-wasi",
1160 Triple::normalize("wasm64-wasi")); // wasm64-unknown-wasi
1163 TEST(TripleTest
, MutateName
) {
1165 EXPECT_EQ(Triple::UnknownArch
, T
.getArch());
1166 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
1167 EXPECT_EQ(Triple::UnknownOS
, T
.getOS());
1168 EXPECT_EQ(Triple::UnknownEnvironment
, T
.getEnvironment());
1170 T
.setArchName("i386");
1171 EXPECT_EQ(Triple::x86
, T
.getArch());
1172 EXPECT_EQ("i386--", T
.getTriple());
1174 T
.setVendorName("pc");
1175 EXPECT_EQ(Triple::x86
, T
.getArch());
1176 EXPECT_EQ(Triple::PC
, T
.getVendor());
1177 EXPECT_EQ("i386-pc-", T
.getTriple());
1179 T
.setOSName("linux");
1180 EXPECT_EQ(Triple::x86
, T
.getArch());
1181 EXPECT_EQ(Triple::PC
, T
.getVendor());
1182 EXPECT_EQ(Triple::Linux
, T
.getOS());
1183 EXPECT_EQ("i386-pc-linux", T
.getTriple());
1185 T
.setEnvironmentName("gnu");
1186 EXPECT_EQ(Triple::x86
, T
.getArch());
1187 EXPECT_EQ(Triple::PC
, T
.getVendor());
1188 EXPECT_EQ(Triple::Linux
, T
.getOS());
1189 EXPECT_EQ("i386-pc-linux-gnu", T
.getTriple());
1191 T
.setOSName("freebsd");
1192 EXPECT_EQ(Triple::x86
, T
.getArch());
1193 EXPECT_EQ(Triple::PC
, T
.getVendor());
1194 EXPECT_EQ(Triple::FreeBSD
, T
.getOS());
1195 EXPECT_EQ("i386-pc-freebsd-gnu", T
.getTriple());
1197 T
.setOSAndEnvironmentName("darwin");
1198 EXPECT_EQ(Triple::x86
, T
.getArch());
1199 EXPECT_EQ(Triple::PC
, T
.getVendor());
1200 EXPECT_EQ(Triple::Darwin
, T
.getOS());
1201 EXPECT_EQ("i386-pc-darwin", T
.getTriple());
1204 TEST(TripleTest
, BitWidthPredicates
) {
1206 EXPECT_FALSE(T
.isArch16Bit());
1207 EXPECT_FALSE(T
.isArch32Bit());
1208 EXPECT_FALSE(T
.isArch64Bit());
1210 T
.setArch(Triple::arm
);
1211 EXPECT_FALSE(T
.isArch16Bit());
1212 EXPECT_TRUE(T
.isArch32Bit());
1213 EXPECT_FALSE(T
.isArch64Bit());
1215 T
.setArch(Triple::hexagon
);
1216 EXPECT_FALSE(T
.isArch16Bit());
1217 EXPECT_TRUE(T
.isArch32Bit());
1218 EXPECT_FALSE(T
.isArch64Bit());
1220 T
.setArch(Triple::mips
);
1221 EXPECT_FALSE(T
.isArch16Bit());
1222 EXPECT_TRUE(T
.isArch32Bit());
1223 EXPECT_FALSE(T
.isArch64Bit());
1225 T
.setArch(Triple::mips64
);
1226 EXPECT_FALSE(T
.isArch16Bit());
1227 EXPECT_FALSE(T
.isArch32Bit());
1228 EXPECT_TRUE(T
.isArch64Bit());
1230 T
.setArch(Triple::msp430
);
1231 EXPECT_TRUE(T
.isArch16Bit());
1232 EXPECT_FALSE(T
.isArch32Bit());
1233 EXPECT_FALSE(T
.isArch64Bit());
1235 T
.setArch(Triple::ppc
);
1236 EXPECT_FALSE(T
.isArch16Bit());
1237 EXPECT_TRUE(T
.isArch32Bit());
1238 EXPECT_FALSE(T
.isArch64Bit());
1240 T
.setArch(Triple::ppc64
);
1241 EXPECT_FALSE(T
.isArch16Bit());
1242 EXPECT_FALSE(T
.isArch32Bit());
1243 EXPECT_TRUE(T
.isArch64Bit());
1245 T
.setArch(Triple::x86
);
1246 EXPECT_FALSE(T
.isArch16Bit());
1247 EXPECT_TRUE(T
.isArch32Bit());
1248 EXPECT_FALSE(T
.isArch64Bit());
1250 T
.setArch(Triple::x86_64
);
1251 EXPECT_FALSE(T
.isArch16Bit());
1252 EXPECT_FALSE(T
.isArch32Bit());
1253 EXPECT_TRUE(T
.isArch64Bit());
1255 T
.setArch(Triple::amdil
);
1256 EXPECT_FALSE(T
.isArch16Bit());
1257 EXPECT_TRUE(T
.isArch32Bit());
1258 EXPECT_FALSE(T
.isArch64Bit());
1260 T
.setArch(Triple::amdil64
);
1261 EXPECT_FALSE(T
.isArch16Bit());
1262 EXPECT_FALSE(T
.isArch32Bit());
1263 EXPECT_TRUE(T
.isArch64Bit());
1265 T
.setArch(Triple::hsail
);
1266 EXPECT_FALSE(T
.isArch16Bit());
1267 EXPECT_TRUE(T
.isArch32Bit());
1268 EXPECT_FALSE(T
.isArch64Bit());
1270 T
.setArch(Triple::hsail64
);
1271 EXPECT_FALSE(T
.isArch16Bit());
1272 EXPECT_FALSE(T
.isArch32Bit());
1273 EXPECT_TRUE(T
.isArch64Bit());
1275 T
.setArch(Triple::spir
);
1276 EXPECT_FALSE(T
.isArch16Bit());
1277 EXPECT_TRUE(T
.isArch32Bit());
1278 EXPECT_FALSE(T
.isArch64Bit());
1280 T
.setArch(Triple::spir64
);
1281 EXPECT_FALSE(T
.isArch16Bit());
1282 EXPECT_FALSE(T
.isArch32Bit());
1283 EXPECT_TRUE(T
.isArch64Bit());
1285 T
.setArch(Triple::spirv
);
1286 EXPECT_FALSE(T
.isArch16Bit());
1287 EXPECT_FALSE(T
.isArch32Bit());
1288 EXPECT_TRUE(T
.isArch64Bit());
1289 EXPECT_TRUE(T
.isSPIRV());
1291 T
.setArch(Triple::spirv32
);
1292 EXPECT_FALSE(T
.isArch16Bit());
1293 EXPECT_TRUE(T
.isArch32Bit());
1294 EXPECT_FALSE(T
.isArch64Bit());
1295 EXPECT_TRUE(T
.isSPIRV());
1297 T
.setArch(Triple::spirv64
);
1298 EXPECT_FALSE(T
.isArch16Bit());
1299 EXPECT_FALSE(T
.isArch32Bit());
1300 EXPECT_TRUE(T
.isArch64Bit());
1301 EXPECT_TRUE(T
.isSPIRV());
1303 T
.setArch(Triple::sparc
);
1304 EXPECT_FALSE(T
.isArch16Bit());
1305 EXPECT_TRUE(T
.isArch32Bit());
1306 EXPECT_FALSE(T
.isArch64Bit());
1308 T
.setArch(Triple::sparcel
);
1309 EXPECT_FALSE(T
.isArch16Bit());
1310 EXPECT_TRUE(T
.isArch32Bit());
1311 EXPECT_FALSE(T
.isArch64Bit());
1313 T
.setArch(Triple::sparcv9
);
1314 EXPECT_FALSE(T
.isArch16Bit());
1315 EXPECT_FALSE(T
.isArch32Bit());
1316 EXPECT_TRUE(T
.isArch64Bit());
1318 T
.setArch(Triple::wasm32
);
1319 EXPECT_FALSE(T
.isArch16Bit());
1320 EXPECT_TRUE(T
.isArch32Bit());
1321 EXPECT_FALSE(T
.isArch64Bit());
1323 T
.setArch(Triple::wasm64
);
1324 EXPECT_FALSE(T
.isArch16Bit());
1325 EXPECT_FALSE(T
.isArch32Bit());
1326 EXPECT_TRUE(T
.isArch64Bit());
1328 T
.setArch(Triple::avr
);
1329 EXPECT_TRUE(T
.isArch16Bit());
1330 EXPECT_FALSE(T
.isArch32Bit());
1331 EXPECT_FALSE(T
.isArch64Bit());
1333 T
.setArch(Triple::lanai
);
1334 EXPECT_FALSE(T
.isArch16Bit());
1335 EXPECT_TRUE(T
.isArch32Bit());
1336 EXPECT_FALSE(T
.isArch64Bit());
1338 T
.setArch(Triple::riscv32
);
1339 EXPECT_FALSE(T
.isArch16Bit());
1340 EXPECT_TRUE(T
.isArch32Bit());
1341 EXPECT_FALSE(T
.isArch64Bit());
1342 EXPECT_TRUE(T
.isRISCV());
1344 T
.setArch(Triple::riscv64
);
1345 EXPECT_FALSE(T
.isArch16Bit());
1346 EXPECT_FALSE(T
.isArch32Bit());
1347 EXPECT_TRUE(T
.isArch64Bit());
1348 EXPECT_TRUE(T
.isRISCV());
1350 T
.setArch(Triple::csky
);
1351 EXPECT_FALSE(T
.isArch16Bit());
1352 EXPECT_TRUE(T
.isArch32Bit());
1353 EXPECT_FALSE(T
.isArch64Bit());
1354 EXPECT_TRUE(T
.isCSKY());
1356 T
.setArch(Triple::loongarch32
);
1357 EXPECT_FALSE(T
.isArch16Bit());
1358 EXPECT_TRUE(T
.isArch32Bit());
1359 EXPECT_FALSE(T
.isArch64Bit());
1360 EXPECT_TRUE(T
.isLoongArch());
1361 EXPECT_TRUE(T
.isLoongArch32());
1363 T
.setArch(Triple::loongarch64
);
1364 EXPECT_FALSE(T
.isArch16Bit());
1365 EXPECT_FALSE(T
.isArch32Bit());
1366 EXPECT_TRUE(T
.isArch64Bit());
1367 EXPECT_TRUE(T
.isLoongArch());
1368 EXPECT_TRUE(T
.isLoongArch64());
1370 T
.setArch(Triple::dxil
);
1371 EXPECT_FALSE(T
.isArch16Bit());
1372 EXPECT_TRUE(T
.isArch32Bit());
1373 EXPECT_FALSE(T
.isArch64Bit());
1374 EXPECT_TRUE(T
.isDXIL());
1376 T
.setArch(Triple::xtensa
);
1377 EXPECT_FALSE(T
.isArch16Bit());
1378 EXPECT_TRUE(T
.isArch32Bit());
1379 EXPECT_FALSE(T
.isArch64Bit());
1382 TEST(TripleTest
, BitWidthArchVariants
) {
1384 EXPECT_EQ(Triple::UnknownArch
, T
.get32BitArchVariant().getArch());
1385 EXPECT_EQ(Triple::UnknownArch
, T
.get64BitArchVariant().getArch());
1387 T
.setArch(Triple::UnknownArch
);
1388 EXPECT_EQ(Triple::UnknownArch
, T
.get32BitArchVariant().getArch());
1389 EXPECT_EQ(Triple::UnknownArch
, T
.get64BitArchVariant().getArch());
1391 T
.setArch(Triple::mips
);
1392 EXPECT_EQ(Triple::mips
, T
.get32BitArchVariant().getArch());
1393 EXPECT_EQ(Triple::NoSubArch
, T
.get32BitArchVariant().getSubArch());
1394 EXPECT_EQ(Triple::mips64
, T
.get64BitArchVariant().getArch());
1395 EXPECT_EQ(Triple::NoSubArch
, T
.get64BitArchVariant().getSubArch());
1397 T
.setArch(Triple::mips
, Triple::MipsSubArch_r6
);
1398 EXPECT_EQ(Triple::mips
, T
.get32BitArchVariant().getArch());
1399 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.get32BitArchVariant().getSubArch());
1400 EXPECT_EQ(Triple::mips64
, T
.get64BitArchVariant().getArch());
1401 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.get64BitArchVariant().getSubArch());
1403 T
.setArch(Triple::mipsel
);
1404 EXPECT_EQ(Triple::mipsel
, T
.get32BitArchVariant().getArch());
1405 EXPECT_EQ(Triple::NoSubArch
, T
.get32BitArchVariant().getSubArch());
1406 EXPECT_EQ(Triple::mips64el
, T
.get64BitArchVariant().getArch());
1407 EXPECT_EQ(Triple::NoSubArch
, T
.get64BitArchVariant().getSubArch());
1409 T
.setArch(Triple::mipsel
, Triple::MipsSubArch_r6
);
1410 EXPECT_EQ(Triple::mipsel
, T
.get32BitArchVariant().getArch());
1411 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.get32BitArchVariant().getSubArch());
1412 EXPECT_EQ(Triple::mips64el
, T
.get64BitArchVariant().getArch());
1413 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.get64BitArchVariant().getSubArch());
1415 T
.setArch(Triple::ppc
);
1416 EXPECT_EQ(Triple::ppc
, T
.get32BitArchVariant().getArch());
1417 EXPECT_EQ(Triple::ppc64
, T
.get64BitArchVariant().getArch());
1419 T
.setArch(Triple::nvptx
);
1420 EXPECT_EQ(Triple::nvptx
, T
.get32BitArchVariant().getArch());
1421 EXPECT_EQ(Triple::nvptx64
, T
.get64BitArchVariant().getArch());
1423 T
.setArch(Triple::sparc
);
1424 EXPECT_EQ(Triple::sparc
, T
.get32BitArchVariant().getArch());
1425 EXPECT_EQ(Triple::sparcv9
, T
.get64BitArchVariant().getArch());
1427 T
.setArch(Triple::x86
);
1428 EXPECT_EQ(Triple::x86
, T
.get32BitArchVariant().getArch());
1429 EXPECT_EQ(Triple::x86_64
, T
.get64BitArchVariant().getArch());
1431 T
.setArch(Triple::mips64
);
1432 EXPECT_EQ(Triple::mips
, T
.get32BitArchVariant().getArch());
1433 EXPECT_EQ(Triple::NoSubArch
, T
.get32BitArchVariant().getSubArch());
1434 EXPECT_EQ(Triple::mips64
, T
.get64BitArchVariant().getArch());
1435 EXPECT_EQ(Triple::NoSubArch
, T
.get64BitArchVariant().getSubArch());
1437 T
.setArch(Triple::mips64
, Triple::MipsSubArch_r6
);
1438 EXPECT_EQ(Triple::mips
, T
.get32BitArchVariant().getArch());
1439 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.get32BitArchVariant().getSubArch());
1440 EXPECT_EQ(Triple::mips64
, T
.get64BitArchVariant().getArch());
1441 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.get64BitArchVariant().getSubArch());
1443 T
.setArch(Triple::mips64el
);
1444 EXPECT_EQ(Triple::mipsel
, T
.get32BitArchVariant().getArch());
1445 EXPECT_EQ(Triple::NoSubArch
, T
.get32BitArchVariant().getSubArch());
1446 EXPECT_EQ(Triple::mips64el
, T
.get64BitArchVariant().getArch());
1447 EXPECT_EQ(Triple::NoSubArch
, T
.get64BitArchVariant().getSubArch());
1449 T
.setArch(Triple::mips64el
, Triple::MipsSubArch_r6
);
1450 EXPECT_EQ(Triple::mipsel
, T
.get32BitArchVariant().getArch());
1451 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.get32BitArchVariant().getSubArch());
1452 EXPECT_EQ(Triple::mips64el
, T
.get64BitArchVariant().getArch());
1453 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.get64BitArchVariant().getSubArch());
1455 T
.setArch(Triple::ppc64
);
1456 EXPECT_EQ(Triple::ppc
, T
.get32BitArchVariant().getArch());
1457 EXPECT_EQ(Triple::ppc64
, T
.get64BitArchVariant().getArch());
1459 T
.setArch(Triple::nvptx64
);
1460 EXPECT_EQ(Triple::nvptx
, T
.get32BitArchVariant().getArch());
1461 EXPECT_EQ(Triple::nvptx64
, T
.get64BitArchVariant().getArch());
1463 T
.setArch(Triple::sparcv9
);
1464 EXPECT_EQ(Triple::sparc
, T
.get32BitArchVariant().getArch());
1465 EXPECT_EQ(Triple::sparcv9
, T
.get64BitArchVariant().getArch());
1467 T
.setArch(Triple::x86_64
);
1468 EXPECT_EQ(Triple::x86
, T
.get32BitArchVariant().getArch());
1469 EXPECT_EQ(Triple::x86_64
, T
.get64BitArchVariant().getArch());
1471 T
.setArch(Triple::amdil
);
1472 EXPECT_EQ(Triple::amdil
, T
.get32BitArchVariant().getArch());
1473 EXPECT_EQ(Triple::amdil64
, T
.get64BitArchVariant().getArch());
1475 T
.setArch(Triple::amdil64
);
1476 EXPECT_EQ(Triple::amdil
, T
.get32BitArchVariant().getArch());
1477 EXPECT_EQ(Triple::amdil64
, T
.get64BitArchVariant().getArch());
1479 T
.setArch(Triple::hsail
);
1480 EXPECT_EQ(Triple::hsail
, T
.get32BitArchVariant().getArch());
1481 EXPECT_EQ(Triple::hsail64
, T
.get64BitArchVariant().getArch());
1483 T
.setArch(Triple::hsail64
);
1484 EXPECT_EQ(Triple::hsail
, T
.get32BitArchVariant().getArch());
1485 EXPECT_EQ(Triple::hsail64
, T
.get64BitArchVariant().getArch());
1487 T
.setArch(Triple::spir
);
1488 EXPECT_EQ(Triple::spir
, T
.get32BitArchVariant().getArch());
1489 EXPECT_EQ(Triple::spir64
, T
.get64BitArchVariant().getArch());
1491 T
.setArch(Triple::spir64
);
1492 EXPECT_EQ(Triple::spir
, T
.get32BitArchVariant().getArch());
1493 EXPECT_EQ(Triple::spir64
, T
.get64BitArchVariant().getArch());
1495 T
.setArch(Triple::spirv
);
1496 EXPECT_EQ(Triple::spirv32
, T
.get32BitArchVariant().getArch());
1497 EXPECT_EQ(Triple::spirv64
, T
.get64BitArchVariant().getArch());
1499 T
.setArch(Triple::spirv32
);
1500 EXPECT_EQ(Triple::spirv32
, T
.get32BitArchVariant().getArch());
1501 EXPECT_EQ(Triple::spirv64
, T
.get64BitArchVariant().getArch());
1503 T
.setArch(Triple::spirv64
);
1504 EXPECT_EQ(Triple::spirv32
, T
.get32BitArchVariant().getArch());
1505 EXPECT_EQ(Triple::spirv64
, T
.get64BitArchVariant().getArch());
1507 T
.setArch(Triple::wasm32
);
1508 EXPECT_EQ(Triple::wasm32
, T
.get32BitArchVariant().getArch());
1509 EXPECT_EQ(Triple::wasm64
, T
.get64BitArchVariant().getArch());
1511 T
.setArch(Triple::wasm64
);
1512 EXPECT_EQ(Triple::wasm32
, T
.get32BitArchVariant().getArch());
1513 EXPECT_EQ(Triple::wasm64
, T
.get64BitArchVariant().getArch());
1515 T
.setArch(Triple::riscv32
);
1516 EXPECT_EQ(Triple::riscv32
, T
.get32BitArchVariant().getArch());
1517 EXPECT_EQ(Triple::riscv64
, T
.get64BitArchVariant().getArch());
1519 T
.setArch(Triple::riscv64
);
1520 EXPECT_EQ(Triple::riscv32
, T
.get32BitArchVariant().getArch());
1521 EXPECT_EQ(Triple::riscv64
, T
.get64BitArchVariant().getArch());
1523 T
.setArch(Triple::csky
);
1524 EXPECT_EQ(Triple::csky
, T
.get32BitArchVariant().getArch());
1525 EXPECT_EQ(Triple::UnknownArch
, T
.get64BitArchVariant().getArch());
1527 T
.setArch(Triple::loongarch32
);
1528 EXPECT_EQ(Triple::loongarch32
, T
.get32BitArchVariant().getArch());
1529 EXPECT_EQ(Triple::loongarch64
, T
.get64BitArchVariant().getArch());
1531 T
.setArch(Triple::loongarch64
);
1532 EXPECT_EQ(Triple::loongarch32
, T
.get32BitArchVariant().getArch());
1533 EXPECT_EQ(Triple::loongarch64
, T
.get64BitArchVariant().getArch());
1535 T
.setArch(Triple::thumbeb
);
1536 EXPECT_EQ(Triple::thumbeb
, T
.get32BitArchVariant().getArch());
1537 EXPECT_EQ(Triple::aarch64_be
, T
.get64BitArchVariant().getArch());
1539 T
.setArch(Triple::thumb
);
1540 EXPECT_EQ(Triple::thumb
, T
.get32BitArchVariant().getArch());
1541 EXPECT_EQ(Triple::aarch64
, T
.get64BitArchVariant().getArch());
1543 T
.setArch(Triple::aarch64
);
1544 EXPECT_EQ(Triple::arm
, T
.get32BitArchVariant().getArch());
1545 EXPECT_EQ(Triple::aarch64
, T
.get64BitArchVariant().getArch());
1547 T
.setArch(Triple::aarch64_be
);
1548 EXPECT_EQ(Triple::armeb
, T
.get32BitArchVariant().getArch());
1549 EXPECT_EQ(Triple::aarch64_be
, T
.get64BitArchVariant().getArch());
1551 T
.setArch(Triple::renderscript32
);
1552 EXPECT_EQ(Triple::renderscript32
, T
.get32BitArchVariant().getArch());
1553 EXPECT_EQ(Triple::renderscript64
, T
.get64BitArchVariant().getArch());
1555 T
.setArch(Triple::renderscript64
);
1556 EXPECT_EQ(Triple::renderscript32
, T
.get32BitArchVariant().getArch());
1557 EXPECT_EQ(Triple::renderscript64
, T
.get64BitArchVariant().getArch());
1559 T
.setArch(Triple::armeb
);
1560 EXPECT_EQ(Triple::armeb
, T
.get32BitArchVariant().getArch());
1561 EXPECT_EQ(Triple::aarch64_be
, T
.get64BitArchVariant().getArch());
1563 T
.setArch(Triple::arm
);
1564 EXPECT_EQ(Triple::arm
, T
.get32BitArchVariant().getArch());
1565 EXPECT_EQ(Triple::aarch64
, T
.get64BitArchVariant().getArch());
1567 T
.setArch(Triple::systemz
);
1568 EXPECT_EQ(Triple::UnknownArch
, T
.get32BitArchVariant().getArch());
1569 EXPECT_EQ(Triple::systemz
, T
.get64BitArchVariant().getArch());
1571 T
.setArch(Triple::xcore
);
1572 EXPECT_EQ(Triple::xcore
, T
.get32BitArchVariant().getArch());
1573 EXPECT_EQ(Triple::UnknownArch
, T
.get64BitArchVariant().getArch());
1575 T
.setArch(Triple::dxil
);
1576 EXPECT_EQ(Triple::dxil
, T
.get32BitArchVariant().getArch());
1577 EXPECT_EQ(Triple::UnknownArch
, T
.get64BitArchVariant().getArch());
1579 T
.setArch(Triple::xtensa
);
1580 EXPECT_EQ(Triple::xtensa
, T
.get32BitArchVariant().getArch());
1581 EXPECT_EQ(Triple::UnknownArch
, T
.get64BitArchVariant().getArch());
1584 TEST(TripleTest
, EndianArchVariants
) {
1586 EXPECT_EQ(Triple::UnknownArch
, T
.getBigEndianArchVariant().getArch());
1587 EXPECT_EQ(Triple::UnknownArch
, T
.getLittleEndianArchVariant().getArch());
1589 T
.setArch(Triple::UnknownArch
);
1590 EXPECT_EQ(Triple::UnknownArch
, T
.getBigEndianArchVariant().getArch());
1591 EXPECT_EQ(Triple::UnknownArch
, T
.getLittleEndianArchVariant().getArch());
1593 T
.setArch(Triple::aarch64_be
);
1594 EXPECT_EQ(Triple::aarch64_be
, T
.getBigEndianArchVariant().getArch());
1595 EXPECT_EQ(Triple::aarch64
, T
.getLittleEndianArchVariant().getArch());
1597 T
.setArch(Triple::aarch64
);
1598 EXPECT_EQ(Triple::aarch64_be
, T
.getBigEndianArchVariant().getArch());
1599 EXPECT_EQ(Triple::aarch64
, T
.getLittleEndianArchVariant().getArch());
1601 T
.setArch(Triple::armeb
);
1602 EXPECT_EQ(Triple::armeb
, T
.getBigEndianArchVariant().getArch());
1603 EXPECT_EQ(Triple::UnknownArch
, T
.getLittleEndianArchVariant().getArch());
1605 T
.setArch(Triple::arm
);
1606 EXPECT_EQ(Triple::UnknownArch
, T
.getBigEndianArchVariant().getArch());
1607 EXPECT_EQ(Triple::arm
, T
.getLittleEndianArchVariant().getArch());
1609 EXPECT_TRUE(T
.isLittleEndian());
1610 T
= Triple("thumb");
1611 EXPECT_TRUE(T
.isLittleEndian());
1612 T
= Triple("armeb");
1613 EXPECT_FALSE(T
.isLittleEndian());
1614 T
= Triple("thumbeb");
1615 EXPECT_FALSE(T
.isLittleEndian());
1617 T
.setArch(Triple::bpfeb
);
1618 EXPECT_EQ(Triple::bpfeb
, T
.getBigEndianArchVariant().getArch());
1619 EXPECT_EQ(Triple::bpfel
, T
.getLittleEndianArchVariant().getArch());
1621 T
.setArch(Triple::bpfel
);
1622 EXPECT_EQ(Triple::bpfeb
, T
.getBigEndianArchVariant().getArch());
1623 EXPECT_EQ(Triple::bpfel
, T
.getLittleEndianArchVariant().getArch());
1625 T
.setArch(Triple::mips64
);
1626 EXPECT_EQ(Triple::mips64
, T
.getBigEndianArchVariant().getArch());
1627 EXPECT_EQ(Triple::NoSubArch
, T
.getBigEndianArchVariant().getSubArch());
1628 EXPECT_EQ(Triple::mips64el
, T
.getLittleEndianArchVariant().getArch());
1629 EXPECT_EQ(Triple::NoSubArch
, T
.getLittleEndianArchVariant().getSubArch());
1631 T
.setArch(Triple::mips64
, Triple::MipsSubArch_r6
);
1632 EXPECT_EQ(Triple::mips64
, T
.getBigEndianArchVariant().getArch());
1633 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getBigEndianArchVariant().getSubArch());
1634 EXPECT_EQ(Triple::mips64el
, T
.getLittleEndianArchVariant().getArch());
1635 EXPECT_EQ(Triple::MipsSubArch_r6
,
1636 T
.getLittleEndianArchVariant().getSubArch());
1638 T
.setArch(Triple::mips64el
);
1639 EXPECT_EQ(Triple::mips64
, T
.getBigEndianArchVariant().getArch());
1640 EXPECT_EQ(Triple::NoSubArch
, T
.getBigEndianArchVariant().getSubArch());
1641 EXPECT_EQ(Triple::mips64el
, T
.getLittleEndianArchVariant().getArch());
1642 EXPECT_EQ(Triple::NoSubArch
, T
.getLittleEndianArchVariant().getSubArch());
1644 T
.setArch(Triple::mips64el
, Triple::MipsSubArch_r6
);
1645 EXPECT_EQ(Triple::mips64
, T
.getBigEndianArchVariant().getArch());
1646 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getBigEndianArchVariant().getSubArch());
1647 EXPECT_EQ(Triple::mips64el
, T
.getLittleEndianArchVariant().getArch());
1648 EXPECT_EQ(Triple::MipsSubArch_r6
,
1649 T
.getLittleEndianArchVariant().getSubArch());
1651 T
.setArch(Triple::mips
);
1652 EXPECT_EQ(Triple::mips
, T
.getBigEndianArchVariant().getArch());
1653 EXPECT_EQ(Triple::NoSubArch
, T
.getBigEndianArchVariant().getSubArch());
1654 EXPECT_EQ(Triple::mipsel
, T
.getLittleEndianArchVariant().getArch());
1655 EXPECT_EQ(Triple::NoSubArch
, T
.getLittleEndianArchVariant().getSubArch());
1657 T
.setArch(Triple::mips
, Triple::MipsSubArch_r6
);
1658 EXPECT_EQ(Triple::mips
, T
.getBigEndianArchVariant().getArch());
1659 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getBigEndianArchVariant().getSubArch());
1660 EXPECT_EQ(Triple::mipsel
, T
.getLittleEndianArchVariant().getArch());
1661 EXPECT_EQ(Triple::MipsSubArch_r6
,
1662 T
.getLittleEndianArchVariant().getSubArch());
1664 T
.setArch(Triple::mipsel
);
1665 EXPECT_EQ(Triple::mips
, T
.getBigEndianArchVariant().getArch());
1666 EXPECT_EQ(Triple::NoSubArch
, T
.getBigEndianArchVariant().getSubArch());
1667 EXPECT_EQ(Triple::mipsel
, T
.getLittleEndianArchVariant().getArch());
1668 EXPECT_EQ(Triple::NoSubArch
, T
.getLittleEndianArchVariant().getSubArch());
1670 T
.setArch(Triple::mipsel
, Triple::MipsSubArch_r6
);
1671 EXPECT_EQ(Triple::mips
, T
.getBigEndianArchVariant().getArch());
1672 EXPECT_EQ(Triple::MipsSubArch_r6
, T
.getBigEndianArchVariant().getSubArch());
1673 EXPECT_EQ(Triple::mipsel
, T
.getLittleEndianArchVariant().getArch());
1674 EXPECT_EQ(Triple::MipsSubArch_r6
,
1675 T
.getLittleEndianArchVariant().getSubArch());
1677 T
.setArch(Triple::ppc
);
1678 EXPECT_EQ(Triple::ppc
, T
.getBigEndianArchVariant().getArch());
1679 EXPECT_EQ(Triple::ppcle
, T
.getLittleEndianArchVariant().getArch());
1681 T
.setArch(Triple::ppc64
);
1682 EXPECT_EQ(Triple::ppc64
, T
.getBigEndianArchVariant().getArch());
1683 EXPECT_EQ(Triple::ppc64le
, T
.getLittleEndianArchVariant().getArch());
1685 T
.setArch(Triple::ppc64le
);
1686 EXPECT_EQ(Triple::ppc64
, T
.getBigEndianArchVariant().getArch());
1687 EXPECT_EQ(Triple::ppc64le
, T
.getLittleEndianArchVariant().getArch());
1689 T
.setArch(Triple::sparc
);
1690 EXPECT_EQ(Triple::sparc
, T
.getBigEndianArchVariant().getArch());
1691 EXPECT_EQ(Triple::sparcel
, T
.getLittleEndianArchVariant().getArch());
1693 T
.setArch(Triple::sparcel
);
1694 EXPECT_EQ(Triple::sparc
, T
.getBigEndianArchVariant().getArch());
1695 EXPECT_EQ(Triple::sparcel
, T
.getLittleEndianArchVariant().getArch());
1697 T
.setArch(Triple::thumb
);
1698 EXPECT_EQ(Triple::UnknownArch
, T
.getBigEndianArchVariant().getArch());
1699 EXPECT_EQ(Triple::thumb
, T
.getLittleEndianArchVariant().getArch());
1701 T
.setArch(Triple::thumbeb
);
1702 EXPECT_EQ(Triple::thumbeb
, T
.getBigEndianArchVariant().getArch());
1703 EXPECT_EQ(Triple::UnknownArch
, T
.getLittleEndianArchVariant().getArch());
1705 T
.setArch(Triple::lanai
);
1706 EXPECT_EQ(Triple::lanai
, T
.getBigEndianArchVariant().getArch());
1707 EXPECT_EQ(Triple::UnknownArch
, T
.getLittleEndianArchVariant().getArch());
1709 T
.setArch(Triple::tcele
);
1710 EXPECT_EQ(Triple::tce
, T
.getBigEndianArchVariant().getArch());
1711 EXPECT_EQ(Triple::tcele
, T
.getLittleEndianArchVariant().getArch());
1713 T
.setArch(Triple::tce
);
1714 EXPECT_EQ(Triple::tce
, T
.getBigEndianArchVariant().getArch());
1715 EXPECT_EQ(Triple::tcele
, T
.getLittleEndianArchVariant().getArch());
1717 T
.setArch(Triple::csky
);
1718 EXPECT_EQ(Triple::UnknownArch
, T
.getBigEndianArchVariant().getArch());
1719 EXPECT_EQ(Triple::csky
, T
.getLittleEndianArchVariant().getArch());
1721 T
.setArch(Triple::loongarch32
);
1722 EXPECT_TRUE(T
.isLittleEndian());
1723 EXPECT_EQ(Triple::UnknownArch
, T
.getBigEndianArchVariant().getArch());
1724 EXPECT_EQ(Triple::loongarch32
, T
.getLittleEndianArchVariant().getArch());
1726 T
.setArch(Triple::loongarch64
);
1727 EXPECT_TRUE(T
.isLittleEndian());
1728 EXPECT_EQ(Triple::UnknownArch
, T
.getBigEndianArchVariant().getArch());
1729 EXPECT_EQ(Triple::loongarch64
, T
.getLittleEndianArchVariant().getArch());
1731 T
.setArch(Triple::dxil
);
1732 EXPECT_TRUE(T
.isLittleEndian());
1733 EXPECT_EQ(Triple::UnknownArch
, T
.getBigEndianArchVariant().getArch());
1734 EXPECT_EQ(Triple::dxil
, T
.getLittleEndianArchVariant().getArch());
1737 TEST(TripleTest
, getOSVersion
) {
1739 VersionTuple Version
;
1741 T
= Triple("i386-apple-darwin9");
1742 EXPECT_TRUE(T
.isMacOSX());
1743 EXPECT_FALSE(T
.isiOS());
1744 EXPECT_FALSE(T
.isArch16Bit());
1745 EXPECT_TRUE(T
.isArch32Bit());
1746 EXPECT_FALSE(T
.isArch64Bit());
1747 T
.getMacOSXVersion(Version
);
1748 EXPECT_EQ(VersionTuple(10, 5), Version
);
1749 Version
= T
.getiOSVersion();
1750 EXPECT_EQ(VersionTuple(5), Version
);
1752 T
= Triple("x86_64-apple-darwin9");
1753 EXPECT_TRUE(T
.isMacOSX());
1754 EXPECT_FALSE(T
.isiOS());
1755 EXPECT_FALSE(T
.isArch16Bit());
1756 EXPECT_FALSE(T
.isArch32Bit());
1757 EXPECT_TRUE(T
.isArch64Bit());
1758 T
.getMacOSXVersion(Version
);
1759 EXPECT_EQ(VersionTuple(10, 5), Version
);
1760 Version
= T
.getiOSVersion();
1761 EXPECT_EQ(VersionTuple(5), Version
);
1763 T
= Triple("x86_64-apple-macosx");
1764 EXPECT_TRUE(T
.isMacOSX());
1765 EXPECT_FALSE(T
.isiOS());
1766 EXPECT_FALSE(T
.isArch16Bit());
1767 EXPECT_FALSE(T
.isArch32Bit());
1768 EXPECT_TRUE(T
.isArch64Bit());
1769 T
.getMacOSXVersion(Version
);
1770 EXPECT_EQ(VersionTuple(10, 4), Version
);
1771 Version
= T
.getiOSVersion();
1772 EXPECT_EQ(VersionTuple(5), Version
);
1774 T
= Triple("x86_64-apple-macosx10.7");
1775 EXPECT_TRUE(T
.isMacOSX());
1776 EXPECT_FALSE(T
.isiOS());
1777 EXPECT_FALSE(T
.isArch16Bit());
1778 EXPECT_FALSE(T
.isArch32Bit());
1779 EXPECT_TRUE(T
.isArch64Bit());
1780 T
.getMacOSXVersion(Version
);
1781 EXPECT_EQ(VersionTuple(10, 7), Version
);
1782 Version
= T
.getiOSVersion();
1783 EXPECT_EQ(VersionTuple(5), Version
);
1785 T
= Triple("x86_64-apple-macos11.0");
1786 EXPECT_TRUE(T
.isMacOSX());
1787 EXPECT_FALSE(T
.isiOS());
1788 EXPECT_FALSE(T
.isArch16Bit());
1789 EXPECT_FALSE(T
.isArch32Bit());
1790 EXPECT_TRUE(T
.isArch64Bit());
1791 T
.getMacOSXVersion(Version
);
1792 EXPECT_EQ(VersionTuple(11, 0), Version
);
1794 T
= Triple("arm64-apple-macosx11.5.8");
1795 EXPECT_TRUE(T
.isMacOSX());
1796 EXPECT_FALSE(T
.isiOS());
1797 EXPECT_FALSE(T
.isArch16Bit());
1798 EXPECT_FALSE(T
.isArch32Bit());
1799 EXPECT_TRUE(T
.isArch64Bit());
1800 T
.getMacOSXVersion(Version
);
1801 EXPECT_EQ(VersionTuple(11, 5, 8), Version
);
1803 // 10.16 forms a valid triple, even though it's not
1804 // a version of a macOS.
1805 T
= Triple("x86_64-apple-macos10.16");
1806 EXPECT_TRUE(T
.isMacOSX());
1807 T
.getMacOSXVersion(Version
);
1808 EXPECT_EQ(VersionTuple(10, 16), Version
);
1810 T
= Triple("x86_64-apple-darwin20");
1811 EXPECT_TRUE(T
.isMacOSX());
1812 T
.getMacOSXVersion(Version
);
1813 EXPECT_EQ(VersionTuple(11), Version
);
1815 // For darwin triples on macOS 11, only compare the major version.
1816 T
= Triple("x86_64-apple-darwin20.2");
1817 EXPECT_TRUE(T
.isMacOSX());
1818 T
.getMacOSXVersion(Version
);
1819 EXPECT_EQ(VersionTuple(11), Version
);
1821 T
= Triple("armv7-apple-ios");
1822 EXPECT_FALSE(T
.isMacOSX());
1823 EXPECT_TRUE(T
.isiOS());
1824 EXPECT_FALSE(T
.isArch16Bit());
1825 EXPECT_TRUE(T
.isArch32Bit());
1826 EXPECT_FALSE(T
.isArch64Bit());
1827 T
.getMacOSXVersion(Version
);
1828 EXPECT_EQ(VersionTuple(10, 4), Version
);
1829 Version
= T
.getiOSVersion();
1830 EXPECT_EQ(VersionTuple(5), Version
);
1832 T
= Triple("armv7-apple-ios7.0");
1833 EXPECT_FALSE(T
.isMacOSX());
1834 EXPECT_TRUE(T
.isiOS());
1835 EXPECT_FALSE(T
.isArch16Bit());
1836 EXPECT_TRUE(T
.isArch32Bit());
1837 EXPECT_FALSE(T
.isArch64Bit());
1838 T
.getMacOSXVersion(Version
);
1839 EXPECT_EQ(VersionTuple(10, 4), Version
);
1840 Version
= T
.getiOSVersion();
1841 EXPECT_EQ(VersionTuple(7, 0), Version
);
1842 EXPECT_FALSE(T
.isSimulatorEnvironment());
1844 T
= Triple("x86_64-apple-ios10.3-simulator");
1845 EXPECT_TRUE(T
.isiOS());
1846 Version
= T
.getiOSVersion();
1847 EXPECT_EQ(VersionTuple(10, 3), Version
);
1848 EXPECT_TRUE(T
.isSimulatorEnvironment());
1849 EXPECT_FALSE(T
.isMacCatalystEnvironment());
1851 T
= Triple("x86_64-apple-ios13.0-macabi");
1852 EXPECT_TRUE(T
.isiOS());
1853 Version
= T
.getiOSVersion();
1854 EXPECT_EQ(VersionTuple(13, 0), Version
);
1855 EXPECT_TRUE(T
.getEnvironment() == Triple::MacABI
);
1856 EXPECT_TRUE(T
.isMacCatalystEnvironment());
1857 EXPECT_FALSE(T
.isSimulatorEnvironment());
1859 T
= Triple("x86_64-apple-driverkit20.1.0");
1860 EXPECT_TRUE(T
.isDriverKit());
1861 EXPECT_TRUE(T
.isOSDarwin());
1862 EXPECT_FALSE(T
.isMacOSX());
1863 EXPECT_FALSE(T
.isiOS());
1864 Version
= T
.getDriverKitVersion();
1865 EXPECT_EQ(VersionTuple(20, 1), Version
);
1867 T
= Triple("x86_64-apple-driverkit20");
1868 Version
= T
.getDriverKitVersion();
1869 EXPECT_EQ(VersionTuple(20, 0), Version
);
1871 // DriverKit version should default to 19.0.
1872 T
= Triple("x86_64-apple-driverkit");
1873 Version
= T
.getDriverKitVersion();
1874 EXPECT_EQ(VersionTuple(19, 0), Version
);
1876 T
= Triple("dxil-unknown-shadermodel6.6-pixel");
1877 EXPECT_EQ(Triple::dxil
, T
.getArch());
1878 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
1879 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
1880 Version
= T
.getOSVersion();
1881 EXPECT_EQ(VersionTuple(6, 6), Version
);
1882 EXPECT_EQ(Triple::Pixel
, T
.getEnvironment());
1884 T
= Triple("dxil-unknown-shadermodel6.0-pixel");
1885 EXPECT_EQ(Triple::dxil
, T
.getArch());
1886 EXPECT_EQ(Triple::UnknownVendor
, T
.getVendor());
1887 EXPECT_EQ(Triple::ShaderModel
, T
.getOS());
1888 Version
= T
.getOSVersion();
1889 EXPECT_EQ(VersionTuple(6, 0), Version
);
1890 EXPECT_EQ(Triple::Pixel
, T
.getEnvironment());
1893 TEST(TripleTest
, getEnvironmentVersion
) {
1895 VersionTuple Version
;
1897 T
= Triple("arm-unknown-linux-android16");
1898 EXPECT_TRUE(T
.isAndroid());
1899 Version
= T
.getEnvironmentVersion();
1900 EXPECT_EQ(VersionTuple(16), Version
);
1901 EXPECT_EQ(Triple::Android
, T
.getEnvironment());
1903 T
= Triple("aarch64-unknown-linux-android21");
1904 EXPECT_TRUE(T
.isAndroid());
1905 Version
= T
.getEnvironmentVersion();
1906 EXPECT_EQ(VersionTuple(21), Version
);
1907 EXPECT_EQ(Triple::Android
, T
.getEnvironment());
1910 TEST(TripleTest
, isMacOSVersionLT
) {
1911 Triple T
= Triple("x86_64-apple-macos11");
1912 EXPECT_TRUE(T
.isMacOSXVersionLT(11, 1, 0));
1913 EXPECT_FALSE(T
.isMacOSXVersionLT(10, 15, 0));
1915 T
= Triple("x86_64-apple-darwin20");
1916 EXPECT_TRUE(T
.isMacOSXVersionLT(11, 1, 0));
1917 EXPECT_FALSE(T
.isMacOSXVersionLT(11, 0, 0));
1918 EXPECT_FALSE(T
.isMacOSXVersionLT(10, 15, 0));
1921 TEST(TripleTest
, CanonicalizeOSVersion
) {
1922 EXPECT_EQ(VersionTuple(10, 15, 4),
1923 Triple::getCanonicalVersionForOS(Triple::MacOSX
,
1924 VersionTuple(10, 15, 4)));
1925 EXPECT_EQ(VersionTuple(11, 0), Triple::getCanonicalVersionForOS(
1926 Triple::MacOSX
, VersionTuple(10, 16)));
1927 EXPECT_EQ(VersionTuple(20),
1928 Triple::getCanonicalVersionForOS(Triple::Darwin
, VersionTuple(20)));
1931 TEST(TripleTest
, FileFormat
) {
1932 EXPECT_EQ(Triple::ELF
, Triple("i686-unknown-linux-gnu").getObjectFormat());
1933 EXPECT_EQ(Triple::ELF
, Triple("i686-unknown-freebsd").getObjectFormat());
1934 EXPECT_EQ(Triple::ELF
, Triple("i686-unknown-netbsd").getObjectFormat());
1935 EXPECT_EQ(Triple::ELF
, Triple("i686--win32-elf").getObjectFormat());
1936 EXPECT_EQ(Triple::ELF
, Triple("i686---elf").getObjectFormat());
1938 EXPECT_EQ(Triple::MachO
, Triple("i686-apple-macosx").getObjectFormat());
1939 EXPECT_EQ(Triple::MachO
, Triple("i686-apple-ios").getObjectFormat());
1940 EXPECT_EQ(Triple::MachO
, Triple("i686---macho").getObjectFormat());
1941 EXPECT_EQ(Triple::MachO
, Triple("powerpc-apple-macosx").getObjectFormat());
1943 EXPECT_EQ(Triple::COFF
, Triple("i686--win32").getObjectFormat());
1945 EXPECT_EQ(Triple::ELF
, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
1946 EXPECT_EQ(Triple::ELF
, Triple("i686-pc-cygwin-elf").getObjectFormat());
1948 EXPECT_EQ(Triple::ELF
, Triple("systemz-ibm-linux").getObjectFormat());
1949 EXPECT_EQ(Triple::ELF
, Triple("systemz-ibm-unknown").getObjectFormat());
1951 EXPECT_EQ(Triple::GOFF
, Triple("s390x-ibm-zos").getObjectFormat());
1952 EXPECT_EQ(Triple::GOFF
, Triple("systemz-ibm-zos").getObjectFormat());
1953 EXPECT_EQ(Triple::GOFF
, Triple("s390x-ibm-zos-goff").getObjectFormat());
1954 EXPECT_EQ(Triple::GOFF
, Triple("s390x-unknown-zos-goff").getObjectFormat());
1955 EXPECT_EQ(Triple::GOFF
, Triple("s390x---goff").getObjectFormat());
1957 EXPECT_EQ(Triple::Wasm
, Triple("wasm32-unknown-unknown").getObjectFormat());
1958 EXPECT_EQ(Triple::Wasm
, Triple("wasm64-unknown-unknown").getObjectFormat());
1959 EXPECT_EQ(Triple::Wasm
, Triple("wasm32-wasi").getObjectFormat());
1960 EXPECT_EQ(Triple::Wasm
, Triple("wasm64-wasi").getObjectFormat());
1961 EXPECT_EQ(Triple::Wasm
, Triple("wasm32-unknown-wasi").getObjectFormat());
1962 EXPECT_EQ(Triple::Wasm
, Triple("wasm64-unknown-wasi").getObjectFormat());
1964 EXPECT_EQ(Triple::Wasm
,
1965 Triple("wasm32-unknown-unknown-wasm").getObjectFormat());
1966 EXPECT_EQ(Triple::Wasm
,
1967 Triple("wasm64-unknown-unknown-wasm").getObjectFormat());
1968 EXPECT_EQ(Triple::Wasm
,
1969 Triple("wasm32-wasi-wasm").getObjectFormat());
1970 EXPECT_EQ(Triple::Wasm
,
1971 Triple("wasm64-wasi-wasm").getObjectFormat());
1972 EXPECT_EQ(Triple::Wasm
,
1973 Triple("wasm32-unknown-wasi-wasm").getObjectFormat());
1974 EXPECT_EQ(Triple::Wasm
,
1975 Triple("wasm64-unknown-wasi-wasm").getObjectFormat());
1977 EXPECT_EQ(Triple::XCOFF
, Triple("powerpc-ibm-aix").getObjectFormat());
1978 EXPECT_EQ(Triple::XCOFF
, Triple("powerpc64-ibm-aix").getObjectFormat());
1979 EXPECT_EQ(Triple::XCOFF
, Triple("powerpc---xcoff").getObjectFormat());
1980 EXPECT_EQ(Triple::XCOFF
, Triple("powerpc64---xcoff").getObjectFormat());
1982 EXPECT_EQ(Triple::ELF
, Triple("csky-unknown-unknown").getObjectFormat());
1983 EXPECT_EQ(Triple::ELF
, Triple("csky-unknown-linux").getObjectFormat());
1985 EXPECT_EQ(Triple::SPIRV
, Triple("spirv-unknown-unknown").getObjectFormat());
1986 EXPECT_EQ(Triple::SPIRV
, Triple("spirv32-unknown-unknown").getObjectFormat());
1987 EXPECT_EQ(Triple::SPIRV
, Triple("spirv64-unknown-unknown").getObjectFormat());
1989 EXPECT_EQ(Triple::ELF
,
1990 Triple("loongarch32-unknown-unknown").getObjectFormat());
1991 EXPECT_EQ(Triple::ELF
, Triple("loongarch64-unknown-linux").getObjectFormat());
1993 Triple
MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
1994 EXPECT_EQ(Triple::ELF
, MSVCNormalized
.getObjectFormat());
1996 Triple
GNUWindowsNormalized(Triple::normalize("i686-pc-windows-gnu-elf"));
1997 EXPECT_EQ(Triple::ELF
, GNUWindowsNormalized
.getObjectFormat());
1999 Triple
CygnusNormalised(Triple::normalize("i686-pc-windows-cygnus-elf"));
2000 EXPECT_EQ(Triple::ELF
, CygnusNormalised
.getObjectFormat());
2002 Triple
CygwinNormalized(Triple::normalize("i686-pc-cygwin-elf"));
2003 EXPECT_EQ(Triple::ELF
, CygwinNormalized
.getObjectFormat());
2005 EXPECT_EQ(Triple::DXContainer
,
2006 Triple("dxil-unknown-shadermodel").getObjectFormat());
2008 Triple T
= Triple("");
2009 T
.setObjectFormat(Triple::ELF
);
2010 EXPECT_EQ(Triple::ELF
, T
.getObjectFormat());
2011 EXPECT_EQ("elf", Triple::getObjectFormatTypeName(T
.getObjectFormat()));
2013 T
.setObjectFormat(Triple::MachO
);
2014 EXPECT_EQ(Triple::MachO
, T
.getObjectFormat());
2015 EXPECT_EQ("macho", Triple::getObjectFormatTypeName(T
.getObjectFormat()));
2017 T
.setObjectFormat(Triple::XCOFF
);
2018 EXPECT_EQ(Triple::XCOFF
, T
.getObjectFormat());
2019 EXPECT_EQ("xcoff", Triple::getObjectFormatTypeName(T
.getObjectFormat()));
2021 T
.setObjectFormat(Triple::GOFF
);
2022 EXPECT_EQ(Triple::GOFF
, T
.getObjectFormat());
2023 EXPECT_EQ("goff", Triple::getObjectFormatTypeName(T
.getObjectFormat()));
2025 T
.setObjectFormat(Triple::SPIRV
);
2026 EXPECT_EQ(Triple::SPIRV
, T
.getObjectFormat());
2027 EXPECT_EQ("spirv", Triple::getObjectFormatTypeName(T
.getObjectFormat()));
2030 TEST(TripleTest
, NormalizeWindows
) {
2031 EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-win32"));
2032 EXPECT_EQ("i686-unknown-windows-msvc", Triple::normalize("i686-win32"));
2033 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32"));
2034 EXPECT_EQ("i686-unknown-windows-gnu", Triple::normalize("i686-mingw32"));
2035 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32-w64"));
2036 EXPECT_EQ("i686-unknown-windows-gnu", Triple::normalize("i686-mingw32-w64"));
2037 EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-cygwin"));
2038 EXPECT_EQ("i686-unknown-windows-cygnus", Triple::normalize("i686-cygwin"));
2040 EXPECT_EQ("x86_64-pc-windows-msvc", Triple::normalize("x86_64-pc-win32"));
2041 EXPECT_EQ("x86_64-unknown-windows-msvc", Triple::normalize("x86_64-win32"));
2042 EXPECT_EQ("x86_64-pc-windows-gnu", Triple::normalize("x86_64-pc-mingw32"));
2043 EXPECT_EQ("x86_64-unknown-windows-gnu", Triple::normalize("x86_64-mingw32"));
2044 EXPECT_EQ("x86_64-pc-windows-gnu",
2045 Triple::normalize("x86_64-pc-mingw32-w64"));
2046 EXPECT_EQ("x86_64-unknown-windows-gnu",
2047 Triple::normalize("x86_64-mingw32-w64"));
2049 EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-win32-elf"));
2050 EXPECT_EQ("i686-unknown-windows-elf", Triple::normalize("i686-win32-elf"));
2051 EXPECT_EQ("i686-pc-windows-macho", Triple::normalize("i686-pc-win32-macho"));
2052 EXPECT_EQ("i686-unknown-windows-macho",
2053 Triple::normalize("i686-win32-macho"));
2055 EXPECT_EQ("x86_64-pc-windows-elf", Triple::normalize("x86_64-pc-win32-elf"));
2056 EXPECT_EQ("x86_64-unknown-windows-elf",
2057 Triple::normalize("x86_64-win32-elf"));
2058 EXPECT_EQ("x86_64-pc-windows-macho",
2059 Triple::normalize("x86_64-pc-win32-macho"));
2060 EXPECT_EQ("x86_64-unknown-windows-macho",
2061 Triple::normalize("x86_64-win32-macho"));
2063 EXPECT_EQ("i686-pc-windows-cygnus",
2064 Triple::normalize("i686-pc-windows-cygnus"));
2065 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-windows-gnu"));
2066 EXPECT_EQ("i686-pc-windows-itanium",
2067 Triple::normalize("i686-pc-windows-itanium"));
2068 EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-windows-msvc"));
2070 EXPECT_EQ("i686-pc-windows-elf",
2071 Triple::normalize("i686-pc-windows-elf-elf"));
2073 EXPECT_TRUE(Triple("x86_64-pc-win32").isWindowsMSVCEnvironment());
2076 TEST(TripleTest
, NormalizeAndroid
) {
2077 EXPECT_EQ("arm-unknown-linux-android16",
2078 Triple::normalize("arm-linux-androideabi16"));
2079 EXPECT_EQ("armv7a-unknown-linux-android",
2080 Triple::normalize("armv7a-linux-androideabi"));
2081 EXPECT_EQ("aarch64-unknown-linux-android21",
2082 Triple::normalize("aarch64-linux-android21"));
2085 TEST(TripleTest
, NormalizeARM
) {
2086 EXPECT_EQ("armv6-unknown-netbsd-eabi",
2087 Triple::normalize("armv6-netbsd-eabi"));
2088 EXPECT_EQ("armv7-unknown-netbsd-eabi",
2089 Triple::normalize("armv7-netbsd-eabi"));
2090 EXPECT_EQ("armv6eb-unknown-netbsd-eabi",
2091 Triple::normalize("armv6eb-netbsd-eabi"));
2092 EXPECT_EQ("armv7eb-unknown-netbsd-eabi",
2093 Triple::normalize("armv7eb-netbsd-eabi"));
2094 EXPECT_EQ("armv6-unknown-netbsd-eabihf",
2095 Triple::normalize("armv6-netbsd-eabihf"));
2096 EXPECT_EQ("armv7-unknown-netbsd-eabihf",
2097 Triple::normalize("armv7-netbsd-eabihf"));
2098 EXPECT_EQ("armv6eb-unknown-netbsd-eabihf",
2099 Triple::normalize("armv6eb-netbsd-eabihf"));
2100 EXPECT_EQ("armv7eb-unknown-netbsd-eabihf",
2101 Triple::normalize("armv7eb-netbsd-eabihf"));
2103 EXPECT_EQ("armv7-suse-linux-gnueabihf",
2104 Triple::normalize("armv7-suse-linux-gnueabi"));
2107 T
= Triple("armv6--netbsd-eabi");
2108 EXPECT_EQ(Triple::arm
, T
.getArch());
2109 T
= Triple("armv6eb--netbsd-eabi");
2110 EXPECT_EQ(Triple::armeb
, T
.getArch());
2111 T
= Triple("armv7-suse-linux-gnueabihf");
2112 EXPECT_EQ(Triple::GNUEABIHF
, T
.getEnvironment());
2115 TEST(TripleTest
, ParseARMArch
) {
2118 Triple T
= Triple("arm");
2119 EXPECT_EQ(Triple::arm
, T
.getArch());
2122 Triple T
= Triple("armeb");
2123 EXPECT_EQ(Triple::armeb
, T
.getArch());
2127 Triple T
= Triple("thumb");
2128 EXPECT_EQ(Triple::thumb
, T
.getArch());
2131 Triple T
= Triple("thumbeb");
2132 EXPECT_EQ(Triple::thumbeb
, T
.getArch());
2136 Triple T
= Triple("arm64");
2137 EXPECT_EQ(Triple::aarch64
, T
.getArch());
2140 Triple T
= Triple("arm64_32");
2141 EXPECT_EQ(Triple::aarch64_32
, T
.getArch());
2144 Triple T
= Triple("aarch64");
2145 EXPECT_EQ(Triple::aarch64
, T
.getArch());
2148 Triple T
= Triple("aarch64_be");
2149 EXPECT_EQ(Triple::aarch64_be
, T
.getArch());
2152 Triple T
= Triple("arm64e");
2153 EXPECT_EQ(Triple::aarch64
, T
.getArch());
2154 EXPECT_EQ(Triple::AArch64SubArch_arm64e
, T
.getSubArch());
2157 Triple T
= Triple("arm64ec");
2158 EXPECT_EQ(Triple::aarch64
, T
.getArch());
2159 EXPECT_EQ(Triple::AArch64SubArch_arm64ec
, T
.getSubArch());
2163 T
.setArch(Triple::aarch64
, Triple::AArch64SubArch_arm64ec
);
2164 EXPECT_EQ("arm64ec", T
.getArchName());
2168 TEST(TripleTest
, isArmT32
) {
2171 Triple T
= Triple("thumbv6m");
2172 EXPECT_FALSE(T
.isArmT32());
2175 Triple T
= Triple("armv8m.base");
2176 EXPECT_FALSE(T
.isArmT32());
2179 Triple T
= Triple("armv7s");
2180 EXPECT_FALSE(T
.isArmT32());
2183 Triple T
= Triple("armv7k");
2184 EXPECT_FALSE(T
.isArmT32());
2187 Triple T
= Triple("armv7ve");
2188 EXPECT_FALSE(T
.isArmT32());
2191 Triple T
= Triple("armv6");
2192 EXPECT_FALSE(T
.isArmT32());
2195 Triple T
= Triple("armv6m");
2196 EXPECT_FALSE(T
.isArmT32());
2199 Triple T
= Triple("armv6k");
2200 EXPECT_FALSE(T
.isArmT32());
2203 Triple T
= Triple("armv6t2");
2204 EXPECT_FALSE(T
.isArmT32());
2207 Triple T
= Triple("armv5");
2208 EXPECT_FALSE(T
.isArmT32());
2211 Triple T
= Triple("armv5te");
2212 EXPECT_FALSE(T
.isArmT32());
2215 Triple T
= Triple("armv4t");
2216 EXPECT_FALSE(T
.isArmT32());
2221 Triple T
= Triple("arm");
2222 EXPECT_TRUE(T
.isArmT32());
2225 Triple T
= Triple("armv7m");
2226 EXPECT_TRUE(T
.isArmT32());
2229 Triple T
= Triple("armv7em");
2230 EXPECT_TRUE(T
.isArmT32());
2233 Triple T
= Triple("armv8m.main");
2234 EXPECT_TRUE(T
.isArmT32());
2237 Triple T
= Triple("armv8.1m.main");
2238 EXPECT_TRUE(T
.isArmT32());
2242 TEST(TripleTest
, isArmMClass
) {
2245 Triple T
= Triple("armv7s");
2246 EXPECT_FALSE(T
.isArmMClass());
2249 Triple T
= Triple("armv7k");
2250 EXPECT_FALSE(T
.isArmMClass());
2253 Triple T
= Triple("armv7ve");
2254 EXPECT_FALSE(T
.isArmMClass());
2257 Triple T
= Triple("armv6");
2258 EXPECT_FALSE(T
.isArmMClass());
2261 Triple T
= Triple("armv6k");
2262 EXPECT_FALSE(T
.isArmMClass());
2265 Triple T
= Triple("armv6t2");
2266 EXPECT_FALSE(T
.isArmMClass());
2269 Triple T
= Triple("armv5");
2270 EXPECT_FALSE(T
.isArmMClass());
2273 Triple T
= Triple("armv5te");
2274 EXPECT_FALSE(T
.isArmMClass());
2277 Triple T
= Triple("armv4t");
2278 EXPECT_FALSE(T
.isArmMClass());
2281 Triple T
= Triple("arm");
2282 EXPECT_FALSE(T
.isArmMClass());
2287 Triple T
= Triple("armv6m");
2288 EXPECT_TRUE(T
.isArmMClass());
2291 Triple T
= Triple("armv7m");
2292 EXPECT_TRUE(T
.isArmMClass());
2295 Triple T
= Triple("armv7em");
2296 EXPECT_TRUE(T
.isArmMClass());
2299 Triple T
= Triple("armv8m.base");
2300 EXPECT_TRUE(T
.isArmMClass());
2303 Triple T
= Triple("armv8m.main");
2304 EXPECT_TRUE(T
.isArmMClass());
2307 Triple T
= Triple("armv8.1m.main");
2308 EXPECT_TRUE(T
.isArmMClass());
2311 } // end anonymous namespace