authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-02-27 17:26:06-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-02-27 17:26:06-07:00
log85ab1b01e73d9b616f8af3951c132920e61be731
tree86e689469e4c674b235a649a49603470f72cfdf8
parente02acc028825ec83951946e4947883c2c96211ce

tools/update_cpu_features: add a "flatten" feature

and use it to clean up aarch64 target CPU features

2 files changed, 455 insertions(+), 163 deletions(-)

lib/std/target/aarch64.zig+243-145
......@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
1//! This file is auto-generated by tools/update_cpu_features.zig.
2
63const std = @import("../std.zig");
74const CpuFeature = std.Target.Cpu.Feature;
85const CpuModel = std.Target.Cpu.Model;
96
107pub const Feature = enum {
11 a34,
128 a65,
139 a76,
1410 aes,
......@@ -17,8 +13,6 @@ pub const Feature = enum {
1713 altnzcv,
1814 am,
1915 amvs,
20 apple_a10,
21 apple_a11,
2216 apple_a12,
2317 apple_a13,
2418 apple_a7,
......@@ -26,6 +20,7 @@ pub const Feature = enum {
2620 arith_cbz_fusion,
2721 balance_fp_ops,
2822 bf16,
23 brbe,
2924 bti,
3025 call_saved_x10,
3126 call_saved_x11,
......@@ -39,8 +34,11 @@ pub const Feature = enum {
3934 ccdp,
4035 ccidx,
4136 ccpp,
37 cmp_bcc_fusion,
4238 complxnum,
43 context_id_rel2,
39 contextidr_el2,
40 cortex_a78c,
41 cortex_r82,
4442 crc,
4543 crypto,
4644 custom_cheap_as_move,
......@@ -50,14 +48,14 @@ pub const Feature = enum {
5048 ecv,
5149 ete,
5250 exynos_cheap_as_move,
53 exynosm4,
51 exynos_m4,
5452 f32mm,
5553 f64mm,
5654 fgt,
57 fmi,
55 flagm,
5856 force_32bit_jump_tables,
59 fp_armv8,
6057 fp16fml,
58 fp_armv8,
6159 fptoint,
6260 fullfp16,
6361 fuse_address,
......@@ -68,9 +66,11 @@ pub const Feature = enum {
6866 fuse_literals,
6967 harden_sls_blr,
7068 harden_sls_retbr,
69 hcx,
7170 i8mm,
7271 jsconv,
7372 lor,
73 ls64,
7474 lse,
7575 lsl_fast,
7676 mpam,
......@@ -83,9 +83,9 @@ pub const Feature = enum {
8383 no_neg_immediates,
8484 nv,
8585 outline_atomics,
86 pa,
8786 pan,
8887 pan_rwv,
88 pauth,
8989 perfmon,
9090 pmu,
9191 predictable_select_expensive,
......@@ -129,6 +129,7 @@ pub const Feature = enum {
129129 slow_strqro_store,
130130 sm4,
131131 spe,
132 spe_eef,
132133 specrestrict,
133134 ssbs,
134135 strict_align,
......@@ -151,15 +152,18 @@ pub const Feature = enum {
151152 use_experimental_zeroing_pseudos,
152153 use_postra_scheduler,
153154 use_reciprocal_square_root,
154 v8a,
155155 v8_1a,
156156 v8_2a,
157157 v8_3a,
158158 v8_4a,
159159 v8_5a,
160160 v8_6a,
161 v8_7a,
162 v8a,
161163 v8r,
162164 vh,
165 wfxt,
166 xs,
163167 zcm,
164168 zcz,
165169 zcz_fp,
......@@ -174,26 +178,16 @@ pub const all_features = blk: {
174178 const len = @typeInfo(Feature).Enum.fields.len;
175179 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
176180 var result: [len]CpuFeature = undefined;
177 result[@enumToInt(Feature.a34)] = .{
178 .llvm_name = "a35",
179 .description = "Cortex-A34 ARM processors",
180 .dependencies = featureSet(&[_]Feature{
181 .crc,
182 .crypto,
183 .perfmon,
184 .v8a,
185 }),
186 };
187181 result[@enumToInt(Feature.a65)] = .{
188182 .llvm_name = "a65",
189183 .description = "Cortex-A65 ARM processors",
190184 .dependencies = featureSet(&[_]Feature{
191185 .crypto,
192186 .dotprod,
193 .fp_armv8,
194187 .fullfp16,
195 .neon,
196 .ras,
188 .fuse_address,
189 .fuse_aes,
190 .fuse_literals,
197191 .rcpc,
198192 .ssbs,
199193 .v8_2a,
......@@ -206,6 +200,7 @@ pub const all_features = blk: {
206200 .crypto,
207201 .dotprod,
208202 .fullfp16,
203 .fuse_aes,
209204 .rcpc,
210205 .ssbs,
211206 .v8_2a,
......@@ -245,49 +240,6 @@ pub const all_features = blk: {
245240 .am,
246241 }),
247242 };
248 result[@enumToInt(Feature.apple_a10)] = .{
249 .llvm_name = "apple-a10",
250 .description = "Apple A10",
251 .dependencies = featureSet(&[_]Feature{
252 .alternate_sextload_cvt_f32_pattern,
253 .arith_bcc_fusion,
254 .arith_cbz_fusion,
255 .crc,
256 .crypto,
257 .disable_latency_sched_heuristic,
258 .fp_armv8,
259 .fuse_aes,
260 .fuse_crypto_eor,
261 .lor,
262 .neon,
263 .pan,
264 .perfmon,
265 .rdm,
266 .vh,
267 .zcm,
268 .zcz,
269 }),
270 };
271 result[@enumToInt(Feature.apple_a11)] = .{
272 .llvm_name = "apple-a11",
273 .description = "Apple A11",
274 .dependencies = featureSet(&[_]Feature{
275 .alternate_sextload_cvt_f32_pattern,
276 .arith_bcc_fusion,
277 .arith_cbz_fusion,
278 .crypto,
279 .disable_latency_sched_heuristic,
280 .fp_armv8,
281 .fullfp16,
282 .fuse_aes,
283 .fuse_crypto_eor,
284 .neon,
285 .perfmon,
286 .v8_2a,
287 .zcm,
288 .zcz,
289 }),
290 };
291243 result[@enumToInt(Feature.apple_a12)] = .{
292244 .llvm_name = "apple-a12",
293245 .description = "Apple A12",
......@@ -297,11 +249,9 @@ pub const all_features = blk: {
297249 .arith_cbz_fusion,
298250 .crypto,
299251 .disable_latency_sched_heuristic,
300 .fp_armv8,
301252 .fullfp16,
302253 .fuse_aes,
303254 .fuse_crypto_eor,
304 .neon,
305255 .perfmon,
306256 .v8_3a,
307257 .zcm,
......@@ -317,12 +267,9 @@ pub const all_features = blk: {
317267 .arith_cbz_fusion,
318268 .crypto,
319269 .disable_latency_sched_heuristic,
320 .fp_armv8,
321270 .fp16fml,
322 .fullfp16,
323271 .fuse_aes,
324272 .fuse_crypto_eor,
325 .neon,
326273 .perfmon,
327274 .sha3,
328275 .v8_4a,
......@@ -339,10 +286,8 @@ pub const all_features = blk: {
339286 .arith_cbz_fusion,
340287 .crypto,
341288 .disable_latency_sched_heuristic,
342 .fp_armv8,
343289 .fuse_aes,
344290 .fuse_crypto_eor,
345 .neon,
346291 .perfmon,
347292 .zcm,
348293 .zcz,
......@@ -369,6 +314,11 @@ pub const all_features = blk: {
369314 .description = "Enable BFloat16 Extension",
370315 .dependencies = featureSet(&[_]Feature{}),
371316 };
317 result[@enumToInt(Feature.brbe)] = .{
318 .llvm_name = "brbe",
319 .description = "Enable Branch Record Buffer Extension",
320 .dependencies = featureSet(&[_]Feature{}),
321 };
372322 result[@enumToInt(Feature.bti)] = .{
373323 .llvm_name = "bti",
374324 .description = "Enable Branch Target Identification",
......@@ -434,6 +384,11 @@ pub const all_features = blk: {
434384 .description = "Enable v8.2 data Cache Clean to Point of Persistence",
435385 .dependencies = featureSet(&[_]Feature{}),
436386 };
387 result[@enumToInt(Feature.cmp_bcc_fusion)] = .{
388 .llvm_name = "cmp-bcc-fusion",
389 .description = "CPU fuses cmp+bcc operations",
390 .dependencies = featureSet(&[_]Feature{}),
391 };
437392 result[@enumToInt(Feature.complxnum)] = .{
438393 .llvm_name = "complxnum",
439394 .description = "Enable v8.3-A Floating-point complex number support",
......@@ -441,11 +396,38 @@ pub const all_features = blk: {
441396 .neon,
442397 }),
443398 };
444 result[@enumToInt(Feature.context_id_rel2)] = .{
399 result[@enumToInt(Feature.contextidr_el2)] = .{
445400 .llvm_name = "CONTEXTIDREL2",
446 .description = "Enable RW operand CONTEXTIDR_EL2",
401 .description = "Enable RW operand Context ID Register (EL2)",
447402 .dependencies = featureSet(&[_]Feature{}),
448403 };
404 result[@enumToInt(Feature.cortex_a78c)] = .{
405 .llvm_name = "cortex-a78c",
406 .description = "Cortex-A78C ARM processors",
407 .dependencies = featureSet(&[_]Feature{
408 .cmp_bcc_fusion,
409 .crypto,
410 .dotprod,
411 .flagm,
412 .fp16fml,
413 .fuse_aes,
414 .pauth,
415 .perfmon,
416 .rcpc,
417 .spe,
418 .ssbs,
419 .use_postra_scheduler,
420 .v8_2a,
421 }),
422 };
423 result[@enumToInt(Feature.cortex_r82)] = .{
424 .llvm_name = "cortex-r82",
425 .description = "Cortex-R82 ARM Processors",
426 .dependencies = featureSet(&[_]Feature{
427 .use_postra_scheduler,
428 .v8r,
429 }),
430 };
449431 result[@enumToInt(Feature.crc)] = .{
450432 .llvm_name = "crc",
451433 .description = "Enable ARMv8 CRC-32 checksum instructions",
......@@ -456,7 +438,6 @@ pub const all_features = blk: {
456438 .description = "Enable cryptographic instructions",
457439 .dependencies = featureSet(&[_]Feature{
458440 .aes,
459 .neon,
460441 .sha2,
461442 }),
462443 };
......@@ -499,7 +480,7 @@ pub const all_features = blk: {
499480 .custom_cheap_as_move,
500481 }),
501482 };
502 result[@enumToInt(Feature.exynosm4)] = .{
483 result[@enumToInt(Feature.exynos_m4)] = .{
503484 .llvm_name = "exynosm4",
504485 .description = "Samsung Exynos-M4 processors",
505486 .dependencies = featureSet(&[_]Feature{
......@@ -541,8 +522,8 @@ pub const all_features = blk: {
541522 .description = "Enable fine grained virtualization traps extension",
542523 .dependencies = featureSet(&[_]Feature{}),
543524 };
544 result[@enumToInt(Feature.fmi)] = .{
545 .llvm_name = "fmi",
525 result[@enumToInt(Feature.flagm)] = .{
526 .llvm_name = "flagm",
546527 .description = "Enable v8.4-A Flag Manipulation Instructions",
547528 .dependencies = featureSet(&[_]Feature{}),
548529 };
......@@ -551,11 +532,6 @@ pub const all_features = blk: {
551532 .description = "Force jump table entries to be 32-bits wide except at MinSize",
552533 .dependencies = featureSet(&[_]Feature{}),
553534 };
554 result[@enumToInt(Feature.fp_armv8)] = .{
555 .llvm_name = "fp-armv8",
556 .description = "Enable ARMv8 FP",
557 .dependencies = featureSet(&[_]Feature{}),
558 };
559535 result[@enumToInt(Feature.fp16fml)] = .{
560536 .llvm_name = "fp16fml",
561537 .description = "Enable FP16 FML instructions",
......@@ -563,6 +539,11 @@ pub const all_features = blk: {
563539 .fullfp16,
564540 }),
565541 };
542 result[@enumToInt(Feature.fp_armv8)] = .{
543 .llvm_name = "fp-armv8",
544 .description = "Enable ARMv8 FP",
545 .dependencies = featureSet(&[_]Feature{}),
546 };
566547 result[@enumToInt(Feature.fptoint)] = .{
567548 .llvm_name = "fptoint",
568549 .description = "Enable FRInt[32|64][Z|X] instructions that round a floating-point number to an integer (in FP format) forcing it to fit into a 32- or 64-bit int",
......@@ -615,6 +596,11 @@ pub const all_features = blk: {
615596 .description = "Harden against straight line speculation across RET and BR instructions",
616597 .dependencies = featureSet(&[_]Feature{}),
617598 };
599 result[@enumToInt(Feature.hcx)] = .{
600 .llvm_name = "hcx",
601 .description = "Enable Armv8.7-A HCRX_EL2 system register",
602 .dependencies = featureSet(&[_]Feature{}),
603 };
618604 result[@enumToInt(Feature.i8mm)] = .{
619605 .llvm_name = "i8mm",
620606 .description = "Enable Matrix Multiply Int8 Extension",
......@@ -632,6 +618,11 @@ pub const all_features = blk: {
632618 .description = "Enables ARM v8.1 Limited Ordering Regions extension",
633619 .dependencies = featureSet(&[_]Feature{}),
634620 };
621 result[@enumToInt(Feature.ls64)] = .{
622 .llvm_name = "ls64",
623 .description = "Enable Armv8.7-A LD64B/ST64B Accelerator Extension",
624 .dependencies = featureSet(&[_]Feature{}),
625 };
635626 result[@enumToInt(Feature.lse)] = .{
636627 .llvm_name = "lse",
637628 .description = "Enable ARMv8.1 Large System Extension (LSE) atomic instructions",
......@@ -665,9 +656,7 @@ pub const all_features = blk: {
665656 .dependencies = featureSet(&[_]Feature{
666657 .crypto,
667658 .dotprod,
668 .fp_armv8,
669659 .fullfp16,
670 .neon,
671660 .rcpc,
672661 .ssbs,
673662 .v8_2a,
......@@ -679,9 +668,7 @@ pub const all_features = blk: {
679668 .dependencies = featureSet(&[_]Feature{
680669 .crypto,
681670 .dotprod,
682 .fp_armv8,
683671 .fullfp16,
684 .neon,
685672 .rcpc,
686673 .spe,
687674 .ssbs,
......@@ -696,9 +683,7 @@ pub const all_features = blk: {
696683 .ete,
697684 .i8mm,
698685 .mte,
699 .sve2,
700686 .sve2_bitperm,
701 .trbe,
702687 .v8_5a,
703688 }),
704689 };
......@@ -709,12 +694,9 @@ pub const all_features = blk: {
709694 .bf16,
710695 .ccdp,
711696 .crypto,
712 .fp_armv8,
713697 .fp16fml,
714 .fullfp16,
715698 .fuse_aes,
716699 .i8mm,
717 .neon,
718700 .perfmon,
719701 .rand,
720702 .spe,
......@@ -731,7 +713,7 @@ pub const all_features = blk: {
731713 };
732714 result[@enumToInt(Feature.nv)] = .{
733715 .llvm_name = "nv",
734 .description = "Enable v8.4-A Nested Virtualization extension",
716 .description = "Enable v8.4-A Nested Virtualization Enchancement",
735717 .dependencies = featureSet(&[_]Feature{}),
736718 };
737719 result[@enumToInt(Feature.outline_atomics)] = .{
......@@ -739,11 +721,6 @@ pub const all_features = blk: {
739721 .description = "Enable out of line atomics to support LSE instructions",
740722 .dependencies = featureSet(&[_]Feature{}),
741723 };
742 result[@enumToInt(Feature.pa)] = .{
743 .llvm_name = "pa",
744 .description = "Enable v8.3-A Pointer Authentication extension",
745 .dependencies = featureSet(&[_]Feature{}),
746 };
747724 result[@enumToInt(Feature.pan)] = .{
748725 .llvm_name = "pan",
749726 .description = "Enables ARM v8.1 Privileged Access-Never extension",
......@@ -756,6 +733,11 @@ pub const all_features = blk: {
756733 .pan,
757734 }),
758735 };
736 result[@enumToInt(Feature.pauth)] = .{
737 .llvm_name = "pauth",
738 .description = "Enable v8.3-A Pointer Authentication extension",
739 .dependencies = featureSet(&[_]Feature{}),
740 };
759741 result[@enumToInt(Feature.perfmon)] = .{
760742 .llvm_name = "perfmon",
761743 .description = "Enable ARMv8 PMUv3 Performance Monitors extension",
......@@ -949,7 +931,6 @@ pub const all_features = blk: {
949931 .llvm_name = "sha3",
950932 .description = "Enable SHA512 and SHA3 support",
951933 .dependencies = featureSet(&[_]Feature{
952 .neon,
953934 .sha2,
954935 }),
955936 };
......@@ -980,6 +961,11 @@ pub const all_features = blk: {
980961 .description = "Enable Statistical Profiling extension",
981962 .dependencies = featureSet(&[_]Feature{}),
982963 };
964 result[@enumToInt(Feature.spe_eef)] = .{
965 .llvm_name = "spe-eef",
966 .description = "Enable extra register in the Statistical Profiling Extension",
967 .dependencies = featureSet(&[_]Feature{}),
968 };
983969 result[@enumToInt(Feature.specrestrict)] = .{
984970 .llvm_name = "specrestrict",
985971 .description = "Enable architectural speculation restriction",
......@@ -998,7 +984,9 @@ pub const all_features = blk: {
998984 result[@enumToInt(Feature.sve)] = .{
999985 .llvm_name = "sve",
1000986 .description = "Enable Scalable Vector Extension (SVE) instructions",
1001 .dependencies = featureSet(&[_]Feature{}),
987 .dependencies = featureSet(&[_]Feature{
988 .fullfp16,
989 }),
1002990 };
1003991 result[@enumToInt(Feature.sve2)] = .{
1004992 .llvm_name = "sve2",
......@@ -1103,14 +1091,6 @@ pub const all_features = blk: {
11031091 .description = "Use the reciprocal square root approximation",
11041092 .dependencies = featureSet(&[_]Feature{}),
11051093 };
1106 result[@enumToInt(Feature.v8a)] = .{
1107 .llvm_name = null,
1108 .description = "Support ARM v8a instructions",
1109 .dependencies = featureSet(&[_]Feature{
1110 .fp_armv8,
1111 .neon,
1112 }),
1113 };
11141094 result[@enumToInt(Feature.v8_1a)] = .{
11151095 .llvm_name = "v8.1a",
11161096 .description = "Support ARM v8.1a instructions",
......@@ -1120,8 +1100,8 @@ pub const all_features = blk: {
11201100 .lse,
11211101 .pan,
11221102 .rdm,
1123 .vh,
11241103 .v8a,
1104 .vh,
11251105 }),
11261106 };
11271107 result[@enumToInt(Feature.v8_2a)] = .{
......@@ -1142,7 +1122,7 @@ pub const all_features = blk: {
11421122 .ccidx,
11431123 .complxnum,
11441124 .jsconv,
1145 .pa,
1125 .pauth,
11461126 .rcpc,
11471127 .v8_2a,
11481128 }),
......@@ -1154,7 +1134,7 @@ pub const all_features = blk: {
11541134 .am,
11551135 .dit,
11561136 .dotprod,
1157 .fmi,
1137 .flagm,
11581138 .mpam,
11591139 .nv,
11601140 .pmu,
......@@ -1192,13 +1172,73 @@ pub const all_features = blk: {
11921172 .v8_5a,
11931173 }),
11941174 };
1175 result[@enumToInt(Feature.v8_7a)] = .{
1176 .llvm_name = "v8.7a",
1177 .description = "Support ARM v8.7a instructions",
1178 .dependencies = featureSet(&[_]Feature{
1179 .hcx,
1180 .v8_6a,
1181 .wfxt,
1182 .xs,
1183 }),
1184 };
1185 result[@enumToInt(Feature.v8a)] = .{
1186 .llvm_name = null,
1187 .description = "Support ARM v8a instructions",
1188 .dependencies = featureSet(&[_]Feature{
1189 .neon,
1190 }),
1191 };
1192 result[@enumToInt(Feature.v8r)] = .{
1193 .llvm_name = "v8r",
1194 .description = "Support ARM v8r instructions",
1195 .dependencies = featureSet(&[_]Feature{
1196 .ccidx,
1197 .ccpp,
1198 .complxnum,
1199 .contextidr_el2,
1200 .crc,
1201 .dit,
1202 .dotprod,
1203 .flagm,
1204 .fp16fml,
1205 .jsconv,
1206 .lse,
1207 .pan_rwv,
1208 .pauth,
1209 .perfmon,
1210 .predres,
1211 .ras,
1212 .rcpc_immo,
1213 .rdm,
1214 .sb,
1215 .sel2,
1216 .sha3,
1217 .sm4,
1218 .specrestrict,
1219 .ssbs,
1220 .tlb_rmi,
1221 .tracev8_4,
1222 .uaops,
1223 }),
1224 };
11951225 result[@enumToInt(Feature.vh)] = .{
11961226 .llvm_name = "vh",
11971227 .description = "Enables ARM v8.1 Virtual Host extension",
11981228 .dependencies = featureSet(&[_]Feature{
1199 .context_id_rel2,
1229 .contextidr_el2,
12001230 }),
12011231 };
1232 result[@enumToInt(Feature.wfxt)] = .{
1233 .llvm_name = "wfxt",
1234 .description = "Enable Armv8.7-A WFET and WFIT instruction",
1235 .dependencies = featureSet(&[_]Feature{}),
1236 };
1237 result[@enumToInt(Feature.xs)] = .{
1238 .llvm_name = "xs",
1239 .description = "Enable Armv8.7-A limited-TLB-maintenance instruction",
1240 .dependencies = featureSet(&[_]Feature{}),
1241 };
12021242 result[@enumToInt(Feature.zcm)] = .{
12031243 .llvm_name = "zcm",
12041244 .description = "Has zero-cycle register moves",
......@@ -1240,11 +1280,11 @@ pub const cpu = struct {
12401280 .name = "a64fx",
12411281 .llvm_name = "a64fx",
12421282 .features = featureSet(&[_]Feature{
1283 .aggressive_fma,
1284 .arith_bcc_fusion,
12431285 .complxnum,
1244 .fp_armv8,
1245 .fullfp16,
1246 .neon,
12471286 .perfmon,
1287 .predictable_select_expensive,
12481288 .sha2,
12491289 .sve,
12501290 .use_postra_scheduler,
......@@ -1255,14 +1295,39 @@ pub const cpu = struct {
12551295 .name = "apple_a10",
12561296 .llvm_name = "apple-a10",
12571297 .features = featureSet(&[_]Feature{
1258 .apple_a10,
1298 .alternate_sextload_cvt_f32_pattern,
1299 .arith_bcc_fusion,
1300 .arith_cbz_fusion,
1301 .crc,
1302 .crypto,
1303 .disable_latency_sched_heuristic,
1304 .fuse_aes,
1305 .fuse_crypto_eor,
1306 .lor,
1307 .pan,
1308 .perfmon,
1309 .rdm,
1310 .vh,
1311 .zcm,
1312 .zcz,
12591313 }),
12601314 };
12611315 pub const apple_a11 = CpuModel{
12621316 .name = "apple_a11",
12631317 .llvm_name = "apple-a11",
12641318 .features = featureSet(&[_]Feature{
1265 .apple_a11,
1319 .alternate_sextload_cvt_f32_pattern,
1320 .arith_bcc_fusion,
1321 .arith_cbz_fusion,
1322 .crypto,
1323 .disable_latency_sched_heuristic,
1324 .fullfp16,
1325 .fuse_aes,
1326 .fuse_crypto_eor,
1327 .perfmon,
1328 .v8_2a,
1329 .zcm,
1330 .zcz,
12661331 }),
12671332 };
12681333 pub const apple_a12 = CpuModel{
......@@ -1279,6 +1344,37 @@ pub const cpu = struct {
12791344 .apple_a13,
12801345 }),
12811346 };
1347 pub const apple_a14 = CpuModel{
1348 .name = "apple_a14",
1349 .llvm_name = "apple-a14",
1350 .features = featureSet(&[_]Feature{
1351 .aggressive_fma,
1352 .alternate_sextload_cvt_f32_pattern,
1353 .altnzcv,
1354 .arith_bcc_fusion,
1355 .arith_cbz_fusion,
1356 .ccdp,
1357 .crypto,
1358 .disable_latency_sched_heuristic,
1359 .fp16fml,
1360 .fptoint,
1361 .fuse_address,
1362 .fuse_aes,
1363 .fuse_arith_logic,
1364 .fuse_crypto_eor,
1365 .fuse_csel,
1366 .fuse_literals,
1367 .perfmon,
1368 .predres,
1369 .sb,
1370 .sha3,
1371 .specrestrict,
1372 .ssbs,
1373 .v8_4a,
1374 .zcm,
1375 .zcz,
1376 }),
1377 };
12821378 pub const apple_a7 = CpuModel{
12831379 .name = "apple_a7",
12841380 .llvm_name = "apple-a7",
......@@ -1327,7 +1423,6 @@ pub const cpu = struct {
13271423 .features = featureSet(&[_]Feature{
13281424 .crypto,
13291425 .fullfp16,
1330 .neon,
13311426 .v8_2a,
13321427 }),
13331428 };
......@@ -1335,14 +1430,20 @@ pub const cpu = struct {
13351430 .name = "cortex_a34",
13361431 .llvm_name = "cortex-a34",
13371432 .features = featureSet(&[_]Feature{
1338 .a34,
1433 .crc,
1434 .crypto,
1435 .perfmon,
1436 .v8a,
13391437 }),
13401438 };
13411439 pub const cortex_a35 = CpuModel{
13421440 .name = "cortex_a35",
13431441 .llvm_name = "cortex-a35",
13441442 .features = featureSet(&[_]Feature{
1345 .a34,
1443 .crc,
1444 .crypto,
1445 .perfmon,
1446 .v8a,
13461447 }),
13471448 };
13481449 pub const cortex_a53 = CpuModel{
......@@ -1410,6 +1511,7 @@ pub const cpu = struct {
14101511 .crc,
14111512 .crypto,
14121513 .fuse_aes,
1514 .fuse_literals,
14131515 .perfmon,
14141516 .v8a,
14151517 }),
......@@ -1456,11 +1558,11 @@ pub const cpu = struct {
14561558 .name = "cortex_a77",
14571559 .llvm_name = "cortex-a77",
14581560 .features = featureSet(&[_]Feature{
1561 .cmp_bcc_fusion,
14591562 .crypto,
14601563 .dotprod,
1461 .fp_armv8,
14621564 .fullfp16,
1463 .neon,
1565 .fuse_aes,
14641566 .rcpc,
14651567 .v8_2a,
14661568 }),
......@@ -1469,12 +1571,11 @@ pub const cpu = struct {
14691571 .name = "cortex_a78",
14701572 .llvm_name = "cortex-a78",
14711573 .features = featureSet(&[_]Feature{
1574 .cmp_bcc_fusion,
14721575 .crypto,
14731576 .dotprod,
1474 .fp_armv8,
14751577 .fullfp16,
14761578 .fuse_aes,
1477 .neon,
14781579 .perfmon,
14791580 .rcpc,
14801581 .spe,
......@@ -1483,24 +1584,29 @@ pub const cpu = struct {
14831584 .v8_2a,
14841585 }),
14851586 };
1587 pub const cortex_a78c = CpuModel{
1588 .name = "cortex_a78c",
1589 .llvm_name = "cortex-a78c",
1590 .features = featureSet(&[_]Feature{
1591 .cortex_a78c,
1592 }),
1593 };
14861594 pub const cortex_r82 = CpuModel{
14871595 .name = "cortex_r82",
14881596 .llvm_name = "cortex-r82",
14891597 .features = featureSet(&[_]Feature{
1490 .use_postra_scheduler,
1491 .v8r,
1598 .cortex_r82,
14921599 }),
14931600 };
14941601 pub const cortex_x1 = CpuModel{
14951602 .name = "cortex_x1",
14961603 .llvm_name = "cortex-x1",
14971604 .features = featureSet(&[_]Feature{
1605 .cmp_bcc_fusion,
14981606 .crypto,
14991607 .dotprod,
1500 .fp_armv8,
15011608 .fullfp16,
15021609 .fuse_aes,
1503 .neon,
15041610 .perfmon,
15051611 .rcpc,
15061612 .spe,
......@@ -1574,14 +1680,14 @@ pub const cpu = struct {
15741680 .name = "exynos_m4",
15751681 .llvm_name = "exynos-m4",
15761682 .features = featureSet(&[_]Feature{
1577 .exynosm4,
1683 .exynos_m4,
15781684 }),
15791685 };
15801686 pub const exynos_m5 = CpuModel{
15811687 .name = "exynos_m5",
15821688 .llvm_name = "exynos-m5",
15831689 .features = featureSet(&[_]Feature{
1584 .exynosm4,
1690 .exynos_m4,
15851691 }),
15861692 };
15871693 pub const falkor = CpuModel{
......@@ -1607,9 +1713,9 @@ pub const cpu = struct {
16071713 .features = featureSet(&[_]Feature{
16081714 .ete,
16091715 .fuse_aes,
1716 .neon,
16101717 .perfmon,
16111718 .use_postra_scheduler,
1612 .v8a,
16131719 }),
16141720 };
16151721 pub const kryo = CpuModel{
......@@ -1623,8 +1729,8 @@ pub const cpu = struct {
16231729 .perfmon,
16241730 .predictable_select_expensive,
16251731 .use_postra_scheduler,
1626 .zcz,
16271732 .v8a,
1733 .zcz,
16281734 }),
16291735 };
16301736 pub const neoverse_e1 = CpuModel{
......@@ -1688,9 +1794,7 @@ pub const cpu = struct {
16881794 .features = featureSet(&[_]Feature{
16891795 .aggressive_fma,
16901796 .arith_bcc_fusion,
1691 .crc,
16921797 .crypto,
1693 .lse,
16941798 .predictable_select_expensive,
16951799 .use_postra_scheduler,
16961800 .v8_1a,
......@@ -1703,12 +1807,7 @@ pub const cpu = struct {
17031807 .aggressive_fma,
17041808 .arith_bcc_fusion,
17051809 .balance_fp_ops,
1706 .crc,
17071810 .crypto,
1708 .fp_armv8,
1709 .lse,
1710 .neon,
1711 .pa,
17121811 .perfmon,
17131812 .predictable_select_expensive,
17141813 .strict_align,
......@@ -1761,7 +1860,6 @@ pub const cpu = struct {
17611860 .custom_cheap_as_move,
17621861 .dotprod,
17631862 .fp16fml,
1764 .fullfp16,
17651863 .fuse_aes,
17661864 .perfmon,
17671865 .spe,
tools/update_cpu_features.zig+212-18
......@@ -8,7 +8,11 @@ const assert = std.debug.assert;
88
99const FeatureOverride = struct {
1010 llvm_name: []const u8,
11 /// If true, completely omit the feature; as if it does not exist.
1112 omit: bool = false,
13 /// If true, omit the feature, but all the dependencies of the feature
14 /// are added in its place.
15 flatten: bool = false,
1216 zig_name: ?[]const u8 = null,
1317 desc: ?[]const u8 = null,
1418 extra_deps: []const []const u8 = &.{},
......@@ -25,6 +29,7 @@ const Feature = struct {
2529 zig_name: []const u8,
2630 desc: []const u8,
2731 deps: []const []const u8,
32 flatten: bool = false,
2833};
2934
3035const LlvmTarget = struct {
......@@ -68,6 +73,8 @@ const llvm_targets = [_]LlvmTarget{
6873 .{
6974 .llvm_name = "exynosm3",
7075 .zig_name = "exynos_m3",
76 .flatten = true,
77 .extra_deps = &.{"v8a"},
7178 },
7279 .{
7380 .llvm_name = "exynosm4",
......@@ -77,6 +84,117 @@ const llvm_targets = [_]LlvmTarget{
7784 .llvm_name = "v8.1a",
7885 .extra_deps = &.{"v8a"},
7986 },
87 .{
88 .llvm_name = "a35",
89 .flatten = true,
90 .extra_deps = &.{"v8a"},
91 },
92 .{
93 .llvm_name = "a53",
94 .flatten = true,
95 .extra_deps = &.{"v8a"},
96 },
97 .{
98 .llvm_name = "a55",
99 .flatten = true,
100 },
101 .{
102 .llvm_name = "a57",
103 .flatten = true,
104 .extra_deps = &.{"v8a"},
105 },
106 .{
107 .llvm_name = "a64fx",
108 .flatten = true,
109 },
110 .{
111 .llvm_name = "a72",
112 .flatten = true,
113 .extra_deps = &.{"v8a"},
114 },
115 .{
116 .llvm_name = "a73",
117 .flatten = true,
118 .extra_deps = &.{"v8a"},
119 },
120 .{
121 .llvm_name = "a75",
122 .flatten = true,
123 },
124 .{
125 .llvm_name = "a77",
126 .flatten = true,
127 },
128 .{
129 .llvm_name = "apple-a10",
130 .flatten = true,
131 },
132 .{
133 .llvm_name = "apple-a11",
134 .flatten = true,
135 },
136 .{
137 .llvm_name = "apple-a14",
138 .flatten = true,
139 },
140 .{
141 .llvm_name = "carmel",
142 .flatten = true,
143 },
144 .{
145 .llvm_name = "cortex-a78",
146 .flatten = true,
147 },
148 .{
149 .llvm_name = "cortex-x1",
150 .flatten = true,
151 },
152 .{
153 .llvm_name = "falkor",
154 .flatten = true,
155 .extra_deps = &.{"v8a"},
156 },
157 .{
158 .llvm_name = "kryo",
159 .flatten = true,
160 .extra_deps = &.{"v8a"},
161 },
162 .{
163 .llvm_name = "saphira",
164 .flatten = true,
165 },
166 .{
167 .llvm_name = "thunderx",
168 .flatten = true,
169 .extra_deps = &.{"v8a"},
170 },
171 .{
172 .llvm_name = "thunderx2t99",
173 .flatten = true,
174 },
175 .{
176 .llvm_name = "thunderx3t110",
177 .flatten = true,
178 },
179 .{
180 .llvm_name = "thunderxt81",
181 .flatten = true,
182 .extra_deps = &.{"v8a"},
183 },
184 .{
185 .llvm_name = "thunderxt83",
186 .flatten = true,
187 .extra_deps = &.{"v8a"},
188 },
189 .{
190 .llvm_name = "thunderxt88",
191 .flatten = true,
192 .extra_deps = &.{"v8a"},
193 },
194 .{
195 .llvm_name = "tsv110",
196 .flatten = true,
197 },
80198 },
81199 .extra_features = &.{
82200 .{
......@@ -85,6 +203,43 @@ const llvm_targets = [_]LlvmTarget{
85203 .deps = &.{ "fp_armv8", "neon" },
86204 },
87205 },
206 .extra_cpus = &.{
207 .{
208 .llvm_name = null,
209 .zig_name = "exynos_m1",
210 .features = &.{
211 "crc",
212 "crypto",
213 "exynos_cheap_as_move",
214 "force_32bit_jump_tables",
215 "fuse_aes",
216 "perfmon",
217 "slow_misaligned_128store",
218 "slow_paired_128",
219 "use_postra_scheduler",
220 "use_reciprocal_square_root",
221 "v8a",
222 "zcz_fp",
223 },
224 },
225 .{
226 .llvm_name = null,
227 .zig_name = "exynos_m2",
228 .features = &.{
229 "crc",
230 "crypto",
231 "exynos_cheap_as_move",
232 "force_32bit_jump_tables",
233 "fuse_aes",
234 "perfmon",
235 "slow_misaligned_128store",
236 "slow_paired_128",
237 "use_postra_scheduler",
238 "v8a",
239 "zcz_fp",
240 },
241 },
242 },
88243 },
89244 .{
90245 .zig_name = "amdgpu",
......@@ -374,22 +529,32 @@ fn processOneTarget(job: Job) anyerror!void {
374529 const llvm_name = kv.value.Object.get("Name").?.String;
375530 if (llvm_name.len == 0) continue;
376531
377 var zig_name = (try llvmNameToZigName(arena, llvm_target, llvm_name)) orelse
378 continue :root_it;
532 var zig_name = try llvmNameToZigName(arena, llvm_name);
379533 var desc = kv.value.Object.get("Desc").?.String;
380534 var deps = std.ArrayList([]const u8).init(arena);
535 var omit = false;
536 var flatten = false;
381537 const implies = kv.value.Object.get("Implies").?.Array;
382538 for (implies.items) |imply| {
383539 const other_key = imply.Object.get("def").?.String;
384540 const other_obj = &root_map.getEntry(other_key).?.value.Object;
385541 const other_llvm_name = other_obj.get("Name").?.String;
386 const other_zig_name = (try llvmNameToZigName(arena, llvm_target, other_llvm_name)) orelse continue;
542 const other_zig_name = (try llvmNameToZigNameOmit(
543 arena,
544 llvm_target,
545 other_llvm_name,
546 )) orelse continue;
387547 try deps.append(other_zig_name);
388548 }
389549 for (llvm_target.feature_overrides) |feature_override| {
390550 if (mem.eql(u8, llvm_name, feature_override.llvm_name)) {
391551 if (feature_override.omit) {
392 continue :root_it;
552 // Still put the feature into the table so that we can
553 // expand dependencies for the feature overrides marked `flatten`.
554 omit = true;
555 }
556 if (feature_override.flatten) {
557 flatten = true;
393558 }
394559 if (feature_override.zig_name) |override_name| {
395560 zig_name = override_name;
......@@ -408,16 +573,18 @@ fn processOneTarget(job: Job) anyerror!void {
408573 .zig_name = zig_name,
409574 .desc = desc,
410575 .deps = deps.items,
576 .flatten = flatten,
411577 };
412578 try features_table.put(zig_name, feature);
413 try all_features.append(feature);
579 if (!omit and !flatten) {
580 try all_features.append(feature);
581 }
414582 }
415583 if (hasSuperclass(&kv.value.Object, "Processor")) {
416584 const llvm_name = kv.value.Object.get("Name").?.String;
417585 if (llvm_name.len == 0) continue;
418586
419 var zig_name = (try llvmNameToZigName(arena, llvm_target, llvm_name)) orelse
420 continue :root_it;
587 var zig_name = try llvmNameToZigName(arena, llvm_name);
421588 var deps = std.ArrayList([]const u8).init(arena);
422589 const features = kv.value.Object.get("Features").?.Array;
423590 for (features.items) |feature| {
......@@ -425,7 +592,11 @@ fn processOneTarget(job: Job) anyerror!void {
425592 const feature_obj = &root_map.getEntry(feature_key).?.value.Object;
426593 const feature_llvm_name = feature_obj.get("Name").?.String;
427594 if (feature_llvm_name.len == 0) continue;
428 const feature_zig_name = (try llvmNameToZigName(arena, llvm_target, feature_llvm_name)) orelse continue;
595 const feature_zig_name = (try llvmNameToZigNameOmit(
596 arena,
597 llvm_target,
598 feature_llvm_name,
599 )) orelse continue;
429600 try deps.append(feature_zig_name);
430601 }
431602 const tune_features = kv.value.Object.get("TuneFeatures").?.Array;
......@@ -434,7 +605,11 @@ fn processOneTarget(job: Job) anyerror!void {
434605 const feature_obj = &root_map.getEntry(feature_key).?.value.Object;
435606 const feature_llvm_name = feature_obj.get("Name").?.String;
436607 if (feature_llvm_name.len == 0) continue;
437 const feature_zig_name = (try llvmNameToZigName(arena, llvm_target, feature_llvm_name)) orelse continue;
608 const feature_zig_name = (try llvmNameToZigNameOmit(
609 arena,
610 llvm_target,
611 feature_llvm_name,
612 )) orelse continue;
438613 try deps.append(feature_zig_name);
439614 }
440615 for (llvm_target.feature_overrides) |feature_override| {
......@@ -549,7 +724,7 @@ fn processOneTarget(job: Job) anyerror!void {
549724 }
550725 var deps_set = std.StringHashMap(void).init(arena);
551726 for (feature.deps) |dep| {
552 try deps_set.put(dep, {});
727 try putDep(&deps_set, features_table, dep);
553728 }
554729 try pruneFeatures(arena, features_table, &deps_set);
555730 var dependencies = std.ArrayList([]const u8).init(arena);
......@@ -594,7 +769,7 @@ fn processOneTarget(job: Job) anyerror!void {
594769 for (all_cpus.items) |cpu| {
595770 var deps_set = std.StringHashMap(void).init(arena);
596771 for (cpu.features) |feature_zig_name| {
597 try deps_set.put(feature_zig_name, {});
772 try putDep(&deps_set, features_table, feature_zig_name);
598773 }
599774 try pruneFeatures(arena, features_table, &deps_set);
600775 var cpu_features = std.ArrayList([]const u8).init(arena);
......@@ -679,7 +854,16 @@ fn asciiLessThan(context: void, a: []const u8, b: []const u8) bool {
679854 return std.ascii.lessThanIgnoreCase(a, b);
680855}
681856
682fn llvmNameToZigName(
857fn llvmNameToZigName(arena: *mem.Allocator, llvm_name: []const u8) ![]const u8 {
858 const duped = try arena.dupe(u8, llvm_name);
859 for (duped) |*byte| switch (byte.*) {
860 '-', '.' => byte.* = '_',
861 else => continue,
862 };
863 return duped;
864}
865
866fn llvmNameToZigNameOmit(
683867 arena: *mem.Allocator,
684868 llvm_target: LlvmTarget,
685869 llvm_name: []const u8,
......@@ -690,12 +874,7 @@ fn llvmNameToZigName(
690874 return feature_override.zig_name orelse break;
691875 }
692876 }
693 const duped = try arena.dupe(u8, llvm_name);
694 for (duped) |*byte| switch (byte.*) {
695 '-', '.' => byte.* = '_',
696 else => continue,
697 };
698 return duped;
877 return try llvmNameToZigName(arena, llvm_name);
699878}
700879
701880fn hasSuperclass(obj: *json.ObjectMap, class_name: []const u8) bool {
......@@ -744,3 +923,18 @@ fn walkFeatures(
744923 try walkFeatures(features_table, deletion_set, other_feature);
745924 }
746925}
926
927fn putDep(
928 deps_set: *std.StringHashMap(void),
929 features_table: std.StringHashMap(Feature),
930 zig_feature_name: []const u8,
931) error{OutOfMemory}!void {
932 const feature = features_table.get(zig_feature_name).?;
933 if (feature.flatten) {
934 for (feature.deps) |dep| {
935 try putDep(deps_set, features_table, dep);
936 }
937 } else {
938 try deps_set.put(zig_feature_name, {});
939 }
940}