[ARM] Masked load and store and predicate tests. NFC
[llvm-complete.git] / unittests / Support / TargetParserTest.cpp
blob64052519226b322a29b82b8497e0730caefa26ce
1 //===----------- TargetParser.cpp - Target Parser -------------------------===//
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/Support/TargetParser.h"
10 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/Support/ARMBuildAttributes.h"
12 #include "gtest/gtest.h"
13 #include <string>
15 using namespace llvm;
17 namespace {
18 const char *ARMArch[] = {
19 "armv2", "armv2a", "armv3", "armv3m", "armv4",
20 "armv4t", "armv5", "armv5t", "armv5e", "armv5te",
21 "armv5tej", "armv6", "armv6j", "armv6k", "armv6hl",
22 "armv6t2", "armv6kz", "armv6z", "armv6zk", "armv6-m",
23 "armv6m", "armv6sm", "armv6s-m", "armv7-a", "armv7",
24 "armv7a", "armv7ve", "armv7hl", "armv7l", "armv7-r",
25 "armv7r", "armv7-m", "armv7m", "armv7k", "armv7s",
26 "armv7e-m", "armv7em", "armv8-a", "armv8", "armv8a",
27 "armv8l", "armv8.1-a", "armv8.1a", "armv8.2-a", "armv8.2a",
28 "armv8.3-a", "armv8.3a", "armv8.4-a", "armv8.4a", "armv8.5-a",
29 "armv8.5a", "armv8-r", "armv8r", "armv8-m.base", "armv8m.base",
30 "armv8-m.main", "armv8m.main", "iwmmxt", "iwmmxt2", "xscale",
31 "armv8.1-m.main",
34 bool testARMCPU(StringRef CPUName, StringRef ExpectedArch,
35 StringRef ExpectedFPU, unsigned ExpectedFlags,
36 StringRef CPUAttr) {
37 ARM::ArchKind AK = ARM::parseCPUArch(CPUName);
38 bool pass = ARM::getArchName(AK).equals(ExpectedArch);
39 unsigned FPUKind = ARM::getDefaultFPU(CPUName, AK);
40 pass &= ARM::getFPUName(FPUKind).equals(ExpectedFPU);
42 unsigned ExtKind = ARM::getDefaultExtensions(CPUName, AK);
43 if (ExtKind > 1 && (ExtKind & ARM::AEK_NONE))
44 pass &= ((ExtKind ^ ARM::AEK_NONE) == ExpectedFlags);
45 else
46 pass &= (ExtKind == ExpectedFlags);
47 pass &= ARM::getCPUAttr(AK).equals(CPUAttr);
49 return pass;
52 TEST(TargetParserTest, testARMCPU) {
53 EXPECT_TRUE(testARMCPU("invalid", "invalid", "invalid",
54 ARM::AEK_NONE, ""));
55 EXPECT_TRUE(testARMCPU("generic", "invalid", "none",
56 ARM::AEK_NONE, ""));
58 EXPECT_TRUE(testARMCPU("arm2", "armv2", "none",
59 ARM::AEK_NONE, "2"));
60 EXPECT_TRUE(testARMCPU("arm3", "armv2a", "none",
61 ARM::AEK_NONE, "2A"));
62 EXPECT_TRUE(testARMCPU("arm6", "armv3", "none",
63 ARM::AEK_NONE, "3"));
64 EXPECT_TRUE(testARMCPU("arm7m", "armv3m", "none",
65 ARM::AEK_NONE, "3M"));
66 EXPECT_TRUE(testARMCPU("arm8", "armv4", "none",
67 ARM::AEK_NONE, "4"));
68 EXPECT_TRUE(testARMCPU("arm810", "armv4", "none",
69 ARM::AEK_NONE, "4"));
70 EXPECT_TRUE(testARMCPU("strongarm", "armv4", "none",
71 ARM::AEK_NONE, "4"));
72 EXPECT_TRUE(testARMCPU("strongarm110", "armv4", "none",
73 ARM::AEK_NONE, "4"));
74 EXPECT_TRUE(testARMCPU("strongarm1100", "armv4", "none",
75 ARM::AEK_NONE, "4"));
76 EXPECT_TRUE(testARMCPU("strongarm1110", "armv4", "none",
77 ARM::AEK_NONE, "4"));
78 EXPECT_TRUE(testARMCPU("arm7tdmi", "armv4t", "none",
79 ARM::AEK_NONE, "4T"));
80 EXPECT_TRUE(testARMCPU("arm7tdmi-s", "armv4t", "none",
81 ARM::AEK_NONE, "4T"));
82 EXPECT_TRUE(testARMCPU("arm710t", "armv4t", "none",
83 ARM::AEK_NONE, "4T"));
84 EXPECT_TRUE(testARMCPU("arm720t", "armv4t", "none",
85 ARM::AEK_NONE, "4T"));
86 EXPECT_TRUE(testARMCPU("arm9", "armv4t", "none",
87 ARM::AEK_NONE, "4T"));
88 EXPECT_TRUE(testARMCPU("arm9tdmi", "armv4t", "none",
89 ARM::AEK_NONE, "4T"));
90 EXPECT_TRUE(testARMCPU("arm920", "armv4t", "none",
91 ARM::AEK_NONE, "4T"));
92 EXPECT_TRUE(testARMCPU("arm920t", "armv4t", "none",
93 ARM::AEK_NONE, "4T"));
94 EXPECT_TRUE(testARMCPU("arm922t", "armv4t", "none",
95 ARM::AEK_NONE, "4T"));
96 EXPECT_TRUE(testARMCPU("arm9312", "armv4t", "none",
97 ARM::AEK_NONE, "4T"));
98 EXPECT_TRUE(testARMCPU("arm940t", "armv4t", "none",
99 ARM::AEK_NONE, "4T"));
100 EXPECT_TRUE(testARMCPU("ep9312", "armv4t", "none",
101 ARM::AEK_NONE, "4T"));
102 EXPECT_TRUE(testARMCPU("arm10tdmi", "armv5t", "none",
103 ARM::AEK_NONE, "5T"));
104 EXPECT_TRUE(testARMCPU("arm1020t", "armv5t", "none",
105 ARM::AEK_NONE, "5T"));
106 EXPECT_TRUE(testARMCPU("arm9e", "armv5te", "none",
107 ARM::AEK_DSP, "5TE"));
108 EXPECT_TRUE(testARMCPU("arm946e-s", "armv5te", "none",
109 ARM::AEK_DSP, "5TE"));
110 EXPECT_TRUE(testARMCPU("arm966e-s", "armv5te", "none",
111 ARM::AEK_DSP, "5TE"));
112 EXPECT_TRUE(testARMCPU("arm968e-s", "armv5te", "none",
113 ARM::AEK_DSP, "5TE"));
114 EXPECT_TRUE(testARMCPU("arm10e", "armv5te", "none",
115 ARM::AEK_DSP, "5TE"));
116 EXPECT_TRUE(testARMCPU("arm1020e", "armv5te", "none",
117 ARM::AEK_DSP, "5TE"));
118 EXPECT_TRUE(testARMCPU("arm1022e", "armv5te", "none",
119 ARM::AEK_DSP, "5TE"));
120 EXPECT_TRUE(testARMCPU("arm926ej-s", "armv5tej", "none",
121 ARM::AEK_DSP, "5TEJ"));
122 EXPECT_TRUE(testARMCPU("arm1136j-s", "armv6", "none",
123 ARM::AEK_DSP, "6"));
124 EXPECT_TRUE(testARMCPU("arm1136jf-s", "armv6", "vfpv2",
125 ARM::AEK_DSP, "6"));
126 EXPECT_TRUE(testARMCPU("arm1136jz-s", "armv6", "none",
127 ARM::AEK_DSP, "6"));
128 EXPECT_TRUE(testARMCPU("arm1176jz-s", "armv6kz", "none",
129 ARM::AEK_SEC | ARM::AEK_DSP, "6KZ"));
130 EXPECT_TRUE(testARMCPU("mpcore", "armv6k", "vfpv2",
131 ARM::AEK_DSP, "6K"));
132 EXPECT_TRUE(testARMCPU("mpcorenovfp", "armv6k", "none",
133 ARM::AEK_DSP, "6K"));
134 EXPECT_TRUE(testARMCPU("arm1176jzf-s", "armv6kz", "vfpv2",
135 ARM::AEK_SEC | ARM::AEK_DSP, "6KZ"));
136 EXPECT_TRUE(testARMCPU("arm1156t2-s", "armv6t2", "none",
137 ARM::AEK_DSP, "6T2"));
138 EXPECT_TRUE(testARMCPU("arm1156t2f-s", "armv6t2", "vfpv2",
139 ARM::AEK_DSP, "6T2"));
140 EXPECT_TRUE(testARMCPU("cortex-m0", "armv6-m", "none",
141 ARM::AEK_NONE, "6-M"));
142 EXPECT_TRUE(testARMCPU("cortex-m0plus", "armv6-m", "none",
143 ARM::AEK_NONE, "6-M"));
144 EXPECT_TRUE(testARMCPU("cortex-m1", "armv6-m", "none",
145 ARM::AEK_NONE, "6-M"));
146 EXPECT_TRUE(testARMCPU("sc000", "armv6-m", "none",
147 ARM::AEK_NONE, "6-M"));
148 EXPECT_TRUE(testARMCPU("cortex-a5", "armv7-a", "neon-vfpv4",
149 ARM::AEK_MP | ARM::AEK_SEC | ARM::AEK_DSP, "7-A"));
150 EXPECT_TRUE(testARMCPU("cortex-a7", "armv7-a", "neon-vfpv4",
151 ARM::AEK_HWDIVTHUMB | ARM::AEK_HWDIVARM | ARM::AEK_MP |
152 ARM::AEK_SEC | ARM::AEK_VIRT | ARM::AEK_DSP,
153 "7-A"));
154 EXPECT_TRUE(testARMCPU("cortex-a8", "armv7-a", "neon",
155 ARM::AEK_SEC | ARM::AEK_DSP, "7-A"));
156 EXPECT_TRUE(testARMCPU("cortex-a9", "armv7-a", "neon-fp16",
157 ARM::AEK_MP | ARM::AEK_SEC | ARM::AEK_DSP, "7-A"));
158 EXPECT_TRUE(testARMCPU("cortex-a12", "armv7-a", "neon-vfpv4",
159 ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
160 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
161 ARM::AEK_DSP,
162 "7-A"));
163 EXPECT_TRUE(testARMCPU("cortex-a15", "armv7-a", "neon-vfpv4",
164 ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
165 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
166 ARM::AEK_DSP,
167 "7-A"));
168 EXPECT_TRUE(testARMCPU("cortex-a17", "armv7-a", "neon-vfpv4",
169 ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
170 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
171 ARM::AEK_DSP,
172 "7-A"));
173 EXPECT_TRUE(testARMCPU("krait", "armv7-a", "neon-vfpv4",
174 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
175 "7-A"));
176 EXPECT_TRUE(testARMCPU("cortex-r4", "armv7-r", "none",
177 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP, "7-R"));
178 EXPECT_TRUE(testARMCPU("cortex-r4f", "armv7-r", "vfpv3-d16",
179 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP, "7-R"));
180 EXPECT_TRUE(testARMCPU("cortex-r5", "armv7-r", "vfpv3-d16",
181 ARM::AEK_MP | ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
182 ARM::AEK_DSP,
183 "7-R"));
184 EXPECT_TRUE(testARMCPU("cortex-r7", "armv7-r", "vfpv3-d16-fp16",
185 ARM::AEK_MP | ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
186 ARM::AEK_DSP,
187 "7-R"));
188 EXPECT_TRUE(testARMCPU("cortex-r8", "armv7-r", "vfpv3-d16-fp16",
189 ARM::AEK_MP | ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
190 ARM::AEK_DSP,
191 "7-R"));
192 EXPECT_TRUE(testARMCPU("cortex-r52", "armv8-r", "neon-fp-armv8",
193 ARM::AEK_CRC | ARM::AEK_MP | ARM::AEK_VIRT |
194 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
195 ARM::AEK_DSP,
196 "8-R"));
197 EXPECT_TRUE(
198 testARMCPU("sc300", "armv7-m", "none", ARM::AEK_HWDIVTHUMB, "7-M"));
199 EXPECT_TRUE(
200 testARMCPU("cortex-m3", "armv7-m", "none", ARM::AEK_HWDIVTHUMB, "7-M"));
201 EXPECT_TRUE(testARMCPU("cortex-m4", "armv7e-m", "fpv4-sp-d16",
202 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP, "7E-M"));
203 EXPECT_TRUE(testARMCPU("cortex-m7", "armv7e-m", "fpv5-d16",
204 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP, "7E-M"));
205 EXPECT_TRUE(testARMCPU("cortex-a32", "armv8-a", "crypto-neon-fp-armv8",
206 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
207 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
208 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
209 "8-A"));
210 EXPECT_TRUE(testARMCPU("cortex-a35", "armv8-a", "crypto-neon-fp-armv8",
211 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
212 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
213 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
214 "8-A"));
215 EXPECT_TRUE(testARMCPU("cortex-a53", "armv8-a", "crypto-neon-fp-armv8",
216 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
217 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
218 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
219 "8-A"));
220 EXPECT_TRUE(testARMCPU("cortex-a55", "armv8.2-a", "crypto-neon-fp-armv8",
221 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
222 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
223 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
224 ARM::AEK_RAS | ARM::AEK_DOTPROD,
225 "8.2-A"));
226 EXPECT_TRUE(testARMCPU("cortex-a57", "armv8-a", "crypto-neon-fp-armv8",
227 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
228 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
229 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
230 "8-A"));
231 EXPECT_TRUE(testARMCPU("cortex-a72", "armv8-a", "crypto-neon-fp-armv8",
232 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
233 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
234 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
235 "8-A"));
236 EXPECT_TRUE(testARMCPU("cortex-a73", "armv8-a", "crypto-neon-fp-armv8",
237 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
238 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
239 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
240 "8-A"));
241 EXPECT_TRUE(testARMCPU("cortex-a75", "armv8.2-a", "crypto-neon-fp-armv8",
242 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
243 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
244 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
245 ARM::AEK_RAS | ARM::AEK_DOTPROD,
246 "8.2-A"));
247 EXPECT_TRUE(testARMCPU("cortex-a76", "armv8.2-a", "crypto-neon-fp-armv8",
248 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
249 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
250 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
251 ARM::AEK_RAS | ARM::AEK_DOTPROD,
252 "8.2-A"));
253 EXPECT_TRUE(testARMCPU("cortex-a76ae", "armv8.2-a", "crypto-neon-fp-armv8",
254 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
255 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
256 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
257 ARM::AEK_RAS | ARM::AEK_DOTPROD,
258 "8.2-A"));
259 EXPECT_TRUE(testARMCPU("neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
260 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
261 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
262 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
263 ARM::AEK_RAS | ARM::AEK_DOTPROD,
264 "8.2-A"));
265 EXPECT_TRUE(testARMCPU("cyclone", "armv8-a", "crypto-neon-fp-armv8",
266 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
267 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
268 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
269 "8-A"));
270 EXPECT_TRUE(testARMCPU("exynos-m1", "armv8-a", "crypto-neon-fp-armv8",
271 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
272 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
273 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
274 "8-A"));
275 EXPECT_TRUE(testARMCPU("exynos-m2", "armv8-a", "crypto-neon-fp-armv8",
276 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
277 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
278 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
279 "8-A"));
280 EXPECT_TRUE(testARMCPU("exynos-m3", "armv8-a", "crypto-neon-fp-armv8",
281 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
282 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
283 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
284 "8-A"));
285 EXPECT_TRUE(testARMCPU("exynos-m4", "armv8.2-a", "crypto-neon-fp-armv8",
286 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
287 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
288 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_DOTPROD |
289 ARM::AEK_FP16 | ARM::AEK_RAS,
290 "8.2-A"));
291 EXPECT_TRUE(testARMCPU("exynos-m5", "armv8.2-a", "crypto-neon-fp-armv8",
292 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
293 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
294 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_DOTPROD |
295 ARM::AEK_FP16 | ARM::AEK_RAS,
296 "8.2-A"));
297 EXPECT_TRUE(testARMCPU("cortex-m23", "armv8-m.base", "none",
298 ARM::AEK_HWDIVTHUMB, "8-M.Baseline"));
299 EXPECT_TRUE(testARMCPU("cortex-m33", "armv8-m.main", "fpv5-sp-d16",
300 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP, "8-M.Mainline"));
301 EXPECT_TRUE(testARMCPU("cortex-m35p", "armv8-m.main", "fpv5-sp-d16",
302 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP, "8-M.Mainline"));
303 EXPECT_TRUE(testARMCPU("iwmmxt", "iwmmxt", "none",
304 ARM::AEK_NONE, "iwmmxt"));
305 EXPECT_TRUE(testARMCPU("xscale", "xscale", "none",
306 ARM::AEK_NONE, "xscale"));
307 EXPECT_TRUE(testARMCPU("swift", "armv7s", "neon-vfpv4",
308 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
309 "7-S"));
312 static constexpr unsigned NumARMCPUArchs = 87;
314 TEST(TargetParserTest, testARMCPUArchList) {
315 SmallVector<StringRef, NumARMCPUArchs> List;
316 ARM::fillValidCPUArchList(List);
318 // No list exists for these in this test suite, so ensure all are
319 // valid, and match the expected 'magic' count.
320 EXPECT_EQ(List.size(), NumARMCPUArchs);
321 for(StringRef CPU : List) {
322 EXPECT_NE(ARM::parseCPUArch(CPU), ARM::ArchKind::INVALID);
326 TEST(TargetParserTest, testInvalidARMArch) {
327 auto InvalidArchStrings = {"armv", "armv99", "noarm"};
328 for (const char* InvalidArch : InvalidArchStrings)
329 EXPECT_EQ(ARM::parseArch(InvalidArch), ARM::ArchKind::INVALID);
332 bool testARMArch(StringRef Arch, StringRef DefaultCPU, StringRef SubArch,
333 unsigned ArchAttr) {
334 ARM::ArchKind AK = ARM::parseArch(Arch);
335 return (AK!= ARM::ArchKind::INVALID) &
336 ARM::getDefaultCPU(Arch).equals(DefaultCPU) &
337 ARM::getSubArch(AK).equals(SubArch) &
338 (ARM::getArchAttr(AK) == ArchAttr);
341 TEST(TargetParserTest, testARMArch) {
342 EXPECT_TRUE(
343 testARMArch("armv2", "arm2", "v2",
344 ARMBuildAttrs::CPUArch::Pre_v4));
345 EXPECT_TRUE(
346 testARMArch("armv2a", "arm3", "v2a",
347 ARMBuildAttrs::CPUArch::Pre_v4));
348 EXPECT_TRUE(
349 testARMArch("armv3", "arm6", "v3",
350 ARMBuildAttrs::CPUArch::Pre_v4));
351 EXPECT_TRUE(
352 testARMArch("armv3m", "arm7m", "v3m",
353 ARMBuildAttrs::CPUArch::Pre_v4));
354 EXPECT_TRUE(
355 testARMArch("armv4", "strongarm", "v4",
356 ARMBuildAttrs::CPUArch::v4));
357 EXPECT_TRUE(
358 testARMArch("armv4t", "arm7tdmi", "v4t",
359 ARMBuildAttrs::CPUArch::v4T));
360 EXPECT_TRUE(
361 testARMArch("armv5t", "arm10tdmi", "v5",
362 ARMBuildAttrs::CPUArch::v5T));
363 EXPECT_TRUE(
364 testARMArch("armv5te", "arm1022e", "v5e",
365 ARMBuildAttrs::CPUArch::v5TE));
366 EXPECT_TRUE(
367 testARMArch("armv5tej", "arm926ej-s", "v5e",
368 ARMBuildAttrs::CPUArch::v5TEJ));
369 EXPECT_TRUE(
370 testARMArch("armv6", "arm1136jf-s", "v6",
371 ARMBuildAttrs::CPUArch::v6));
372 EXPECT_TRUE(
373 testARMArch("armv6k", "mpcore", "v6k",
374 ARMBuildAttrs::CPUArch::v6K));
375 EXPECT_TRUE(
376 testARMArch("armv6t2", "arm1156t2-s", "v6t2",
377 ARMBuildAttrs::CPUArch::v6T2));
378 EXPECT_TRUE(
379 testARMArch("armv6kz", "arm1176jzf-s", "v6kz",
380 ARMBuildAttrs::CPUArch::v6KZ));
381 EXPECT_TRUE(
382 testARMArch("armv6-m", "cortex-m0", "v6m",
383 ARMBuildAttrs::CPUArch::v6_M));
384 EXPECT_TRUE(
385 testARMArch("armv7-a", "generic", "v7",
386 ARMBuildAttrs::CPUArch::v7));
387 EXPECT_TRUE(
388 testARMArch("armv7ve", "generic", "v7ve",
389 ARMBuildAttrs::CPUArch::v7));
390 EXPECT_TRUE(
391 testARMArch("armv7-r", "cortex-r4", "v7r",
392 ARMBuildAttrs::CPUArch::v7));
393 EXPECT_TRUE(
394 testARMArch("armv7-m", "cortex-m3", "v7m",
395 ARMBuildAttrs::CPUArch::v7));
396 EXPECT_TRUE(
397 testARMArch("armv7e-m", "cortex-m4", "v7em",
398 ARMBuildAttrs::CPUArch::v7E_M));
399 EXPECT_TRUE(
400 testARMArch("armv8-a", "generic", "v8",
401 ARMBuildAttrs::CPUArch::v8_A));
402 EXPECT_TRUE(
403 testARMArch("armv8.1-a", "generic", "v8.1a",
404 ARMBuildAttrs::CPUArch::v8_A));
405 EXPECT_TRUE(
406 testARMArch("armv8.2-a", "generic", "v8.2a",
407 ARMBuildAttrs::CPUArch::v8_A));
408 EXPECT_TRUE(
409 testARMArch("armv8.3-a", "generic", "v8.3a",
410 ARMBuildAttrs::CPUArch::v8_A));
411 EXPECT_TRUE(
412 testARMArch("armv8.4-a", "generic", "v8.4a",
413 ARMBuildAttrs::CPUArch::v8_A));
414 EXPECT_TRUE(
415 testARMArch("armv8.5-a", "generic", "v8.5a",
416 ARMBuildAttrs::CPUArch::v8_A));
417 EXPECT_TRUE(
418 testARMArch("armv8-r", "cortex-r52", "v8r",
419 ARMBuildAttrs::CPUArch::v8_R));
420 EXPECT_TRUE(
421 testARMArch("armv8-m.base", "generic", "v8m.base",
422 ARMBuildAttrs::CPUArch::v8_M_Base));
423 EXPECT_TRUE(
424 testARMArch("armv8-m.main", "generic", "v8m.main",
425 ARMBuildAttrs::CPUArch::v8_M_Main));
426 EXPECT_TRUE(
427 testARMArch("armv8.1-m.main", "generic", "v8.1m.main",
428 ARMBuildAttrs::CPUArch::v8_1_M_Main));
429 EXPECT_TRUE(
430 testARMArch("iwmmxt", "iwmmxt", "",
431 ARMBuildAttrs::CPUArch::v5TE));
432 EXPECT_TRUE(
433 testARMArch("iwmmxt2", "generic", "",
434 ARMBuildAttrs::CPUArch::v5TE));
435 EXPECT_TRUE(
436 testARMArch("xscale", "xscale", "v5e",
437 ARMBuildAttrs::CPUArch::v5TE));
438 EXPECT_TRUE(
439 testARMArch("armv7s", "swift", "v7s",
440 ARMBuildAttrs::CPUArch::v7));
441 EXPECT_TRUE(
442 testARMArch("armv7k", "generic", "v7k",
443 ARMBuildAttrs::CPUArch::v7));
446 bool testARMExtension(StringRef CPUName,ARM::ArchKind ArchKind, StringRef ArchExt) {
447 return ARM::getDefaultExtensions(CPUName, ArchKind) &
448 ARM::parseArchExt(ArchExt);
451 TEST(TargetParserTest, testARMExtension) {
452 EXPECT_FALSE(testARMExtension("arm2", ARM::ArchKind::INVALID, "thumb"));
453 EXPECT_FALSE(testARMExtension("arm3", ARM::ArchKind::INVALID, "thumb"));
454 EXPECT_FALSE(testARMExtension("arm6", ARM::ArchKind::INVALID, "thumb"));
455 EXPECT_FALSE(testARMExtension("arm7m", ARM::ArchKind::INVALID, "thumb"));
456 EXPECT_FALSE(testARMExtension("strongarm", ARM::ArchKind::INVALID, "dsp"));
457 EXPECT_FALSE(testARMExtension("arm7tdmi", ARM::ArchKind::INVALID, "dsp"));
458 EXPECT_FALSE(testARMExtension("arm10tdmi",
459 ARM::ArchKind::INVALID, "simd"));
460 EXPECT_FALSE(testARMExtension("arm1022e", ARM::ArchKind::INVALID, "simd"));
461 EXPECT_FALSE(testARMExtension("arm926ej-s",
462 ARM::ArchKind::INVALID, "simd"));
463 EXPECT_FALSE(testARMExtension("arm1136jf-s",
464 ARM::ArchKind::INVALID, "crypto"));
465 EXPECT_FALSE(testARMExtension("arm1176j-s",
466 ARM::ArchKind::INVALID, "crypto"));
467 EXPECT_FALSE(testARMExtension("arm1156t2-s",
468 ARM::ArchKind::INVALID, "crypto"));
469 EXPECT_FALSE(testARMExtension("arm1176jzf-s",
470 ARM::ArchKind::INVALID, "crypto"));
471 EXPECT_FALSE(testARMExtension("cortex-m0",
472 ARM::ArchKind::INVALID, "crypto"));
473 EXPECT_FALSE(testARMExtension("cortex-a8",
474 ARM::ArchKind::INVALID, "crypto"));
475 EXPECT_FALSE(testARMExtension("cortex-r4",
476 ARM::ArchKind::INVALID, "crypto"));
477 EXPECT_FALSE(testARMExtension("cortex-m3",
478 ARM::ArchKind::INVALID, "crypto"));
479 EXPECT_FALSE(testARMExtension("cortex-a53",
480 ARM::ArchKind::INVALID, "ras"));
481 EXPECT_FALSE(testARMExtension("cortex-a53",
482 ARM::ArchKind::INVALID, "fp16"));
483 EXPECT_TRUE(testARMExtension("cortex-a55",
484 ARM::ArchKind::INVALID, "fp16"));
485 EXPECT_FALSE(testARMExtension("cortex-a55",
486 ARM::ArchKind::INVALID, "fp16fml"));
487 EXPECT_TRUE(testARMExtension("cortex-a75",
488 ARM::ArchKind::INVALID, "fp16"));
489 EXPECT_FALSE(testARMExtension("cortex-a75",
490 ARM::ArchKind::INVALID, "fp16fml"));
491 EXPECT_FALSE(testARMExtension("cortex-r52",
492 ARM::ArchKind::INVALID, "ras"));
493 EXPECT_FALSE(testARMExtension("iwmmxt", ARM::ArchKind::INVALID, "crc"));
494 EXPECT_FALSE(testARMExtension("xscale", ARM::ArchKind::INVALID, "crc"));
495 EXPECT_FALSE(testARMExtension("swift", ARM::ArchKind::INVALID, "crc"));
497 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV2, "thumb"));
498 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV2A, "thumb"));
499 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV3, "thumb"));
500 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV3M, "thumb"));
501 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV4, "dsp"));
502 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV4T, "dsp"));
503 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV5T, "simd"));
504 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV5TE, "simd"));
505 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV5TEJ, "simd"));
506 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV6, "crypto"));
507 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV6K, "crypto"));
508 EXPECT_FALSE(testARMExtension("generic",
509 ARM::ArchKind::ARMV6T2, "crypto"));
510 EXPECT_FALSE(testARMExtension("generic",
511 ARM::ArchKind::ARMV6KZ, "crypto"));
512 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV6M, "crypto"));
513 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV7A, "crypto"));
514 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV7R, "crypto"));
515 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV7M, "crypto"));
516 EXPECT_FALSE(testARMExtension("generic",
517 ARM::ArchKind::ARMV7EM, "crypto"));
518 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8A, "ras"));
519 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_1A, "ras"));
520 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_2A, "profile"));
521 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_2A, "fp16"));
522 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_2A, "fp16fml"));
523 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_3A, "fp16"));
524 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_3A, "fp16fml"));
525 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_4A, "fp16"));
526 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_4A, "fp16fml"));
527 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8R, "ras"));
528 EXPECT_FALSE(testARMExtension("generic",
529 ARM::ArchKind::ARMV8MBaseline, "crc"));
530 EXPECT_FALSE(testARMExtension("generic",
531 ARM::ArchKind::ARMV8MMainline, "crc"));
532 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::IWMMXT, "crc"));
533 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::IWMMXT2, "crc"));
534 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::XSCALE, "crc"));
535 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV7S, "crypto"));
536 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV7K, "crypto"));
539 TEST(TargetParserTest, ARMFPUVersion) {
540 for (ARM::FPUKind FK = static_cast<ARM::FPUKind>(0);
541 FK <= ARM::FPUKind::FK_LAST;
542 FK = static_cast<ARM::FPUKind>(static_cast<unsigned>(FK) + 1))
543 if (FK == ARM::FK_LAST || ARM::getFPUName(FK) == "invalid" ||
544 ARM::getFPUName(FK) == "none" || ARM::getFPUName(FK) == "softvfp")
545 EXPECT_EQ(ARM::FPUVersion::NONE, ARM::getFPUVersion(FK));
546 else
547 EXPECT_NE(ARM::FPUVersion::NONE, ARM::getFPUVersion(FK));
550 TEST(TargetParserTest, ARMFPUNeonSupportLevel) {
551 for (ARM::FPUKind FK = static_cast<ARM::FPUKind>(0);
552 FK <= ARM::FPUKind::FK_LAST;
553 FK = static_cast<ARM::FPUKind>(static_cast<unsigned>(FK) + 1))
554 if (FK == ARM::FK_LAST ||
555 ARM::getFPUName(FK).find("neon") == std::string::npos)
556 EXPECT_EQ(ARM::NeonSupportLevel::None,
557 ARM::getFPUNeonSupportLevel(FK));
558 else
559 EXPECT_NE(ARM::NeonSupportLevel::None,
560 ARM::getFPUNeonSupportLevel(FK));
563 TEST(TargetParserTest, ARMFPURestriction) {
564 for (ARM::FPUKind FK = static_cast<ARM::FPUKind>(0);
565 FK <= ARM::FPUKind::FK_LAST;
566 FK = static_cast<ARM::FPUKind>(static_cast<unsigned>(FK) + 1)) {
567 if (FK == ARM::FK_LAST ||
568 (ARM::getFPUName(FK).find("d16") == std::string::npos &&
569 ARM::getFPUName(FK).find("vfpv3xd") == std::string::npos))
570 EXPECT_EQ(ARM::FPURestriction::None, ARM::getFPURestriction(FK));
571 else
572 EXPECT_NE(ARM::FPURestriction::None, ARM::getFPURestriction(FK));
576 TEST(TargetParserTest, ARMExtensionFeatures) {
577 std::map<unsigned, std::vector<StringRef>> Extensions;
579 for (auto &Ext : ARM::ARCHExtNames) {
580 if (Ext.Feature && Ext.NegFeature)
581 Extensions[Ext.ID] = { StringRef(Ext.Feature),
582 StringRef(Ext.NegFeature) };
585 Extensions[ARM::AEK_HWDIVARM] = { "+hwdiv-arm", "-hwdiv-arm" };
586 Extensions[ARM::AEK_HWDIVTHUMB] = { "+hwdiv", "-hwdiv" };
588 std::vector<StringRef> Features;
590 EXPECT_FALSE(ARM::getExtensionFeatures(ARM::AEK_INVALID, Features));
592 for (auto &E : Extensions) {
593 // test +extension
594 Features.clear();
595 ARM::getExtensionFeatures(E.first, Features);
596 auto Found =
597 std::find(std::begin(Features), std::end(Features), E.second.at(0));
598 EXPECT_TRUE(Found != std::end(Features));
599 EXPECT_TRUE(Extensions.size() == Features.size());
601 // test -extension
602 Features.clear();
603 ARM::getExtensionFeatures(~E.first, Features);
604 Found = std::find(std::begin(Features), std::end(Features), E.second.at(1));
605 EXPECT_TRUE(Found != std::end(Features));
606 EXPECT_TRUE(Extensions.size() == Features.size());
610 TEST(TargetParserTest, ARMFPUFeatures) {
611 std::vector<StringRef> Features;
612 for (ARM::FPUKind FK = static_cast<ARM::FPUKind>(0);
613 FK <= ARM::FPUKind::FK_LAST;
614 FK = static_cast<ARM::FPUKind>(static_cast<unsigned>(FK) + 1))
615 EXPECT_TRUE((FK == ARM::FK_INVALID || FK >= ARM::FK_LAST)
616 ? !ARM::getFPUFeatures(FK, Features)
617 : ARM::getFPUFeatures(FK, Features));
620 TEST(TargetParserTest, ARMArchExtFeature) {
621 const char *ArchExt[][4] = {{"crc", "nocrc", "+crc", "-crc"},
622 {"crypto", "nocrypto", "+crypto", "-crypto"},
623 {"dsp", "nodsp", "+dsp", "-dsp"},
624 {"fp", "nofp", nullptr, nullptr},
625 {"idiv", "noidiv", nullptr, nullptr},
626 {"mp", "nomp", nullptr, nullptr},
627 {"simd", "nosimd", nullptr, nullptr},
628 {"sec", "nosec", nullptr, nullptr},
629 {"virt", "novirt", nullptr, nullptr},
630 {"fp16", "nofp16", "+fullfp16", "-fullfp16"},
631 {"fp16fml", "nofp16fml", "+fp16fml", "-fp16fml"},
632 {"ras", "noras", "+ras", "-ras"},
633 {"dotprod", "nodotprod", "+dotprod", "-dotprod"},
634 {"os", "noos", nullptr, nullptr},
635 {"iwmmxt", "noiwmmxt", nullptr, nullptr},
636 {"iwmmxt2", "noiwmmxt2", nullptr, nullptr},
637 {"maverick", "maverick", nullptr, nullptr},
638 {"xscale", "noxscale", nullptr, nullptr},
639 {"sb", "nosb", "+sb", "-sb"},
640 {"mve", "nomve", "+mve", "-mve"},
641 {"mve.fp", "nomve.fp", "+mve.fp", "-mve.fp"}};
643 for (unsigned i = 0; i < array_lengthof(ArchExt); i++) {
644 EXPECT_EQ(StringRef(ArchExt[i][2]), ARM::getArchExtFeature(ArchExt[i][0]));
645 EXPECT_EQ(StringRef(ArchExt[i][3]), ARM::getArchExtFeature(ArchExt[i][1]));
649 TEST(TargetParserTest, ARMparseHWDiv) {
650 const char *hwdiv[] = {"thumb", "arm", "arm,thumb", "thumb,arm"};
652 for (unsigned i = 0; i < array_lengthof(hwdiv); i++)
653 EXPECT_NE(ARM::AEK_INVALID, ARM::parseHWDiv((StringRef)hwdiv[i]));
656 TEST(TargetParserTest, ARMparseArchEndianAndISA) {
657 const char *Arch[] = {
658 "v2", "v2a", "v3", "v3m", "v4", "v4t", "v5", "v5t",
659 "v5e", "v5te", "v5tej", "v6", "v6j", "v6k", "v6hl", "v6t2",
660 "v6kz", "v6z", "v6zk", "v6-m", "v6m", "v6sm", "v6s-m", "v7-a",
661 "v7", "v7a", "v7ve", "v7hl", "v7l", "v7-r", "v7r", "v7-m",
662 "v7m", "v7k", "v7s", "v7e-m", "v7em", "v8-a", "v8", "v8a",
663 "v8l", "v8.1-a", "v8.1a", "v8.2-a", "v8.2a", "v8.3-a", "v8.3a", "v8.4-a",
664 "v8.4a", "v8.5-a","v8.5a", "v8-r", "v8m.base", "v8m.main", "v8.1m.main"
667 for (unsigned i = 0; i < array_lengthof(Arch); i++) {
668 std::string arm_1 = "armeb" + (std::string)(Arch[i]);
669 std::string arm_2 = "arm" + (std::string)(Arch[i]) + "eb";
670 std::string arm_3 = "arm" + (std::string)(Arch[i]);
671 std::string thumb_1 = "thumbeb" + (std::string)(Arch[i]);
672 std::string thumb_2 = "thumb" + (std::string)(Arch[i]) + "eb";
673 std::string thumb_3 = "thumb" + (std::string)(Arch[i]);
675 EXPECT_EQ(ARM::EndianKind::BIG, ARM::parseArchEndian(arm_1));
676 EXPECT_EQ(ARM::EndianKind::BIG, ARM::parseArchEndian(arm_2));
677 EXPECT_EQ(ARM::EndianKind::LITTLE, ARM::parseArchEndian(arm_3));
679 EXPECT_EQ(ARM::ISAKind::ARM, ARM::parseArchISA(arm_1));
680 EXPECT_EQ(ARM::ISAKind::ARM, ARM::parseArchISA(arm_2));
681 EXPECT_EQ(ARM::ISAKind::ARM, ARM::parseArchISA(arm_3));
682 if (i >= 4) {
683 EXPECT_EQ(ARM::EndianKind::BIG, ARM::parseArchEndian(thumb_1));
684 EXPECT_EQ(ARM::EndianKind::BIG, ARM::parseArchEndian(thumb_2));
685 EXPECT_EQ(ARM::EndianKind::LITTLE, ARM::parseArchEndian(thumb_3));
687 EXPECT_EQ(ARM::ISAKind::THUMB, ARM::parseArchISA(thumb_1));
688 EXPECT_EQ(ARM::ISAKind::THUMB, ARM::parseArchISA(thumb_2));
689 EXPECT_EQ(ARM::ISAKind::THUMB, ARM::parseArchISA(thumb_3));
693 EXPECT_EQ(ARM::EndianKind::LITTLE, ARM::parseArchEndian("aarch64"));
694 EXPECT_EQ(ARM::EndianKind::LITTLE, ARM::parseArchEndian("arm64_32"));
695 EXPECT_EQ(ARM::EndianKind::BIG, ARM::parseArchEndian("aarch64_be"));
697 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("aarch64"));
698 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("aarch64_be"));
699 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("arm64"));
700 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("arm64_be"));
701 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("arm64_32"));
702 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("aarch64_32"));
705 TEST(TargetParserTest, ARMparseArchProfile) {
706 for (unsigned i = 0; i < array_lengthof(ARMArch); i++) {
707 switch (ARM::parseArch(ARMArch[i])) {
708 case ARM::ArchKind::ARMV6M:
709 case ARM::ArchKind::ARMV7M:
710 case ARM::ArchKind::ARMV7EM:
711 case ARM::ArchKind::ARMV8MMainline:
712 case ARM::ArchKind::ARMV8MBaseline:
713 case ARM::ArchKind::ARMV8_1MMainline:
714 EXPECT_EQ(ARM::ProfileKind::M, ARM::parseArchProfile(ARMArch[i]));
715 break;
716 case ARM::ArchKind::ARMV7R:
717 case ARM::ArchKind::ARMV8R:
718 EXPECT_EQ(ARM::ProfileKind::R, ARM::parseArchProfile(ARMArch[i]));
719 break;
720 case ARM::ArchKind::ARMV7A:
721 case ARM::ArchKind::ARMV7VE:
722 case ARM::ArchKind::ARMV7K:
723 case ARM::ArchKind::ARMV8A:
724 case ARM::ArchKind::ARMV8_1A:
725 case ARM::ArchKind::ARMV8_2A:
726 case ARM::ArchKind::ARMV8_3A:
727 case ARM::ArchKind::ARMV8_4A:
728 case ARM::ArchKind::ARMV8_5A:
729 EXPECT_EQ(ARM::ProfileKind::A, ARM::parseArchProfile(ARMArch[i]));
730 break;
731 default:
732 EXPECT_EQ(ARM::ProfileKind::INVALID, ARM::parseArchProfile(ARMArch[i]));
733 break;
738 TEST(TargetParserTest, ARMparseArchVersion) {
739 for (unsigned i = 0; i < array_lengthof(ARMArch); i++)
740 if (((std::string)ARMArch[i]).substr(0, 4) == "armv")
741 EXPECT_EQ((ARMArch[i][4] - 48u), ARM::parseArchVersion(ARMArch[i]));
742 else
743 EXPECT_EQ(5u, ARM::parseArchVersion(ARMArch[i]));
746 bool testAArch64CPU(StringRef CPUName, StringRef ExpectedArch,
747 StringRef ExpectedFPU, unsigned ExpectedFlags,
748 StringRef CPUAttr) {
749 AArch64::ArchKind AK = AArch64::parseCPUArch(CPUName);
750 bool pass = AArch64::getArchName(AK).equals(ExpectedArch);
752 unsigned ExtKind = AArch64::getDefaultExtensions(CPUName, AK);
753 if (ExtKind > 1 && (ExtKind & AArch64::AEK_NONE))
754 pass &= ((ExtKind ^ AArch64::AEK_NONE) == ExpectedFlags);
755 else
756 pass &= (ExtKind == ExpectedFlags);
758 pass &= AArch64::getCPUAttr(AK).equals(CPUAttr);
760 return pass;
763 TEST(TargetParserTest, testAArch64CPU) {
764 EXPECT_TRUE(testAArch64CPU(
765 "invalid", "invalid", "invalid",
766 AArch64::AEK_NONE, ""));
767 EXPECT_TRUE(testAArch64CPU(
768 "generic", "invalid", "none",
769 AArch64::AEK_NONE, ""));
771 EXPECT_TRUE(testAArch64CPU(
772 "cortex-a35", "armv8-a", "crypto-neon-fp-armv8",
773 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
774 AArch64::AEK_SIMD, "8-A"));
775 EXPECT_TRUE(testAArch64CPU(
776 "cortex-a53", "armv8-a", "crypto-neon-fp-armv8",
777 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
778 AArch64::AEK_SIMD, "8-A"));
779 EXPECT_TRUE(testAArch64CPU(
780 "cortex-a55", "armv8.2-a", "crypto-neon-fp-armv8",
781 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
782 AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
783 AArch64::AEK_RDM | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
784 AArch64::AEK_RCPC, "8.2-A"));
785 EXPECT_TRUE(testAArch64CPU(
786 "cortex-a57", "armv8-a", "crypto-neon-fp-armv8",
787 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
788 AArch64::AEK_SIMD, "8-A"));
789 EXPECT_TRUE(testAArch64CPU(
790 "cortex-a65", "armv8.2-a", "crypto-neon-fp-armv8",
791 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_DOTPROD |
792 AArch64::AEK_FP | AArch64::AEK_FP16 | AArch64::AEK_LSE |
793 AArch64::AEK_RAS | AArch64::AEK_RCPC | AArch64::AEK_RDM |
794 AArch64::AEK_SIMD | AArch64::AEK_SSBS,
795 "8.2-A"));
796 EXPECT_TRUE(testAArch64CPU(
797 "cortex-a65ae", "armv8.2-a", "crypto-neon-fp-armv8",
798 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_DOTPROD |
799 AArch64::AEK_FP | AArch64::AEK_FP16 | AArch64::AEK_LSE |
800 AArch64::AEK_RAS | AArch64::AEK_RCPC | AArch64::AEK_RDM |
801 AArch64::AEK_SIMD | AArch64::AEK_SSBS,
802 "8.2-A"));
803 EXPECT_TRUE(testAArch64CPU(
804 "cortex-a72", "armv8-a", "crypto-neon-fp-armv8",
805 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
806 AArch64::AEK_SIMD, "8-A"));
807 EXPECT_TRUE(testAArch64CPU(
808 "cortex-a73", "armv8-a", "crypto-neon-fp-armv8",
809 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
810 AArch64::AEK_SIMD, "8-A"));
811 EXPECT_TRUE(testAArch64CPU(
812 "cortex-a75", "armv8.2-a", "crypto-neon-fp-armv8",
813 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
814 AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
815 AArch64::AEK_RDM | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
816 AArch64::AEK_RCPC, "8.2-A"));
817 EXPECT_TRUE(testAArch64CPU(
818 "cortex-a76", "armv8.2-a", "crypto-neon-fp-armv8",
819 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
820 AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
821 AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
822 AArch64::AEK_RCPC| AArch64::AEK_SSBS, "8.2-A"));
823 EXPECT_TRUE(testAArch64CPU(
824 "cortex-a76ae", "armv8.2-a", "crypto-neon-fp-armv8",
825 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
826 AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
827 AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
828 AArch64::AEK_RCPC| AArch64::AEK_SSBS, "8.2-A"));
829 EXPECT_TRUE(testAArch64CPU(
830 "cyclone", "armv8-a", "crypto-neon-fp-armv8",
831 AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
832 EXPECT_TRUE(testAArch64CPU(
833 "exynos-m1", "armv8-a", "crypto-neon-fp-armv8",
834 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
835 AArch64::AEK_SIMD, "8-A"));
836 EXPECT_TRUE(testAArch64CPU(
837 "exynos-m2", "armv8-a", "crypto-neon-fp-armv8",
838 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
839 AArch64::AEK_SIMD, "8-A"));
840 EXPECT_TRUE(testAArch64CPU(
841 "exynos-m3", "armv8-a", "crypto-neon-fp-armv8",
842 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
843 AArch64::AEK_SIMD, "8-A"));
844 EXPECT_TRUE(testAArch64CPU(
845 "exynos-m4", "armv8.2-a", "crypto-neon-fp-armv8",
846 AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
847 AArch64::AEK_DOTPROD | AArch64::AEK_FP | AArch64::AEK_FP16 |
848 AArch64::AEK_LSE | AArch64::AEK_RAS | AArch64::AEK_RDM |
849 AArch64::AEK_SIMD, "8.2-A"));
850 EXPECT_TRUE(testAArch64CPU(
851 "exynos-m5", "armv8.2-a", "crypto-neon-fp-armv8",
852 AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
853 AArch64::AEK_DOTPROD | AArch64::AEK_FP | AArch64::AEK_FP16 |
854 AArch64::AEK_LSE | AArch64::AEK_RAS | AArch64::AEK_RDM |
855 AArch64::AEK_SIMD, "8.2-A"));
856 EXPECT_TRUE(testAArch64CPU(
857 "falkor", "armv8-a", "crypto-neon-fp-armv8",
858 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
859 AArch64::AEK_SIMD | AArch64::AEK_RDM, "8-A"));
860 EXPECT_TRUE(testAArch64CPU(
861 "kryo", "armv8-a", "crypto-neon-fp-armv8",
862 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
863 AArch64::AEK_SIMD, "8-A"));
864 EXPECT_TRUE(testAArch64CPU(
865 "neoverse-e1", "armv8.2-a", "crypto-neon-fp-armv8",
866 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_DOTPROD |
867 AArch64::AEK_FP | AArch64::AEK_FP16 | AArch64::AEK_LSE |
868 AArch64::AEK_RAS | AArch64::AEK_RCPC | AArch64::AEK_RDM |
869 AArch64::AEK_SIMD | AArch64::AEK_SSBS,
870 "8.2-A"));
871 EXPECT_TRUE(testAArch64CPU(
872 "neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
873 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_DOTPROD |
874 AArch64::AEK_FP | AArch64::AEK_FP16 | AArch64::AEK_LSE |
875 AArch64::AEK_PROFILE | AArch64::AEK_RAS | AArch64::AEK_RCPC |
876 AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_SSBS,
877 "8.2-A"));
878 EXPECT_TRUE(testAArch64CPU(
879 "thunderx2t99", "armv8.1-a", "crypto-neon-fp-armv8",
880 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_LSE |
881 AArch64::AEK_RDM | AArch64::AEK_FP | AArch64::AEK_SIMD, "8.1-A"));
882 EXPECT_TRUE(testAArch64CPU(
883 "thunderx", "armv8-a", "crypto-neon-fp-armv8",
884 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_SIMD |
885 AArch64::AEK_FP | AArch64::AEK_PROFILE,
886 "8-A"));
887 EXPECT_TRUE(testAArch64CPU(
888 "thunderxt81", "armv8-a", "crypto-neon-fp-armv8",
889 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_SIMD |
890 AArch64::AEK_FP | AArch64::AEK_PROFILE,
891 "8-A"));
892 EXPECT_TRUE(testAArch64CPU(
893 "thunderxt83", "armv8-a", "crypto-neon-fp-armv8",
894 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_SIMD |
895 AArch64::AEK_FP | AArch64::AEK_PROFILE,
896 "8-A"));
897 EXPECT_TRUE(testAArch64CPU(
898 "thunderxt88", "armv8-a", "crypto-neon-fp-armv8",
899 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_SIMD |
900 AArch64::AEK_FP | AArch64::AEK_PROFILE,
901 "8-A"));
902 EXPECT_TRUE(testAArch64CPU(
903 "tsv110", "armv8.2-a", "crypto-neon-fp-armv8",
904 AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
905 AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
906 AArch64::AEK_RDM | AArch64::AEK_PROFILE | AArch64::AEK_FP16 |
907 AArch64::AEK_FP16FML | AArch64::AEK_DOTPROD,
908 "8.2-A"));
911 static constexpr unsigned NumAArch64CPUArchs = 28;
913 TEST(TargetParserTest, testAArch64CPUArchList) {
914 SmallVector<StringRef, NumAArch64CPUArchs> List;
915 AArch64::fillValidCPUArchList(List);
917 // No list exists for these in this test suite, so ensure all are
918 // valid, and match the expected 'magic' count.
919 EXPECT_EQ(List.size(), NumAArch64CPUArchs);
920 for(StringRef CPU : List) {
921 EXPECT_NE(AArch64::parseCPUArch(CPU), AArch64::ArchKind::INVALID);
925 bool testAArch64Arch(StringRef Arch, StringRef DefaultCPU, StringRef SubArch,
926 unsigned ArchAttr) {
927 AArch64::ArchKind AK = AArch64::parseArch(Arch);
928 return (AK != AArch64::ArchKind::INVALID) &
929 AArch64::getDefaultCPU(Arch).equals(DefaultCPU) &
930 AArch64::getSubArch(AK).equals(SubArch) &
931 (AArch64::getArchAttr(AK) == ArchAttr);
934 TEST(TargetParserTest, testAArch64Arch) {
935 EXPECT_TRUE(testAArch64Arch("armv8-a", "cortex-a53", "v8",
936 ARMBuildAttrs::CPUArch::v8_A));
937 EXPECT_TRUE(testAArch64Arch("armv8.1-a", "generic", "v8.1a",
938 ARMBuildAttrs::CPUArch::v8_A));
939 EXPECT_TRUE(testAArch64Arch("armv8.2-a", "generic", "v8.2a",
940 ARMBuildAttrs::CPUArch::v8_A));
941 EXPECT_TRUE(testAArch64Arch("armv8.3-a", "generic", "v8.3a",
942 ARMBuildAttrs::CPUArch::v8_A));
943 EXPECT_TRUE(testAArch64Arch("armv8.4-a", "generic", "v8.4a",
944 ARMBuildAttrs::CPUArch::v8_A));
945 EXPECT_TRUE(testAArch64Arch("armv8.5-a", "generic", "v8.5a",
946 ARMBuildAttrs::CPUArch::v8_A));
949 bool testAArch64Extension(StringRef CPUName, AArch64::ArchKind AK,
950 StringRef ArchExt) {
951 return AArch64::getDefaultExtensions(CPUName, AK) &
952 AArch64::parseArchExt(ArchExt);
955 TEST(TargetParserTest, testAArch64Extension) {
956 EXPECT_FALSE(testAArch64Extension("cortex-a35",
957 AArch64::ArchKind::INVALID, "ras"));
958 EXPECT_FALSE(testAArch64Extension("cortex-a53",
959 AArch64::ArchKind::INVALID, "ras"));
960 EXPECT_TRUE(testAArch64Extension("cortex-a55",
961 AArch64::ArchKind::INVALID, "ras"));
962 EXPECT_FALSE(testAArch64Extension("cortex-a57",
963 AArch64::ArchKind::INVALID, "ras"));
964 EXPECT_FALSE(testAArch64Extension("cortex-a72",
965 AArch64::ArchKind::INVALID, "ras"));
966 EXPECT_FALSE(testAArch64Extension("cortex-a73",
967 AArch64::ArchKind::INVALID, "ras"));
968 EXPECT_TRUE(testAArch64Extension("cortex-a75",
969 AArch64::ArchKind::INVALID, "ras"));
970 EXPECT_FALSE(testAArch64Extension("cyclone",
971 AArch64::ArchKind::INVALID, "ras"));
972 EXPECT_FALSE(testAArch64Extension("exynos-m1",
973 AArch64::ArchKind::INVALID, "ras"));
974 EXPECT_FALSE(testAArch64Extension("exynos-m2",
975 AArch64::ArchKind::INVALID, "ras"));
976 EXPECT_FALSE(testAArch64Extension("exynos-m3",
977 AArch64::ArchKind::INVALID, "ras"));
978 EXPECT_TRUE(testAArch64Extension("exynos-m4",
979 AArch64::ArchKind::INVALID, "dotprod"));
980 EXPECT_TRUE(testAArch64Extension("exynos-m4",
981 AArch64::ArchKind::INVALID, "fp16"));
982 EXPECT_TRUE(testAArch64Extension("exynos-m4",
983 AArch64::ArchKind::INVALID, "lse"));
984 EXPECT_TRUE(testAArch64Extension("exynos-m4",
985 AArch64::ArchKind::INVALID, "ras"));
986 EXPECT_TRUE(testAArch64Extension("exynos-m4",
987 AArch64::ArchKind::INVALID, "rdm"));
988 EXPECT_TRUE(testAArch64Extension("exynos-m5",
989 AArch64::ArchKind::INVALID, "dotprod"));
990 EXPECT_TRUE(testAArch64Extension("exynos-m5",
991 AArch64::ArchKind::INVALID, "fp16"));
992 EXPECT_TRUE(testAArch64Extension("exynos-m5",
993 AArch64::ArchKind::INVALID, "lse"));
994 EXPECT_TRUE(testAArch64Extension("exynos-m5",
995 AArch64::ArchKind::INVALID, "ras"));
996 EXPECT_TRUE(testAArch64Extension("exynos-m5",
997 AArch64::ArchKind::INVALID, "rdm"));
998 EXPECT_TRUE(testAArch64Extension("falkor",
999 AArch64::ArchKind::INVALID, "rdm"));
1000 EXPECT_FALSE(testAArch64Extension("kryo",
1001 AArch64::ArchKind::INVALID, "ras"));
1002 EXPECT_TRUE(testAArch64Extension("saphira",
1003 AArch64::ArchKind::INVALID, "crc"));
1004 EXPECT_TRUE(testAArch64Extension("saphira",
1005 AArch64::ArchKind::INVALID, "lse"));
1006 EXPECT_TRUE(testAArch64Extension("saphira",
1007 AArch64::ArchKind::INVALID, "rdm"));
1008 EXPECT_TRUE(testAArch64Extension("saphira",
1009 AArch64::ArchKind::INVALID, "ras"));
1010 EXPECT_TRUE(testAArch64Extension("saphira",
1011 AArch64::ArchKind::INVALID, "rcpc"));
1012 EXPECT_TRUE(testAArch64Extension("saphira",
1013 AArch64::ArchKind::INVALID, "profile"));
1014 EXPECT_FALSE(testAArch64Extension("saphira",
1015 AArch64::ArchKind::INVALID, "fp16"));
1016 EXPECT_TRUE(testAArch64Extension("cortex-a55",
1017 AArch64::ArchKind::INVALID, "fp16"));
1018 EXPECT_FALSE(testAArch64Extension("cortex-a55",
1019 AArch64::ArchKind::INVALID, "fp16fml"));
1020 EXPECT_TRUE(testAArch64Extension("cortex-a55",
1021 AArch64::ArchKind::INVALID, "dotprod"));
1022 EXPECT_TRUE(testAArch64Extension("cortex-a75",
1023 AArch64::ArchKind::INVALID, "fp16"));
1024 EXPECT_FALSE(testAArch64Extension("cortex-a75",
1025 AArch64::ArchKind::INVALID, "fp16fml"));
1026 EXPECT_TRUE(testAArch64Extension("cortex-a75",
1027 AArch64::ArchKind::INVALID, "dotprod"));
1028 EXPECT_FALSE(testAArch64Extension("thunderx2t99",
1029 AArch64::ArchKind::INVALID, "ras"));
1030 EXPECT_FALSE(testAArch64Extension("thunderx",
1031 AArch64::ArchKind::INVALID, "lse"));
1032 EXPECT_FALSE(testAArch64Extension("thunderxt81",
1033 AArch64::ArchKind::INVALID, "lse"));
1034 EXPECT_FALSE(testAArch64Extension("thunderxt83",
1035 AArch64::ArchKind::INVALID, "lse"));
1036 EXPECT_FALSE(testAArch64Extension("thunderxt88",
1037 AArch64::ArchKind::INVALID, "lse"));
1038 EXPECT_TRUE(testAArch64Extension("tsv110",
1039 AArch64::ArchKind::INVALID, "crypto"));
1040 EXPECT_FALSE(testAArch64Extension("tsv110",
1041 AArch64::ArchKind::INVALID, "sha3"));
1042 EXPECT_FALSE(testAArch64Extension("tsv110",
1043 AArch64::ArchKind::INVALID, "sm4"));
1044 EXPECT_TRUE(testAArch64Extension("tsv110",
1045 AArch64::ArchKind::INVALID, "ras"));
1046 EXPECT_TRUE(testAArch64Extension("tsv110",
1047 AArch64::ArchKind::INVALID, "profile"));
1048 EXPECT_TRUE(testAArch64Extension("tsv110",
1049 AArch64::ArchKind::INVALID, "fp16"));
1050 EXPECT_TRUE(testAArch64Extension("tsv110",
1051 AArch64::ArchKind::INVALID, "fp16fml"));
1052 EXPECT_TRUE(testAArch64Extension("tsv110",
1053 AArch64::ArchKind::INVALID, "dotprod"));
1055 EXPECT_FALSE(testAArch64Extension(
1056 "generic", AArch64::ArchKind::ARMV8A, "ras"));
1057 EXPECT_FALSE(testAArch64Extension(
1058 "generic", AArch64::ArchKind::ARMV8_1A, "ras"));
1059 EXPECT_FALSE(testAArch64Extension(
1060 "generic", AArch64::ArchKind::ARMV8_2A, "profile"));
1061 EXPECT_FALSE(testAArch64Extension(
1062 "generic", AArch64::ArchKind::ARMV8_2A, "fp16"));
1063 EXPECT_FALSE(testAArch64Extension(
1064 "generic", AArch64::ArchKind::ARMV8_2A, "fp16fml"));
1065 EXPECT_FALSE(testAArch64Extension(
1066 "generic", AArch64::ArchKind::ARMV8_3A, "fp16"));
1067 EXPECT_FALSE(testAArch64Extension(
1068 "generic", AArch64::ArchKind::ARMV8_3A, "fp16fml"));
1069 EXPECT_FALSE(testAArch64Extension(
1070 "generic", AArch64::ArchKind::ARMV8_4A, "fp16"));
1071 EXPECT_FALSE(testAArch64Extension(
1072 "generic", AArch64::ArchKind::ARMV8_4A, "fp16fml"));
1075 TEST(TargetParserTest, AArch64ExtensionFeatures) {
1076 std::vector<unsigned> Extensions = {
1077 AArch64::AEK_CRC, AArch64::AEK_CRYPTO,
1078 AArch64::AEK_FP, AArch64::AEK_SIMD,
1079 AArch64::AEK_FP16, AArch64::AEK_PROFILE,
1080 AArch64::AEK_RAS, AArch64::AEK_LSE,
1081 AArch64::AEK_RDM, AArch64::AEK_DOTPROD,
1082 AArch64::AEK_SVE, AArch64::AEK_SVE2,
1083 AArch64::AEK_SVE2AES, AArch64::AEK_SVE2SM4,
1084 AArch64::AEK_SVE2SHA3, AArch64::AEK_SVE2BITPERM,
1085 AArch64::AEK_RCPC, AArch64::AEK_FP16FML };
1087 std::vector<StringRef> Features;
1089 unsigned ExtVal = 0;
1090 for (auto Ext : Extensions)
1091 ExtVal |= Ext;
1093 EXPECT_FALSE(AArch64::getExtensionFeatures(AArch64::AEK_INVALID, Features));
1094 EXPECT_TRUE(!Features.size());
1096 AArch64::getExtensionFeatures(ExtVal, Features);
1097 EXPECT_TRUE(Extensions.size() == Features.size());
1099 auto B = std::begin(Features);
1100 auto E = std::end(Features);
1102 EXPECT_TRUE(std::find(B, E, "+crc") != E);
1103 EXPECT_TRUE(std::find(B, E, "+crypto") != E);
1104 EXPECT_TRUE(std::find(B, E, "+fp-armv8") != E);
1105 EXPECT_TRUE(std::find(B, E, "+neon") != E);
1106 EXPECT_TRUE(std::find(B, E, "+fullfp16") != E);
1107 EXPECT_TRUE(std::find(B, E, "+spe") != E);
1108 EXPECT_TRUE(std::find(B, E, "+ras") != E);
1109 EXPECT_TRUE(std::find(B, E, "+lse") != E);
1110 EXPECT_TRUE(std::find(B, E, "+rdm") != E);
1111 EXPECT_TRUE(std::find(B, E, "+dotprod") != E);
1112 EXPECT_TRUE(std::find(B, E, "+rcpc") != E);
1113 EXPECT_TRUE(std::find(B, E, "+fp16fml") != E);
1114 EXPECT_TRUE(std::find(B, E, "+sve") != E);
1115 EXPECT_TRUE(std::find(B, E, "+sve2") != E);
1116 EXPECT_TRUE(std::find(B, E, "+sve2-aes") != E);
1117 EXPECT_TRUE(std::find(B, E, "+sve2-sm4") != E);
1118 EXPECT_TRUE(std::find(B, E, "+sve2-sha3") != E);
1119 EXPECT_TRUE(std::find(B, E, "+sve2-bitperm") != E);
1122 TEST(TargetParserTest, AArch64ArchFeatures) {
1123 std::vector<StringRef> Features;
1125 for (auto AK : AArch64::ArchKinds)
1126 EXPECT_TRUE((AK == AArch64::ArchKind::INVALID)
1127 ? !AArch64::getArchFeatures(AK, Features)
1128 : AArch64::getArchFeatures(AK, Features));
1131 TEST(TargetParserTest, AArch64ArchExtFeature) {
1132 const char *ArchExt[][4] = {{"crc", "nocrc", "+crc", "-crc"},
1133 {"crypto", "nocrypto", "+crypto", "-crypto"},
1134 {"fp", "nofp", "+fp-armv8", "-fp-armv8"},
1135 {"simd", "nosimd", "+neon", "-neon"},
1136 {"fp16", "nofp16", "+fullfp16", "-fullfp16"},
1137 {"fp16fml", "nofp16fml", "+fp16fml", "-fp16fml"},
1138 {"profile", "noprofile", "+spe", "-spe"},
1139 {"ras", "noras", "+ras", "-ras"},
1140 {"lse", "nolse", "+lse", "-lse"},
1141 {"rdm", "nordm", "+rdm", "-rdm"},
1142 {"sve", "nosve", "+sve", "-sve"},
1143 {"sve2", "nosve2", "+sve2", "-sve2"},
1144 {"sve2-aes", "nosve2-aes", "+sve2-aes",
1145 "-sve2-aes"},
1146 {"sve2-sm4", "nosve2-sm4", "+sve2-sm4",
1147 "-sve2-sm4"},
1148 {"sve2-sha3", "nosve2-sha3", "+sve2-sha3",
1149 "-sve2-sha3"},
1150 {"sve2-bitperm", "nosve2-bitperm",
1151 "+sve2-bitperm", "-sve2-bitperm"},
1152 {"dotprod", "nodotprod", "+dotprod", "-dotprod"},
1153 {"rcpc", "norcpc", "+rcpc", "-rcpc" },
1154 {"rng", "norng", "+rand", "-rand"},
1155 {"memtag", "nomemtag", "+mte", "-mte"},
1156 {"tme", "notme", "+tme", "-tme"},
1157 {"ssbs", "nossbs", "+ssbs", "-ssbs"},
1158 {"sb", "nosb", "+sb", "-sb"},
1159 {"predres", "nopredres", "+predres", "-predres"}
1162 for (unsigned i = 0; i < array_lengthof(ArchExt); i++) {
1163 EXPECT_EQ(StringRef(ArchExt[i][2]),
1164 AArch64::getArchExtFeature(ArchExt[i][0]));
1165 EXPECT_EQ(StringRef(ArchExt[i][3]),
1166 AArch64::getArchExtFeature(ArchExt[i][1]));