[ELF] Make some InputSection/InputFile member functions const. NFC
[llvm-project.git] / llvm / unittests / TargetParser / TargetParserTest.cpp
blobd41e254922562c95a57faace11a316e83a9cbf1e
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/TargetParser/TargetParser.h"
10 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/ADT/StringMap.h"
12 #include "llvm/ADT/StringExtras.h"
13 #include "llvm/Support/ARMBuildAttributes.h"
14 #include "llvm/Support/FormatVariadic.h"
15 #include "llvm/TargetParser/AArch64TargetParser.h"
16 #include "llvm/TargetParser/ARMTargetParser.h"
17 #include "llvm/TargetParser/ARMTargetParserCommon.h"
18 #include "llvm/TargetParser/Triple.h"
19 #include "gmock/gmock.h"
20 #include "gtest/gtest.h"
21 #include <optional>
22 #include <sstream>
23 #include <string>
25 using namespace llvm;
27 namespace {
28 const char *ARMArch[] = {
29 "armv4", "armv4t", "armv5", "armv5t", "armv5e",
30 "armv5te", "armv5tej", "armv6", "armv6j", "armv6k",
31 "armv6hl", "armv6t2", "armv6kz", "armv6z", "armv6zk",
32 "armv6-m", "armv6m", "armv6sm", "armv6s-m", "armv7-a",
33 "armv7", "armv7a", "armv7ve", "armv7hl", "armv7l",
34 "armv7-r", "armv7r", "armv7-m", "armv7m", "armv7k",
35 "armv7s", "armv7e-m", "armv7em", "armv8-a", "armv8",
36 "armv8a", "armv8l", "armv8.1-a", "armv8.1a", "armv8.2-a",
37 "armv8.2a", "armv8.3-a", "armv8.3a", "armv8.4-a", "armv8.4a",
38 "armv8.5-a", "armv8.5a", "armv8.6-a", "armv8.6a", "armv8.7-a",
39 "armv8.7a", "armv8.8-a", "armv8.8a", "armv8.9-a", "armv8.9a",
40 "armv8-r", "armv8r", "armv8-m.base", "armv8m.base", "armv8-m.main",
41 "armv8m.main", "iwmmxt", "iwmmxt2", "xscale", "armv8.1-m.main",
42 "armv9-a", "armv9", "armv9a", "armv9.1-a", "armv9.1a",
43 "armv9.2-a", "armv9.2a", "armv9.3-a", "armv9.3a", "armv9.4-a",
44 "armv9.4a",
47 std::string FormatExtensionFlags(int64_t Flags) {
48 std::vector<StringRef> Features;
50 if (Flags & ARM::AEK_NONE)
51 Features.push_back("none");
52 ARM::getExtensionFeatures(Flags, Features);
54 // The target parser also includes every extension you don't have.
55 // E.g. if AEK_CRC is not set then it adds "-crc". Not useful here.
56 Features.erase(std::remove_if(Features.begin(), Features.end(),
57 [](StringRef extension) {
58 return extension.startswith("-");
59 }),
60 Features.end());
62 return llvm::join(Features, ", ");
65 std::string FormatExtensionFlags(AArch64::ExtensionBitset Flags) {
66 std::vector<StringRef> Features;
68 // AEK_NONE is not meant to be shown to the user so the target parser
69 // does not recognise it. It is relevant here though.
70 if (Flags.test(AArch64::AEK_NONE))
71 Features.push_back("none");
72 AArch64::getExtensionFeatures(Flags, Features);
74 // The target parser also includes every extension you don't have.
75 // E.g. if AEK_CRC is not set then it adds "-crc". Not useful here.
76 Features.erase(std::remove_if(Features.begin(), Features.end(),
77 [](StringRef extension) {
78 return extension.startswith("-");
79 }),
80 Features.end());
82 return llvm::join(Features, ", ");
85 std::string SerializeExtensionFlags(AArch64::ExtensionBitset Flags) {
86 std::string SerializedFlags;
87 std::ostringstream ss;
88 int HexValue = 0;
89 for (unsigned int i = 0; i < AArch64::AEK_NUM_EXTENSIONS; i++) {
90 HexValue <<= 1;
91 HexValue |= (int)Flags[i];
92 if ((i + 1) % 4 == 0) {
93 ss << std::hex << HexValue;
94 HexValue = 0;
97 // check if there are remainig unhandled bits
98 if ((AArch64::AEK_NUM_EXTENSIONS % 4) != 0)
99 ss << std::hex << HexValue;
101 SerializedFlags = ss.str();
102 return SerializedFlags;
105 template <ARM::ISAKind ISAKind> struct AssertSameExtensionFlags {
106 AssertSameExtensionFlags(StringRef CPUName) : CPUName(CPUName) {}
108 testing::AssertionResult operator()(const char *m_expr, const char *n_expr,
109 uint64_t ExpectedFlags,
110 uint64_t GotFlags) {
111 if (ExpectedFlags == GotFlags)
112 return testing::AssertionSuccess();
114 return testing::AssertionFailure() << llvm::formatv(
115 "CPU: {4}\n"
116 "Expected extension flags: {0} ({1:x})\n"
117 " Got extension flags: {2} ({3:x})\n",
118 FormatExtensionFlags(ExpectedFlags),
119 ExpectedFlags, FormatExtensionFlags(GotFlags),
120 ExpectedFlags, CPUName);
123 testing::AssertionResult
124 operator()(const char *m_expr, const char *n_expr,
125 AArch64::ExtensionBitset ExpectedFlags,
126 AArch64::ExtensionBitset GotFlags) {
127 if (ExpectedFlags == GotFlags)
128 return testing::AssertionSuccess();
130 return testing::AssertionFailure() << llvm::formatv(
131 "CPU: {4}\n"
132 "Expected extension flags: {0} ({1:x})\n"
133 " Got extension flags: {2} ({3:x})\n",
134 FormatExtensionFlags(ExpectedFlags),
135 SerializeExtensionFlags(ExpectedFlags),
136 FormatExtensionFlags(GotFlags),
137 SerializeExtensionFlags(ExpectedFlags), CPUName);
140 private:
141 StringRef CPUName;
144 template <typename T> struct ARMCPUTestParams {
145 ARMCPUTestParams(StringRef CPUName, StringRef ExpectedArch,
146 StringRef ExpectedFPU, T ExpectedFlags, StringRef CPUAttr)
147 : CPUName(CPUName), ExpectedArch(ExpectedArch), ExpectedFPU(ExpectedFPU),
148 ExpectedFlags(ExpectedFlags), CPUAttr(CPUAttr) {}
150 friend std::ostream &operator<<(std::ostream &os,
151 const ARMCPUTestParams<T> &params) {
152 os << "\"" << params.CPUName.str() << "\", \"" << params.ExpectedArch.str()
153 << "\", \"" << params.ExpectedFPU.str() << "\", 0x";
154 if constexpr (std::is_same<T, uint64_t>::value)
155 os << std::hex << params.ExpectedFlags;
156 else
157 os << SerializeExtensionFlags(params.ExpectedFlags);
158 os << ", \"" << params.CPUAttr.str() << "\"";
159 return os;
162 StringRef CPUName;
163 StringRef ExpectedArch;
164 StringRef ExpectedFPU;
165 T ExpectedFlags;
166 StringRef CPUAttr;
169 class ARMCPUTestFixture
170 : public ::testing::TestWithParam<ARMCPUTestParams<uint64_t>> {};
172 TEST_P(ARMCPUTestFixture, ARMCPUTests) {
173 auto params = GetParam();
175 ARM::ArchKind AK = ARM::parseCPUArch(params.CPUName);
176 EXPECT_EQ(params.ExpectedArch, ARM::getArchName(AK));
178 ARM::FPUKind FPUKind = ARM::getDefaultFPU(params.CPUName, AK);
179 EXPECT_EQ(params.ExpectedFPU, ARM::getFPUName(FPUKind));
181 uint64_t default_extensions = ARM::getDefaultExtensions(params.CPUName, AK);
182 EXPECT_PRED_FORMAT2(
183 AssertSameExtensionFlags<ARM::ISAKind::ARM>(params.CPUName),
184 params.ExpectedFlags, default_extensions);
186 EXPECT_EQ(params.CPUAttr, ARM::getCPUAttr(AK));
189 // Note that we include ARM::AEK_NONE even when there are other extensions
190 // we expect. This is because the default extensions for a CPU are the sum
191 // of the default extensions for its architecture and for the CPU.
192 // So if a CPU has no extra extensions, it adds AEK_NONE.
193 INSTANTIATE_TEST_SUITE_P(
194 ARMCPUTestsPart1, ARMCPUTestFixture,
195 ::testing::Values(
196 ARMCPUTestParams<uint64_t>("invalid", "invalid", "invalid", ARM::AEK_NONE, ""),
197 ARMCPUTestParams<uint64_t>("generic", "invalid", "none", ARM::AEK_NONE, ""),
199 ARMCPUTestParams<uint64_t>("arm8", "armv4", "none", ARM::AEK_NONE, "4"),
200 ARMCPUTestParams<uint64_t>("arm810", "armv4", "none", ARM::AEK_NONE, "4"),
201 ARMCPUTestParams<uint64_t>("strongarm", "armv4", "none", ARM::AEK_NONE, "4"),
202 ARMCPUTestParams<uint64_t>("strongarm110", "armv4", "none", ARM::AEK_NONE, "4"),
203 ARMCPUTestParams<uint64_t>("strongarm1100", "armv4", "none", ARM::AEK_NONE, "4"),
204 ARMCPUTestParams<uint64_t>("strongarm1110", "armv4", "none", ARM::AEK_NONE, "4"),
205 ARMCPUTestParams<uint64_t>("arm7tdmi", "armv4t", "none", ARM::AEK_NONE, "4T"),
206 ARMCPUTestParams<uint64_t>("arm7tdmi-s", "armv4t", "none", ARM::AEK_NONE, "4T"),
207 ARMCPUTestParams<uint64_t>("arm710t", "armv4t", "none", ARM::AEK_NONE, "4T"),
208 ARMCPUTestParams<uint64_t>("arm720t", "armv4t", "none", ARM::AEK_NONE, "4T"),
209 ARMCPUTestParams<uint64_t>("arm9", "armv4t", "none", ARM::AEK_NONE, "4T"),
210 ARMCPUTestParams<uint64_t>("arm9tdmi", "armv4t", "none", ARM::AEK_NONE, "4T"),
211 ARMCPUTestParams<uint64_t>("arm920", "armv4t", "none", ARM::AEK_NONE, "4T"),
212 ARMCPUTestParams<uint64_t>("arm920t", "armv4t", "none", ARM::AEK_NONE, "4T"),
213 ARMCPUTestParams<uint64_t>("arm922t", "armv4t", "none", ARM::AEK_NONE, "4T"),
214 ARMCPUTestParams<uint64_t>("arm940t", "armv4t", "none", ARM::AEK_NONE, "4T"),
215 ARMCPUTestParams<uint64_t>("ep9312", "armv4t", "none", ARM::AEK_NONE, "4T"),
216 ARMCPUTestParams<uint64_t>("arm10tdmi", "armv5t", "none", ARM::AEK_NONE, "5T"),
217 ARMCPUTestParams<uint64_t>("arm1020t", "armv5t", "none", ARM::AEK_NONE, "5T"),
218 ARMCPUTestParams<uint64_t>("arm9e", "armv5te", "none",
219 ARM::AEK_NONE | ARM::AEK_DSP, "5TE"),
220 ARMCPUTestParams<uint64_t>("arm946e-s", "armv5te", "none",
221 ARM::AEK_NONE | ARM::AEK_DSP, "5TE"),
222 ARMCPUTestParams<uint64_t>("arm966e-s", "armv5te", "none",
223 ARM::AEK_NONE | ARM::AEK_DSP, "5TE"),
224 ARMCPUTestParams<uint64_t>("arm968e-s", "armv5te", "none",
225 ARM::AEK_NONE | ARM::AEK_DSP, "5TE"),
226 ARMCPUTestParams<uint64_t>("arm10e", "armv5te", "none",
227 ARM::AEK_NONE | ARM::AEK_DSP, "5TE"),
228 ARMCPUTestParams<uint64_t>("arm1020e", "armv5te", "none",
229 ARM::AEK_NONE | ARM::AEK_DSP, "5TE"),
230 ARMCPUTestParams<uint64_t>("arm1022e", "armv5te", "none",
231 ARM::AEK_NONE | ARM::AEK_DSP, "5TE"),
232 ARMCPUTestParams<uint64_t>("arm926ej-s", "armv5tej", "none",
233 ARM::AEK_NONE | ARM::AEK_DSP, "5TEJ"),
234 ARMCPUTestParams<uint64_t>("arm1136j-s", "armv6", "none",
235 ARM::AEK_NONE | ARM::AEK_DSP, "6"),
236 ARMCPUTestParams<uint64_t>("arm1136jf-s", "armv6", "vfpv2",
237 ARM::AEK_NONE | ARM::AEK_DSP, "6"),
238 ARMCPUTestParams<uint64_t>("arm1176jz-s", "armv6kz", "none",
239 ARM::AEK_NONE | ARM::AEK_SEC | ARM::AEK_DSP, "6KZ"),
240 ARMCPUTestParams<uint64_t>("mpcore", "armv6k", "vfpv2",
241 ARM::AEK_NONE | ARM::AEK_DSP, "6K"),
242 ARMCPUTestParams<uint64_t>("mpcorenovfp", "armv6k", "none",
243 ARM::AEK_NONE | ARM::AEK_DSP, "6K"),
244 ARMCPUTestParams<uint64_t>("arm1176jzf-s", "armv6kz", "vfpv2",
245 ARM::AEK_NONE | ARM::AEK_SEC | ARM::AEK_DSP, "6KZ"),
246 ARMCPUTestParams<uint64_t>("arm1156t2-s", "armv6t2", "none",
247 ARM::AEK_NONE | ARM::AEK_DSP, "6T2"),
248 ARMCPUTestParams<uint64_t>("arm1156t2f-s", "armv6t2", "vfpv2",
249 ARM::AEK_NONE | ARM::AEK_DSP, "6T2"),
250 ARMCPUTestParams<uint64_t>("cortex-m0", "armv6-m", "none", ARM::AEK_NONE, "6-M"),
251 ARMCPUTestParams<uint64_t>("cortex-m0plus", "armv6-m", "none", ARM::AEK_NONE,
252 "6-M"),
253 ARMCPUTestParams<uint64_t>("cortex-m1", "armv6-m", "none", ARM::AEK_NONE, "6-M"),
254 ARMCPUTestParams<uint64_t>("sc000", "armv6-m", "none", ARM::AEK_NONE, "6-M"),
255 ARMCPUTestParams<uint64_t>("cortex-a5", "armv7-a", "neon-vfpv4",
256 ARM::AEK_MP | ARM::AEK_SEC | ARM::AEK_DSP, "7-A"),
257 ARMCPUTestParams<uint64_t>("cortex-a7", "armv7-a", "neon-vfpv4",
258 ARM::AEK_HWDIVTHUMB | ARM::AEK_HWDIVARM | ARM::AEK_MP |
259 ARM::AEK_SEC | ARM::AEK_VIRT | ARM::AEK_DSP,
260 "7-A"),
261 ARMCPUTestParams<uint64_t>("cortex-a8", "armv7-a", "neon",
262 ARM::AEK_SEC | ARM::AEK_DSP, "7-A")));
264 // gtest in llvm has a limit of 50 test cases when using ::Values so we split
265 // them into 2 blocks
266 INSTANTIATE_TEST_SUITE_P(
267 ARMCPUTestsPart2, ARMCPUTestFixture,
268 ::testing::Values(
269 ARMCPUTestParams<uint64_t>("cortex-a9", "armv7-a", "neon-fp16",
270 ARM::AEK_MP | ARM::AEK_SEC | ARM::AEK_DSP, "7-A"),
271 ARMCPUTestParams<uint64_t>("cortex-a12", "armv7-a", "neon-vfpv4",
272 ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
273 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
274 ARM::AEK_DSP,
275 "7-A"),
276 ARMCPUTestParams<uint64_t>("cortex-a15", "armv7-a", "neon-vfpv4",
277 ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
278 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
279 ARM::AEK_DSP,
280 "7-A"),
281 ARMCPUTestParams<uint64_t>("cortex-a17", "armv7-a", "neon-vfpv4",
282 ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
283 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
284 ARM::AEK_DSP,
285 "7-A"),
286 ARMCPUTestParams<uint64_t>("krait", "armv7-a", "neon-vfpv4",
287 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
288 "7-A"),
289 ARMCPUTestParams<uint64_t>("cortex-r4", "armv7-r", "none",
290 ARM::AEK_NONE | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
291 "7-R"),
292 ARMCPUTestParams<uint64_t>("cortex-r4f", "armv7-r", "vfpv3-d16",
293 ARM::AEK_NONE | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
294 "7-R"),
295 ARMCPUTestParams<uint64_t>("cortex-r5", "armv7-r", "vfpv3-d16",
296 ARM::AEK_MP | ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
297 ARM::AEK_DSP,
298 "7-R"),
299 ARMCPUTestParams<uint64_t>("cortex-r7", "armv7-r", "vfpv3-d16-fp16",
300 ARM::AEK_MP | ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
301 ARM::AEK_DSP,
302 "7-R"),
303 ARMCPUTestParams<uint64_t>("cortex-r8", "armv7-r", "vfpv3-d16-fp16",
304 ARM::AEK_MP | ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
305 ARM::AEK_DSP,
306 "7-R"),
307 ARMCPUTestParams<uint64_t>("cortex-r52", "armv8-r", "neon-fp-armv8",
308 ARM::AEK_NONE | ARM::AEK_CRC | ARM::AEK_MP |
309 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
310 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
311 "8-R"),
312 ARMCPUTestParams<uint64_t>("sc300", "armv7-m", "none",
313 ARM::AEK_NONE | ARM::AEK_HWDIVTHUMB, "7-M"),
314 ARMCPUTestParams<uint64_t>("cortex-m3", "armv7-m", "none",
315 ARM::AEK_NONE | ARM::AEK_HWDIVTHUMB, "7-M"),
316 ARMCPUTestParams<uint64_t>("cortex-m4", "armv7e-m", "fpv4-sp-d16",
317 ARM::AEK_NONE | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
318 "7E-M"),
319 ARMCPUTestParams<uint64_t>("cortex-m7", "armv7e-m", "fpv5-d16",
320 ARM::AEK_NONE | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
321 "7E-M"),
322 ARMCPUTestParams<uint64_t>("cortex-a32", "armv8-a", "crypto-neon-fp-armv8",
323 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
324 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
325 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
326 "8-A"),
327 ARMCPUTestParams<uint64_t>("cortex-a35", "armv8-a", "crypto-neon-fp-armv8",
328 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
329 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
330 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
331 "8-A"),
332 ARMCPUTestParams<uint64_t>("cortex-a53", "armv8-a", "crypto-neon-fp-armv8",
333 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
334 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
335 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
336 "8-A"),
337 ARMCPUTestParams<uint64_t>("cortex-a55", "armv8.2-a", "crypto-neon-fp-armv8",
338 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
339 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
340 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP |
341 ARM::AEK_FP16 | ARM::AEK_RAS | ARM::AEK_DOTPROD,
342 "8.2-A"),
343 ARMCPUTestParams<uint64_t>("cortex-a57", "armv8-a", "crypto-neon-fp-armv8",
344 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
345 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
346 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
347 "8-A"),
348 ARMCPUTestParams<uint64_t>("cortex-a72", "armv8-a", "crypto-neon-fp-armv8",
349 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
350 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
351 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
352 "8-A"),
353 ARMCPUTestParams<uint64_t>("cortex-a73", "armv8-a", "crypto-neon-fp-armv8",
354 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
355 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
356 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
357 "8-A"),
358 ARMCPUTestParams<uint64_t>("cortex-a75", "armv8.2-a", "crypto-neon-fp-armv8",
359 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
360 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
361 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP |
362 ARM::AEK_FP16 | ARM::AEK_RAS | ARM::AEK_DOTPROD,
363 "8.2-A"),
364 ARMCPUTestParams<uint64_t>("cortex-a76", "armv8.2-a", "crypto-neon-fp-armv8",
365 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
366 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
367 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP |
368 ARM::AEK_FP16 | ARM::AEK_RAS | ARM::AEK_DOTPROD,
369 "8.2-A"),
370 ARMCPUTestParams<uint64_t>("cortex-a76ae", "armv8.2-a", "crypto-neon-fp-armv8",
371 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
372 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
373 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP |
374 ARM::AEK_FP16 | ARM::AEK_RAS | ARM::AEK_DOTPROD,
375 "8.2-A"),
376 ARMCPUTestParams<uint64_t>("cortex-a78c", "armv8.2-a", "crypto-neon-fp-armv8",
377 ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
378 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
379 ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS |
380 ARM::AEK_FP16 | ARM::AEK_DOTPROD,
381 "8.2-A"),
382 ARMCPUTestParams<uint64_t>("cortex-a710", "armv9-a", "neon-fp-armv8",
383 ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
384 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
385 ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS |
386 ARM::AEK_DOTPROD | ARM::AEK_FP16FML |
387 ARM::AEK_BF16 | ARM::AEK_I8MM | ARM::AEK_SB,
388 "9-A"),
389 ARMCPUTestParams<uint64_t>("cortex-a77", "armv8.2-a", "crypto-neon-fp-armv8",
390 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
391 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
392 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP |
393 ARM::AEK_FP16 | ARM::AEK_RAS | ARM::AEK_DOTPROD,
394 "8.2-A"),
395 ARMCPUTestParams<uint64_t>("cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
396 ARM::AEK_DOTPROD | ARM::AEK_FP16 | ARM::AEK_SEC |
397 ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
398 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_CRC |
399 ARM::AEK_RAS,
400 "8.2-A"),
401 ARMCPUTestParams<uint64_t>("cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
402 ARM::AEK_RAS | ARM::AEK_FP16 | ARM::AEK_DOTPROD |
403 ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
404 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
405 ARM::AEK_DSP | ARM::AEK_CRC,
406 "8.2-A"),
407 ARMCPUTestParams<uint64_t>("cortex-x1c", "armv8.2-a", "crypto-neon-fp-armv8",
408 ARM::AEK_RAS | ARM::AEK_FP16 | ARM::AEK_DOTPROD |
409 ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
410 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
411 ARM::AEK_DSP | ARM::AEK_CRC,
412 "8.2-A"),
413 ARMCPUTestParams<uint64_t>("neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
414 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
415 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
416 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP |
417 ARM::AEK_FP16 | ARM::AEK_RAS | ARM::AEK_DOTPROD,
418 "8.2-A"),
419 ARMCPUTestParams<uint64_t>("neoverse-n2", "armv8.5-a", "crypto-neon-fp-armv8",
420 ARM::AEK_CRC | ARM::AEK_HWDIVTHUMB |
421 ARM::AEK_HWDIVARM | ARM::AEK_MP | ARM::AEK_SEC |
422 ARM::AEK_VIRT | ARM::AEK_DSP | ARM::AEK_BF16 |
423 ARM::AEK_DOTPROD | ARM::AEK_RAS | ARM::AEK_I8MM |
424 ARM::AEK_SB,
425 "8.5-A"),
426 ARMCPUTestParams<uint64_t>("neoverse-v1", "armv8.4-a", "crypto-neon-fp-armv8",
427 ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
428 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
429 ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS |
430 ARM::AEK_FP16 | ARM::AEK_BF16 | ARM::AEK_DOTPROD,
431 "8.4-A"),
432 ARMCPUTestParams<uint64_t>("cyclone", "armv8-a", "crypto-neon-fp-armv8",
433 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
434 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
435 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
436 "8-A"),
437 ARMCPUTestParams<uint64_t>("exynos-m3", "armv8-a", "crypto-neon-fp-armv8",
438 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
439 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
440 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
441 "8-A"),
442 ARMCPUTestParams<uint64_t>("exynos-m4", "armv8.2-a", "crypto-neon-fp-armv8",
443 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
444 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
445 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP |
446 ARM::AEK_DOTPROD | ARM::AEK_FP16 | ARM::AEK_RAS,
447 "8.2-A"),
448 ARMCPUTestParams<uint64_t>("exynos-m5", "armv8.2-a", "crypto-neon-fp-armv8",
449 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
450 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
451 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP |
452 ARM::AEK_DOTPROD | ARM::AEK_FP16 | ARM::AEK_RAS,
453 "8.2-A"),
454 ARMCPUTestParams<uint64_t>("cortex-m23", "armv8-m.base", "none",
455 ARM::AEK_NONE | ARM::AEK_HWDIVTHUMB, "8-M.Baseline"),
456 ARMCPUTestParams<uint64_t>("cortex-m33", "armv8-m.main", "fpv5-sp-d16",
457 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP, "8-M.Mainline"),
458 ARMCPUTestParams<uint64_t>("cortex-m35p", "armv8-m.main", "fpv5-sp-d16",
459 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP, "8-M.Mainline"),
460 ARMCPUTestParams<uint64_t>("cortex-m55", "armv8.1-m.main",
461 "fp-armv8-fullfp16-d16",
462 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_SIMD |
463 ARM::AEK_FP | ARM::AEK_RAS | ARM::AEK_LOB |
464 ARM::AEK_FP16,
465 "8.1-M.Mainline"),
466 ARMCPUTestParams<uint64_t>("cortex-m85", "armv8.1-m.main",
467 "fp-armv8-fullfp16-d16",
468 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_SIMD |
469 ARM::AEK_FP | ARM::AEK_RAS | ARM::AEK_LOB |
470 ARM::AEK_FP16 | ARM::AEK_PACBTI,
471 "8.1-M.Mainline"),
472 ARMCPUTestParams<uint64_t>("iwmmxt", "iwmmxt", "none", ARM::AEK_NONE, "iwmmxt"),
473 ARMCPUTestParams<uint64_t>("xscale", "xscale", "none", ARM::AEK_NONE, "xscale"),
474 ARMCPUTestParams<uint64_t>("swift", "armv7s", "neon-vfpv4",
475 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
476 "7-S")));
478 static constexpr unsigned NumARMCPUArchs = 89;
480 TEST(TargetParserTest, testARMCPUArchList) {
481 SmallVector<StringRef, NumARMCPUArchs> List;
482 ARM::fillValidCPUArchList(List);
484 // No list exists for these in this test suite, so ensure all are
485 // valid, and match the expected 'magic' count.
486 EXPECT_EQ(List.size(), NumARMCPUArchs);
487 for(StringRef CPU : List) {
488 EXPECT_NE(ARM::parseCPUArch(CPU), ARM::ArchKind::INVALID);
492 TEST(TargetParserTest, testInvalidARMArch) {
493 auto InvalidArchStrings = {"armv", "armv99", "noarm"};
494 for (const char* InvalidArch : InvalidArchStrings)
495 EXPECT_EQ(ARM::parseArch(InvalidArch), ARM::ArchKind::INVALID);
498 bool testARMArch(StringRef Arch, StringRef DefaultCPU, StringRef SubArch,
499 unsigned ArchAttr) {
500 ARM::ArchKind AK = ARM::parseArch(Arch);
501 bool Result = (AK != ARM::ArchKind::INVALID);
502 Result &= ARM::getDefaultCPU(Arch).equals(DefaultCPU);
503 Result &= ARM::getSubArch(AK).equals(SubArch);
504 Result &= (ARM::getArchAttr(AK) == ArchAttr);
505 return Result;
508 TEST(TargetParserTest, testARMArch) {
509 EXPECT_TRUE(
510 testARMArch("armv4", "strongarm", "v4",
511 ARMBuildAttrs::CPUArch::v4));
512 EXPECT_TRUE(
513 testARMArch("armv4t", "arm7tdmi", "v4t",
514 ARMBuildAttrs::CPUArch::v4T));
515 EXPECT_TRUE(
516 testARMArch("armv5t", "arm10tdmi", "v5",
517 ARMBuildAttrs::CPUArch::v5T));
518 EXPECT_TRUE(
519 testARMArch("armv5te", "arm1022e", "v5e",
520 ARMBuildAttrs::CPUArch::v5TE));
521 EXPECT_TRUE(
522 testARMArch("armv5tej", "arm926ej-s", "v5e",
523 ARMBuildAttrs::CPUArch::v5TEJ));
524 EXPECT_TRUE(
525 testARMArch("armv6", "arm1136jf-s", "v6",
526 ARMBuildAttrs::CPUArch::v6));
527 EXPECT_TRUE(
528 testARMArch("armv6k", "mpcore", "v6k",
529 ARMBuildAttrs::CPUArch::v6K));
530 EXPECT_TRUE(
531 testARMArch("armv6t2", "arm1156t2-s", "v6t2",
532 ARMBuildAttrs::CPUArch::v6T2));
533 EXPECT_TRUE(
534 testARMArch("armv6kz", "arm1176jzf-s", "v6kz",
535 ARMBuildAttrs::CPUArch::v6KZ));
536 EXPECT_TRUE(
537 testARMArch("armv6-m", "cortex-m0", "v6m",
538 ARMBuildAttrs::CPUArch::v6_M));
539 EXPECT_TRUE(
540 testARMArch("armv7-a", "generic", "v7",
541 ARMBuildAttrs::CPUArch::v7));
542 EXPECT_TRUE(
543 testARMArch("armv7ve", "generic", "v7ve",
544 ARMBuildAttrs::CPUArch::v7));
545 EXPECT_TRUE(
546 testARMArch("armv7-r", "cortex-r4", "v7r",
547 ARMBuildAttrs::CPUArch::v7));
548 EXPECT_TRUE(
549 testARMArch("armv7-m", "cortex-m3", "v7m",
550 ARMBuildAttrs::CPUArch::v7));
551 EXPECT_TRUE(
552 testARMArch("armv7e-m", "cortex-m4", "v7em",
553 ARMBuildAttrs::CPUArch::v7E_M));
554 EXPECT_TRUE(
555 testARMArch("armv8-a", "generic", "v8a",
556 ARMBuildAttrs::CPUArch::v8_A));
557 EXPECT_TRUE(
558 testARMArch("armv8.1-a", "generic", "v8.1a",
559 ARMBuildAttrs::CPUArch::v8_A));
560 EXPECT_TRUE(
561 testARMArch("armv8.2-a", "generic", "v8.2a",
562 ARMBuildAttrs::CPUArch::v8_A));
563 EXPECT_TRUE(
564 testARMArch("armv8.3-a", "generic", "v8.3a",
565 ARMBuildAttrs::CPUArch::v8_A));
566 EXPECT_TRUE(
567 testARMArch("armv8.4-a", "generic", "v8.4a",
568 ARMBuildAttrs::CPUArch::v8_A));
569 EXPECT_TRUE(
570 testARMArch("armv8.5-a", "generic", "v8.5a",
571 ARMBuildAttrs::CPUArch::v8_A));
572 EXPECT_TRUE(
573 testARMArch("armv8.6-a", "generic", "v8.6a",
574 ARMBuildAttrs::CPUArch::v8_A));
575 EXPECT_TRUE(
576 testARMArch("armv8.7-a", "generic", "v8.7a",
577 ARMBuildAttrs::CPUArch::v8_A));
578 EXPECT_TRUE(testARMArch("armv8.8-a", "generic", "v8.8a",
579 ARMBuildAttrs::CPUArch::v8_A));
580 EXPECT_TRUE(
581 testARMArch("armv8.9-a", "generic", "v8.9a",
582 ARMBuildAttrs::CPUArch::v8_A));
583 EXPECT_TRUE(
584 testARMArch("armv9-a", "generic", "v9a",
585 ARMBuildAttrs::CPUArch::v9_A));
586 EXPECT_TRUE(
587 testARMArch("armv9.1-a", "generic", "v9.1a",
588 ARMBuildAttrs::CPUArch::v9_A));
589 EXPECT_TRUE(
590 testARMArch("armv9.2-a", "generic", "v9.2a",
591 ARMBuildAttrs::CPUArch::v9_A));
592 EXPECT_TRUE(
593 testARMArch("armv9.3-a", "generic", "v9.3a",
594 ARMBuildAttrs::CPUArch::v9_A));
595 EXPECT_TRUE(
596 testARMArch("armv9.4-a", "generic", "v9.4a",
597 ARMBuildAttrs::CPUArch::v9_A));
598 EXPECT_TRUE(
599 testARMArch("armv8-r", "cortex-r52", "v8r",
600 ARMBuildAttrs::CPUArch::v8_R));
601 EXPECT_TRUE(
602 testARMArch("armv8-m.base", "generic", "v8m.base",
603 ARMBuildAttrs::CPUArch::v8_M_Base));
604 EXPECT_TRUE(
605 testARMArch("armv8-m.main", "generic", "v8m.main",
606 ARMBuildAttrs::CPUArch::v8_M_Main));
607 EXPECT_TRUE(
608 testARMArch("armv8.1-m.main", "generic", "v8.1m.main",
609 ARMBuildAttrs::CPUArch::v8_1_M_Main));
610 EXPECT_TRUE(
611 testARMArch("iwmmxt", "iwmmxt", "",
612 ARMBuildAttrs::CPUArch::v5TE));
613 EXPECT_TRUE(
614 testARMArch("iwmmxt2", "generic", "",
615 ARMBuildAttrs::CPUArch::v5TE));
616 EXPECT_TRUE(
617 testARMArch("xscale", "xscale", "v5e",
618 ARMBuildAttrs::CPUArch::v5TE));
619 EXPECT_TRUE(
620 testARMArch("armv7s", "swift", "v7s",
621 ARMBuildAttrs::CPUArch::v7));
622 EXPECT_TRUE(
623 testARMArch("armv7k", "generic", "v7k",
624 ARMBuildAttrs::CPUArch::v7));
627 bool testARMExtension(StringRef CPUName,ARM::ArchKind ArchKind, StringRef ArchExt) {
628 return ARM::getDefaultExtensions(CPUName, ArchKind) &
629 ARM::parseArchExt(ArchExt);
632 TEST(TargetParserTest, testARMExtension) {
633 EXPECT_FALSE(testARMExtension("strongarm", ARM::ArchKind::INVALID, "dsp"));
634 EXPECT_FALSE(testARMExtension("arm7tdmi", ARM::ArchKind::INVALID, "dsp"));
635 EXPECT_FALSE(testARMExtension("arm10tdmi",
636 ARM::ArchKind::INVALID, "simd"));
637 EXPECT_FALSE(testARMExtension("arm1022e", ARM::ArchKind::INVALID, "simd"));
638 EXPECT_FALSE(testARMExtension("arm926ej-s",
639 ARM::ArchKind::INVALID, "simd"));
640 EXPECT_FALSE(testARMExtension("arm1136jf-s",
641 ARM::ArchKind::INVALID, "crypto"));
642 EXPECT_FALSE(testARMExtension("arm1156t2-s",
643 ARM::ArchKind::INVALID, "crypto"));
644 EXPECT_FALSE(testARMExtension("arm1176jzf-s",
645 ARM::ArchKind::INVALID, "crypto"));
646 EXPECT_FALSE(testARMExtension("cortex-m0",
647 ARM::ArchKind::INVALID, "crypto"));
648 EXPECT_FALSE(testARMExtension("cortex-a8",
649 ARM::ArchKind::INVALID, "crypto"));
650 EXPECT_FALSE(testARMExtension("cortex-r4",
651 ARM::ArchKind::INVALID, "crypto"));
652 EXPECT_FALSE(testARMExtension("cortex-m3",
653 ARM::ArchKind::INVALID, "crypto"));
654 EXPECT_FALSE(testARMExtension("cortex-a53",
655 ARM::ArchKind::INVALID, "ras"));
656 EXPECT_FALSE(testARMExtension("cortex-a53",
657 ARM::ArchKind::INVALID, "fp16"));
658 EXPECT_TRUE(testARMExtension("cortex-a55",
659 ARM::ArchKind::INVALID, "fp16"));
660 EXPECT_FALSE(testARMExtension("cortex-a55",
661 ARM::ArchKind::INVALID, "fp16fml"));
662 EXPECT_TRUE(testARMExtension("cortex-a75",
663 ARM::ArchKind::INVALID, "fp16"));
664 EXPECT_FALSE(testARMExtension("cortex-a75",
665 ARM::ArchKind::INVALID, "fp16fml"));
666 EXPECT_FALSE(testARMExtension("cortex-r52",
667 ARM::ArchKind::INVALID, "ras"));
668 EXPECT_FALSE(testARMExtension("iwmmxt", ARM::ArchKind::INVALID, "crc"));
669 EXPECT_FALSE(testARMExtension("xscale", ARM::ArchKind::INVALID, "crc"));
670 EXPECT_FALSE(testARMExtension("swift", ARM::ArchKind::INVALID, "crc"));
672 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV4, "dsp"));
673 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV4T, "dsp"));
674 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV5T, "simd"));
675 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV5TE, "simd"));
676 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV5TEJ, "simd"));
677 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV6, "crypto"));
678 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV6K, "crypto"));
679 EXPECT_FALSE(testARMExtension("generic",
680 ARM::ArchKind::ARMV6T2, "crypto"));
681 EXPECT_FALSE(testARMExtension("generic",
682 ARM::ArchKind::ARMV6KZ, "crypto"));
683 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV6M, "crypto"));
684 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV7A, "crypto"));
685 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV7R, "crypto"));
686 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV7M, "crypto"));
687 EXPECT_FALSE(testARMExtension("generic",
688 ARM::ArchKind::ARMV7EM, "crypto"));
689 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8A, "ras"));
690 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_1A, "ras"));
691 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_2A, "profile"));
692 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_2A, "fp16"));
693 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_2A, "fp16fml"));
694 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_3A, "fp16"));
695 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_3A, "fp16fml"));
696 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_4A, "fp16"));
697 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8_4A, "fp16fml"));
698 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV8R, "ras"));
699 EXPECT_FALSE(testARMExtension("generic",
700 ARM::ArchKind::ARMV8MBaseline, "crc"));
701 EXPECT_FALSE(testARMExtension("generic",
702 ARM::ArchKind::ARMV8MMainline, "crc"));
703 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::IWMMXT, "crc"));
704 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::IWMMXT2, "crc"));
705 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::XSCALE, "crc"));
706 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV7S, "crypto"));
707 EXPECT_FALSE(testARMExtension("generic", ARM::ArchKind::ARMV7K, "crypto"));
710 TEST(TargetParserTest, ARMFPUVersion) {
711 for (ARM::FPUKind FK = static_cast<ARM::FPUKind>(0);
712 FK <= ARM::FPUKind::FK_LAST;
713 FK = static_cast<ARM::FPUKind>(static_cast<unsigned>(FK) + 1))
714 if (FK == ARM::FK_LAST || ARM::getFPUName(FK) == "invalid" ||
715 ARM::getFPUName(FK) == "none" || ARM::getFPUName(FK) == "softvfp")
716 EXPECT_EQ(ARM::FPUVersion::NONE, ARM::getFPUVersion(FK));
717 else
718 EXPECT_NE(ARM::FPUVersion::NONE, ARM::getFPUVersion(FK));
721 TEST(TargetParserTest, ARMFPUNeonSupportLevel) {
722 for (ARM::FPUKind FK = static_cast<ARM::FPUKind>(0);
723 FK <= ARM::FPUKind::FK_LAST;
724 FK = static_cast<ARM::FPUKind>(static_cast<unsigned>(FK) + 1))
725 if (FK == ARM::FK_LAST ||
726 ARM::getFPUName(FK).find("neon") == std::string::npos)
727 EXPECT_EQ(ARM::NeonSupportLevel::None,
728 ARM::getFPUNeonSupportLevel(FK));
729 else
730 EXPECT_NE(ARM::NeonSupportLevel::None,
731 ARM::getFPUNeonSupportLevel(FK));
734 TEST(TargetParserTest, ARMFPURestriction) {
735 for (ARM::FPUKind FK = static_cast<ARM::FPUKind>(0);
736 FK <= ARM::FPUKind::FK_LAST;
737 FK = static_cast<ARM::FPUKind>(static_cast<unsigned>(FK) + 1)) {
738 if (FK == ARM::FK_LAST ||
739 (ARM::getFPUName(FK).find("d16") == std::string::npos &&
740 ARM::getFPUName(FK).find("vfpv3xd") == std::string::npos))
741 EXPECT_EQ(ARM::FPURestriction::None, ARM::getFPURestriction(FK));
742 else
743 EXPECT_NE(ARM::FPURestriction::None, ARM::getFPURestriction(FK));
747 TEST(TargetParserTest, ARMExtensionFeatures) {
748 std::map<uint64_t, std::vector<StringRef>> Extensions;
750 for (auto &Ext : ARM::ARCHExtNames) {
751 if (!Ext.Feature.empty() && !Ext.NegFeature.empty())
752 Extensions[Ext.ID] = {Ext.Feature, Ext.NegFeature};
755 Extensions[ARM::AEK_HWDIVARM] = { "+hwdiv-arm", "-hwdiv-arm" };
756 Extensions[ARM::AEK_HWDIVTHUMB] = { "+hwdiv", "-hwdiv" };
758 std::vector<StringRef> Features;
760 EXPECT_FALSE(ARM::getExtensionFeatures(ARM::AEK_INVALID, Features));
762 for (auto &E : Extensions) {
763 // test +extension
764 Features.clear();
765 ARM::getExtensionFeatures(E.first, Features);
766 EXPECT_TRUE(llvm::is_contained(Features, E.second.at(0)));
767 EXPECT_EQ(Extensions.size(), Features.size());
769 // test -extension
770 Features.clear();
771 ARM::getExtensionFeatures(~E.first, Features);
772 EXPECT_TRUE(llvm::is_contained(Features, E.second.at(1)));
773 EXPECT_EQ(Extensions.size(), Features.size());
777 TEST(TargetParserTest, ARMFPUFeatures) {
778 std::vector<StringRef> Features;
779 for (ARM::FPUKind FK = static_cast<ARM::FPUKind>(0);
780 FK <= ARM::FPUKind::FK_LAST;
781 FK = static_cast<ARM::FPUKind>(static_cast<unsigned>(FK) + 1)) {
782 if (FK == ARM::FK_INVALID || FK >= ARM::FK_LAST)
783 EXPECT_FALSE(ARM::getFPUFeatures(FK, Features));
784 else
785 EXPECT_TRUE(ARM::getFPUFeatures(FK, Features));
789 TEST(TargetParserTest, ARMArchExtFeature) {
790 const char *ArchExt[][4] = {{"crc", "nocrc", "+crc", "-crc"},
791 {"crypto", "nocrypto", "+crypto", "-crypto"},
792 {"dsp", "nodsp", "+dsp", "-dsp"},
793 {"fp", "nofp", nullptr, nullptr},
794 {"idiv", "noidiv", nullptr, nullptr},
795 {"mp", "nomp", nullptr, nullptr},
796 {"simd", "nosimd", nullptr, nullptr},
797 {"sec", "nosec", nullptr, nullptr},
798 {"virt", "novirt", nullptr, nullptr},
799 {"fp16", "nofp16", "+fullfp16", "-fullfp16"},
800 {"fp16fml", "nofp16fml", "+fp16fml", "-fp16fml"},
801 {"ras", "noras", "+ras", "-ras"},
802 {"dotprod", "nodotprod", "+dotprod", "-dotprod"},
803 {"os", "noos", nullptr, nullptr},
804 {"iwmmxt", "noiwmmxt", nullptr, nullptr},
805 {"iwmmxt2", "noiwmmxt2", nullptr, nullptr},
806 {"maverick", "maverick", nullptr, nullptr},
807 {"xscale", "noxscale", nullptr, nullptr},
808 {"sb", "nosb", "+sb", "-sb"},
809 {"i8mm", "noi8mm", "+i8mm", "-i8mm"},
810 {"mve", "nomve", "+mve", "-mve"},
811 {"mve.fp", "nomve.fp", "+mve.fp", "-mve.fp"}};
813 for (unsigned i = 0; i < std::size(ArchExt); i++) {
814 EXPECT_EQ(StringRef(ArchExt[i][2]), ARM::getArchExtFeature(ArchExt[i][0]));
815 EXPECT_EQ(StringRef(ArchExt[i][3]), ARM::getArchExtFeature(ArchExt[i][1]));
819 static bool
820 testArchExtDependency(const char *ArchExt,
821 const std::initializer_list<const char *> &Expected) {
822 std::vector<StringRef> Features;
823 ARM::FPUKind FPUKind;
825 if (!ARM::appendArchExtFeatures("", ARM::ArchKind::ARMV8_1MMainline, ArchExt,
826 Features, FPUKind))
827 return false;
829 return llvm::all_of(Expected, [&](StringRef Ext) {
830 return llvm::is_contained(Features, Ext);
834 TEST(TargetParserTest, ARMArchExtDependencies) {
835 EXPECT_TRUE(testArchExtDependency("mve", {"+mve", "+dsp"}));
836 EXPECT_TRUE(testArchExtDependency("mve.fp", {"+mve.fp", "+mve", "+dsp"}));
837 EXPECT_TRUE(testArchExtDependency("nodsp", {"-dsp", "-mve", "-mve.fp"}));
838 EXPECT_TRUE(testArchExtDependency("nomve", {"-mve", "-mve.fp"}));
841 TEST(TargetParserTest, ARMparseHWDiv) {
842 const char *hwdiv[] = {"thumb", "arm", "arm,thumb", "thumb,arm"};
844 for (unsigned i = 0; i < std::size(hwdiv); i++)
845 EXPECT_NE(ARM::AEK_INVALID, ARM::parseHWDiv((StringRef)hwdiv[i]));
848 TEST(TargetParserTest, ARMparseArchEndianAndISA) {
849 const char *Arch[] = {
850 "v2", "v2a", "v3", "v3m", "v4", "v4t",
851 "v5", "v5t", "v5e", "v5te", "v5tej", "v6",
852 "v6j", "v6k", "v6hl", "v6t2", "v6kz", "v6z",
853 "v6zk", "v6-m", "v6m", "v6sm", "v6s-m", "v7-a",
854 "v7", "v7a", "v7ve", "v7hl", "v7l", "v7-r",
855 "v7r", "v7-m", "v7m", "v7k", "v7s", "v7e-m",
856 "v7em", "v8-a", "v8", "v8a", "v8l", "v8.1-a",
857 "v8.1a", "v8.2-a", "v8.2a", "v8.3-a", "v8.3a", "v8.4-a",
858 "v8.4a", "v8.5-a", "v8.5a", "v8.6-a", "v8.6a", "v8.7-a",
859 "v8.7a", "v8.8-a", "v8.8a", "v8-r", "v8m.base", "v8m.main",
860 "v8.1m.main"};
862 for (unsigned i = 0; i < std::size(Arch); i++) {
863 std::string arm_1 = "armeb" + (std::string)(Arch[i]);
864 std::string arm_2 = "arm" + (std::string)(Arch[i]) + "eb";
865 std::string arm_3 = "arm" + (std::string)(Arch[i]);
866 std::string thumb_1 = "thumbeb" + (std::string)(Arch[i]);
867 std::string thumb_2 = "thumb" + (std::string)(Arch[i]) + "eb";
868 std::string thumb_3 = "thumb" + (std::string)(Arch[i]);
870 EXPECT_EQ(ARM::EndianKind::BIG, ARM::parseArchEndian(arm_1));
871 EXPECT_EQ(ARM::EndianKind::BIG, ARM::parseArchEndian(arm_2));
872 EXPECT_EQ(ARM::EndianKind::LITTLE, ARM::parseArchEndian(arm_3));
874 EXPECT_EQ(ARM::ISAKind::ARM, ARM::parseArchISA(arm_1));
875 EXPECT_EQ(ARM::ISAKind::ARM, ARM::parseArchISA(arm_2));
876 EXPECT_EQ(ARM::ISAKind::ARM, ARM::parseArchISA(arm_3));
877 if (i >= 4) {
878 EXPECT_EQ(ARM::EndianKind::BIG, ARM::parseArchEndian(thumb_1));
879 EXPECT_EQ(ARM::EndianKind::BIG, ARM::parseArchEndian(thumb_2));
880 EXPECT_EQ(ARM::EndianKind::LITTLE, ARM::parseArchEndian(thumb_3));
882 EXPECT_EQ(ARM::ISAKind::THUMB, ARM::parseArchISA(thumb_1));
883 EXPECT_EQ(ARM::ISAKind::THUMB, ARM::parseArchISA(thumb_2));
884 EXPECT_EQ(ARM::ISAKind::THUMB, ARM::parseArchISA(thumb_3));
888 EXPECT_EQ(ARM::EndianKind::LITTLE, ARM::parseArchEndian("aarch64"));
889 EXPECT_EQ(ARM::EndianKind::LITTLE, ARM::parseArchEndian("arm64_32"));
890 EXPECT_EQ(ARM::EndianKind::BIG, ARM::parseArchEndian("aarch64_be"));
892 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("aarch64"));
893 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("aarch64_be"));
894 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("arm64"));
895 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("arm64_be"));
896 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("arm64_32"));
897 EXPECT_EQ(ARM::ISAKind::AARCH64, ARM::parseArchISA("aarch64_32"));
900 TEST(TargetParserTest, ARMparseArchProfile) {
901 for (unsigned i = 0; i < std::size(ARMArch); i++) {
902 switch (ARM::parseArch(ARMArch[i])) {
903 case ARM::ArchKind::ARMV6M:
904 case ARM::ArchKind::ARMV7M:
905 case ARM::ArchKind::ARMV7EM:
906 case ARM::ArchKind::ARMV8MMainline:
907 case ARM::ArchKind::ARMV8MBaseline:
908 case ARM::ArchKind::ARMV8_1MMainline:
909 EXPECT_EQ(ARM::ProfileKind::M, ARM::parseArchProfile(ARMArch[i]));
910 break;
911 case ARM::ArchKind::ARMV7R:
912 case ARM::ArchKind::ARMV8R:
913 EXPECT_EQ(ARM::ProfileKind::R, ARM::parseArchProfile(ARMArch[i]));
914 break;
915 case ARM::ArchKind::ARMV7A:
916 case ARM::ArchKind::ARMV7VE:
917 case ARM::ArchKind::ARMV7K:
918 case ARM::ArchKind::ARMV8A:
919 case ARM::ArchKind::ARMV8_1A:
920 case ARM::ArchKind::ARMV8_2A:
921 case ARM::ArchKind::ARMV8_3A:
922 case ARM::ArchKind::ARMV8_4A:
923 case ARM::ArchKind::ARMV8_5A:
924 case ARM::ArchKind::ARMV8_6A:
925 case ARM::ArchKind::ARMV8_7A:
926 case ARM::ArchKind::ARMV8_8A:
927 case ARM::ArchKind::ARMV8_9A:
928 case ARM::ArchKind::ARMV9A:
929 case ARM::ArchKind::ARMV9_1A:
930 case ARM::ArchKind::ARMV9_2A:
931 case ARM::ArchKind::ARMV9_3A:
932 case ARM::ArchKind::ARMV9_4A:
933 EXPECT_EQ(ARM::ProfileKind::A, ARM::parseArchProfile(ARMArch[i]));
934 break;
935 default:
936 EXPECT_EQ(ARM::ProfileKind::INVALID, ARM::parseArchProfile(ARMArch[i]));
937 break;
942 TEST(TargetParserTest, ARMparseArchVersion) {
943 for (unsigned i = 0; i < std::size(ARMArch); i++)
944 if (((std::string)ARMArch[i]).substr(0, 4) == "armv")
945 EXPECT_EQ((ARMArch[i][4] - 48u), ARM::parseArchVersion(ARMArch[i]));
946 else
947 EXPECT_EQ(5u, ARM::parseArchVersion(ARMArch[i]));
950 TEST(TargetParserTest, getARMCPUForArch) {
951 // Platform specific defaults.
953 llvm::Triple Triple("arm--nacl");
954 EXPECT_EQ("cortex-a8", ARM::getARMCPUForArch(Triple));
957 llvm::Triple Triple("arm--openbsd");
958 EXPECT_EQ("cortex-a8", ARM::getARMCPUForArch(Triple));
961 llvm::Triple Triple("armv6-unknown-freebsd");
962 EXPECT_EQ("arm1176jzf-s", ARM::getARMCPUForArch(Triple));
965 llvm::Triple Triple("thumbv6-unknown-freebsd");
966 EXPECT_EQ("arm1176jzf-s", ARM::getARMCPUForArch(Triple));
969 llvm::Triple Triple("armebv6-unknown-freebsd");
970 EXPECT_EQ("arm1176jzf-s", ARM::getARMCPUForArch(Triple));
973 llvm::Triple Triple("arm--win32");
974 EXPECT_EQ("cortex-a9", ARM::getARMCPUForArch(Triple));
975 EXPECT_EQ("generic", ARM::getARMCPUForArch(Triple, "armv8-a"));
977 // Some alternative architectures
979 llvm::Triple Triple("armv7k-apple-ios9");
980 EXPECT_EQ("cortex-a7", ARM::getARMCPUForArch(Triple));
983 llvm::Triple Triple("armv7k-apple-watchos3");
984 EXPECT_EQ("cortex-a7", ARM::getARMCPUForArch(Triple));
987 llvm::Triple Triple("armv7k-apple-tvos9");
988 EXPECT_EQ("cortex-a7", ARM::getARMCPUForArch(Triple));
990 // armeb is permitted, but armebeb is not
992 llvm::Triple Triple("armeb-none-eabi");
993 EXPECT_EQ("arm7tdmi", ARM::getARMCPUForArch(Triple));
996 llvm::Triple Triple("armebeb-none-eabi");
997 EXPECT_EQ("", ARM::getARMCPUForArch(Triple));
1000 llvm::Triple Triple("armebv6eb-none-eabi");
1001 EXPECT_EQ("", ARM::getARMCPUForArch(Triple));
1003 // xscaleeb is permitted, but armebxscale is not
1005 llvm::Triple Triple("xscaleeb-none-eabi");
1006 EXPECT_EQ("xscale", ARM::getARMCPUForArch(Triple));
1009 llvm::Triple Triple("armebxscale-none-eabi");
1010 EXPECT_EQ("", ARM::getARMCPUForArch(Triple));
1014 TEST(TargetParserTest, ARMPrintSupportedExtensions) {
1015 std::string expected = "All available -march extensions for ARM\n\n"
1016 " Name Description\n"
1017 " crc This is a long dummy description\n"
1018 " crypto\n"
1019 " sha2\n";
1021 StringMap<StringRef> DummyMap;
1022 DummyMap["crc"] = "This is a long dummy description";
1024 outs().flush();
1025 testing::internal::CaptureStdout();
1026 ARM::PrintSupportedExtensions(DummyMap);
1027 outs().flush();
1028 std::string captured = testing::internal::GetCapturedStdout();
1030 // Check that the start of the output is as expected.
1031 EXPECT_EQ(0ULL, captured.find(expected));
1033 // Should not include "none" or "invalid".
1034 EXPECT_EQ(std::string::npos, captured.find("none"));
1035 EXPECT_EQ(std::string::npos, captured.find("invalid"));
1036 // Should not include anything that lacks a feature name. Checking a few here
1037 // but not all as if one is hidden correctly the rest should be.
1038 EXPECT_EQ(std::string::npos, captured.find("simd"));
1039 EXPECT_EQ(std::string::npos, captured.find("maverick"));
1040 EXPECT_EQ(std::string::npos, captured.find("xscale"));
1043 class AArch64CPUTestFixture
1044 : public ::testing::TestWithParam<
1045 ARMCPUTestParams<AArch64::ExtensionBitset>> {};
1047 TEST_P(AArch64CPUTestFixture, testAArch64CPU) {
1048 auto params = GetParam();
1050 const std::optional<AArch64::CpuInfo> Cpu = AArch64::parseCpu(params.CPUName);
1051 EXPECT_TRUE(Cpu);
1052 EXPECT_EQ(params.ExpectedArch, Cpu->Arch.Name);
1054 EXPECT_PRED_FORMAT2(
1055 AssertSameExtensionFlags<ARM::ISAKind::AARCH64>(params.CPUName),
1056 params.ExpectedFlags, Cpu->getImpliedExtensions());
1059 INSTANTIATE_TEST_SUITE_P(
1060 AArch64CPUTests, AArch64CPUTestFixture,
1061 ::testing::Values(
1062 ARMCPUTestParams<AArch64::ExtensionBitset>(
1063 "cortex-a34", "armv8-a", "crypto-neon-fp-armv8",
1064 (AArch64::ExtensionBitset(
1065 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1066 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1067 "8-A"),
1068 ARMCPUTestParams<AArch64::ExtensionBitset>(
1069 "cortex-a35", "armv8-a", "crypto-neon-fp-armv8",
1070 (AArch64::ExtensionBitset(
1071 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1072 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1073 "8-A"),
1074 ARMCPUTestParams<AArch64::ExtensionBitset>(
1075 "cortex-a53", "armv8-a", "crypto-neon-fp-armv8",
1076 (AArch64::ExtensionBitset(
1077 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1078 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1079 "8-A"),
1080 ARMCPUTestParams<AArch64::ExtensionBitset>(
1081 "cortex-a55", "armv8.2-a", "crypto-neon-fp-armv8",
1082 (AArch64::ExtensionBitset(
1083 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1084 AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_RAS,
1085 AArch64::AEK_LSE, AArch64::AEK_RDM, AArch64::AEK_FP16,
1086 AArch64::AEK_DOTPROD, AArch64::AEK_RCPC})),
1087 "8.2-A"),
1088 ARMCPUTestParams<AArch64::ExtensionBitset>(
1089 "cortex-a510", "armv9-a", "neon-fp-armv8",
1090 (AArch64::ExtensionBitset(
1091 {AArch64::AEK_CRC, AArch64::AEK_FP, AArch64::AEK_SIMD,
1092 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_RDM,
1093 AArch64::AEK_RCPC, AArch64::AEK_DOTPROD, AArch64::AEK_BF16,
1094 AArch64::AEK_I8MM, AArch64::AEK_SVE, AArch64::AEK_SVE2,
1095 AArch64::AEK_SVE2BITPERM, AArch64::AEK_PAUTH, AArch64::AEK_MTE,
1096 AArch64::AEK_SSBS, AArch64::AEK_FP16, AArch64::AEK_FP16FML,
1097 AArch64::AEK_SB})),
1098 "9-A"),
1099 ARMCPUTestParams<AArch64::ExtensionBitset>(
1100 "cortex-a520", "armv9.2-a", "crypto-neon-fp-armv8",
1101 (AArch64::ExtensionBitset(
1102 {AArch64::AEK_BF16, AArch64::AEK_I8MM, AArch64::AEK_SVE,
1103 AArch64::AEK_SVE2, AArch64::AEK_FP16, AArch64::AEK_DOTPROD,
1104 AArch64::AEK_LSE, AArch64::AEK_RDM, AArch64::AEK_SIMD,
1105 AArch64::AEK_RCPC, AArch64::AEK_RAS, AArch64::AEK_CRC,
1106 AArch64::AEK_FP, AArch64::AEK_SB, AArch64::AEK_SSBS,
1107 AArch64::AEK_MTE, AArch64::AEK_FP16FML, AArch64::AEK_PAUTH,
1108 AArch64::AEK_SVE2BITPERM, AArch64::AEK_FLAGM,
1109 AArch64::AEK_PERFMON, AArch64::AEK_PREDRES})),
1110 "9.2-A"),
1111 ARMCPUTestParams<AArch64::ExtensionBitset>(
1112 "cortex-a57", "armv8-a", "crypto-neon-fp-armv8",
1113 (AArch64::ExtensionBitset(
1114 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1115 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1116 "8-A"),
1117 ARMCPUTestParams<AArch64::ExtensionBitset>(
1118 "cortex-a65", "armv8.2-a", "crypto-neon-fp-armv8",
1119 (AArch64::ExtensionBitset(
1120 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1121 AArch64::AEK_DOTPROD, AArch64::AEK_FP, AArch64::AEK_FP16,
1122 AArch64::AEK_LSE, AArch64::AEK_RAS, AArch64::AEK_RCPC,
1123 AArch64::AEK_RDM, AArch64::AEK_SIMD, AArch64::AEK_SSBS})),
1124 "8.2-A"),
1125 ARMCPUTestParams<AArch64::ExtensionBitset>(
1126 "cortex-a65ae", "armv8.2-a", "crypto-neon-fp-armv8",
1127 (AArch64::ExtensionBitset(
1128 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1129 AArch64::AEK_DOTPROD, AArch64::AEK_FP, AArch64::AEK_FP16,
1130 AArch64::AEK_LSE, AArch64::AEK_RAS, AArch64::AEK_RCPC,
1131 AArch64::AEK_RDM, AArch64::AEK_SIMD, AArch64::AEK_SSBS})),
1132 "8.2-A"),
1133 ARMCPUTestParams<AArch64::ExtensionBitset>(
1134 "cortex-a72", "armv8-a", "crypto-neon-fp-armv8",
1135 (AArch64::ExtensionBitset(
1136 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1137 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1138 "8-A"),
1139 ARMCPUTestParams<AArch64::ExtensionBitset>(
1140 "cortex-a73", "armv8-a", "crypto-neon-fp-armv8",
1141 (AArch64::ExtensionBitset(
1142 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1143 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1144 "8-A"),
1145 ARMCPUTestParams<AArch64::ExtensionBitset>(
1146 "cortex-a75", "armv8.2-a", "crypto-neon-fp-armv8",
1147 (AArch64::ExtensionBitset(
1148 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1149 AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_RAS,
1150 AArch64::AEK_LSE, AArch64::AEK_RDM, AArch64::AEK_FP16,
1151 AArch64::AEK_DOTPROD, AArch64::AEK_RCPC})),
1152 "8.2-A"),
1153 ARMCPUTestParams<AArch64::ExtensionBitset>(
1154 "cortex-a76", "armv8.2-a", "crypto-neon-fp-armv8",
1155 (AArch64::ExtensionBitset(
1156 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1157 AArch64::AEK_FP, AArch64::AEK_RDM, AArch64::AEK_SIMD,
1158 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_FP16,
1159 AArch64::AEK_DOTPROD, AArch64::AEK_RCPC, AArch64::AEK_SSBS})),
1160 "8.2-A"),
1161 ARMCPUTestParams<AArch64::ExtensionBitset>(
1162 "cortex-a76ae", "armv8.2-a", "crypto-neon-fp-armv8",
1163 (AArch64::ExtensionBitset(
1164 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1165 AArch64::AEK_FP, AArch64::AEK_RDM, AArch64::AEK_SIMD,
1166 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_FP16,
1167 AArch64::AEK_DOTPROD, AArch64::AEK_RCPC, AArch64::AEK_SSBS})),
1168 "8.2-A"),
1169 ARMCPUTestParams<AArch64::ExtensionBitset>(
1170 "cortex-a77", "armv8.2-a", "crypto-neon-fp-armv8",
1171 (AArch64::ExtensionBitset(
1172 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1173 AArch64::AEK_FP, AArch64::AEK_RDM, AArch64::AEK_SIMD,
1174 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_FP16,
1175 AArch64::AEK_DOTPROD, AArch64::AEK_RCPC, AArch64::AEK_SSBS})),
1176 "8.2-A"),
1177 ARMCPUTestParams<AArch64::ExtensionBitset>(
1178 "cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
1179 (AArch64::ExtensionBitset(
1180 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1181 AArch64::AEK_FP, AArch64::AEK_RDM, AArch64::AEK_SIMD,
1182 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_FP16,
1183 AArch64::AEK_DOTPROD, AArch64::AEK_RCPC, AArch64::AEK_SSBS,
1184 AArch64::AEK_PROFILE})),
1185 "8.2-A"),
1186 ARMCPUTestParams<AArch64::ExtensionBitset>(
1187 "cortex-a78c", "armv8.2-a", "crypto-neon-fp-armv8",
1188 (AArch64::ExtensionBitset(
1189 {AArch64::AEK_RAS, AArch64::AEK_CRC, AArch64::AEK_AES,
1190 AArch64::AEK_SHA2, AArch64::AEK_FP, AArch64::AEK_SIMD,
1191 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_RDM,
1192 AArch64::AEK_FP16, AArch64::AEK_DOTPROD, AArch64::AEK_RCPC,
1193 AArch64::AEK_SSBS, AArch64::AEK_PROFILE, AArch64::AEK_FLAGM,
1194 AArch64::AEK_PAUTH, AArch64::AEK_FP16FML})),
1195 "8.2-A"),
1196 ARMCPUTestParams<AArch64::ExtensionBitset>(
1197 "cortex-a710", "armv9-a", "neon-fp-armv8",
1198 (AArch64::ExtensionBitset(
1199 {AArch64::AEK_CRC, AArch64::AEK_FP, AArch64::AEK_SIMD,
1200 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_RDM,
1201 AArch64::AEK_RCPC, AArch64::AEK_DOTPROD, AArch64::AEK_MTE,
1202 AArch64::AEK_FP16, AArch64::AEK_FP16FML, AArch64::AEK_SVE,
1203 AArch64::AEK_SVE2, AArch64::AEK_SVE2BITPERM,
1204 AArch64::AEK_PAUTH, AArch64::AEK_FLAGM, AArch64::AEK_SB,
1205 AArch64::AEK_I8MM, AArch64::AEK_BF16})),
1206 "9-A"),
1207 ARMCPUTestParams<AArch64::ExtensionBitset>(
1208 "cortex-a715", "armv9-a", "neon-fp-armv8",
1209 (AArch64::ExtensionBitset(
1210 {AArch64::AEK_CRC, AArch64::AEK_FP,
1211 AArch64::AEK_BF16, AArch64::AEK_SIMD,
1212 AArch64::AEK_RAS, AArch64::AEK_LSE,
1213 AArch64::AEK_RDM, AArch64::AEK_RCPC,
1214 AArch64::AEK_DOTPROD, AArch64::AEK_MTE,
1215 AArch64::AEK_PAUTH, AArch64::AEK_SVE,
1216 AArch64::AEK_SVE2, AArch64::AEK_SVE2BITPERM,
1217 AArch64::AEK_SSBS, AArch64::AEK_SB,
1218 AArch64::AEK_I8MM, AArch64::AEK_PERFMON,
1219 AArch64::AEK_PREDRES, AArch64::AEK_PROFILE,
1220 AArch64::AEK_FP16FML, AArch64::AEK_FP16,
1221 AArch64::AEK_FLAGM})),
1222 "9-A"),
1223 ARMCPUTestParams<AArch64::ExtensionBitset>(
1224 "cortex-a720", "armv9.2-a", "crypto-neon-fp-armv8",
1225 (AArch64::ExtensionBitset(
1226 {AArch64::AEK_BF16, AArch64::AEK_I8MM, AArch64::AEK_SVE,
1227 AArch64::AEK_SVE2, AArch64::AEK_FP16, AArch64::AEK_DOTPROD,
1228 AArch64::AEK_LSE, AArch64::AEK_RDM, AArch64::AEK_SIMD,
1229 AArch64::AEK_RCPC, AArch64::AEK_RAS, AArch64::AEK_CRC,
1230 AArch64::AEK_FP, AArch64::AEK_SB, AArch64::AEK_SSBS,
1231 AArch64::AEK_MTE, AArch64::AEK_FP16FML, AArch64::AEK_PAUTH,
1232 AArch64::AEK_SVE2BITPERM, AArch64::AEK_FLAGM,
1233 AArch64::AEK_PERFMON, AArch64::AEK_PREDRES,
1234 AArch64::AEK_PROFILE})),
1235 "9.2-A"),
1236 ARMCPUTestParams<AArch64::ExtensionBitset>(
1237 "neoverse-v1", "armv8.4-a", "crypto-neon-fp-armv8",
1238 (AArch64::ExtensionBitset(
1239 {AArch64::AEK_RAS, AArch64::AEK_SVE, AArch64::AEK_SSBS,
1240 AArch64::AEK_RCPC, AArch64::AEK_CRC, AArch64::AEK_FP,
1241 AArch64::AEK_SIMD, AArch64::AEK_RAS, AArch64::AEK_LSE,
1242 AArch64::AEK_RDM, AArch64::AEK_RCPC, AArch64::AEK_DOTPROD,
1243 AArch64::AEK_AES, AArch64::AEK_SHA2, AArch64::AEK_SHA3,
1244 AArch64::AEK_SM4, AArch64::AEK_FP16, AArch64::AEK_BF16,
1245 AArch64::AEK_PROFILE, AArch64::AEK_RAND, AArch64::AEK_FP16FML,
1246 AArch64::AEK_I8MM})),
1247 "8.4-A"),
1248 ARMCPUTestParams<AArch64::ExtensionBitset>(
1249 "neoverse-v2", "armv9-a", "neon-fp-armv8",
1250 (AArch64::ExtensionBitset(
1251 {AArch64::AEK_RAS, AArch64::AEK_SVE,
1252 AArch64::AEK_SSBS, AArch64::AEK_RCPC,
1253 AArch64::AEK_CRC, AArch64::AEK_FP,
1254 AArch64::AEK_SIMD, AArch64::AEK_MTE,
1255 AArch64::AEK_LSE, AArch64::AEK_RDM,
1256 AArch64::AEK_RCPC, AArch64::AEK_DOTPROD,
1257 AArch64::AEK_FP16, AArch64::AEK_BF16,
1258 AArch64::AEK_SVE2, AArch64::AEK_PROFILE,
1259 AArch64::AEK_FP16FML, AArch64::AEK_I8MM,
1260 AArch64::AEK_SVE2BITPERM, AArch64::AEK_RAND})),
1261 "9-A"),
1262 ARMCPUTestParams<AArch64::ExtensionBitset>(
1263 "cortex-r82", "armv8-r", "crypto-neon-fp-armv8",
1264 (AArch64::ExtensionBitset(
1265 {AArch64::AEK_CRC, AArch64::AEK_RDM, AArch64::AEK_SSBS,
1266 AArch64::AEK_DOTPROD, AArch64::AEK_FP, AArch64::AEK_SIMD,
1267 AArch64::AEK_FP16, AArch64::AEK_FP16FML, AArch64::AEK_RAS,
1268 AArch64::AEK_RCPC, AArch64::AEK_LSE, AArch64::AEK_SB})),
1269 "8-R"),
1270 ARMCPUTestParams<AArch64::ExtensionBitset>(
1271 "cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
1272 (AArch64::ExtensionBitset(
1273 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1274 AArch64::AEK_FP, AArch64::AEK_RDM, AArch64::AEK_SIMD,
1275 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_FP16,
1276 AArch64::AEK_DOTPROD, AArch64::AEK_RCPC, AArch64::AEK_SSBS,
1277 AArch64::AEK_PROFILE})),
1278 "8.2-A"),
1279 ARMCPUTestParams<AArch64::ExtensionBitset>(
1280 "cortex-x1c", "armv8.2-a", "crypto-neon-fp-armv8",
1281 (AArch64::ExtensionBitset(
1282 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1283 AArch64::AEK_FP, AArch64::AEK_RDM, AArch64::AEK_SIMD,
1284 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_FP16,
1285 AArch64::AEK_DOTPROD, AArch64::AEK_RCPC, AArch64::AEK_SSBS,
1286 AArch64::AEK_PAUTH, AArch64::AEK_PROFILE})),
1287 "8.2-A"),
1288 ARMCPUTestParams<AArch64::ExtensionBitset>(
1289 "cortex-x2", "armv9-a", "neon-fp-armv8",
1290 (AArch64::ExtensionBitset(
1291 {AArch64::AEK_CRC, AArch64::AEK_FP, AArch64::AEK_SIMD,
1292 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_RDM,
1293 AArch64::AEK_RCPC, AArch64::AEK_DOTPROD, AArch64::AEK_MTE,
1294 AArch64::AEK_PAUTH, AArch64::AEK_I8MM, AArch64::AEK_BF16,
1295 AArch64::AEK_SVE, AArch64::AEK_SVE2, AArch64::AEK_SVE2BITPERM,
1296 AArch64::AEK_SSBS, AArch64::AEK_SB, AArch64::AEK_FP16,
1297 AArch64::AEK_FP16FML})),
1298 "9-A"),
1299 ARMCPUTestParams<AArch64::ExtensionBitset>(
1300 "cortex-x3", "armv9-a", "neon-fp-armv8",
1301 (AArch64::ExtensionBitset(
1302 {AArch64::AEK_CRC, AArch64::AEK_FP,
1303 AArch64::AEK_BF16, AArch64::AEK_SIMD,
1304 AArch64::AEK_RAS, AArch64::AEK_LSE,
1305 AArch64::AEK_RDM, AArch64::AEK_RCPC,
1306 AArch64::AEK_DOTPROD, AArch64::AEK_MTE,
1307 AArch64::AEK_PAUTH, AArch64::AEK_SVE,
1308 AArch64::AEK_SVE2, AArch64::AEK_SVE2BITPERM,
1309 AArch64::AEK_SB, AArch64::AEK_PROFILE,
1310 AArch64::AEK_PERFMON, AArch64::AEK_I8MM,
1311 AArch64::AEK_FP16, AArch64::AEK_FP16FML,
1312 AArch64::AEK_PREDRES, AArch64::AEK_FLAGM,
1313 AArch64::AEK_SSBS})),
1314 "9-A"),
1315 ARMCPUTestParams<AArch64::ExtensionBitset>(
1316 "cortex-x4", "armv9.2-a", "crypto-neon-fp-armv8",
1317 (AArch64::ExtensionBitset(
1318 {AArch64::AEK_BF16, AArch64::AEK_I8MM, AArch64::AEK_SVE,
1319 AArch64::AEK_SVE2, AArch64::AEK_FP16, AArch64::AEK_DOTPROD,
1320 AArch64::AEK_LSE, AArch64::AEK_RDM, AArch64::AEK_SIMD,
1321 AArch64::AEK_RCPC, AArch64::AEK_RAS, AArch64::AEK_CRC,
1322 AArch64::AEK_FP, AArch64::AEK_SB, AArch64::AEK_SSBS,
1323 AArch64::AEK_MTE, AArch64::AEK_FP16FML, AArch64::AEK_PAUTH,
1324 AArch64::AEK_SVE2BITPERM, AArch64::AEK_FLAGM,
1325 AArch64::AEK_PERFMON, AArch64::AEK_PREDRES,
1326 AArch64::AEK_PROFILE})),
1327 "9.2-A"),
1328 ARMCPUTestParams<AArch64::ExtensionBitset>(
1329 "cyclone", "armv8-a", "crypto-neon-fp-armv8",
1330 (AArch64::ExtensionBitset(
1331 {AArch64::AEK_NONE, AArch64::AEK_AES, AArch64::AEK_SHA2,
1332 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1333 "8-A"),
1334 ARMCPUTestParams<AArch64::ExtensionBitset>(
1335 "apple-a7", "armv8-a", "crypto-neon-fp-armv8",
1336 (AArch64::ExtensionBitset(
1337 {AArch64::AEK_NONE, AArch64::AEK_AES, AArch64::AEK_SHA2,
1338 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1339 "8-A"),
1340 ARMCPUTestParams<AArch64::ExtensionBitset>(
1341 "apple-a8", "armv8-a", "crypto-neon-fp-armv8",
1342 (AArch64::ExtensionBitset(
1343 {AArch64::AEK_NONE, AArch64::AEK_AES, AArch64::AEK_SHA2,
1344 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1345 "8-A"),
1346 ARMCPUTestParams<AArch64::ExtensionBitset>(
1347 "apple-a9", "armv8-a", "crypto-neon-fp-armv8",
1348 (AArch64::ExtensionBitset(
1349 {AArch64::AEK_NONE, AArch64::AEK_AES, AArch64::AEK_SHA2,
1350 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1351 "8-A"),
1352 ARMCPUTestParams<AArch64::ExtensionBitset>(
1353 "apple-a10", "armv8-a", "crypto-neon-fp-armv8",
1354 (AArch64::ExtensionBitset(
1355 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1356 AArch64::AEK_FP, AArch64::AEK_RDM, AArch64::AEK_SIMD})),
1357 "8-A"),
1358 ARMCPUTestParams<AArch64::ExtensionBitset>(
1359 "apple-a11", "armv8.2-a", "crypto-neon-fp-armv8",
1360 (AArch64::ExtensionBitset(
1361 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1362 AArch64::AEK_FP, AArch64::AEK_LSE, AArch64::AEK_RAS,
1363 AArch64::AEK_RDM, AArch64::AEK_SIMD, AArch64::AEK_FP16})),
1364 "8.2-A"),
1365 ARMCPUTestParams<AArch64::ExtensionBitset>(
1366 "apple-a12", "armv8.3-a", "crypto-neon-fp-armv8",
1367 (AArch64::ExtensionBitset(
1368 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1369 AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_LSE,
1370 AArch64::AEK_RAS, AArch64::AEK_RDM, AArch64::AEK_RCPC,
1371 AArch64::AEK_FP16})),
1372 "8.3-A"),
1373 ARMCPUTestParams<AArch64::ExtensionBitset>(
1374 "apple-a13", "armv8.4-a", "crypto-neon-fp-armv8",
1375 (AArch64::ExtensionBitset(
1376 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1377 AArch64::AEK_SHA3, AArch64::AEK_FP, AArch64::AEK_SIMD,
1378 AArch64::AEK_LSE, AArch64::AEK_RAS, AArch64::AEK_RDM,
1379 AArch64::AEK_RCPC, AArch64::AEK_DOTPROD, AArch64::AEK_FP16,
1380 AArch64::AEK_FP16FML, AArch64::AEK_SHA3})),
1381 "8.4-A"),
1382 ARMCPUTestParams<AArch64::ExtensionBitset>(
1383 "apple-a14", "armv8.5-a", "crypto-neon-fp-armv8",
1384 (AArch64::ExtensionBitset(
1385 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1386 AArch64::AEK_SHA3, AArch64::AEK_FP, AArch64::AEK_SIMD,
1387 AArch64::AEK_LSE, AArch64::AEK_RAS, AArch64::AEK_RDM,
1388 AArch64::AEK_RCPC, AArch64::AEK_DOTPROD, AArch64::AEK_FP16,
1389 AArch64::AEK_FP16FML, AArch64::AEK_SHA3})),
1390 "8.5-A"),
1391 ARMCPUTestParams<AArch64::ExtensionBitset>(
1392 "apple-a15", "armv8.5-a", "crypto-neon-fp-armv8",
1393 (AArch64::ExtensionBitset(
1394 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1395 AArch64::AEK_SHA3, AArch64::AEK_FP, AArch64::AEK_SIMD,
1396 AArch64::AEK_LSE, AArch64::AEK_RAS, AArch64::AEK_RDM,
1397 AArch64::AEK_RCPC, AArch64::AEK_DOTPROD, AArch64::AEK_FP16,
1398 AArch64::AEK_FP16FML, AArch64::AEK_SHA3, AArch64::AEK_BF16,
1399 AArch64::AEK_I8MM})),
1400 "8.5-A"),
1401 ARMCPUTestParams<AArch64::ExtensionBitset>(
1402 "apple-a16", "armv8.5-a", "crypto-neon-fp-armv8",
1403 (AArch64::ExtensionBitset(
1404 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1405 AArch64::AEK_SHA3, AArch64::AEK_FP, AArch64::AEK_SIMD,
1406 AArch64::AEK_LSE, AArch64::AEK_RAS, AArch64::AEK_RDM,
1407 AArch64::AEK_RCPC, AArch64::AEK_DOTPROD, AArch64::AEK_FP16,
1408 AArch64::AEK_FP16FML, AArch64::AEK_SHA3, AArch64::AEK_BF16,
1409 AArch64::AEK_I8MM})),
1410 "8.5-A"),
1411 ARMCPUTestParams<AArch64::ExtensionBitset>(
1412 "apple-m1", "armv8.5-a", "crypto-neon-fp-armv8",
1413 (AArch64::ExtensionBitset(
1414 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1415 AArch64::AEK_SHA3, AArch64::AEK_FP, AArch64::AEK_SIMD,
1416 AArch64::AEK_LSE, AArch64::AEK_RAS, AArch64::AEK_RDM,
1417 AArch64::AEK_RCPC, AArch64::AEK_DOTPROD, AArch64::AEK_FP16,
1418 AArch64::AEK_FP16FML, AArch64::AEK_SHA3})),
1419 "8.5-A"),
1420 ARMCPUTestParams<AArch64::ExtensionBitset>(
1421 "apple-m2", "armv8.5-a", "crypto-neon-fp-armv8",
1422 (AArch64::ExtensionBitset(
1423 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1424 AArch64::AEK_SHA3, AArch64::AEK_FP, AArch64::AEK_SIMD,
1425 AArch64::AEK_LSE, AArch64::AEK_RAS, AArch64::AEK_RDM,
1426 AArch64::AEK_RCPC, AArch64::AEK_DOTPROD, AArch64::AEK_FP16,
1427 AArch64::AEK_FP16FML, AArch64::AEK_SHA3, AArch64::AEK_BF16,
1428 AArch64::AEK_I8MM})),
1429 "8.5-A"),
1430 ARMCPUTestParams<AArch64::ExtensionBitset>(
1431 "apple-s4", "armv8.3-a", "crypto-neon-fp-armv8",
1432 (AArch64::ExtensionBitset(
1433 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1434 AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_LSE,
1435 AArch64::AEK_RAS, AArch64::AEK_RDM, AArch64::AEK_RCPC,
1436 AArch64::AEK_FP16})),
1437 "8.3-A"),
1438 ARMCPUTestParams<AArch64::ExtensionBitset>(
1439 "apple-s5", "armv8.3-a", "crypto-neon-fp-armv8",
1440 (AArch64::ExtensionBitset(
1441 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1442 AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_LSE,
1443 AArch64::AEK_RAS, AArch64::AEK_RDM, AArch64::AEK_RCPC,
1444 AArch64::AEK_FP16})),
1445 "8.3-A"),
1446 ARMCPUTestParams<AArch64::ExtensionBitset>(
1447 "exynos-m3", "armv8-a", "crypto-neon-fp-armv8",
1448 (AArch64::ExtensionBitset(
1449 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1450 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1451 "8-A"),
1452 ARMCPUTestParams<AArch64::ExtensionBitset>(
1453 "exynos-m4", "armv8.2-a", "crypto-neon-fp-armv8",
1454 (AArch64::ExtensionBitset(
1455 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1456 AArch64::AEK_DOTPROD, AArch64::AEK_FP, AArch64::AEK_FP16,
1457 AArch64::AEK_LSE, AArch64::AEK_RAS, AArch64::AEK_RDM,
1458 AArch64::AEK_SIMD})),
1459 "8.2-A"),
1460 ARMCPUTestParams<AArch64::ExtensionBitset>(
1461 "exynos-m5", "armv8.2-a", "crypto-neon-fp-armv8",
1462 (AArch64::ExtensionBitset(
1463 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1464 AArch64::AEK_DOTPROD, AArch64::AEK_FP, AArch64::AEK_FP16,
1465 AArch64::AEK_LSE, AArch64::AEK_RAS, AArch64::AEK_RDM,
1466 AArch64::AEK_SIMD})),
1467 "8.2-A"),
1468 ARMCPUTestParams<AArch64::ExtensionBitset>(
1469 "falkor", "armv8-a", "crypto-neon-fp-armv8",
1470 (AArch64::ExtensionBitset(
1471 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1472 AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_RDM})),
1473 "8-A"),
1474 ARMCPUTestParams<AArch64::ExtensionBitset>(
1475 "kryo", "armv8-a", "crypto-neon-fp-armv8",
1476 (AArch64::ExtensionBitset(
1477 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1478 AArch64::AEK_FP, AArch64::AEK_SIMD})),
1479 "8-A"),
1480 ARMCPUTestParams<AArch64::ExtensionBitset>(
1481 "neoverse-e1", "armv8.2-a", "crypto-neon-fp-armv8",
1482 (AArch64::ExtensionBitset(
1483 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1484 AArch64::AEK_DOTPROD, AArch64::AEK_FP, AArch64::AEK_FP16,
1485 AArch64::AEK_LSE, AArch64::AEK_RAS, AArch64::AEK_RCPC,
1486 AArch64::AEK_RDM, AArch64::AEK_SIMD, AArch64::AEK_SSBS})),
1487 "8.2-A"),
1488 ARMCPUTestParams<AArch64::ExtensionBitset>(
1489 "neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
1490 (AArch64::ExtensionBitset(
1491 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1492 AArch64::AEK_DOTPROD, AArch64::AEK_FP, AArch64::AEK_FP16,
1493 AArch64::AEK_LSE, AArch64::AEK_PROFILE, AArch64::AEK_RAS,
1494 AArch64::AEK_RCPC, AArch64::AEK_RDM, AArch64::AEK_SIMD,
1495 AArch64::AEK_SSBS})),
1496 "8.2-A"),
1497 ARMCPUTestParams<AArch64::ExtensionBitset>(
1498 "neoverse-n2", "armv8.5-a", "crypto-neon-fp-armv8",
1499 (AArch64::ExtensionBitset(
1500 {AArch64::AEK_CRC, AArch64::AEK_AES,
1501 AArch64::AEK_SHA2, AArch64::AEK_SHA3,
1502 AArch64::AEK_SM4, AArch64::AEK_FP,
1503 AArch64::AEK_SIMD, AArch64::AEK_FP16,
1504 AArch64::AEK_RAS, AArch64::AEK_LSE,
1505 AArch64::AEK_SVE, AArch64::AEK_DOTPROD,
1506 AArch64::AEK_RCPC, AArch64::AEK_RDM,
1507 AArch64::AEK_MTE, AArch64::AEK_SSBS,
1508 AArch64::AEK_SB, AArch64::AEK_SVE2,
1509 AArch64::AEK_SVE2BITPERM, AArch64::AEK_BF16,
1510 AArch64::AEK_I8MM})),
1511 "8.5-A"),
1512 ARMCPUTestParams<AArch64::ExtensionBitset>(
1513 "ampere1", "armv8.6-a", "crypto-neon-fp-armv8",
1514 (AArch64::ExtensionBitset(
1515 {AArch64::AEK_CRC, AArch64::AEK_FP, AArch64::AEK_FP16,
1516 AArch64::AEK_SIMD, AArch64::AEK_RAS, AArch64::AEK_LSE,
1517 AArch64::AEK_RDM, AArch64::AEK_RCPC, AArch64::AEK_DOTPROD,
1518 AArch64::AEK_SHA3, AArch64::AEK_BF16, AArch64::AEK_SHA2,
1519 AArch64::AEK_AES, AArch64::AEK_I8MM, AArch64::AEK_SSBS,
1520 AArch64::AEK_SB, AArch64::AEK_RAND})),
1521 "8.6-A"),
1522 ARMCPUTestParams<AArch64::ExtensionBitset>(
1523 "ampere1a", "armv8.6-a", "crypto-neon-fp-armv8",
1524 (AArch64::ExtensionBitset(
1525 {AArch64::AEK_CRC, AArch64::AEK_FP, AArch64::AEK_FP16,
1526 AArch64::AEK_SIMD, AArch64::AEK_RAS, AArch64::AEK_LSE,
1527 AArch64::AEK_RDM, AArch64::AEK_RCPC, AArch64::AEK_DOTPROD,
1528 AArch64::AEK_SM4, AArch64::AEK_SHA3, AArch64::AEK_BF16,
1529 AArch64::AEK_SHA2, AArch64::AEK_AES, AArch64::AEK_I8MM,
1530 AArch64::AEK_SSBS, AArch64::AEK_SB, AArch64::AEK_RAND,
1531 AArch64::AEK_MTE})),
1532 "8.6-A"),
1533 ARMCPUTestParams<AArch64::ExtensionBitset>(
1534 "neoverse-512tvb", "armv8.4-a", "crypto-neon-fp-armv8",
1535 (AArch64::ExtensionBitset(
1536 {AArch64::AEK_RAS, AArch64::AEK_SVE, AArch64::AEK_SSBS,
1537 AArch64::AEK_RCPC, AArch64::AEK_CRC, AArch64::AEK_FP,
1538 AArch64::AEK_SIMD, AArch64::AEK_RAS, AArch64::AEK_LSE,
1539 AArch64::AEK_RDM, AArch64::AEK_RCPC, AArch64::AEK_DOTPROD,
1540 AArch64::AEK_AES, AArch64::AEK_SHA2, AArch64::AEK_SHA3,
1541 AArch64::AEK_SM4, AArch64::AEK_FP16, AArch64::AEK_BF16,
1542 AArch64::AEK_PROFILE, AArch64::AEK_RAND, AArch64::AEK_FP16FML,
1543 AArch64::AEK_I8MM})),
1544 "8.4-A"),
1545 ARMCPUTestParams<AArch64::ExtensionBitset>(
1546 "thunderx2t99", "armv8.1-a", "crypto-neon-fp-armv8",
1547 (AArch64::ExtensionBitset(
1548 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1549 AArch64::AEK_LSE, AArch64::AEK_RDM, AArch64::AEK_FP,
1550 AArch64::AEK_SIMD})),
1551 "8.1-A"),
1552 ARMCPUTestParams<AArch64::ExtensionBitset>(
1553 "thunderx3t110", "armv8.3-a", "crypto-neon-fp-armv8",
1554 (AArch64::ExtensionBitset(
1555 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1556 AArch64::AEK_LSE, AArch64::AEK_RDM, AArch64::AEK_FP,
1557 AArch64::AEK_SIMD, AArch64::AEK_RAS, AArch64::AEK_RCPC})),
1558 "8.3-A"),
1559 ARMCPUTestParams<AArch64::ExtensionBitset>(
1560 "thunderx", "armv8-a", "crypto-neon-fp-armv8",
1561 (AArch64::ExtensionBitset(
1562 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1563 AArch64::AEK_SIMD, AArch64::AEK_FP})),
1564 "8-A"),
1565 ARMCPUTestParams<AArch64::ExtensionBitset>(
1566 "thunderxt81", "armv8-a", "crypto-neon-fp-armv8",
1567 (AArch64::ExtensionBitset(
1568 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1569 AArch64::AEK_SIMD, AArch64::AEK_FP})),
1570 "8-A"),
1571 ARMCPUTestParams<AArch64::ExtensionBitset>(
1572 "thunderxt83", "armv8-a", "crypto-neon-fp-armv8",
1573 (AArch64::ExtensionBitset(
1574 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1575 AArch64::AEK_SIMD, AArch64::AEK_FP})),
1576 "8-A"),
1577 ARMCPUTestParams<AArch64::ExtensionBitset>(
1578 "thunderxt88", "armv8-a", "crypto-neon-fp-armv8",
1579 (AArch64::ExtensionBitset(
1580 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1581 AArch64::AEK_SIMD, AArch64::AEK_FP})),
1582 "8-A"),
1583 ARMCPUTestParams<AArch64::ExtensionBitset>(
1584 "tsv110", "armv8.2-a", "crypto-neon-fp-armv8",
1585 (AArch64::ExtensionBitset(
1586 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1587 AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_RAS,
1588 AArch64::AEK_LSE, AArch64::AEK_RDM, AArch64::AEK_PROFILE,
1589 AArch64::AEK_FP16, AArch64::AEK_FP16FML,
1590 AArch64::AEK_DOTPROD})),
1591 "8.2-A"),
1592 ARMCPUTestParams<AArch64::ExtensionBitset>(
1593 "a64fx", "armv8.2-a", "crypto-neon-fp-armv8",
1594 (AArch64::ExtensionBitset(
1595 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1596 AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_FP16,
1597 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_SVE,
1598 AArch64::AEK_RDM})),
1599 "8.2-A"),
1600 ARMCPUTestParams<AArch64::ExtensionBitset>(
1601 "carmel", "armv8.2-a", "crypto-neon-fp-armv8",
1602 (AArch64::ExtensionBitset(
1603 {AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
1604 AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_FP16,
1605 AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_RDM})),
1606 "8.2-A")));
1608 // Note: number of CPUs includes aliases.
1609 static constexpr unsigned NumAArch64CPUArchs = 65;
1611 TEST(TargetParserTest, testAArch64CPUArchList) {
1612 SmallVector<StringRef, NumAArch64CPUArchs> List;
1613 AArch64::fillValidCPUArchList(List);
1615 // No list exists for these in this test suite, so ensure all are
1616 // valid, and match the expected 'magic' count.
1617 EXPECT_EQ(List.size(), NumAArch64CPUArchs);
1618 for (StringRef CPU : List) {
1619 EXPECT_TRUE(AArch64::parseCpu(CPU));
1623 bool testAArch64Arch(StringRef Arch, StringRef DefaultCPU, StringRef SubArch,
1624 unsigned ArchAttr) {
1625 const std::optional<AArch64::ArchInfo> AI = AArch64::parseArch(Arch);
1626 return AI.has_value();
1629 TEST(TargetParserTest, testAArch64Arch) {
1630 EXPECT_TRUE(testAArch64Arch("armv8-a", "cortex-a53", "v8a",
1631 ARMBuildAttrs::CPUArch::v8_A));
1632 EXPECT_TRUE(testAArch64Arch("armv8.1-a", "generic", "v8.1a",
1633 ARMBuildAttrs::CPUArch::v8_A));
1634 EXPECT_TRUE(testAArch64Arch("armv8.2-a", "generic", "v8.2a",
1635 ARMBuildAttrs::CPUArch::v8_A));
1636 EXPECT_TRUE(testAArch64Arch("armv8.3-a", "generic", "v8.3a",
1637 ARMBuildAttrs::CPUArch::v8_A));
1638 EXPECT_TRUE(testAArch64Arch("armv8.4-a", "generic", "v8.4a",
1639 ARMBuildAttrs::CPUArch::v8_A));
1640 EXPECT_TRUE(testAArch64Arch("armv8.5-a", "generic", "v8.5a",
1641 ARMBuildAttrs::CPUArch::v8_A));
1642 EXPECT_TRUE(testAArch64Arch("armv8.6-a", "generic", "v8.6a",
1643 ARMBuildAttrs::CPUArch::v8_A));
1644 EXPECT_TRUE(testAArch64Arch("armv8.7-a", "generic", "v8.7a",
1645 ARMBuildAttrs::CPUArch::v8_A));
1646 EXPECT_TRUE(testAArch64Arch("armv8.8-a", "generic", "v8.8a",
1647 ARMBuildAttrs::CPUArch::v8_A));
1648 EXPECT_TRUE(testAArch64Arch("armv8.9-a", "generic", "v8.9a",
1649 ARMBuildAttrs::CPUArch::v8_A));
1650 EXPECT_TRUE(testAArch64Arch("armv9-a", "generic", "v9a",
1651 ARMBuildAttrs::CPUArch::v8_A));
1652 EXPECT_TRUE(testAArch64Arch("armv9.1-a", "generic", "v9.1a",
1653 ARMBuildAttrs::CPUArch::v8_A));
1654 EXPECT_TRUE(testAArch64Arch("armv9.2-a", "generic", "v9.2a",
1655 ARMBuildAttrs::CPUArch::v8_A));
1656 EXPECT_TRUE(testAArch64Arch("armv9.3-a", "generic", "v9.3a",
1657 ARMBuildAttrs::CPUArch::v8_A));
1658 EXPECT_TRUE(testAArch64Arch("armv9.4-a", "generic", "v9.4a",
1659 ARMBuildAttrs::CPUArch::v8_A));
1660 EXPECT_TRUE(testAArch64Arch("armv9.5-a", "generic", "v9.5a",
1661 ARMBuildAttrs::CPUArch::v8_A));
1664 bool testAArch64Extension(StringRef CPUName, StringRef ArchExt) {
1665 std::optional<AArch64::ExtensionInfo> Extension =
1666 AArch64::parseArchExtension(ArchExt);
1667 if (!Extension)
1668 return false;
1669 std::optional<AArch64::CpuInfo> CpuInfo = AArch64::parseCpu(CPUName);
1670 return CpuInfo->getImpliedExtensions().test(Extension->ID);
1673 bool testAArch64Extension(const AArch64::ArchInfo &AI, StringRef ArchExt) {
1674 std::optional<AArch64::ExtensionInfo> Extension =
1675 AArch64::parseArchExtension(ArchExt);
1676 if (!Extension)
1677 return false;
1678 return AI.DefaultExts.test(Extension->ID);
1681 TEST(TargetParserTest, testAArch64Extension) {
1682 EXPECT_FALSE(testAArch64Extension("cortex-a34", "ras"));
1683 EXPECT_FALSE(testAArch64Extension("cortex-a35", "ras"));
1684 EXPECT_FALSE(testAArch64Extension("cortex-a53", "ras"));
1685 EXPECT_TRUE(testAArch64Extension("cortex-a55", "ras"));
1686 EXPECT_TRUE(testAArch64Extension("cortex-a55", "fp16"));
1687 EXPECT_FALSE(testAArch64Extension("cortex-a55", "fp16fml"));
1688 EXPECT_TRUE(testAArch64Extension("cortex-a55", "dotprod"));
1689 EXPECT_FALSE(testAArch64Extension("cortex-a57", "ras"));
1690 EXPECT_FALSE(testAArch64Extension("cortex-a72", "ras"));
1691 EXPECT_FALSE(testAArch64Extension("cortex-a73", "ras"));
1692 EXPECT_TRUE(testAArch64Extension("cortex-a75", "ras"));
1693 EXPECT_TRUE(testAArch64Extension("cortex-a75", "fp16"));
1694 EXPECT_FALSE(testAArch64Extension("cortex-a75", "fp16fml"));
1695 EXPECT_TRUE(testAArch64Extension("cortex-a75", "dotprod"));
1696 EXPECT_TRUE(testAArch64Extension("cortex-r82", "ras"));
1697 EXPECT_TRUE(testAArch64Extension("cortex-r82", "fp16"));
1698 EXPECT_TRUE(testAArch64Extension("cortex-r82", "fp16fml"));
1699 EXPECT_TRUE(testAArch64Extension("cortex-r82", "dotprod"));
1700 EXPECT_TRUE(testAArch64Extension("cortex-r82", "lse"));
1701 EXPECT_FALSE(testAArch64Extension("cyclone", "ras"));
1702 EXPECT_FALSE(testAArch64Extension("exynos-m3", "ras"));
1703 EXPECT_TRUE(testAArch64Extension("exynos-m4", "dotprod"));
1704 EXPECT_TRUE(testAArch64Extension("exynos-m4", "fp16"));
1705 EXPECT_TRUE(testAArch64Extension("exynos-m4", "lse"));
1706 EXPECT_TRUE(testAArch64Extension("exynos-m4", "ras"));
1707 EXPECT_TRUE(testAArch64Extension("exynos-m4", "rdm"));
1708 EXPECT_TRUE(testAArch64Extension("exynos-m5", "dotprod"));
1709 EXPECT_TRUE(testAArch64Extension("exynos-m5", "fp16"));
1710 EXPECT_TRUE(testAArch64Extension("exynos-m5", "lse"));
1711 EXPECT_TRUE(testAArch64Extension("exynos-m5", "ras"));
1712 EXPECT_TRUE(testAArch64Extension("exynos-m5", "rdm"));
1713 EXPECT_TRUE(testAArch64Extension("falkor", "rdm"));
1714 EXPECT_FALSE(testAArch64Extension("kryo", "ras"));
1715 EXPECT_TRUE(testAArch64Extension("saphira", "crc"));
1716 EXPECT_TRUE(testAArch64Extension("saphira", "lse"));
1717 EXPECT_TRUE(testAArch64Extension("saphira", "rdm"));
1718 EXPECT_TRUE(testAArch64Extension("saphira", "ras"));
1719 EXPECT_TRUE(testAArch64Extension("saphira", "rcpc"));
1720 EXPECT_TRUE(testAArch64Extension("saphira", "profile"));
1721 EXPECT_FALSE(testAArch64Extension("saphira", "fp16"));
1722 EXPECT_FALSE(testAArch64Extension("thunderx2t99", "ras"));
1723 EXPECT_FALSE(testAArch64Extension("thunderx", "lse"));
1724 EXPECT_FALSE(testAArch64Extension("thunderxt81", "lse"));
1725 EXPECT_FALSE(testAArch64Extension("thunderxt83", "lse"));
1726 EXPECT_FALSE(testAArch64Extension("thunderxt88", "lse"));
1727 EXPECT_TRUE(testAArch64Extension("tsv110", "aes"));
1728 EXPECT_TRUE(testAArch64Extension("tsv110", "sha2"));
1729 EXPECT_FALSE(testAArch64Extension("tsv110", "sha3"));
1730 EXPECT_FALSE(testAArch64Extension("tsv110", "sm4"));
1731 EXPECT_TRUE(testAArch64Extension("tsv110", "ras"));
1732 EXPECT_TRUE(testAArch64Extension("tsv110", "profile"));
1733 EXPECT_TRUE(testAArch64Extension("tsv110", "fp16"));
1734 EXPECT_TRUE(testAArch64Extension("tsv110", "fp16fml"));
1735 EXPECT_TRUE(testAArch64Extension("tsv110", "dotprod"));
1736 EXPECT_TRUE(testAArch64Extension("a64fx", "fp16"));
1737 EXPECT_TRUE(testAArch64Extension("a64fx", "sve"));
1738 EXPECT_FALSE(testAArch64Extension("a64fx", "sve2"));
1739 EXPECT_TRUE(testAArch64Extension("carmel", "aes"));
1740 EXPECT_TRUE(testAArch64Extension("carmel", "sha2"));
1741 EXPECT_TRUE(testAArch64Extension("carmel", "fp16"));
1743 EXPECT_FALSE(testAArch64Extension(AArch64::ARMV8A, "ras"));
1744 EXPECT_FALSE(testAArch64Extension(AArch64::ARMV8_1A, "ras"));
1745 EXPECT_FALSE(testAArch64Extension(AArch64::ARMV8_2A, "profile"));
1746 EXPECT_FALSE(testAArch64Extension(AArch64::ARMV8_2A, "fp16"));
1747 EXPECT_FALSE(testAArch64Extension(AArch64::ARMV8_2A, "fp16fml"));
1748 EXPECT_FALSE(testAArch64Extension(AArch64::ARMV8_3A, "fp16"));
1749 EXPECT_FALSE(testAArch64Extension(AArch64::ARMV8_3A, "fp16fml"));
1750 EXPECT_FALSE(testAArch64Extension(AArch64::ARMV8_4A, "fp16"));
1751 EXPECT_FALSE(testAArch64Extension(AArch64::ARMV8_4A, "fp16fml"));
1754 TEST(TargetParserTest, AArch64ExtensionFeatures) {
1755 std::vector<uint64_t> Extensions = {
1756 AArch64::AEK_CRC, AArch64::AEK_LSE,
1757 AArch64::AEK_RDM, AArch64::AEK_CRYPTO,
1758 AArch64::AEK_SM4, AArch64::AEK_SHA3,
1759 AArch64::AEK_SHA2, AArch64::AEK_AES,
1760 AArch64::AEK_DOTPROD, AArch64::AEK_FP,
1761 AArch64::AEK_SIMD, AArch64::AEK_FP16,
1762 AArch64::AEK_FP16FML, AArch64::AEK_PROFILE,
1763 AArch64::AEK_RAS, AArch64::AEK_SVE,
1764 AArch64::AEK_SVE2, AArch64::AEK_SVE2AES,
1765 AArch64::AEK_SVE2SM4, AArch64::AEK_SVE2SHA3,
1766 AArch64::AEK_SVE2BITPERM, AArch64::AEK_RCPC,
1767 AArch64::AEK_RAND, AArch64::AEK_MTE,
1768 AArch64::AEK_SSBS, AArch64::AEK_SB,
1769 AArch64::AEK_PREDRES, AArch64::AEK_BF16,
1770 AArch64::AEK_I8MM, AArch64::AEK_F32MM,
1771 AArch64::AEK_F64MM, AArch64::AEK_TME,
1772 AArch64::AEK_LS64, AArch64::AEK_BRBE,
1773 AArch64::AEK_PAUTH, AArch64::AEK_FLAGM,
1774 AArch64::AEK_SME, AArch64::AEK_SMEF64F64,
1775 AArch64::AEK_SMEI16I64, AArch64::AEK_SME2,
1776 AArch64::AEK_HBC, AArch64::AEK_MOPS,
1777 AArch64::AEK_PERFMON, AArch64::AEK_SVE2p1,
1778 AArch64::AEK_SME2p1, AArch64::AEK_B16B16,
1779 AArch64::AEK_SMEF16F16, AArch64::AEK_CSSC,
1780 AArch64::AEK_RCPC3, AArch64::AEK_THE,
1781 AArch64::AEK_D128, AArch64::AEK_LSE128,
1782 AArch64::AEK_SPECRES2, AArch64::AEK_RASv2,
1783 AArch64::AEK_ITE, AArch64::AEK_GCS,
1784 AArch64::AEK_FPMR, AArch64::AEK_FP8,
1785 AArch64::AEK_FAMINMAX, AArch64::AEK_FP8FMA,
1786 AArch64::AEK_SSVE_FP8FMA, AArch64::AEK_FP8DOT2,
1787 AArch64::AEK_SSVE_FP8DOT2, AArch64::AEK_FP8DOT4,
1788 AArch64::AEK_SSVE_FP8DOT4, AArch64::AEK_LUT,
1789 AArch64::AEK_SME_LUTv2, AArch64::AEK_SMEF8F16,
1790 AArch64::AEK_SMEF8F32};
1792 std::vector<StringRef> Features;
1794 AArch64::ExtensionBitset ExtVal;
1795 for (auto Ext : Extensions)
1796 ExtVal.set(Ext);
1798 // NONE has no feature names.
1799 // We return True here because NONE is a valid choice.
1800 EXPECT_TRUE(AArch64::getExtensionFeatures(
1801 AArch64::ExtensionBitset({AArch64::AEK_NONE}), Features));
1802 EXPECT_TRUE(!Features.size());
1804 AArch64::getExtensionFeatures(ExtVal, Features);
1805 EXPECT_EQ(Extensions.size(), Features.size());
1807 EXPECT_TRUE(llvm::is_contained(Features, "+crc"));
1808 EXPECT_TRUE(llvm::is_contained(Features, "+lse"));
1809 EXPECT_TRUE(llvm::is_contained(Features, "+rdm"));
1810 EXPECT_TRUE(llvm::is_contained(Features, "+crypto"));
1811 EXPECT_TRUE(llvm::is_contained(Features, "+sm4"));
1812 EXPECT_TRUE(llvm::is_contained(Features, "+sha3"));
1813 EXPECT_TRUE(llvm::is_contained(Features, "+sha2"));
1814 EXPECT_TRUE(llvm::is_contained(Features, "+aes"));
1815 EXPECT_TRUE(llvm::is_contained(Features, "+dotprod"));
1816 EXPECT_TRUE(llvm::is_contained(Features, "+fp-armv8"));
1817 EXPECT_TRUE(llvm::is_contained(Features, "+neon"));
1818 EXPECT_TRUE(llvm::is_contained(Features, "+fullfp16"));
1819 EXPECT_TRUE(llvm::is_contained(Features, "+fp16fml"));
1820 EXPECT_TRUE(llvm::is_contained(Features, "+spe"));
1821 EXPECT_TRUE(llvm::is_contained(Features, "+ras"));
1822 EXPECT_TRUE(llvm::is_contained(Features, "+sve"));
1823 EXPECT_TRUE(llvm::is_contained(Features, "+sve2"));
1824 EXPECT_TRUE(llvm::is_contained(Features, "+sve2-aes"));
1825 EXPECT_TRUE(llvm::is_contained(Features, "+sve2-sm4"));
1826 EXPECT_TRUE(llvm::is_contained(Features, "+sve2-sha3"));
1827 EXPECT_TRUE(llvm::is_contained(Features, "+sve2-bitperm"));
1828 EXPECT_TRUE(llvm::is_contained(Features, "+sve2p1"));
1829 EXPECT_TRUE(llvm::is_contained(Features, "+b16b16"));
1830 EXPECT_TRUE(llvm::is_contained(Features, "+rcpc"));
1831 EXPECT_TRUE(llvm::is_contained(Features, "+rand"));
1832 EXPECT_TRUE(llvm::is_contained(Features, "+mte"));
1833 EXPECT_TRUE(llvm::is_contained(Features, "+ssbs"));
1834 EXPECT_TRUE(llvm::is_contained(Features, "+sb"));
1835 EXPECT_TRUE(llvm::is_contained(Features, "+predres"));
1836 EXPECT_TRUE(llvm::is_contained(Features, "+bf16"));
1837 EXPECT_TRUE(llvm::is_contained(Features, "+i8mm"));
1838 EXPECT_TRUE(llvm::is_contained(Features, "+f32mm"));
1839 EXPECT_TRUE(llvm::is_contained(Features, "+f64mm"));
1840 EXPECT_TRUE(llvm::is_contained(Features, "+tme"));
1841 EXPECT_TRUE(llvm::is_contained(Features, "+ls64"));
1842 EXPECT_TRUE(llvm::is_contained(Features, "+brbe"));
1843 EXPECT_TRUE(llvm::is_contained(Features, "+pauth"));
1844 EXPECT_TRUE(llvm::is_contained(Features, "+flagm"));
1845 EXPECT_TRUE(llvm::is_contained(Features, "+sme"));
1846 EXPECT_TRUE(llvm::is_contained(Features, "+sme-f64f64"));
1847 EXPECT_TRUE(llvm::is_contained(Features, "+sme-i16i64"));
1848 EXPECT_TRUE(llvm::is_contained(Features, "+sme-f16f16"));
1849 EXPECT_TRUE(llvm::is_contained(Features, "+sme2"));
1850 EXPECT_TRUE(llvm::is_contained(Features, "+sme2p1"));
1851 EXPECT_TRUE(llvm::is_contained(Features, "+hbc"));
1852 EXPECT_TRUE(llvm::is_contained(Features, "+mops"));
1853 EXPECT_TRUE(llvm::is_contained(Features, "+perfmon"));
1854 EXPECT_TRUE(llvm::is_contained(Features, "+cssc"));
1855 EXPECT_TRUE(llvm::is_contained(Features, "+rcpc3"));
1856 EXPECT_TRUE(llvm::is_contained(Features, "+the"));
1857 EXPECT_TRUE(llvm::is_contained(Features, "+d128"));
1858 EXPECT_TRUE(llvm::is_contained(Features, "+lse128"));
1859 EXPECT_TRUE(llvm::is_contained(Features, "+specres2"));
1860 EXPECT_TRUE(llvm::is_contained(Features, "+ite"));
1861 EXPECT_TRUE(llvm::is_contained(Features, "+gcs"));
1862 EXPECT_TRUE(llvm::is_contained(Features, "+fpmr"));
1863 EXPECT_TRUE(llvm::is_contained(Features, "+fp8"));
1864 EXPECT_TRUE(llvm::is_contained(Features, "+faminmax"));
1865 EXPECT_TRUE(llvm::is_contained(Features, "+fp8fma"));
1866 EXPECT_TRUE(llvm::is_contained(Features, "+ssve-fp8fma"));
1867 EXPECT_TRUE(llvm::is_contained(Features, "+fp8dot2"));
1868 EXPECT_TRUE(llvm::is_contained(Features, "+ssve-fp8dot2"));
1869 EXPECT_TRUE(llvm::is_contained(Features, "+fp8dot4"));
1870 EXPECT_TRUE(llvm::is_contained(Features, "+ssve-fp8dot4"));
1871 EXPECT_TRUE(llvm::is_contained(Features, "+lut"));
1872 EXPECT_TRUE(llvm::is_contained(Features, "+sme-lutv2"));
1873 EXPECT_TRUE(llvm::is_contained(Features, "+sme-f8f16"));
1874 EXPECT_TRUE(llvm::is_contained(Features, "+sme-f8f32"));
1876 // Assuming we listed every extension above, this should produce the same
1877 // result. (note that AEK_NONE doesn't have a name so it won't be in the
1878 // result despite its bit being set)
1879 std::vector<StringRef> AllFeatures;
1880 EXPECT_TRUE(AArch64::getExtensionFeatures(ExtVal, AllFeatures));
1881 EXPECT_THAT(Features, ::testing::ContainerEq(AllFeatures));
1884 TEST(TargetParserTest, AArch64ArchFeatures) {
1885 EXPECT_EQ(AArch64::ARMV8A.ArchFeature, "+v8a");
1886 EXPECT_EQ(AArch64::ARMV8_1A.ArchFeature, "+v8.1a");
1887 EXPECT_EQ(AArch64::ARMV8_2A.ArchFeature, "+v8.2a");
1888 EXPECT_EQ(AArch64::ARMV8_3A.ArchFeature, "+v8.3a");
1889 EXPECT_EQ(AArch64::ARMV8_4A.ArchFeature, "+v8.4a");
1890 EXPECT_EQ(AArch64::ARMV8_5A.ArchFeature, "+v8.5a");
1891 EXPECT_EQ(AArch64::ARMV8_6A.ArchFeature, "+v8.6a");
1892 EXPECT_EQ(AArch64::ARMV8_7A.ArchFeature, "+v8.7a");
1893 EXPECT_EQ(AArch64::ARMV8_8A.ArchFeature, "+v8.8a");
1894 EXPECT_EQ(AArch64::ARMV8_9A.ArchFeature, "+v8.9a");
1895 EXPECT_EQ(AArch64::ARMV9A.ArchFeature, "+v9a");
1896 EXPECT_EQ(AArch64::ARMV9_1A.ArchFeature, "+v9.1a");
1897 EXPECT_EQ(AArch64::ARMV9_2A.ArchFeature, "+v9.2a");
1898 EXPECT_EQ(AArch64::ARMV9_3A.ArchFeature, "+v9.3a");
1899 EXPECT_EQ(AArch64::ARMV9_4A.ArchFeature, "+v9.4a");
1900 EXPECT_EQ(AArch64::ARMV9_5A.ArchFeature, "+v9.5a");
1901 EXPECT_EQ(AArch64::ARMV8R.ArchFeature, "+v8r");
1904 TEST(TargetParserTest, AArch64ArchPartialOrder) {
1905 for (const auto *A : AArch64::ArchInfos) {
1906 EXPECT_EQ(*A, *A);
1908 // v8r has no relation to other valid architectures
1909 if (*A != AArch64::ARMV8R) {
1910 EXPECT_FALSE(A->implies(AArch64::ARMV8R));
1911 EXPECT_FALSE(AArch64::ARMV8R.implies(*A));
1915 for (const auto *A : {
1916 &AArch64::ARMV8_1A,
1917 &AArch64::ARMV8_2A,
1918 &AArch64::ARMV8_3A,
1919 &AArch64::ARMV8_4A,
1920 &AArch64::ARMV8_5A,
1921 &AArch64::ARMV8_6A,
1922 &AArch64::ARMV8_7A,
1923 &AArch64::ARMV8_8A,
1924 &AArch64::ARMV8_9A,
1926 EXPECT_TRUE(A->implies(AArch64::ARMV8A));
1928 for (const auto *A :
1929 {&AArch64::ARMV9_1A, &AArch64::ARMV9_2A, &AArch64::ARMV9_3A,
1930 &AArch64::ARMV9_4A, &AArch64::ARMV9_5A})
1931 EXPECT_TRUE(A->implies(AArch64::ARMV9A));
1933 EXPECT_TRUE(AArch64::ARMV8_1A.implies(AArch64::ARMV8A));
1934 EXPECT_TRUE(AArch64::ARMV8_2A.implies(AArch64::ARMV8_1A));
1935 EXPECT_TRUE(AArch64::ARMV8_3A.implies(AArch64::ARMV8_2A));
1936 EXPECT_TRUE(AArch64::ARMV8_4A.implies(AArch64::ARMV8_3A));
1937 EXPECT_TRUE(AArch64::ARMV8_5A.implies(AArch64::ARMV8_4A));
1938 EXPECT_TRUE(AArch64::ARMV8_6A.implies(AArch64::ARMV8_5A));
1939 EXPECT_TRUE(AArch64::ARMV8_7A.implies(AArch64::ARMV8_6A));
1940 EXPECT_TRUE(AArch64::ARMV8_8A.implies(AArch64::ARMV8_7A));
1941 EXPECT_TRUE(AArch64::ARMV8_9A.implies(AArch64::ARMV8_8A));
1943 EXPECT_TRUE(AArch64::ARMV9_1A.implies(AArch64::ARMV9A));
1944 EXPECT_TRUE(AArch64::ARMV9_2A.implies(AArch64::ARMV9_1A));
1945 EXPECT_TRUE(AArch64::ARMV9_3A.implies(AArch64::ARMV9_2A));
1946 EXPECT_TRUE(AArch64::ARMV9_4A.implies(AArch64::ARMV9_3A));
1947 EXPECT_TRUE(AArch64::ARMV9_5A.implies(AArch64::ARMV9_4A));
1949 EXPECT_TRUE(AArch64::ARMV9A.implies(AArch64::ARMV8_5A));
1950 EXPECT_TRUE(AArch64::ARMV9_1A.implies(AArch64::ARMV8_6A));
1951 EXPECT_TRUE(AArch64::ARMV9_2A.implies(AArch64::ARMV8_7A));
1952 EXPECT_TRUE(AArch64::ARMV9_3A.implies(AArch64::ARMV8_8A));
1953 EXPECT_TRUE(AArch64::ARMV9_4A.implies(AArch64::ARMV8_9A));
1956 TEST(TargetParserTest, AArch64ArchExtFeature) {
1957 const char *ArchExt[][4] = {
1958 {"crc", "nocrc", "+crc", "-crc"},
1959 {"crypto", "nocrypto", "+crypto", "-crypto"},
1960 {"flagm", "noflagm", "+flagm", "-flagm"},
1961 {"fp", "nofp", "+fp-armv8", "-fp-armv8"},
1962 {"simd", "nosimd", "+neon", "-neon"},
1963 {"fp16", "nofp16", "+fullfp16", "-fullfp16"},
1964 {"fp16fml", "nofp16fml", "+fp16fml", "-fp16fml"},
1965 {"profile", "noprofile", "+spe", "-spe"},
1966 {"ras", "noras", "+ras", "-ras"},
1967 {"lse", "nolse", "+lse", "-lse"},
1968 {"rdm", "nordm", "+rdm", "-rdm"},
1969 {"sve", "nosve", "+sve", "-sve"},
1970 {"sve2", "nosve2", "+sve2", "-sve2"},
1971 {"sve2-aes", "nosve2-aes", "+sve2-aes", "-sve2-aes"},
1972 {"sve2-sm4", "nosve2-sm4", "+sve2-sm4", "-sve2-sm4"},
1973 {"sve2-sha3", "nosve2-sha3", "+sve2-sha3", "-sve2-sha3"},
1974 {"sve2p1", "nosve2p1", "+sve2p1", "-sve2p1"},
1975 {"b16b16", "nob16b16", "+b16b16", "-b16b16"},
1976 {"sve2-bitperm", "nosve2-bitperm", "+sve2-bitperm", "-sve2-bitperm"},
1977 {"dotprod", "nodotprod", "+dotprod", "-dotprod"},
1978 {"rcpc", "norcpc", "+rcpc", "-rcpc"},
1979 {"rng", "norng", "+rand", "-rand"},
1980 {"memtag", "nomemtag", "+mte", "-mte"},
1981 {"tme", "notme", "+tme", "-tme"},
1982 {"pauth", "nopauth", "+pauth", "-pauth"},
1983 {"ssbs", "nossbs", "+ssbs", "-ssbs"},
1984 {"sb", "nosb", "+sb", "-sb"},
1985 {"predres", "nopredres", "+predres", "-predres"},
1986 {"i8mm", "noi8mm", "+i8mm", "-i8mm"},
1987 {"f32mm", "nof32mm", "+f32mm", "-f32mm"},
1988 {"f64mm", "nof64mm", "+f64mm", "-f64mm"},
1989 {"sme", "nosme", "+sme", "-sme"},
1990 {"sme-f64f64", "nosme-f64f64", "+sme-f64f64", "-sme-f64f64"},
1991 {"sme-i16i64", "nosme-i16i64", "+sme-i16i64", "-sme-i16i64"},
1992 {"sme-f16f16", "nosme-f16f16", "+sme-f16f16", "-sme-f16f16"},
1993 {"sme2", "nosme2", "+sme2", "-sme2"},
1994 {"sme2p1", "nosme2p1", "+sme2p1", "-sme2p1"},
1995 {"hbc", "nohbc", "+hbc", "-hbc"},
1996 {"mops", "nomops", "+mops", "-mops"},
1997 {"pmuv3", "nopmuv3", "+perfmon", "-perfmon"},
1998 {"predres2", "nopredres2", "+specres2", "-specres2"},
1999 {"rasv2", "norasv2", "+rasv2", "-rasv2"},
2000 {"gcs", "nogcs", "+gcs", "-gcs"},
2001 {"fpmr", "nofpmr", "+fpmr", "-fpmr"},
2002 {"fp8", "nofp8", "+fp8", "-fp8"},
2003 {"faminmax", "nofaminmax", "+faminmax", "-faminmax"},
2004 {"fp8fma", "nofp8fma", "+fp8fma", "-fp8fma"},
2005 {"ssve-fp8fma", "nossve-fp8fma", "+ssve-fp8fma", "-ssve-fp8fma"},
2006 {"fp8dot2", "nofp8dot2", "+fp8dot2", "-fp8dot2"},
2007 {"ssve-fp8dot2", "nossve-fp8dot2", "+ssve-fp8dot2", "-ssve-fp8dot2"},
2008 {"fp8dot4", "nofp8dot4", "+fp8dot4", "-fp8dot4"},
2009 {"ssve-fp8dot4", "nossve-fp8dot4", "+ssve-fp8dot4", "-ssve-fp8dot4"},
2010 {"lut", "nolut", "+lut", "-lut"},
2011 {"sme-lutv2", "nosme-lutv2", "+sme-lutv2", "-sme-lutv2"},
2012 {"sme-f8f16", "nosme-f8f16", "+sme-f8f16", "-sme-f8f16"},
2013 {"sme-f8f32", "nosme-f8f32", "+sme-f8f32", "-sme-f8f32"},
2016 for (unsigned i = 0; i < std::size(ArchExt); i++) {
2017 EXPECT_EQ(StringRef(ArchExt[i][2]),
2018 AArch64::getArchExtFeature(ArchExt[i][0]));
2019 EXPECT_EQ(StringRef(ArchExt[i][3]),
2020 AArch64::getArchExtFeature(ArchExt[i][1]));
2024 TEST(TargetParserTest, AArch64PrintSupportedExtensions) {
2025 std::string expected = "All available -march extensions for AArch64\n\n"
2026 " Name Description\n"
2027 " aes This is a long dummy description\n"
2028 " b16b16\n"
2029 " bf16\n";
2031 StringMap<StringRef> DummyMap;
2032 DummyMap["aes"] = "This is a long dummy description";
2034 outs().flush();
2035 testing::internal::CaptureStdout();
2036 AArch64::PrintSupportedExtensions(DummyMap);
2037 outs().flush();
2038 std::string captured = testing::internal::GetCapturedStdout();
2040 // Check that the start of the output is as expected.
2041 EXPECT_EQ(0ULL, captured.find(expected));
2043 // Should not include "none".
2044 EXPECT_EQ(std::string::npos, captured.find("none"));
2045 // Should not include anything that lacks a feature name. Checking a few here
2046 // but not all as if one is hidden correctly the rest should be.
2047 EXPECT_EQ(std::string::npos, captured.find("memtag3"));
2048 EXPECT_EQ(std::string::npos, captured.find("sha1"));
2049 EXPECT_EQ(std::string::npos, captured.find("ssbs2"));
2052 } // namespace